diff --git a/src/client.js b/src/client.js index 561201107..78aeae86f 100644 --- a/src/client.js +++ b/src/client.js @@ -252,12 +252,30 @@ class AclDavService { propPatch(model, acls) { const aclList = [] for (const i in acls) { - aclList.push({ type: ACL_PROPERTIES.PROPERTY_ACL_ENTRY, data: acls[i].getProperties() }) + aclList.push({ type: ACL_PROPERTIES.PROPERTY_ACL_ENTRY, data: acls[i].getProperties() }) } const props = {} props[ACL_PROPERTIES.PROPERTY_ACL_LIST] = aclList + return client._client.propPatch(client._client.baseUrl + model.path.replaceAll('#', '%23') + '/' + encodeURIComponent(model.name), props) - } + .then(response => { + if (response.status === 207) { + return response + } else if (response.status === 403) { + // Handle permission denied scenario + console.error('Permission denied:', response.status, response.statusText) + throw new Error(t('groupfolders', 'Permission denied. User does not have sufficient permissions.')) + } else { + // Handle unexpected status codes + console.error('Unexpected status:', response.status, response.statusText) + throw new Error(t('groupfolders', 'Unexpected status from server')) + } + }).catch(error => { + // Handle network errors or exceptions + console.error('Error in propPatch:', error) + throw error + }) + } } diff --git a/src/components/SharingSidebarView.vue b/src/components/SharingSidebarView.vue index 27a4ac9b1..75e769800 100644 --- a/src/components/SharingSidebarView.vue +++ b/src/components/SharingSidebarView.vue @@ -355,7 +355,7 @@ export default { }) }, - changePermission(item, permission, $event) { + async changePermission(item, permission, $event) { const index = this.list.indexOf(item) const inherit = $event === STATES.INHERIT_ALLOW || $event === STATES.INHERIT_DENY || $event === STATES.INHERIT_DEFAULT const allow = $event === STATES.SELF_ALLOW @@ -374,9 +374,16 @@ export default { } item.inherited = false Vue.set(this.list, index, item) - client.propPatch(this.model, this.list.filter(rule => !rule.inherited)).then(() => { - // TODO block UI during save - }) + // TODO: Block UI during save + try { + await client.propPatch(this.model, this.list.filter(rule => !rule.inherited)) + console.debug('Permissions updated successfully') + } catch (error) { + console.error('Failed to save changes:', error) + showError(error) + } finally { + // TODO: Unblock the UI after the operation completes + } }, }, }