Skip to content

Commit 3ffb482

Browse files
committed
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]>
1 parent 2c6d506 commit 3ffb482

File tree

3 files changed

+67
-19
lines changed

3 files changed

+67
-19
lines changed

apps/files_sharing/js/dist/files_sharing_tab.js

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files_sharing/js/dist/files_sharing_tab.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files_sharing/src/components/SharingEntry.vue

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
ref="canEdit"
4141
:checked.sync="canEdit"
4242
:value="permissionsEdit"
43-
:disabled="saving">
43+
:disabled="saving || !canSetEdit">
4444
{{ t('files_sharing', 'Allow editing') }}
4545
</ActionCheckbox>
4646

@@ -50,7 +50,7 @@
5050
ref="canCreate"
5151
:checked.sync="canCreate"
5252
:value="permissionsCreate"
53-
:disabled="saving">
53+
:disabled="saving || !canSetCreate">
5454
{{ t('files_sharing', 'Allow creating') }}
5555
</ActionCheckbox>
5656

@@ -60,7 +60,7 @@
6060
ref="canDelete"
6161
:checked.sync="canDelete"
6262
:value="permissionsDelete"
63-
:disabled="saving">
63+
:disabled="saving || !canSetDelete">
6464
{{ t('files_sharing', 'Allow deleting') }}
6565
</ActionCheckbox>
6666

@@ -69,7 +69,7 @@
6969
ref="canReshare"
7070
:checked.sync="canReshare"
7171
:value="permissionsShare"
72-
:disabled="saving">
72+
:disabled="saving || !canSetReshare">
7373
{{ t('files_sharing', 'Allow resharing') }}
7474
</ActionCheckbox>
7575

@@ -216,6 +216,54 @@ export default {
216216
&& this.share.type !== this.SHARE_TYPES.SHARE_TYPE_REMOTE_GROUP
217217
},
218218
219+
/**
220+
* Can the sharer set whether the sharee can edit the file ?
221+
*
222+
* @returns {boolean}
223+
*/
224+
canSetEdit() {
225+
// If the owner revoked the permission after the resharer granted it
226+
// the share still has the permission, and the resharer is still
227+
// allowed to revoke it too (but not to grant it again).
228+
return (this.fileInfo.sharePermissions & OC.PERMISSION_UPDATE) || this.canEdit
229+
},
230+
231+
/**
232+
* Can the sharer set whether the sharee can create the file ?
233+
*
234+
* @returns {boolean}
235+
*/
236+
canSetCreate() {
237+
// If the owner revoked the permission after the resharer granted it
238+
// the share still has the permission, and the resharer is still
239+
// allowed to revoke it too (but not to grant it again).
240+
return (this.fileInfo.sharePermissions & OC.PERMISSION_CREATE) || this.canCreate
241+
},
242+
243+
/**
244+
* Can the sharer set whether the sharee can delete the file ?
245+
*
246+
* @returns {boolean}
247+
*/
248+
canSetDelete() {
249+
// If the owner revoked the permission after the resharer granted it
250+
// the share still has the permission, and the resharer is still
251+
// allowed to revoke it too (but not to grant it again).
252+
return (this.fileInfo.sharePermissions & OC.PERMISSION_DELETE) || this.canDelete
253+
},
254+
255+
/**
256+
* Can the sharer set whether the sharee can reshare the file ?
257+
*
258+
* @returns {boolean}
259+
*/
260+
canSetReshare() {
261+
// If the owner revoked the permission after the resharer granted it
262+
// the share still has the permission, and the resharer is still
263+
// allowed to revoke it too (but not to grant it again).
264+
return (this.fileInfo.sharePermissions & OC.PERMISSION_SHARE) || this.canReshare
265+
},
266+
219267
/**
220268
* Can the sharee edit the shared file ?
221269
*/

0 commit comments

Comments
 (0)