diff --git a/packages/web-app-files/src/components/SideBar/Shares/FileShares.vue b/packages/web-app-files/src/components/SideBar/Shares/FileShares.vue index 4e743f8cebc..d59d65f0a25 100644 --- a/packages/web-app-files/src/components/SideBar/Shares/FileShares.vue +++ b/packages/web-app-files/src/components/SideBar/Shares/FileShares.vue @@ -83,7 +83,7 @@ import { shareInviteCollaboratorHelp, shareInviteCollaboratorHelpCern } from '../../../helpers/contextualHelpers' -import { defineComponent, PropType } from 'vue' +import { computed, defineComponent, PropType } from 'vue' import { isProjectSpaceResource, SpaceResource } from 'web-client/src/helpers' import { createFileRouteOptions } from 'web-pkg/src/helpers/router' @@ -103,9 +103,19 @@ export default defineComponent({ setup() { const store = useStore() const sharesListCollapsed = !store.getters.configuration.options.sidebar.shares.showAllOnLoad + const currentUserIsMemberOfSpace = computed(() => { + const userId = store.getters.user?.id + if (!userId) { + return false + } + return store.getters['runtime/spaces/spaceMembers'].some( + (member) => member.collaborator?.name === userId + ) + }) return { sharesListCollapsed, + currentUserIsMemberOfSpace, hasProjectSpaces: useCapabilityProjectSpacesEnabled(), hasShareJail: useCapabilityShareJailEnabled(), hasResharing: useCapabilityFilesSharingResharing() @@ -224,7 +234,7 @@ export default defineComponent({ return ( this.space?.driveType === 'project' && this.highlightedFile.type !== 'space' && - this.space?.isMember(this.user) + this.currentUserIsMemberOfSpace ) } }, @@ -336,18 +346,23 @@ export default defineComponent({ return null }, + // fixMe: head-breaking logic isShareModifiable(collaborator) { - const isSharableResource = this.space && isProjectSpaceResource(this.space) + const isPersonalSpaceShare = !isProjectSpaceResource(this.space) + const isPersonalMember = this.currentUserIsMemberOfSpace + const isIndirectPersonalCollaborator = collaborator.indirect + const isProjectSpaceShare = !isPersonalSpaceShare + const isManager = this.space?.isManager(this.user) - if (!isSharableResource) { - return false + if (isPersonalSpaceShare && isPersonalMember && isManager) { + return true } - if (this.space?.isManager(this.user)) { + if (isPersonalSpaceShare && !isIndirectPersonalCollaborator) { return true } - if (collaborator.indirect) { + if (isProjectSpaceShare && isManager) { return true } diff --git a/packages/web-app-files/tests/unit/components/SideBar/Shares/FileShares.spec.ts b/packages/web-app-files/tests/unit/components/SideBar/Shares/FileShares.spec.ts index fc0bd753981..c9c00ead8b1 100644 --- a/packages/web-app-files/tests/unit/components/SideBar/Shares/FileShares.spec.ts +++ b/packages/web-app-files/tests/unit/components/SideBar/Shares/FileShares.spec.ts @@ -121,10 +121,7 @@ describe('FileShares', () => { it('loads space members if a space is given and the current user is member', () => { const user = { id: '1' } const space = mockDeep({ driveType: 'project' }) - const spaceMembers = [ - { collaborator: { name: user.id } }, - { collaborator: { name: 2 } } - ] + const spaceMembers = [{ collaborator: { name: user.id } }, { collaborator: { name: 2 } }] const collaborator = getCollaborator() collaborator.collaborator = { ...collaborator.collaborator, name: user.id } const { wrapper } = getWrapper({ space, collaborators: [collaborator], user, spaceMembers }) diff --git a/packages/web-app-files/tests/unit/components/SideBar/Shares/__snapshots__/FileShares.spec.ts.snap b/packages/web-app-files/tests/unit/components/SideBar/Shares/__snapshots__/FileShares.spec.ts.snap index 4fdc648797d..58fb7f416b0 100644 --- a/packages/web-app-files/tests/unit/components/SideBar/Shares/__snapshots__/FileShares.spec.ts.snap +++ b/packages/web-app-files/tests/unit/components/SideBar/Shares/__snapshots__/FileShares.spec.ts.snap @@ -32,16 +32,16 @@ exports[`FileShares collaborators list renders sharedWithLabel and sharee list 1
@@ -61,12 +61,21 @@ exports[`FileShares current space loads space members if a space is given and th

Shared with

-
`; diff --git a/packages/web-client/src/helpers/resource/types.ts b/packages/web-client/src/helpers/resource/types.ts index ca591432c1a..9679fb842ba 100644 --- a/packages/web-client/src/helpers/resource/types.ts +++ b/packages/web-client/src/helpers/resource/types.ts @@ -65,7 +65,6 @@ export interface Resource { isMounted?(): boolean getDomSelector?(): string - matchingSpace?: any resourceOwner?: User