From cd9821abe60af94b6894eb9cc9216f815e747cd5 Mon Sep 17 00:00:00 2001 From: Matteo Date: Thu, 29 Oct 2026 06:09:07 +0100 Subject: [PATCH] feat(web): [OCISDEV-1516] warn about group members without vault access when sharing Show a notice in the share form when a group is selected for a vault resource, and add the same information to the "Share with people" help. Signed-off-by: Matteo --- .../InviteCollaboratorForm.vue | 40 +++++++++++---- .../components/SideBar/Shares/FileShares.vue | 16 ++++-- .../contextualHelpers/useContextualHelpers.ts | 15 ++++++ .../src/helpers/resource/vault.ts | 11 ++++ .../InviteCollaboratorForm.spec.ts | 50 ++++++++++++++++++- .../SideBar/Shares/FileShares.spec.ts | 38 ++++++++++++-- 6 files changed, 152 insertions(+), 18 deletions(-) create mode 100644 web/packages/web-app-files/src/helpers/resource/vault.ts diff --git a/web/packages/web-app-files/src/components/SideBar/Shares/Collaborators/InviteCollaborator/InviteCollaboratorForm.vue b/web/packages/web-app-files/src/components/SideBar/Shares/Collaborators/InviteCollaborator/InviteCollaboratorForm.vue index 389ee9f2066..44e9f16cdd3 100644 --- a/web/packages/web-app-files/src/components/SideBar/Shares/Collaborators/InviteCollaborator/InviteCollaboratorForm.vue +++ b/web/packages/web-app-files/src/components/SideBar/Shares/Collaborators/InviteCollaborator/InviteCollaboratorForm.vue @@ -105,6 +105,23 @@ /> +
+
+
+
saveButtonLabel || $gettext('Share')) -// A resource lives in the vault if its storage provider is the vault one. Space resources carry -// the full drive id in storageId, plain resources only the provider id, hence the split. -const isVaultResource = computed(() => { - const storageId = unref(resource)?.storageId - if (!unref(capabilityRefs.vaultEnabled) || typeof storageId !== 'string') { - return false - } - return storageId.split('$')[0] === VAULT_STORAGE_PROVIDER_ID -}) +const isVaultResource = computed(() => + isVaultResourceHelper(unref(resource), unref(capabilityRefs.vaultEnabled)) +) + +// group members without vault access are filtered out by the server when it sends the share +// notifications, and they can't open the resource either +const showVaultGroupNotice = computed( + () => + unref(isVaultResource) && + unref(selectedCollaborators).some(({ shareType }) => shareType === ShareTypes.group.value) +) // no local fallback: the default lives only in the server's vault config const vaultDefaultExpirationDays = capabilityRefs.vaultDefaultShareExpirationDays diff --git a/web/packages/web-app-files/src/components/SideBar/Shares/FileShares.vue b/web/packages/web-app-files/src/components/SideBar/Shares/FileShares.vue index 2e79cef2a51..6fd87a38e3f 100644 --- a/web/packages/web-app-files/src/components/SideBar/Shares/FileShares.vue +++ b/web/packages/web-app-files/src/components/SideBar/Shares/FileShares.vue @@ -110,6 +110,7 @@ import { } from '@ownclouders/web-pkg' import { isLocationSharesActive } from '@ownclouders/web-pkg' import { textUtils } from '../../../helpers/textUtils' +import { isVaultResource } from '../../../helpers/resource/vault' import { isShareSpaceResource, ShareTypes } from '@ownclouders/web-client' import InviteCollaboratorForm from './Collaborators/InviteCollaborator/InviteCollaboratorForm.vue' import CollaboratorListItem from './Collaborators/ListItem.vue' @@ -144,7 +145,11 @@ const { getSpaceMembers } = useSpacesStore() const configStore = useConfigStore() const { options: configOptions } = storeToRefs(configStore) -const { shareInviteCollaboratorHelp, shareInviteCollaboratorHelpCern } = useContextualHelpers() +const { + shareInviteCollaboratorHelp, + shareInviteCollaboratorHelpCern, + shareInviteCollaboratorHelpVault +} = useContextualHelpers() const sharesStore = useSharesStore() const { addShare, deleteShare } = sharesStore @@ -203,14 +208,17 @@ const collaborators = computed(() => { const inviteCollaboratorHelp = computed(() => { const cernFeatures = configOptions.value.cernFeatures + const mergedHelp = { ...unref(shareInviteCollaboratorHelp) } if (cernFeatures) { - const mergedHelp = { ...unref(shareInviteCollaboratorHelp) } mergedHelp.list = [...unref(shareInviteCollaboratorHelpCern).list, ...mergedHelp.list] - return mergedHelp } - return unref(shareInviteCollaboratorHelp) + if (isVaultResource(unref(resource), capabilityStore.vaultEnabled)) { + mergedHelp.list = [...mergedHelp.list, ...unref(shareInviteCollaboratorHelpVault).list] + } + + return mergedHelp }) const helpersEnabled = computed(() => { diff --git a/web/packages/web-app-files/src/composables/contextualHelpers/useContextualHelpers.ts b/web/packages/web-app-files/src/composables/contextualHelpers/useContextualHelpers.ts index b3d14950c81..1fe67dd2f52 100644 --- a/web/packages/web-app-files/src/composables/contextualHelpers/useContextualHelpers.ts +++ b/web/packages/web-app-files/src/composables/contextualHelpers/useContextualHelpers.ts @@ -63,6 +63,20 @@ export const useContextualHelpers = () => { }) ) + const shareInviteCollaboratorHelpVault = computed(() => + filterContextHelper({ + title: '', + list: [ + { text: $gettext('Groups in the vault'), headline: true }, + { + text: $gettext( + 'If you share with a group, only group members with vault access will receive a notification and can access the share.' + ) + } + ] + }) + ) + const shareSpaceAddMemberHelp = computed(() => filterContextHelper({ title: $gettext('Add members to this Space'), @@ -134,6 +148,7 @@ export const useContextualHelpers = () => { return { shareInviteCollaboratorHelp, shareInviteCollaboratorHelpCern, + shareInviteCollaboratorHelpVault, shareSpaceAddMemberHelp, shareViaLinkHelp, shareViaIndirectLinkHelp, diff --git a/web/packages/web-app-files/src/helpers/resource/vault.ts b/web/packages/web-app-files/src/helpers/resource/vault.ts new file mode 100644 index 00000000000..22d858a0fd7 --- /dev/null +++ b/web/packages/web-app-files/src/helpers/resource/vault.ts @@ -0,0 +1,11 @@ +import { Resource, VAULT_STORAGE_PROVIDER_ID } from '@ownclouders/web-client' + +// A resource lives in the vault if its storage provider is the vault one. Space resources carry +// the full drive id in storageId, plain resources only the provider id, hence the split. +export const isVaultResource = (resource: Resource, vaultEnabled: boolean): boolean => { + const storageId = resource?.storageId + if (!vaultEnabled || typeof storageId !== 'string') { + return false + } + return storageId.split('$')[0] === VAULT_STORAGE_PROVIDER_ID +} diff --git a/web/packages/web-app-files/tests/unit/components/SideBar/Shares/Collaborators/InviteCollaborator/InviteCollaboratorForm.spec.ts b/web/packages/web-app-files/tests/unit/components/SideBar/Shares/Collaborators/InviteCollaborator/InviteCollaboratorForm.spec.ts index 68e1512a78b..f4422c5821f 100644 --- a/web/packages/web-app-files/tests/unit/components/SideBar/Shares/Collaborators/InviteCollaborator/InviteCollaboratorForm.spec.ts +++ b/web/packages/web-app-files/tests/unit/components/SideBar/Shares/Collaborators/InviteCollaborator/InviteCollaboratorForm.spec.ts @@ -10,7 +10,12 @@ import { } from '@ownclouders/web-test-helpers' import { Resource, SpaceResource, VAULT_STORAGE_PROVIDER_ID } from '@ownclouders/web-client' import { useSharesStore } from '@ownclouders/web-pkg' -import { CollaboratorAutoCompleteItem, CollaboratorShare, ShareRole } from '@ownclouders/web-client' +import { + CollaboratorAutoCompleteItem, + CollaboratorShare, + ShareRole, + ShareTypes +} from '@ownclouders/web-client' import { Group, User } from '@ownclouders/web-client/graph/generated' import { OcButton } from '@ownclouders/design-system/components' import RoleDropdown from '../../../../../../../src/components/SideBar/Shares/Collaborators/RoleDropdown.vue' @@ -179,6 +184,49 @@ describe('InviteCollaboratorForm', () => { ) }) }) + describe('vault group notice', () => { + const vaultCapabilities = { + files_sharing: { federation: { incoming: true, outgoing: true } }, + vault: { enabled: true, vault_storage_provider: '' } + } + + it('shows when a group is selected for a vault resource', async () => { + const { wrapper } = getWrapper({ + capabilities: vaultCapabilities, + resource: mock({ ...folderMock, storageId: VAULT_STORAGE_PROVIDER_ID }) + }) + wrapper.vm.selectedCollaborators = [ + mock({ shareType: ShareTypes.group.value }) + ] + await wrapper.vm.$nextTick() + + expect(wrapper.find('[data-testid="vault-group-notice"]').exists()).toBeTruthy() + }) + it('does not show when only users are selected', async () => { + const { wrapper } = getWrapper({ + capabilities: vaultCapabilities, + resource: mock({ ...folderMock, storageId: VAULT_STORAGE_PROVIDER_ID }) + }) + wrapper.vm.selectedCollaborators = [ + mock({ shareType: ShareTypes.user.value }) + ] + await wrapper.vm.$nextTick() + + expect(wrapper.find('[data-testid="vault-group-notice"]').exists()).toBeFalsy() + }) + it('does not show for a group outside the vault', async () => { + const { wrapper } = getWrapper({ + capabilities: vaultCapabilities, + resource: mock({ ...folderMock, storageId: 'some-other-provider' }) + }) + wrapper.vm.selectedCollaborators = [ + mock({ shareType: ShareTypes.group.value }) + ] + await wrapper.vm.$nextTick() + + expect(wrapper.find('[data-testid="vault-group-notice"]').exists()).toBeFalsy() + }) + }) describe('vault default expiration notice', () => { const vaultCapabilities = { files_sharing: { federation: { incoming: true, outgoing: true } }, diff --git a/web/packages/web-app-files/tests/unit/components/SideBar/Shares/FileShares.spec.ts b/web/packages/web-app-files/tests/unit/components/SideBar/Shares/FileShares.spec.ts index 338c0f7b137..9e4b84092b7 100644 --- a/web/packages/web-app-files/tests/unit/components/SideBar/Shares/FileShares.spec.ts +++ b/web/packages/web-app-files/tests/unit/components/SideBar/Shares/FileShares.spec.ts @@ -1,6 +1,6 @@ import FileShares from '../../../../../src/components/SideBar/Shares/FileShares.vue' import { mock } from 'vitest-mock-extended' -import { Resource } from '@ownclouders/web-client' +import { Resource, VAULT_STORAGE_PROVIDER_ID } from '@ownclouders/web-client' import { SpaceResource } from '@ownclouders/web-client' import { v4 as uuidV4 } from 'uuid' import { CollaboratorShare, ShareRole, ShareTypes } from '@ownclouders/web-client' @@ -53,6 +53,35 @@ describe('FileShares', () => { }) }) + describe('invite collaborator help', () => { + const hasVaultGroupHint = (wrapper: VueWrapper) => + wrapper.vm.inviteCollaboratorHelp.list.some( + ({ text }: { text: string }) => text === 'Groups in the vault' + ) + + it('explains group shares for a vault resource', () => { + const { wrapper } = getWrapper({ + vaultEnabled: true, + resource: mock({ + isReceivedShare: () => false, + canShare: () => true, + storageId: VAULT_STORAGE_PROVIDER_ID + }) + }) + expect(hasVaultGroupHint(wrapper)).toBeTruthy() + }) + it('does not explain group shares for a resource outside the vault', () => { + const { wrapper } = getWrapper({ + vaultEnabled: true, + resource: mock({ + isReceivedShare: () => false, + canShare: () => true, + storageId: 'some-other-provider' + }) + }) + expect(hasVaultGroupHint(wrapper)).toBeFalsy() + }) + }) describe('collaborators list', () => { let collaborators: CollaboratorShare[] beforeEach(() => { @@ -169,7 +198,8 @@ function getWrapper({ spaceMembers = [], user = undefined, ancestorMetaData = {}, - canShare = true + canShare = true, + vaultEnabled = false }: { mountType?: typeof mount resource?: Resource @@ -179,11 +209,13 @@ function getWrapper({ user?: User ancestorMetaData?: AncestorMetaData canShare?: boolean + vaultEnabled?: boolean } = {}) { vi.mocked(useCanShare).mockReturnValue({ canShare: () => canShare }) const capabilities = { - files_sharing: { deny_access: false } + files_sharing: { deny_access: false }, + vault: { enabled: vaultEnabled } } satisfies Partial if (spaceMembers.length) {