Skip to content

Commit

Permalink
refactor: file sharing (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba authored Nov 30, 2024
1 parent 7953e43 commit 98c7538
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Sources/Screens/Sharing/SharingBatch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct SharingBatch: View, TokenDistributing {
TabView(selection: $selection) {
Tab("Users", systemImage: "person", value: Tag.users) {
NavigationStack {
SharingUserPermission(
SharingUserForm(
fileIDs: fileIDs,
sharingStore: sharingStore,
workspaceStore: workspaceStore,
Expand All @@ -45,7 +45,7 @@ struct SharingBatch: View, TokenDistributing {
}
Tab("Groups", systemImage: "person.2", value: Tag.groups) {
NavigationStack {
SharingGroupPermission(
SharingGroupForm(
fileIDs: fileIDs,
sharingStore: sharingStore,
workspaceStore: workspaceStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import SwiftUI
import VoltaserveCore

struct SharingGroupPermission: View, FormValidatable, ErrorPresentable {
struct SharingGroupForm: View, FormValidatable, ErrorPresentable {
@ObservedObject private var sharingStore: SharingStore
@ObservedObject private var workspaceStore: WorkspaceStore
@Environment(\.dismiss) private var dismiss
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import SwiftUI
import VoltaserveCore

struct SharingGroupList: View {
struct SharingGroupPermissions: View {
@ObservedObject private var sharingStore: SharingStore
@ObservedObject private var workspaceStore: WorkspaceStore
@State private var group: VOGroup.Entity?
Expand All @@ -31,7 +31,7 @@ struct SharingGroupList: View {
} else {
List(groupPermissions, id: \.id) { groupPermission in
NavigationLink {
SharingGroupPermission(
SharingGroupForm(
fileIDs: [fileID],
sharingStore: sharingStore,
workspaceStore: workspaceStore,
Expand Down
8 changes: 4 additions & 4 deletions Sources/Screens/Sharing/SharingOverview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ struct SharingOverview: View, ViewDataProvider, LoadStateProvider, TimerLifecycl
NavigationStack {
TabView(selection: $selection) {
Tab("Users", systemImage: "person", value: Tag.users) {
SharingUserList(
SharingUserPermissions(
fileID,
sharingStore: sharingStore,
workspaceStore: workspaceStore
)
}
.badge(userPermissionCount)
Tab("Groups", systemImage: "person.2", value: Tag.groups) {
SharingGroupList(
SharingGroupPermissions(
fileID,
sharingStore: sharingStore,
workspaceStore: workspaceStore
Expand All @@ -55,13 +55,13 @@ struct SharingOverview: View, ViewDataProvider, LoadStateProvider, TimerLifecycl
ToolbarItem(placement: .topBarLeading) {
NavigationLink {
if selection == .users {
SharingUserPermission(
SharingUserForm(
fileIDs: [fileID],
sharingStore: sharingStore,
workspaceStore: workspaceStore
)
} else if selection == .groups {
SharingGroupPermission(
SharingGroupForm(
fileIDs: [fileID],
sharingStore: sharingStore,
workspaceStore: workspaceStore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import SwiftUI
import VoltaserveCore

struct SharingUserPermission: View, FormValidatable, ErrorPresentable {
struct SharingUserForm: View, FormValidatable, ErrorPresentable {
@ObservedObject private var sharingStore: SharingStore
@ObservedObject private var workspaceStore: WorkspaceStore
@Environment(\.dismiss) private var dismiss
Expand Down Expand Up @@ -49,7 +49,7 @@ struct SharingUserPermission: View, FormValidatable, ErrorPresentable {
Section(header: VOSectionHeader("User Permission")) {
NavigationLink {
if let workspace = workspaceStore.current {
UserSelector(organizationID: workspace.organization.id) { user in
UserSelector(organizationID: workspace.organization.id, excludeMe: true) { user in
self.user = user
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import SwiftUI
import VoltaserveCore

struct SharingUserList: View, TokenDistributing {
struct SharingUserPermissions: View, TokenDistributing {
@EnvironmentObject private var tokenStore: TokenStore
@ObservedObject private var sharingStore: SharingStore
@ObservedObject private var workspaceStore: WorkspaceStore
Expand All @@ -34,7 +34,7 @@ struct SharingUserList: View, TokenDistributing {
} else {
List(userPermissions, id: \.id) { userPermission in
NavigationLink {
SharingUserPermission(
SharingUserForm(
fileIDs: [fileID],
sharingStore: sharingStore,
workspaceStore: workspaceStore,
Expand Down
4 changes: 4 additions & 0 deletions Sources/Screens/User/UserSelector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@ struct UserSelector: View, ViewDataProvider, LoadStateProvider, TimerLifecycle,
private let groupID: String?
private let organizationID: String?
private let excludeGroupMembers: Bool?
private let excludeMe: Bool?

init(
organizationID: String? = nil,
groupID: String? = nil,
excludeGroupMembers: Bool? = nil,
excludeMe: Bool? = nil,
onCompletion: ((VOUser.Entity) -> Void)? = nil
) {
self.organizationID = organizationID
self.groupID = groupID
self.excludeGroupMembers = excludeGroupMembers
self.excludeMe = excludeMe
self.onCompletion = onCompletion
}

Expand Down Expand Up @@ -89,6 +92,7 @@ struct UserSelector: View, ViewDataProvider, LoadStateProvider, TimerLifecycle,
userStore.organizationID = organizationID
userStore.groupID = groupID
userStore.excludeGroupMembers = excludeGroupMembers
userStore.excludeMe = excludeMe
if let token = tokenStore.token {
assignTokenToStores(token)
startTimers()
Expand Down
2 changes: 2 additions & 0 deletions Sources/Screens/User/UserStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class UserStore: ObservableObject {
var organizationID: String?
var groupID: String?
var excludeGroupMembers: Bool?
var excludeMe: Bool?
var invitationID: String?

var token: VOToken.Value? {
Expand Down Expand Up @@ -92,6 +93,7 @@ class UserStore: ObservableObject {
organizationID: organizationID,
groupID: groupID,
excludeGroupMembers: excludeGroupMembers,
excludeMe: excludeMe,
page: page,
size: size
))
Expand Down
8 changes: 4 additions & 4 deletions Voltaserve.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@
Server/ServerOverview.swift,
Server/ServerRow.swift,
Sharing/SharingBatch.swift,
Sharing/SharingGroupList.swift,
Sharing/SharingGroupPermission.swift,
Sharing/SharingGroupForm.swift,
Sharing/SharingGroupPermissions.swift,
Sharing/SharingGroupRow.swift,
Sharing/SharingOverview.swift,
Sharing/SharingStore.swift,
Sharing/SharingUserList.swift,
Sharing/SharingUserPermission.swift,
Sharing/SharingUserForm.swift,
Sharing/SharingUserPermissions.swift,
Sharing/SharingUserRow.swift,
SignIn/SignIn.swift,
SignIn/TokenStore.swift,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"location" : "https://github.com/kouprlabs/voltaserve-swift.git",
"state" : {
"branch" : "main",
"revision" : "c3e98454a3ee6a71f1d4021926f4623460027c55"
"revision" : "65cd117d479727ebf638276425bd92026f4b6270"
}
}
],
Expand Down

0 comments on commit 98c7538

Please sign in to comment.