Skip to content

Commit

Permalink
fix(DavClient): Provide proper feedback for dav requests
Browse files Browse the repository at this point in the history
Before this commit there is no error handling whatsover for this requests and
the user won't get any visual feedback whatsover irrespective of what goes down
at the server level.

Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
  • Loading branch information
nfebe committed Jul 2, 2024
1 parent cbad351 commit 9cc07b0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
22 changes: 20 additions & 2 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}

}

Expand Down
15 changes: 11 additions & 4 deletions src/components/SharingSidebarView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
},
},
}
Expand Down

0 comments on commit 9cc07b0

Please sign in to comment.