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> Signed-off-by: npmbuildbot[bot] <npmbuildbot[bot]@users.noreply.github.com>
This commit is contained in:
parent
4401cd2717
commit
87be93126f
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -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>
|
||||
|
||||
|
@ -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 ?
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue