Skip to content

Commit 7f3503b

Browse files
committed
- SDK update to add OCUser.permissions
- AccountControllerSpacesGridViewController: determine canManageSpaces based on logged in user's permissions - OCDrive+ManagementActions: add alert asking user for confirmation before deleting a space
1 parent de3b349 commit 7f3503b

File tree

4 files changed

+35
-16
lines changed

4 files changed

+35
-16
lines changed

ownCloud/Resources/Localizable.xcstrings

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6697,6 +6697,9 @@
66976697
}
66986698
}
66996699
}
6700+
},
6701+
"Are you sure you want to delete this space? This action cannot be undone." : {
6702+
67006703
},
67016704
"Are you sure you want to unshare these items?" : {
67026705
"localizations" : {
@@ -18370,6 +18373,9 @@
1837018373
}
1837118374
}
1837218375
}
18376+
},
18377+
"Delete space \"{{driveName}}\"?" : {
18378+
1837318379
},
1837418380
"Delete unused local copies" : {
1837518381
"localizations" : {

ownCloudAppShared/Client/Account/Controller/AccountControllerSpacesGridViewController.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ class AccountControllerSpacesGridViewController: CollectionViewController, ViewC
2424
var noSpacesCondition: DataSourceCondition?
2525

2626
var canManageSpaces: Bool {
27-
return true
27+
if let userPermissions = clientContext?.core?.connection.loggedInUser?.permissions {
28+
return userPermissions.canCreateSpaces
29+
}
30+
return false
2831
}
2932

3033
var spacesDataSource: OCDataSourceComposition = OCDataSourceComposition(sources: [])

ownCloudAppShared/Client/Spaces/OCDrive+ManagementActions.swift

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,30 @@ extension OCDrive {
8080
}
8181

8282
func delete(with clientContext: ClientContext?) {
83-
guard let core = clientContext?.core else { return }
84-
85-
core.deleteDrive(self, completionHandler: { error in
86-
if let error {
87-
OnMainThread {
88-
let alertController = ThemedAlertController(
89-
with: OCLocalizedFormat("Error deleting {{driveName}}", ["driveName" : self.name ?? OCLocalizedString("space", nil)]),
90-
message: error.localizedDescription,
91-
okLabel: OCLocalizedString("OK", nil),
92-
action: nil)
93-
94-
clientContext?.present(alertController, animated: true)
83+
let alertController = ThemedAlertController(
84+
title: OCLocalizedFormat("Delete space \"{{driveName}}\"?", ["driveName" : self.name ?? OCLocalizedString("space", nil)]),
85+
message: OCLocalizedString("Are you sure you want to delete this space? This action cannot be undone.", nil),
86+
preferredStyle: .alert)
87+
88+
alertController.addAction(UIAlertAction(title: OCLocalizedString("Cancel", nil), style: .cancel, handler: nil))
89+
alertController.addAction(UIAlertAction(title: OCLocalizedString("Delete", nil), style: .destructive, handler: { [weak clientContext] (_) in
90+
guard let core = clientContext?.core else { return }
91+
92+
core.deleteDrive(self, completionHandler: { error in
93+
if let error {
94+
OnMainThread {
95+
let alertController = ThemedAlertController(
96+
with: OCLocalizedFormat("Error deleting {{driveName}}", ["driveName" : self.name ?? OCLocalizedString("space", nil)]),
97+
message: error.localizedDescription,
98+
okLabel: OCLocalizedString("OK", nil),
99+
action: nil)
100+
101+
clientContext?.present(alertController, animated: true)
102+
}
95103
}
96-
}
97-
})
104+
})
105+
}))
106+
107+
clientContext?.present(alertController, animated: true)
98108
}
99109
}

0 commit comments

Comments
 (0)