From a354df8597054b77670d1d0b418b2bd2b5391400 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Tue, 11 Oct 2022 14:16:57 +0200 Subject: [PATCH 1/5] Hide actions in space trash bins in case of insufficient permissions --- changelog/unreleased/bugfix-space-trashbin-actions | 6 ++++++ packages/web-app-files/src/mixins/actions/delete.js | 10 +++++++++- .../web-app-files/src/mixins/actions/emptyTrashBin.js | 8 ++++++++ packages/web-app-files/src/mixins/actions/restore.ts | 8 +++++++- .../web-app-files/src/views/spaces/GenericTrash.vue | 9 ++++++++- 5 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 changelog/unreleased/bugfix-space-trashbin-actions diff --git a/changelog/unreleased/bugfix-space-trashbin-actions b/changelog/unreleased/bugfix-space-trashbin-actions new file mode 100644 index 00000000000..cb8e3b243bf --- /dev/null +++ b/changelog/unreleased/bugfix-space-trashbin-actions @@ -0,0 +1,6 @@ +Bugfix: Hide actions in space trash bins + +Actions in space trash bins are now hidden if the current user has insufficient permissions. + +https://github.com/owncloud/web/pull/7768 +https://github.com/owncloud/web/issues/7702 diff --git a/packages/web-app-files/src/mixins/actions/delete.js b/packages/web-app-files/src/mixins/actions/delete.js index b918e817f2f..1afe81b5d23 100644 --- a/packages/web-app-files/src/mixins/actions/delete.js +++ b/packages/web-app-files/src/mixins/actions/delete.js @@ -6,12 +6,13 @@ import { isLocationTrashActive, isLocationCommonActive } from '../../router' +import { isProjectSpaceResource } from 'web-client/src/helpers' export default { mixins: [MixinDeleteResources], computed: { ...mapState('Files', ['currentFolder']), - ...mapGetters(['capabilities']), + ...mapGetters(['capabilities', 'user']), $_delete_items() { return [ { @@ -60,6 +61,13 @@ export default { if (this.capabilities?.files?.permanent_deletion === false) { return false } + + const { manager, editor } = this.space?.spaceRoles + const isProjectSpace = isProjectSpaceResource(this.space) + if (isProjectSpace && ![...manager, ...editor].includes(this.user.uuid)) { + return false + } + return resources.length > 0 }, componentType: 'button', diff --git a/packages/web-app-files/src/mixins/actions/emptyTrashBin.js b/packages/web-app-files/src/mixins/actions/emptyTrashBin.js index a6d7659caa0..a2ea62b9268 100644 --- a/packages/web-app-files/src/mixins/actions/emptyTrashBin.js +++ b/packages/web-app-files/src/mixins/actions/emptyTrashBin.js @@ -1,6 +1,7 @@ import { mapActions, mapGetters, mapState } from 'vuex' import { isLocationTrashActive } from '../../router' import { buildWebDavFilesTrashPath, buildWebDavSpacesTrashPath } from '../../helpers/resources' +import { isProjectSpaceResource } from 'web-client/src/helpers' export default { computed: { @@ -21,6 +22,13 @@ export default { if (this.capabilities?.files?.permanent_deletion === false) { return false } + + const { manager, editor } = this.space?.spaceRoles + const isProjectSpace = isProjectSpaceResource(this.space) + if (isProjectSpace && ![...manager, ...editor].includes(this.user.uuid)) { + return false + } + // empty trash bin is not available for individual resources, but only for the trash bin as a whole return resources.length === 0 }, diff --git a/packages/web-app-files/src/mixins/actions/restore.ts b/packages/web-app-files/src/mixins/actions/restore.ts index 946ae866ca7..bc206da8258 100644 --- a/packages/web-app-files/src/mixins/actions/restore.ts +++ b/packages/web-app-files/src/mixins/actions/restore.ts @@ -7,7 +7,7 @@ import { buildWebDavSpacesTrashPath } from '../../helpers/resources' import { clientService } from 'web-pkg/src/services' -import { buildWebDavSpacesPath } from 'web-client/src/helpers' +import { buildWebDavSpacesPath, isProjectSpaceResource } from 'web-client/src/helpers' export default { computed: { @@ -29,6 +29,12 @@ export default { return false } + const { manager, editor } = this.space?.spaceRoles + const isProjectSpace = isProjectSpaceResource(this.space) + if (isProjectSpace && ![...manager, ...editor].includes(this.user.uuid)) { + return false + } + return resources.length > 0 }, componentType: 'button', diff --git a/packages/web-app-files/src/views/spaces/GenericTrash.vue b/packages/web-app-files/src/views/spaces/GenericTrash.vue index ed10452a24d..b0e5bccec91 100644 --- a/packages/web-app-files/src/views/spaces/GenericTrash.vue +++ b/packages/web-app-files/src/views/spaces/GenericTrash.vue @@ -34,6 +34,7 @@ :sort-by="sortBy" :sort-dir="sortDir" :space="space" + :has-actions="showActions" @sort="handleSort" >