diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2020-06-12 00:19:04 +0300 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2020-06-12 01:05:36 +0300 |
commit | 3ffb482b4e22aea92ec7fc17557080267bff4770 (patch) | |
tree | d2cbb5fd64223fcbab515234e652027b19bdaed3 /apps/files_sharing/src/components/SharingEntry.vue | |
parent | 2c6d5068ad3c565678cc12e15c262c3e58c12d0a (diff) |
Fix share permission checkboxes enabled when permissions can not be set
A sharee can reshare a file and set the edit, create, delete and share
permissions of the reshare only if the received share has edit, create,
delete and share permissions, or if they were revoked in the received
share after being set in the reshare. Therefore, the permission
checkboxes in the share menu should be enabled only if the user can set
them (otherwise trying to check them will lead to an error).
Note that "sharePermissions" has all the permissions if the file is not
a reshare but a file owned by the user.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps/files_sharing/src/components/SharingEntry.vue')
-rw-r--r-- | apps/files_sharing/src/components/SharingEntry.vue | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/apps/files_sharing/src/components/SharingEntry.vue b/apps/files_sharing/src/components/SharingEntry.vue index 4af3a6b4431..70b95544b64 100644 --- a/apps/files_sharing/src/components/SharingEntry.vue +++ b/apps/files_sharing/src/components/SharingEntry.vue @@ -40,7 +40,7 @@ ref="canEdit" :checked.sync="canEdit" :value="permissionsEdit" - :disabled="saving"> + :disabled="saving || !canSetEdit"> {{ t('files_sharing', 'Allow editing') }} </ActionCheckbox> @@ -50,7 +50,7 @@ ref="canCreate" :checked.sync="canCreate" :value="permissionsCreate" - :disabled="saving"> + :disabled="saving || !canSetCreate"> {{ t('files_sharing', 'Allow creating') }} </ActionCheckbox> @@ -60,7 +60,7 @@ ref="canDelete" :checked.sync="canDelete" :value="permissionsDelete" - :disabled="saving"> + :disabled="saving || !canSetDelete"> {{ t('files_sharing', 'Allow deleting') }} </ActionCheckbox> @@ -69,7 +69,7 @@ ref="canReshare" :checked.sync="canReshare" :value="permissionsShare" - :disabled="saving"> + :disabled="saving || !canSetReshare"> {{ t('files_sharing', 'Allow resharing') }} </ActionCheckbox> @@ -217,6 +217,54 @@ export default { }, /** + * Can the sharer set whether the sharee can edit the file ? + * + * @returns {boolean} + */ + canSetEdit() { + // If the owner revoked the permission after the resharer granted it + // the share still has the permission, and the resharer is still + // allowed to revoke it too (but not to grant it again). + return (this.fileInfo.sharePermissions & OC.PERMISSION_UPDATE) || this.canEdit + }, + + /** + * Can the sharer set whether the sharee can create the file ? + * + * @returns {boolean} + */ + canSetCreate() { + // If the owner revoked the permission after the resharer granted it + // the share still has the permission, and the resharer is still + // allowed to revoke it too (but not to grant it again). + return (this.fileInfo.sharePermissions & OC.PERMISSION_CREATE) || this.canCreate + }, + + /** + * Can the sharer set whether the sharee can delete the file ? + * + * @returns {boolean} + */ + canSetDelete() { + // If the owner revoked the permission after the resharer granted it + // the share still has the permission, and the resharer is still + // allowed to revoke it too (but not to grant it again). + return (this.fileInfo.sharePermissions & OC.PERMISSION_DELETE) || this.canDelete + }, + + /** + * Can the sharer set whether the sharee can reshare the file ? + * + * @returns {boolean} + */ + canSetReshare() { + // If the owner revoked the permission after the resharer granted it + // the share still has the permission, and the resharer is still + // allowed to revoke it too (but not to grant it again). + return (this.fileInfo.sharePermissions & OC.PERMISSION_SHARE) || this.canReshare + }, + + /** * Can the sharee edit the shared file ? */ canEdit: { |