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 <matteo.sonnenholzner@kiteworks.com>
This commit is contained in:
Matteo authored and Roman Perekhod committed 2026-10-29 13:55:17 +01:00
1 parent b5cc5cc415
commit cd9821abe6
6 files changed
+152 -18

No files matched your search

@@ -105,6 +105,23 @@
/>
</div>
</div>
<div id="vault-group-notice-status" role="status">
<div
v-if="showVaultGroupNotice"
class="oc-flex oc-flex-middle oc-gap-s oc-background-muted oc-rounded oc-p-s oc-mb-s oc-text-small"
data-testid="vault-group-notice"
>
<oc-icon name="information" size="small" aria-hidden="true" />
<span
v-text="
$pgettext(
'Notice shown when sharing a resource inside the vault with a group',
'Group members without vault access will not receive a notification and cannot access the share.'
)
"
/>
</div>
</div>
<div class="oc-flex oc-flex-between oc-flex-middle oc-mb-l oc-mt-s">
<role-dropdown
mode="create"
@@ -199,7 +216,7 @@ import {
} from '@ownclouders/web-pkg'
import { computed, inject, ref, unref, watch, onMounted, nextTick, Ref, useTemplateRef } from 'vue'
import { Resource, SpaceResource, VAULT_STORAGE_PROVIDER_ID } from '@ownclouders/web-client'
import { Resource, SpaceResource } from '@ownclouders/web-client'
import { DateTime } from 'luxon'
import { OcDrop } from '@ownclouders/design-system/components'
import { useTask } from 'vue-concurrency'
@@ -207,6 +224,7 @@ import { useGettext } from 'vue3-gettext'
import { isProjectSpaceResource } from '@ownclouders/web-client'
import { Group } from '@ownclouders/web-client/graph/generated'
import ExpirationDateIndicator from '../../ExpirationDateIndicator.vue'
import { isVaultResource as isVaultResourceHelper } from '../../../../../helpers/resource/vault'
type AccountType = {
prefix: string
@@ -317,15 +335,17 @@ const accountTypes: AccountType[] = [
]
const saveButtonText = computed(() => 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
@@ -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(() => {
@@ -63,6 +63,20 @@ export const useContextualHelpers = () => {
})
)
const shareInviteCollaboratorHelpVault = computed<ContextualHelperData>(() =>
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<ContextualHelperData>(() =>
filterContextHelper({
title: $gettext('Add members to this Space'),
@@ -134,6 +148,7 @@ export const useContextualHelpers = () => {
return {
shareInviteCollaboratorHelp,
shareInviteCollaboratorHelpCern,
shareInviteCollaboratorHelpVault,
shareSpaceAddMemberHelp,
shareViaLinkHelp,
shareViaIndirectLinkHelp,
@@ -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
}
@@ -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<Resource>({ ...folderMock, storageId: VAULT_STORAGE_PROVIDER_ID })
})
wrapper.vm.selectedCollaborators = [
mock<CollaboratorAutoCompleteItem>({ 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<Resource>({ ...folderMock, storageId: VAULT_STORAGE_PROVIDER_ID })
})
wrapper.vm.selectedCollaborators = [
mock<CollaboratorAutoCompleteItem>({ 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<Resource>({ ...folderMock, storageId: 'some-other-provider' })
})
wrapper.vm.selectedCollaborators = [
mock<CollaboratorAutoCompleteItem>({ 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 } },
@@ -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<any, any>) =>
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<Resource>({
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<Resource>({
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<CapabilityStore['capabilities']>
if (spaceMembers.length) {