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 46b5bedc63b..ef12e4e76d5 100644 --- a/packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue +++ b/packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue @@ -116,6 +116,7 @@ import { useCapabilityShareJailEnabled, useCapabilityFilesSharingResharing, useCapabilityFilesSharingPublicCanEdit, + useCapabilityFilesSharingPublicCanContribute, useCapabilityFilesSharingPublicAlias } from 'web-pkg/src/composables' import { shareViaLinkHelp, shareViaIndirectLinkHelp } from '../../../helpers/contextualHelpers' @@ -153,6 +154,7 @@ export default defineComponent({ hasShareJail: useCapabilityShareJailEnabled(), hasResharing: useCapabilityFilesSharingResharing(), hasPublicLinkEditing: useCapabilityFilesSharingPublicCanEdit(), + hasPublicLinkContribute: useCapabilityFilesSharingPublicCanContribute(), hasPublicLinkAliasSupport: useCapabilityFilesSharingPublicAlias(), indirectLinkListCollapsed, linkListCollapsed @@ -561,6 +563,7 @@ export default defineComponent({ this.incomingParentShare.permissions, this.resource.isFolder, this.hasPublicLinkEditing, + this.hasPublicLinkContribute, this.hasPublicLinkAliasSupport, !!link.password ) @@ -569,6 +572,7 @@ export default defineComponent({ return LinkShareRoles.list( this.resource.isFolder, this.hasPublicLinkEditing, + this.hasPublicLinkContribute, this.hasPublicLinkAliasSupport, !!link.password ) diff --git a/packages/web-app-files/tests/unit/components/SideBar/Shares/Links/DetailsAndEdit.spec.ts b/packages/web-app-files/tests/unit/components/SideBar/Shares/Links/DetailsAndEdit.spec.ts index 9ee426ad9fd..59ad472301d 100644 --- a/packages/web-app-files/tests/unit/components/SideBar/Shares/Links/DetailsAndEdit.spec.ts +++ b/packages/web-app-files/tests/unit/components/SideBar/Shares/Links/DetailsAndEdit.spec.ts @@ -9,7 +9,7 @@ import { import { mockDeep } from 'jest-mock-extended' import { Resource } from 'web-client' -const availableRoleOptions = LinkShareRoles.list(false, true, true) +const availableRoleOptions = LinkShareRoles.list(false, true, true, true) const exampleLink = { name: 'Example link', diff --git a/packages/web-client/src/helpers/share/role.ts b/packages/web-client/src/helpers/share/role.ts index fc02c8d88d3..f94812792c6 100644 --- a/packages/web-client/src/helpers/share/role.ts +++ b/packages/web-client/src/helpers/share/role.ts @@ -359,7 +359,6 @@ export abstract class LinkShareRoles { static readonly all = [ linkRoleViewerFile, linkRoleViewerFolder, - linkRoleContributorFolder, linkRoleEditorFolder, linkRoleUploaderFolder ] @@ -367,18 +366,26 @@ export abstract class LinkShareRoles { static list( isFolder: boolean, canEditFile = false, + canContribute = false, hasAliasLinks = false, hasPassword = false ): ShareRole[] { return [ ...(hasAliasLinks && !hasPassword ? [linkRoleInternalFile, linkRoleInternalFolder] : []), ...this.all, - ...(canEditFile ? [linkRoleEditorFile] : []) + ...(canEditFile ? [linkRoleEditorFile] : []), + ...(canContribute ? [linkRoleContributorFolder] : []) ].filter((r) => r.folder === isFolder) } static getByBitmask(bitmask: number, isFolder: boolean): ShareRole { - return [...this.all, linkRoleEditorFile, linkRoleInternalFile, linkRoleInternalFolder] // Always return all roles + return [ + ...this.all, + linkRoleEditorFile, + linkRoleContributorFolder, + linkRoleInternalFile, + linkRoleInternalFolder + ] // Always return all roles .find((r) => r.folder === isFolder && r.bitmask(false) === bitmask) } @@ -387,6 +394,7 @@ export abstract class LinkShareRoles { * @param bitmask * @param isFolder * @param canEditFile + * @param canContribute * @param hasAliasLinks * @param hasPassword */ @@ -394,13 +402,15 @@ export abstract class LinkShareRoles { bitmask: number, isFolder: boolean, canEditFile = false, + canContribute = false, hasAliasLinks = false, hasPassword = false ): ShareRole[] { return [ ...(hasAliasLinks && !hasPassword ? [linkRoleInternalFile, linkRoleInternalFolder] : []), ...this.all, - ...(canEditFile ? [linkRoleEditorFile] : []) + ...(canEditFile ? [linkRoleEditorFile] : []), + ...(canContribute ? [linkRoleContributorFolder] : []) ].filter((r) => { return r.folder === isFolder && bitmask === (bitmask | r.bitmask(false)) }) diff --git a/packages/web-pkg/src/composables/capability/useCapability.ts b/packages/web-pkg/src/composables/capability/useCapability.ts index 0af0600fe55..94918e5253a 100644 --- a/packages/web-pkg/src/composables/capability/useCapability.ts +++ b/packages/web-pkg/src/composables/capability/useCapability.ts @@ -73,6 +73,10 @@ export const useCapabilityFilesSharingPublicCanEdit = createCapabilityComposable 'files_sharing.public.can_edit', false ) +export const useCapabilityFilesSharingPublicCanContribute = createCapabilityComposable( + 'files_sharing.public.can_contribute', + true +) export const useCapabilityFilesSharingPublicAlias = createCapabilityComposable( 'files_sharing.public.alias', false