From e970dde64ecf9ca5e03aa60efb194116b087f7b6 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Wed, 27 Mar 2024 07:22:56 +0100 Subject: [PATCH] refactor: merge share functions.ts and functionsNG.ts files --- .../services/folder/loaderSharedViaLink.ts | 2 +- .../src/services/folder/loaderSharedWithMe.ts | 2 +- .../services/folder/loaderSharedWithOthers.ts | 2 +- .../web-client/src/helpers/share/functions.ts | 281 +++++++++++++++++- .../src/helpers/share/functionsNG.ts | 279 ----------------- .../src/components/SideBar/FileSideBar.vue | 2 +- .../files/useFileActionsCopyQuicklink.ts | 2 +- .../composables/piniaStores/shares/shares.ts | 2 +- .../src/composables/piniaStores/spaces.ts | 2 +- .../files/useFileActionsCopyQuicklink.spec.ts | 5 +- .../composables/piniaStores/shares.spec.ts | 4 +- 11 files changed, 292 insertions(+), 291 deletions(-) delete mode 100644 packages/web-client/src/helpers/share/functionsNG.ts diff --git a/packages/web-app-files/src/services/folder/loaderSharedViaLink.ts b/packages/web-app-files/src/services/folder/loaderSharedViaLink.ts index f5c3a53cd0f..c07f0abf718 100644 --- a/packages/web-app-files/src/services/folder/loaderSharedViaLink.ts +++ b/packages/web-app-files/src/services/folder/loaderSharedViaLink.ts @@ -2,7 +2,7 @@ import { FolderLoader, FolderLoaderTask, TaskContext } from '../folder' import { Router } from 'vue-router' import { useTask } from 'vue-concurrency' import { isLocationSharesActive } from '@ownclouders/web-pkg' -import { buildOutgoingShareResource } from '@ownclouders/web-client/src/helpers/share/functionsNG' +import { buildOutgoingShareResource } from '@ownclouders/web-client/src/helpers/share/functions' export class FolderLoaderSharedViaLink implements FolderLoader { public isEnabled(): boolean { diff --git a/packages/web-app-files/src/services/folder/loaderSharedWithMe.ts b/packages/web-app-files/src/services/folder/loaderSharedWithMe.ts index 89cbdbddf6b..8a49b4d8936 100644 --- a/packages/web-app-files/src/services/folder/loaderSharedWithMe.ts +++ b/packages/web-app-files/src/services/folder/loaderSharedWithMe.ts @@ -1,7 +1,7 @@ import { FolderLoader, FolderLoaderTask, TaskContext } from '../folder' import { Router } from 'vue-router' import { useTask } from 'vue-concurrency' -import { buildIncomingShareResource } from '@ownclouders/web-client/src/helpers/share/functionsNG' +import { buildIncomingShareResource } from '@ownclouders/web-client/src/helpers/share/functions' import { isLocationSharesActive } from '@ownclouders/web-pkg' export class FolderLoaderSharedWithMe implements FolderLoader { diff --git a/packages/web-app-files/src/services/folder/loaderSharedWithOthers.ts b/packages/web-app-files/src/services/folder/loaderSharedWithOthers.ts index b07f65fec80..b49b4fe02a5 100644 --- a/packages/web-app-files/src/services/folder/loaderSharedWithOthers.ts +++ b/packages/web-app-files/src/services/folder/loaderSharedWithOthers.ts @@ -2,7 +2,7 @@ import { FolderLoader, FolderLoaderTask, TaskContext } from '../folder' import { Router } from 'vue-router' import { useTask } from 'vue-concurrency' import { isLocationSharesActive } from '@ownclouders/web-pkg' -import { buildOutgoingShareResource } from '@ownclouders/web-client/src/helpers/share/functionsNG' +import { buildOutgoingShareResource } from '@ownclouders/web-client/src/helpers/share/functions' export class FolderLoaderSharedWithOthers implements FolderLoader { public isEnabled(): boolean { diff --git a/packages/web-client/src/helpers/share/functions.ts b/packages/web-client/src/helpers/share/functions.ts index cd78d8f6b6d..5c170b63220 100644 --- a/packages/web-client/src/helpers/share/functions.ts +++ b/packages/web-client/src/helpers/share/functions.ts @@ -1,5 +1,18 @@ import { Resource } from '../resource' -import { ShareResource, OutgoingShareResource, IncomingShareResource } from './types' +import { + ShareResource, + OutgoingShareResource, + IncomingShareResource, + CollaboratorShare, + GraphSharePermission, + LinkShare +} from './types' +import { extractDomSelector, extractExtensionFromFile, extractStorageId } from '../resource' +import { ShareTypes } from './type' +import { buildWebDavSpacesPath } from '../space' +import { DriveItem, Identity, Permission, UnifiedRoleDefinition, User } from '../../generated' +import { urlJoin } from '../../utils' +import { uniq } from 'lodash-es' export const isShareResource = (resource: Resource): resource is ShareResource => { return Object.hasOwn(resource, 'sharedWith') @@ -12,3 +25,269 @@ export const isOutgoingShareResource = (resource: Resource): resource is Outgoin export const isIncomingShareResource = (resource: Resource): resource is IncomingShareResource => { return isShareResource(resource) && !resource.outgoing } + +export const getShareResourceRoles = ({ + driveItem, + graphRoles +}: { + driveItem: DriveItem + graphRoles: UnifiedRoleDefinition[] +}) => { + return driveItem.remoteItem?.permissions.reduce((acc, permission) => { + permission.roles?.forEach((roleId) => { + const role = graphRoles.find(({ id }) => id === roleId) + if (role && !acc.some(({ id }) => id === role.id)) { + acc.push(role) + } + }) + + return acc + }, []) +} + +export const getShareResourcePermissions = ({ + driveItem, + shareRoles +}: { + driveItem: DriveItem + shareRoles: UnifiedRoleDefinition[] +}): GraphSharePermission[] => { + if (!shareRoles.length) { + // the server lists plain permissions if it doesn't find a corresponding role + const permissions = driveItem.remoteItem?.permissions.reduce( + (acc, permission) => { + const permissions = permission['@libre.graph.permissions.actions'] as GraphSharePermission[] + if (permissions) { + acc.push(...permissions) + } + + return acc + }, + [] + ) + return [...new Set(permissions)] + } + + const permissions = shareRoles.reduce((acc, role) => { + role.rolePermissions.forEach((permission) => { + acc.push(...permission.allowedResourceActions) + }) + return acc + }, []) + + return [...new Set(permissions)] +} + +export function buildIncomingShareResource({ + driveItem, + graphRoles +}: { + driveItem: DriveItem + graphRoles: UnifiedRoleDefinition[] +}): IncomingShareResource { + const resourceName = driveItem.name || driveItem.remoteItem.name + const storageId = extractStorageId(driveItem.remoteItem.id) + + const shareTypes = uniq( + driveItem.remoteItem.permissions.map((p) => + p.grantedToV2.group ? ShareTypes.group.value : ShareTypes.user.value + ) + ) + + const sharedWith = driveItem.remoteItem.permissions.map(({ grantedToV2 }) => { + const identity = grantedToV2.group || grantedToV2.user + return { + ...identity, + shareType: grantedToV2.group ? ShareTypes.group.value : ShareTypes.user.value + } + }) + + const sharedBy = driveItem.remoteItem.permissions.reduce((acc, permission) => { + const sharedBy = permission.invitation.invitedBy.user + if (!acc.some(({ id }) => id === sharedBy.id)) { + acc.push(sharedBy) + } + return acc + }, []) + + const shareRoles = getShareResourceRoles({ driveItem, graphRoles }) + const sharePermissions = getShareResourcePermissions({ driveItem, shareRoles }) + + const resource: IncomingShareResource = { + id: driveItem.id, + shareId: driveItem.remoteItem.permissions[0].id, + driveId: driveItem.parentReference?.driveId, + path: '/', + name: resourceName, + fileId: driveItem.remoteItem.id, + storageId, + parentFolderId: driveItem.parentReference?.id, + sdate: driveItem.lastModifiedDateTime, // FIXME: share date is missing in API + indicators: [], + tags: [], + webDavPath: buildWebDavSpacesPath(driveItem.id, '/'), + sharedBy, + owner: driveItem.remoteItem.createdBy?.user, + sharedWith, + shareTypes, + isFolder: !!driveItem.folder, + type: !!driveItem.folder ? 'folder' : 'file', + mimeType: driveItem.file?.mimeType || 'httpd/unix-directory', + syncEnabled: driveItem['@client.synchronize'], + hidden: driveItem['@UI.Hidden'], + shareRoles, + sharePermissions, + outgoing: false, + canRename: () => driveItem['@client.synchronize'], + canDownload: () => sharePermissions.includes(GraphSharePermission.readBasic), + canUpload: () => sharePermissions.includes(GraphSharePermission.createUpload), + canCreate: () => sharePermissions.includes(GraphSharePermission.createChildren), + canBeDeleted: () => sharePermissions.includes(GraphSharePermission.deleteStandard), + canEditTags: () => sharePermissions.includes(GraphSharePermission.createChildren), + isMounted: () => false, + isReceivedShare: () => true, + canShare: () => false, + canDeny: () => false, + getDomSelector: () => extractDomSelector(driveItem.id) + } + + resource.extension = extractExtensionFromFile(resource) + + return resource +} + +export function buildOutgoingShareResource({ + driveItem, + user +}: { + driveItem: DriveItem + user: User +}): OutgoingShareResource { + const storageId = extractStorageId(driveItem.id) + const path = urlJoin(driveItem.parentReference.path, driveItem.name) + + const resource: OutgoingShareResource = { + id: driveItem.id, + shareId: driveItem.permissions[0].id, + driveId: driveItem.parentReference?.driveId, + path, + name: driveItem.name, + fileId: driveItem.id, + storageId, + parentFolderId: driveItem.parentReference?.id, + sdate: driveItem.lastModifiedDateTime, // FIXME: share date is missing in API + indicators: [], + tags: [], + webDavPath: buildWebDavSpacesPath(storageId, path), + sharedBy: [{ id: user.id, displayName: user.displayName }], + owner: { id: user.id, displayName: user.displayName }, + sharedWith: driveItem.permissions.map((p) => { + if (p.link) { + return { + id: p.id, + displayName: p.link['@libre.graph.displayName'], + shareType: ShareTypes.link.value + } + } + if (p.grantedToV2.group) { + return { ...p.grantedToV2.group, shareType: ShareTypes.group.value } + } + return { ...p.grantedToV2.user, shareType: ShareTypes.user.value } + }), + shareTypes: driveItem.permissions.map((p) => { + if (p.link) { + return ShareTypes.link.value + } + if (p.grantedToV2.group) { + return ShareTypes.group.value + } + return ShareTypes.user.value + }), + isFolder: !!driveItem.folder, + type: !!driveItem.folder ? 'folder' : 'file', + mimeType: driveItem.file?.mimeType || 'httpd/unix-directory', + outgoing: true, + canRename: () => true, + canDownload: () => true, + canUpload: () => true, + canCreate: () => true, + canBeDeleted: () => true, + canEditTags: () => true, + isMounted: () => false, + isReceivedShare: () => true, + canShare: () => true, + canDeny: () => true, + getDomSelector: () => extractDomSelector(driveItem.id) + } + + resource.extension = extractExtensionFromFile(resource) + + return resource +} + +export function buildCollaboratorShare({ + graphPermission, + graphRoles, + resourceId, + spaceId, + user, + indirect = false +}: { + graphPermission: Permission + graphRoles: UnifiedRoleDefinition[] + resourceId: string + spaceId: string + user: User + indirect?: boolean +}): CollaboratorShare { + const role = graphRoles.find(({ id }) => id === graphPermission.roles?.[0]) + const isSpace = resourceId === spaceId + + let shareType: number + if (graphPermission.grantedToV2.group) { + shareType = isSpace ? ShareTypes.spaceGroup.value : ShareTypes.group.value + } else { + shareType = isSpace ? ShareTypes.spaceUser.value : ShareTypes.user.value + } + + return { + id: graphPermission.id, + resourceId, + indirect, + shareType, + role, + sharedBy: { id: user.id, displayName: user.displayName }, + sharedWith: graphPermission.grantedToV2.user || graphPermission.grantedToV2.group, + permissions: (graphPermission['@libre.graph.permissions.actions'] + ? graphPermission['@libre.graph.permissions.actions'] + : role.rolePermissions.flatMap((p) => p.allowedResourceActions)) as GraphSharePermission[], + expirationDateTime: graphPermission.expirationDateTime + } +} + +export function buildLinkShare({ + graphPermission, + user, + resourceId, + indirect = false +}: { + graphPermission: Permission + user: User + resourceId: string + indirect?: boolean +}): LinkShare { + return { + id: graphPermission.id, + resourceId, + indirect, + shareType: ShareTypes.link.value, + sharedBy: { id: user.id, displayName: user.displayName }, + hasPassword: graphPermission.hasPassword, + expirationDateTime: graphPermission.expirationDateTime, + displayName: graphPermission.link['@libre.graph.displayName'], + isQuickLink: graphPermission.link['@libre.graph.quickLink'], + type: graphPermission.link.type, + webUrl: graphPermission.link.webUrl, + preventsDownload: graphPermission.link.preventsDownload + } +} diff --git a/packages/web-client/src/helpers/share/functionsNG.ts b/packages/web-client/src/helpers/share/functionsNG.ts deleted file mode 100644 index 2b7bd92fa53..00000000000 --- a/packages/web-client/src/helpers/share/functionsNG.ts +++ /dev/null @@ -1,279 +0,0 @@ -import { extractDomSelector, extractExtensionFromFile, extractStorageId } from '../resource' -import { ShareTypes } from './type' -import { buildWebDavSpacesPath } from '../space' -import { DriveItem, Identity, Permission, UnifiedRoleDefinition, User } from '../../generated' -import { - CollaboratorShare, - GraphSharePermission, - IncomingShareResource, - LinkShare, - OutgoingShareResource -} from './types' -import { urlJoin } from '../../utils' -import { uniq } from 'lodash-es' - -export const getShareResourceRoles = ({ - driveItem, - graphRoles -}: { - driveItem: DriveItem - graphRoles: UnifiedRoleDefinition[] -}) => { - return driveItem.remoteItem?.permissions.reduce((acc, permission) => { - permission.roles?.forEach((roleId) => { - const role = graphRoles.find(({ id }) => id === roleId) - if (role && !acc.some(({ id }) => id === role.id)) { - acc.push(role) - } - }) - - return acc - }, []) -} - -export const getShareResourcePermissions = ({ - driveItem, - shareRoles -}: { - driveItem: DriveItem - shareRoles: UnifiedRoleDefinition[] -}): GraphSharePermission[] => { - if (!shareRoles.length) { - // the server lists plain permissions if it doesn't find a corresponding role - const permissions = driveItem.remoteItem?.permissions.reduce( - (acc, permission) => { - const permissions = permission['@libre.graph.permissions.actions'] as GraphSharePermission[] - if (permissions) { - acc.push(...permissions) - } - - return acc - }, - [] - ) - return [...new Set(permissions)] - } - - const permissions = shareRoles.reduce((acc, role) => { - role.rolePermissions.forEach((permission) => { - acc.push(...permission.allowedResourceActions) - }) - return acc - }, []) - - return [...new Set(permissions)] -} - -export function buildIncomingShareResource({ - driveItem, - graphRoles -}: { - driveItem: DriveItem - graphRoles: UnifiedRoleDefinition[] -}): IncomingShareResource { - const resourceName = driveItem.name || driveItem.remoteItem.name - const storageId = extractStorageId(driveItem.remoteItem.id) - - const shareTypes = uniq( - driveItem.remoteItem.permissions.map((p) => - p.grantedToV2.group ? ShareTypes.group.value : ShareTypes.user.value - ) - ) - - const sharedWith = driveItem.remoteItem.permissions.map(({ grantedToV2 }) => { - const identity = grantedToV2.group || grantedToV2.user - return { - ...identity, - shareType: grantedToV2.group ? ShareTypes.group.value : ShareTypes.user.value - } - }) - - const sharedBy = driveItem.remoteItem.permissions.reduce((acc, permission) => { - const sharedBy = permission.invitation.invitedBy.user - if (!acc.some(({ id }) => id === sharedBy.id)) { - acc.push(sharedBy) - } - return acc - }, []) - - const shareRoles = getShareResourceRoles({ driveItem, graphRoles }) - const sharePermissions = getShareResourcePermissions({ driveItem, shareRoles }) - - const resource: IncomingShareResource = { - id: driveItem.id, - shareId: driveItem.remoteItem.permissions[0].id, - driveId: driveItem.parentReference?.driveId, - path: '/', - name: resourceName, - fileId: driveItem.remoteItem.id, - storageId, - parentFolderId: driveItem.parentReference?.id, - sdate: driveItem.lastModifiedDateTime, // FIXME: share date is missing in API - indicators: [], - tags: [], - webDavPath: buildWebDavSpacesPath(driveItem.id, '/'), - sharedBy, - owner: driveItem.remoteItem.createdBy?.user, - sharedWith, - shareTypes, - isFolder: !!driveItem.folder, - type: !!driveItem.folder ? 'folder' : 'file', - mimeType: driveItem.file?.mimeType || 'httpd/unix-directory', - syncEnabled: driveItem['@client.synchronize'], - hidden: driveItem['@UI.Hidden'], - shareRoles, - sharePermissions, - outgoing: false, - canRename: () => driveItem['@client.synchronize'], - canDownload: () => sharePermissions.includes(GraphSharePermission.readBasic), - canUpload: () => sharePermissions.includes(GraphSharePermission.createUpload), - canCreate: () => sharePermissions.includes(GraphSharePermission.createChildren), - canBeDeleted: () => sharePermissions.includes(GraphSharePermission.deleteStandard), - canEditTags: () => sharePermissions.includes(GraphSharePermission.createChildren), - isMounted: () => false, - isReceivedShare: () => true, - canShare: () => false, - canDeny: () => false, - getDomSelector: () => extractDomSelector(driveItem.id) - } - - resource.extension = extractExtensionFromFile(resource) - - return resource -} - -export function buildOutgoingShareResource({ - driveItem, - user -}: { - driveItem: DriveItem - user: User -}): OutgoingShareResource { - const storageId = extractStorageId(driveItem.id) - const path = urlJoin(driveItem.parentReference.path, driveItem.name) - - const resource: OutgoingShareResource = { - id: driveItem.id, - shareId: driveItem.permissions[0].id, - driveId: driveItem.parentReference?.driveId, - path, - name: driveItem.name, - fileId: driveItem.id, - storageId, - parentFolderId: driveItem.parentReference?.id, - sdate: driveItem.lastModifiedDateTime, // FIXME: share date is missing in API - indicators: [], - tags: [], - webDavPath: buildWebDavSpacesPath(storageId, path), - sharedBy: [{ id: user.id, displayName: user.displayName }], - owner: { id: user.id, displayName: user.displayName }, - sharedWith: driveItem.permissions.map((p) => { - if (p.link) { - return { - id: p.id, - displayName: p.link['@libre.graph.displayName'], - shareType: ShareTypes.link.value - } - } - if (p.grantedToV2.group) { - return { ...p.grantedToV2.group, shareType: ShareTypes.group.value } - } - return { ...p.grantedToV2.user, shareType: ShareTypes.user.value } - }), - shareTypes: driveItem.permissions.map((p) => { - if (p.link) { - return ShareTypes.link.value - } - if (p.grantedToV2.group) { - return ShareTypes.group.value - } - return ShareTypes.user.value - }), - isFolder: !!driveItem.folder, - type: !!driveItem.folder ? 'folder' : 'file', - mimeType: driveItem.file?.mimeType || 'httpd/unix-directory', - outgoing: true, - canRename: () => true, - canDownload: () => true, - canUpload: () => true, - canCreate: () => true, - canBeDeleted: () => true, - canEditTags: () => true, - isMounted: () => false, - isReceivedShare: () => true, - canShare: () => true, - canDeny: () => true, - getDomSelector: () => extractDomSelector(driveItem.id) - } - - resource.extension = extractExtensionFromFile(resource) - - return resource -} - -export function buildCollaboratorShare({ - graphPermission, - graphRoles, - resourceId, - spaceId, - user, - indirect = false -}: { - graphPermission: Permission - graphRoles: UnifiedRoleDefinition[] - resourceId: string - spaceId: string - user: User - indirect?: boolean -}): CollaboratorShare { - const role = graphRoles.find(({ id }) => id === graphPermission.roles?.[0]) - const isSpace = resourceId === spaceId - - let shareType: number - if (graphPermission.grantedToV2.group) { - shareType = isSpace ? ShareTypes.spaceGroup.value : ShareTypes.group.value - } else { - shareType = isSpace ? ShareTypes.spaceUser.value : ShareTypes.user.value - } - - return { - id: graphPermission.id, - resourceId, - indirect, - shareType, - role, - sharedBy: { id: user.id, displayName: user.displayName }, - sharedWith: graphPermission.grantedToV2.user || graphPermission.grantedToV2.group, - permissions: (graphPermission['@libre.graph.permissions.actions'] - ? graphPermission['@libre.graph.permissions.actions'] - : role.rolePermissions.flatMap((p) => p.allowedResourceActions)) as GraphSharePermission[], - expirationDateTime: graphPermission.expirationDateTime - } -} - -export function buildLinkShare({ - graphPermission, - user, - resourceId, - indirect = false -}: { - graphPermission: Permission - user: User - resourceId: string - indirect?: boolean -}): LinkShare { - return { - id: graphPermission.id, - resourceId, - indirect, - shareType: ShareTypes.link.value, - sharedBy: { id: user.id, displayName: user.displayName }, - hasPassword: graphPermission.hasPassword, - expirationDateTime: graphPermission.expirationDateTime, - displayName: graphPermission.link['@libre.graph.displayName'], - isQuickLink: graphPermission.link['@libre.graph.quickLink'], - type: graphPermission.link.type, - webUrl: graphPermission.link.webUrl, - preventsDownload: graphPermission.link.preventsDownload - } -} diff --git a/packages/web-pkg/src/components/SideBar/FileSideBar.vue b/packages/web-pkg/src/components/SideBar/FileSideBar.vue index 1eb927e367f..fc35a95062a 100644 --- a/packages/web-pkg/src/components/SideBar/FileSideBar.vue +++ b/packages/web-pkg/src/components/SideBar/FileSideBar.vue @@ -71,7 +71,7 @@ import { useTask } from 'vue-concurrency' import { buildCollaboratorShare, buildLinkShare -} from '@ownclouders/web-client/src/helpers/share/functionsNG' +} from '@ownclouders/web-client/src/helpers/share/functions' import { Permission } from '@ownclouders/web-client/src/generated' export default defineComponent({ diff --git a/packages/web-pkg/src/composables/actions/files/useFileActionsCopyQuicklink.ts b/packages/web-pkg/src/composables/actions/files/useFileActionsCopyQuicklink.ts index 854ad75a427..7eee37ca859 100644 --- a/packages/web-pkg/src/composables/actions/files/useFileActionsCopyQuicklink.ts +++ b/packages/web-pkg/src/composables/actions/files/useFileActionsCopyQuicklink.ts @@ -8,7 +8,7 @@ import { useClipboard } from '../../clipboard' import { Resource, SpaceResource } from '@ownclouders/web-client' import { useFileActionsCreateLink } from './useFileActionsCreateLink' import { useMessages, useUserStore } from '../../piniaStores' -import { buildLinkShare } from '@ownclouders/web-client/src/helpers/share/functionsNG' +import { buildLinkShare } from '@ownclouders/web-client/src/helpers/share/functions' import { getGraphItemId } from '@ownclouders/web-client/src/helpers' export const useFileActionsCopyQuickLink = () => { diff --git a/packages/web-pkg/src/composables/piniaStores/shares/shares.ts b/packages/web-pkg/src/composables/piniaStores/shares/shares.ts index e23f247e7b2..038feb69d10 100644 --- a/packages/web-pkg/src/composables/piniaStores/shares/shares.ts +++ b/packages/web-pkg/src/composables/piniaStores/shares/shares.ts @@ -24,7 +24,7 @@ import { useUserStore } from '../user' import { buildLinkShare, buildCollaboratorShare -} from '@ownclouders/web-client/src/helpers/share/functionsNG' +} from '@ownclouders/web-client/src/helpers/share/functions' export const useSharesStore = defineStore('shares', () => { const resourcesStore = useResourcesStore() diff --git a/packages/web-pkg/src/composables/piniaStores/spaces.ts b/packages/web-pkg/src/composables/piniaStores/spaces.ts index fd17d4914fa..ec9964646bb 100644 --- a/packages/web-pkg/src/composables/piniaStores/spaces.ts +++ b/packages/web-pkg/src/composables/piniaStores/spaces.ts @@ -12,7 +12,7 @@ import { import type { CollaboratorShare } from '@ownclouders/web-client/src/helpers' import { useUserStore } from './user' import { ConfigStore, useConfigStore } from './config' -import { buildCollaboratorShare } from '@ownclouders/web-client/src/helpers/share/functionsNG' +import { buildCollaboratorShare } from '@ownclouders/web-client/src/helpers/share/functions' import { useSharesStore } from './shares' export const sortSpaceMembers = (shares: CollaboratorShare[]) => { diff --git a/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsCopyQuicklink.spec.ts b/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsCopyQuicklink.spec.ts index 65a2dcb1bad..f142f029b07 100644 --- a/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsCopyQuicklink.spec.ts +++ b/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsCopyQuicklink.spec.ts @@ -9,7 +9,7 @@ import { FileAction } from '../../../../../src/composables/actions' import { useCanShare } from '../../../../../src/composables/shares' import { Resource, SpaceResource } from '@ownclouders/web-client' import { LinkShare } from '@ownclouders/web-client/src/helpers/share' -import { buildLinkShare } from '@ownclouders/web-client/src/helpers/share/functionsNG' +import { buildLinkShare } from '@ownclouders/web-client/src/helpers/share/functions' import { useClipboard } from '../../../../../src/composables/clipboard' import { useMessages } from '../../../../../src/composables/piniaStores' import { Permission } from '@ownclouders/web-client/src/generated' @@ -26,7 +26,8 @@ vi.mock('../../../../../src/composables/clipboard', () => ({ useClipboard: vi.fn() })) -vi.mock('@ownclouders/web-client/src/helpers/share/functionsNG', () => ({ +vi.mock('@ownclouders/web-client/src/helpers/share/functions', async (importOriginal) => ({ + ...(await importOriginal()), buildLinkShare: vi.fn() })) diff --git a/packages/web-pkg/tests/unit/composables/piniaStores/shares.spec.ts b/packages/web-pkg/tests/unit/composables/piniaStores/shares.spec.ts index 1552c73e3ac..dd2c45b1e1d 100644 --- a/packages/web-pkg/tests/unit/composables/piniaStores/shares.spec.ts +++ b/packages/web-pkg/tests/unit/composables/piniaStores/shares.spec.ts @@ -16,9 +16,9 @@ import { Permission, User } from '@ownclouders/web-client/src/generated' import { buildCollaboratorShare, buildLinkShare -} from '@ownclouders/web-client/src/helpers/share/functionsNG' +} from '@ownclouders/web-client/src/helpers/share/functions' -vi.mock('@ownclouders/web-client/src/helpers/share/functionsNG', () => ({ +vi.mock('@ownclouders/web-client/src/helpers/share/functions', () => ({ buildLinkShare: vi.fn((share) => share), buildCollaboratorShare: vi.fn((share) => share) }))