Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
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 <[email protected]>
  • Loading branch information
danxuliu committed Jun 11, 2020
commit 3ffb482b4e22aea92ec7fc17557080267bff4770
28 changes: 14 additions & 14 deletions apps/files_sharing/js/dist/files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/files_sharing/js/dist/files_sharing_tab.js.map

Large diffs are not rendered by default.

56 changes: 52 additions & 4 deletions apps/files_sharing/src/components/SharingEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
ref="canEdit"
:checked.sync="canEdit"
:value="permissionsEdit"
:disabled="saving">
:disabled="saving || !canSetEdit">
{{ t('files_sharing', 'Allow editing') }}
</ActionCheckbox>

Expand All @@ -50,7 +50,7 @@
ref="canCreate"
:checked.sync="canCreate"
:value="permissionsCreate"
:disabled="saving">
:disabled="saving || !canSetCreate">
{{ t('files_sharing', 'Allow creating') }}
</ActionCheckbox>

Expand All @@ -60,7 +60,7 @@
ref="canDelete"
:checked.sync="canDelete"
:value="permissionsDelete"
:disabled="saving">
:disabled="saving || !canSetDelete">
{{ t('files_sharing', 'Allow deleting') }}
</ActionCheckbox>

Expand All @@ -69,7 +69,7 @@
ref="canReshare"
:checked.sync="canReshare"
:value="permissionsShare"
:disabled="saving">
:disabled="saving || !canSetReshare">
{{ t('files_sharing', 'Allow resharing') }}
</ActionCheckbox>

Expand Down Expand Up @@ -216,6 +216,54 @@ export default {
&& this.share.type !== this.SHARE_TYPES.SHARE_TYPE_REMOTE_GROUP
},

/**
* 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 ?
*/
Expand Down