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"
|
ref="canEdit"
|
||||||
:checked.sync="canEdit"
|
:checked.sync="canEdit"
|
||||||
:value="permissionsEdit"
|
:value="permissionsEdit"
|
||||||
:disabled="saving">
|
:disabled="saving || !canSetEdit">
|
||||||
{{ t('files_sharing', 'Allow editing') }}
|
{{ t('files_sharing', 'Allow editing') }}
|
||||||
</ActionCheckbox>
|
</ActionCheckbox>
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
ref="canCreate"
|
ref="canCreate"
|
||||||
:checked.sync="canCreate"
|
:checked.sync="canCreate"
|
||||||
:value="permissionsCreate"
|
:value="permissionsCreate"
|
||||||
:disabled="saving">
|
:disabled="saving || !canSetCreate">
|
||||||
{{ t('files_sharing', 'Allow creating') }}
|
{{ t('files_sharing', 'Allow creating') }}
|
||||||
</ActionCheckbox>
|
</ActionCheckbox>
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
ref="canDelete"
|
ref="canDelete"
|
||||||
:checked.sync="canDelete"
|
:checked.sync="canDelete"
|
||||||
:value="permissionsDelete"
|
:value="permissionsDelete"
|
||||||
:disabled="saving">
|
:disabled="saving || !canSetDelete">
|
||||||
{{ t('files_sharing', 'Allow deleting') }}
|
{{ t('files_sharing', 'Allow deleting') }}
|
||||||
</ActionCheckbox>
|
</ActionCheckbox>
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
ref="canReshare"
|
ref="canReshare"
|
||||||
:checked.sync="canReshare"
|
:checked.sync="canReshare"
|
||||||
:value="permissionsShare"
|
:value="permissionsShare"
|
||||||
:disabled="saving">
|
:disabled="saving || !canSetReshare">
|
||||||
{{ t('files_sharing', 'Allow resharing') }}
|
{{ t('files_sharing', 'Allow resharing') }}
|
||||||
</ActionCheckbox>
|
</ActionCheckbox>
|
||||||
|
|
||||||
|
@ -216,6 +216,54 @@ export default {
|
||||||
&& this.share.type !== this.SHARE_TYPES.SHARE_TYPE_REMOTE_GROUP
|
&& 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 ?
|
* Can the sharee edit the shared file ?
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue