From e966f633787332896fcff63670f8cae815510a14 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Mon, 6 Mar 2023 13:16:19 +0100 Subject: [PATCH] Add support for a public link permission --- .../enhancement-public-link-permission | 6 +++ .../src/components/FilesList/QuickActions.vue | 4 +- .../components/SideBar/Shares/FileLinks.vue | 29 +++++++------ .../SideBar/Shares/Links/CreateQuickLink.vue | 10 ++++- .../web-app-files/src/helpers/share/link.ts | 6 ++- .../src/mixins/actions/createQuicklink.ts | 3 +- packages/web-app-files/src/quickActions.ts | 4 +- .../SideBar/Shares/FileLinks.spec.ts | 41 +++++++++++++++++-- packages/web-client/src/helpers/share/role.ts | 33 +++++++++------ packages/web-pkg/src/utils/types.ts | 1 + .../src/services/auth/abilities.ts | 1 + .../src/services/auth/userManager.ts | 3 +- .../unit/services/auth/abilities.spec.ts | 5 +++ 13 files changed, 108 insertions(+), 38 deletions(-) create mode 100644 changelog/unreleased/enhancement-public-link-permission diff --git a/changelog/unreleased/enhancement-public-link-permission b/changelog/unreleased/enhancement-public-link-permission new file mode 100644 index 00000000000..1bcb7d2ce37 --- /dev/null +++ b/changelog/unreleased/enhancement-public-link-permission @@ -0,0 +1,6 @@ +Enhancement: Public link permission `PublicLink.Write.all` + +Support for the public link permission `PublicLink.Write.all` has been added. Users without this permission won't be able to create public links (except for oC10 instances where this permission is being set implicitly). + +https://github.com/owncloud/web/pull/8541 +https://github.com/owncloud/web/issues/8540 diff --git a/packages/web-app-files/src/components/FilesList/QuickActions.vue b/packages/web-app-files/src/components/FilesList/QuickActions.vue index 98e03f50c0c..8a9f0f7647f 100644 --- a/packages/web-app-files/src/components/FilesList/QuickActions.vue +++ b/packages/web-app-files/src/components/FilesList/QuickActions.vue @@ -8,7 +8,9 @@ appearance="raw" class="oc-mr-xs quick-action-button oc-p-xs" :class="`files-quick-action-${action.id}`" - @click="action.handler({ ...$language, item, client: $client, store: $store })" + @click=" + action.handler({ ...$language, item, client: $client, store: $store, ability: $ability }) + " > diff --git a/packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue b/packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue index 5e402839f09..4a5ae951d6d 100644 --- a/packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue +++ b/packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue @@ -5,7 +5,7 @@

@@ -31,7 +31,7 @@ />


can('create-all', 'PublicLink')) return { ...useGraphClient(), @@ -176,7 +179,8 @@ export default defineComponent({ linkListCollapsed, outgoingLinks, directLinks, - indirectLinks + indirectLinks, + canCreatePublicLinks } }, computed: { @@ -255,7 +259,7 @@ export default defineComponent({ return shareViaIndirectLinkHelp }, - canCreatePublicLinks() { + canCreateLinks() { if (this.resource.isReceivedShare() && !this.hasResharing) { return false } @@ -269,7 +273,7 @@ export default defineComponent({ }, canEdit() { - return this.canCreatePublicLinks + return this.canCreateLinks }, noResharePermsMessage() { @@ -363,7 +367,7 @@ export default defineComponent({ this.checkLinkToCreate({ link: { name: this.$gettext('Link'), - permissions: 1, + permissions: this.canCreatePublicLinks ? 1 : 0, expiration: this.expirationDate.default, password: false } @@ -452,7 +456,6 @@ export default defineComponent({ await this.addLink({ path, client: this.$client, - $gettext: this.$gettext, storageId: this.resource.fileId || this.resource.id, params }).catch((e) => { @@ -541,14 +544,15 @@ export default defineComponent({ }, getAvailableRoleOptions(link) { - if (this.incomingParentShare && this.canCreatePublicLinks) { + if (this.incomingParentShare && this.canCreateLinks) { return LinkShareRoles.filterByBitmask( this.incomingParentShare.permissions, this.resource.isFolder, this.hasPublicLinkEditing, this.hasPublicLinkContribute, this.hasPublicLinkAliasSupport, - !!link.password + !!link.password, + this.canCreatePublicLinks ) } @@ -557,7 +561,8 @@ export default defineComponent({ this.hasPublicLinkEditing, this.hasPublicLinkContribute, this.hasPublicLinkAliasSupport, - !!link.password + !!link.password, + this.canCreatePublicLinks ) } } diff --git a/packages/web-app-files/src/components/SideBar/Shares/Links/CreateQuickLink.vue b/packages/web-app-files/src/components/SideBar/Shares/Links/CreateQuickLink.vue index 22f3805c1ef..d04b21be2dd 100644 --- a/packages/web-app-files/src/components/SideBar/Shares/Links/CreateQuickLink.vue +++ b/packages/web-app-files/src/components/SideBar/Shares/Links/CreateQuickLink.vue @@ -18,7 +18,8 @@