ExampleTitle
diff --git a/packages/web-app-files/tests/unit/components/Spaces/SpaceContextActions.spec.ts b/packages/web-app-files/tests/unit/components/Spaces/SpaceContextActions.spec.ts
index 5fba54a41de..1a36e88d568 100644
--- a/packages/web-app-files/tests/unit/components/Spaces/SpaceContextActions.spec.ts
+++ b/packages/web-app-files/tests/unit/components/Spaces/SpaceContextActions.spec.ts
@@ -12,7 +12,8 @@ import { mock } from 'jest-mock-extended'
const spaceMock = {
id: '1',
- root: { permissions: [{ roles: ['manager'], grantedToIdentities: [{ user: { id: 1 } }] }] }
+ root: { permissions: [{ roles: ['manager'], grantedToIdentities: [{ user: { id: 1 } }] }] },
+ driveType: 'project'
}
describe('SpaceContextActions', () => {
diff --git a/packages/web-app-files/tests/unit/composables/actions/files/useFileActionsCopy.spec.ts b/packages/web-app-files/tests/unit/composables/actions/files/useFileActionsCopy.spec.ts
index 1bebaadf48c..fecc38a37d4 100644
--- a/packages/web-app-files/tests/unit/composables/actions/files/useFileActionsCopy.spec.ts
+++ b/packages/web-app-files/tests/unit/composables/actions/files/useFileActionsCopy.spec.ts
@@ -14,32 +14,6 @@ import { useFileActionsCopy } from 'web-app-files/src/composables'
describe('copy', () => {
describe('search context', () => {
describe('computed property "actions"', () => {
- describe('label', () => {
- it.each([
- {
- resources: [{ id: '1' }, { id: '2' }] as Resource[],
- copyAbleCount: 2
- },
- {
- resources: [
- { id: '1' },
- { id: '2' },
- { id: '3' },
- { id: '5', driveType: 'project' }
- ] as Resource[],
- copyAbleCount: 3
- }
- ])('should be set correctly', ({ resources, copyAbleCount }) => {
- const { wrapper } = getWrapper({
- searchLocation: true,
- setup: ({ actions }) => {
- expect(unref(actions)[0].label({ space: null, resources })).toContain(
- `(${copyAbleCount.toString()})`
- )
- }
- })
- })
- })
describe('handler', () => {
it.each([
{
diff --git a/packages/web-app-files/tests/unit/composables/actions/files/useFileActionsDelete.spec.ts b/packages/web-app-files/tests/unit/composables/actions/files/useFileActionsDelete.spec.ts
index af3db7c95af..cd69ed5f53f 100644
--- a/packages/web-app-files/tests/unit/composables/actions/files/useFileActionsDelete.spec.ts
+++ b/packages/web-app-files/tests/unit/composables/actions/files/useFileActionsDelete.spec.ts
@@ -93,40 +93,6 @@ describe('delete', () => {
})
describe('search context', () => {
describe('computed property "actions"', () => {
- describe('label', () => {
- it.each([
- {
- resources: [
- { canBeDeleted: () => true, isShareRoot: () => false },
- { canBeDeleted: () => true, isShareRoot: () => false }
- ] as Resource[],
- deletableCount: 2
- },
- {
- resources: [
- { canBeDeleted: () => true, isShareRoot: () => false },
- { canBeDeleted: () => true, isShareRoot: () => false },
- { canBeDeleted: () => true, isShareRoot: () => false },
- { canBeDeleted: () => false, isShareRoot: () => false },
- { canBeDeleted: () => true, isShareRoot: () => true },
- { canBeDeleted: () => true, isShareRoot: () => false, driveType: 'project' }
- ] as Resource[],
- deletableCount: 3
- }
- ])('should be set correctly', ({ resources, deletableCount }) => {
- const { wrapper } = getWrapper({
- searchLocation: true,
- setup: () => {
- const store = useStore()
- const { actions } = useFileActionsDelete({ store })
-
- expect(unref(actions)[0].label({ space: null, resources })).toContain(
- `(${deletableCount.toString()})`
- )
- }
- })
- })
- })
describe('handler', () => {
it.each([
{
diff --git a/packages/web-app-files/tests/unit/composables/actions/files/useFileActionsDownloadArchive.spec.ts b/packages/web-app-files/tests/unit/composables/actions/files/useFileActionsDownloadArchive.spec.ts
index 8aa45a46e8b..0ab45e51715 100644
--- a/packages/web-app-files/tests/unit/composables/actions/files/useFileActionsDownloadArchive.spec.ts
+++ b/packages/web-app-files/tests/unit/composables/actions/files/useFileActionsDownloadArchive.spec.ts
@@ -17,39 +17,6 @@ jest.mock('web-pkg/src/composables/archiverService/useArchiverService')
describe('downloadArchive', () => {
describe('search context', () => {
describe('computed property "actions"', () => {
- describe('label', () => {
- it.each([
- {
- resources: [
- { id: '1', canDownload: () => true },
- { id: '2', canDownload: () => true }
- ] as Resource[],
- downloadableCount: 2
- },
- {
- resources: [
- { id: '1', canDownload: () => true },
- { id: '2', canDownload: () => true },
- { id: '3', canDownload: () => true },
- { id: '4', canDownload: () => false },
- { id: '5', canDownload: () => true, driveType: 'project' }
- ] as Resource[],
- downloadableCount: 3
- }
- ])('should be set correctly', ({ resources, downloadableCount }) => {
- const { wrapper } = getWrapper({
- searchLocation: true,
- setup: () => {
- const store = useStore()
- const { actions } = useFileActionsDownloadArchive({ store })
-
- expect(unref(actions)[0].label({ space: null, resources })).toContain(
- `(${downloadableCount.toString()})`
- )
- }
- })
- })
- })
describe('handler', () => {
it.each([
{
diff --git a/packages/web-app-files/tests/unit/views/spaces/__snapshots__/Projects.spec.ts.snap b/packages/web-app-files/tests/unit/views/spaces/__snapshots__/Projects.spec.ts.snap
index 47c56a971bf..c72b09da23c 100644
--- a/packages/web-app-files/tests/unit/views/spaces/__snapshots__/Projects.spec.ts.snap
+++ b/packages/web-app-files/tests/unit/views/spaces/__snapshots__/Projects.spec.ts.snap
@@ -4,7 +4,7 @@ exports[`Projects view different files view states lists all available project s
-
+
diff --git a/packages/web-client/src/helpers/resource/types.ts b/packages/web-client/src/helpers/resource/types.ts
index 338dcadafcc..0ffbe828caf 100644
--- a/packages/web-client/src/helpers/resource/types.ts
+++ b/packages/web-client/src/helpers/resource/types.ts
@@ -86,7 +86,7 @@ export interface Resource {
canBeRestored?(): boolean
canDeny?(): boolean
canEditDescription?({ user }: { user?: User; ability?: Ability }): boolean
- canRestore?({ user }: { user?: User }): boolean
+ canRestore?({ user }: { user?: User; ability?: any }): boolean
canDisable?({ user }: { user?: User; ability?: any }): boolean
canEditImage?({ user }: { user?: User }): boolean
canEditReadme?({ user }: { user?: User }): boolean
diff --git a/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsDelete.ts b/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsDelete.ts
index 9e1be70eb7c..4033259846f 100644
--- a/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsDelete.ts
+++ b/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsDelete.ts
@@ -7,6 +7,7 @@ import { useAbility } from '../../ability'
import { useStore } from '../../store'
import { SpaceAction, SpaceActionOptions } from '../types'
import { Store } from 'vuex'
+import { isProjectSpaceResource } from 'web-client/src/helpers'
export const useSpaceActionsDelete = ({ store }: { store?: Store
} = {}) => {
store = store || useStore()
@@ -17,7 +18,9 @@ export const useSpaceActionsDelete = ({ store }: { store?: Store } = {}) =>
const route = useRoute()
const filterResourcesToDelete = (resources: SpaceResource[]) => {
- return resources.filter((r) => r.canBeDeleted({ user: store.getters.user, ability }))
+ return resources.filter(
+ (r) => isProjectSpaceResource(r) && r.canBeDeleted({ user: store.getters.user, ability })
+ )
}
const deleteSpaces = async (spaces: SpaceResource[]) => {
@@ -112,13 +115,7 @@ export const useSpaceActionsDelete = ({ store }: { store?: Store } = {}) =>
{
name: 'delete',
icon: 'delete-bin',
- label: ({ resources }) => {
- if (resources.length === 1) {
- return $gettext('Delete')
- }
- const allowedCount = filterResourcesToDelete(resources).length
- return $gettext('Delete (%{count})', { count: allowedCount.toString() })
- },
+ label: () => $gettext('Delete'),
handler,
isEnabled: ({ resources }) => {
return !!filterResourcesToDelete(resources).length
diff --git a/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsDisable.ts b/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsDisable.ts
index 886e368152f..8d8ab716d5f 100644
--- a/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsDisable.ts
+++ b/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsDisable.ts
@@ -7,6 +7,7 @@ import { useStore } from '../../store'
import { useAbility } from '../../ability'
import { useClientService, useLoadingService } from 'web-pkg/src/composables'
import { Store } from 'vuex'
+import { isProjectSpaceResource } from 'web-client/src/helpers'
export const useSpaceActionsDisable = ({ store }: { store?: Store } = {}) => {
store = store || useStore()
@@ -18,7 +19,9 @@ export const useSpaceActionsDisable = ({ store }: { store?: Store } = {}) =
const loadingService = useLoadingService()
const filterResourcesToDisable = (resources): SpaceResource[] => {
- return resources.filter((r) => r.canDisable({ user: store.getters.user, ability }))
+ return resources.filter(
+ (r) => isProjectSpaceResource(r) && r.canDisable({ user: store.getters.user, ability })
+ )
}
const disableSpaces = async (spaces: SpaceResource[]) => {
@@ -121,13 +124,7 @@ export const useSpaceActionsDisable = ({ store }: { store?: Store } = {}) =
{
name: 'disable',
icon: 'stop-circle',
- label: ({ resources }) => {
- if (resources.length === 1) {
- return $gettext('Disable')
- }
- const allowedCount = filterResourcesToDisable(resources).length
- return $gettext('Disable (%{count})', { count: allowedCount.toString() })
- },
+ label: () => $gettext('Disable'),
handler,
isEnabled: ({ resources }) => {
return !!filterResourcesToDisable(resources).length
diff --git a/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsEditQuota.ts b/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsEditQuota.ts
index 8029e917be3..d68ae228804 100644
--- a/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsEditQuota.ts
+++ b/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsEditQuota.ts
@@ -3,6 +3,7 @@ import { computed, ref } from 'vue'
import { SpaceAction } from '../types'
import { useGettext } from 'vue3-gettext'
import { useAbility } from '../../ability'
+import { isProjectSpaceResource } from 'web-client/src/helpers'
export const useSpaceActionsEditQuota = ({ store }: { store?: Store } = {}) => {
const { $gettext } = useGettext()
@@ -30,7 +31,7 @@ export const useSpaceActionsEditQuota = ({ store }: { store?: Store } = {})
if (!resources || !resources.length) {
return false
}
- if (resources.some((r) => r.spaceQuota === false)) {
+ if (resources.some((r) => !isProjectSpaceResource(r) || r.spaceQuota === false)) {
return false
}
return ability.can('set-quota-all', 'Drive')
diff --git a/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsRestore.ts b/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsRestore.ts
index 4bef55058d0..a2b8e835e9c 100644
--- a/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsRestore.ts
+++ b/packages/web-pkg/src/composables/actions/spaces/useSpaceActionsRestore.ts
@@ -5,6 +5,7 @@ import { SpaceAction, SpaceActionOptions } from '../types'
import { useRoute } from '../../router'
import { useAbility, useClientService, useLoadingService, useStore } from 'web-pkg/src/composables'
import { useGettext } from 'vue3-gettext'
+import { isProjectSpaceResource } from 'web-client/src/helpers'
export const useSpaceActionsRestore = ({ store }: { store?: Store } = {}) => {
store = store || useStore()
@@ -15,7 +16,9 @@ export const useSpaceActionsRestore = ({ store }: { store?: Store } = {}) =
const route = useRoute()
const filterResourcesToRestore = (resources): SpaceResource[] => {
- return resources.filter((r) => r.canRestore({ user: store.getters.user, ability }))
+ return resources.filter(
+ (r) => isProjectSpaceResource(r) && r.canRestore({ user: store.getters.user, ability })
+ )
}
const restoreSpaces = async (spaces: SpaceResource[]) => {
@@ -125,13 +128,7 @@ export const useSpaceActionsRestore = ({ store }: { store?: Store } = {}) =
{
name: 'restore',
icon: 'play-circle',
- label: ({ resources }) => {
- if (resources.length === 1) {
- return $gettext('Enable')
- }
- const allowedCount = filterResourcesToRestore(resources).length
- return $gettext('Enable (%{count})', { count: allowedCount.toString() })
- },
+ label: () => $gettext('Enable'),
handler,
isEnabled: ({ resources }) => {
return !!filterResourcesToRestore(resources).length
diff --git a/packages/web-pkg/tests/unit/composables/actions/spaces/useSpaceActionsDelete.spec.ts b/packages/web-pkg/tests/unit/composables/actions/spaces/useSpaceActionsDelete.spec.ts
index 819d6bd395a..80058c89f4e 100644
--- a/packages/web-pkg/tests/unit/composables/actions/spaces/useSpaceActionsDelete.spec.ts
+++ b/packages/web-pkg/tests/unit/composables/actions/spaces/useSpaceActionsDelete.spec.ts
@@ -25,7 +25,8 @@ describe('delete', () => {
id: '1',
root: {
permissions: [{ roles: ['manager'], grantedToIdentities: [{ user: { id: 1 } }] }]
- }
+ },
+ driveType: 'project'
}
const { wrapper } = getWrapper({
setup: ({ actions }) => {
@@ -39,7 +40,8 @@ describe('delete', () => {
root: {
permissions: [{ roles: ['manager'], grantedToIdentities: [{ user: { id: 1 } }] }],
deleted: { state: 'trashed' }
- }
+ },
+ driveType: 'project'
}
const { wrapper } = getWrapper({
setup: ({ actions }) => {
@@ -53,7 +55,8 @@ describe('delete', () => {
root: {
permissions: [{ roles: ['viewer'], grantedToIdentities: [{ user: { id: 1 } }] }],
deleted: { state: 'trashed' }
- }
+ },
+ driveType: 'project'
}
const { wrapper } = getWrapper({
setup: ({ actions }) => {
@@ -68,7 +71,9 @@ describe('delete', () => {
const { wrapper } = getWrapper({
setup: async ({ actions }, { storeOptions }) => {
await unref(actions)[0].handler({
- resources: [mock({ id: 1, canBeDeleted: () => true })]
+ resources: [
+ mock({ id: 1, canBeDeleted: () => true, driveType: 'project' })
+ ]
})
expect(storeOptions.actions.createModal).toHaveBeenCalledTimes(1)
@@ -79,7 +84,9 @@ describe('delete', () => {
const { wrapper } = getWrapper({
setup: async ({ actions }, { storeOptions }) => {
await unref(actions)[0].handler({
- resources: [mock({ id: 1, canBeDeleted: () => false })]
+ resources: [
+ mock({ id: 1, canBeDeleted: () => false, driveType: 'project' })
+ ]
})
expect(storeOptions.actions.createModal).toHaveBeenCalledTimes(0)
@@ -94,7 +101,9 @@ describe('delete', () => {
setup: async ({ actions, deleteSpaces }, { storeOptions, clientService }) => {
clientService.graphAuthenticated.drives.deleteDrive.mockResolvedValue(mockAxiosResolve())
- await deleteSpaces([mock({ id: 1, canBeDeleted: () => true })])
+ await deleteSpaces([
+ mock({ id: 1, canBeDeleted: () => true, driveType: 'project' })
+ ])
expect(storeOptions.actions.hideModal).toHaveBeenCalledTimes(1)
expect(storeOptions.actions.showMessage).toHaveBeenCalledTimes(1)
@@ -107,7 +116,9 @@ describe('delete', () => {
const { wrapper } = getWrapper({
setup: async ({ actions, deleteSpaces }, { clientService, storeOptions }) => {
clientService.graphAuthenticated.drives.deleteDrive.mockRejectedValue(new Error())
- await deleteSpaces([mock({ id: 1, canBeDeleted: () => true })])
+ await deleteSpaces([
+ mock({ id: 1, canBeDeleted: () => true, driveType: 'project' })
+ ])
expect(storeOptions.actions.showErrorMessage).toHaveBeenCalledTimes(1)
}
diff --git a/packages/web-pkg/tests/unit/composables/actions/spaces/useSpaceActionsDisable.spec.ts b/packages/web-pkg/tests/unit/composables/actions/spaces/useSpaceActionsDisable.spec.ts
index fbedb327cd3..fc30b5bc08a 100644
--- a/packages/web-pkg/tests/unit/composables/actions/spaces/useSpaceActionsDisable.spec.ts
+++ b/packages/web-pkg/tests/unit/composables/actions/spaces/useSpaceActionsDisable.spec.ts
@@ -25,7 +25,8 @@ describe('disable', () => {
id: '1',
root: {
permissions: [{ roles: ['manager'], grantedToIdentities: [{ user: { id: 1 } }] }]
- }
+ },
+ driveType: 'project'
}
const { wrapper } = getWrapper({
setup: ({ actions }) => {
@@ -52,7 +53,8 @@ describe('disable', () => {
id: '1',
root: {
permissions: [{ roles: ['viewer'], grantedToIdentities: [{ user: { id: 1 } }] }]
- }
+ },
+ driveType: 'project'
}
const { wrapper } = getWrapper({
setup: ({ actions }) => {
@@ -67,7 +69,9 @@ describe('disable', () => {
const { wrapper } = getWrapper({
setup: async ({ actions }, { storeOptions }) => {
await unref(actions)[0].handler({
- resources: [mock({ id: 1, canDisable: () => true })]
+ resources: [
+ mock({ id: 1, canDisable: () => true, driveType: 'project' })
+ ]
})
expect(storeOptions.actions.createModal).toHaveBeenCalledTimes(1)
@@ -78,7 +82,9 @@ describe('disable', () => {
const { wrapper } = getWrapper({
setup: async ({ actions }, { storeOptions }) => {
await unref(actions)[0].handler({
- resources: [mock({ id: 1, canDisable: () => false })]
+ resources: [
+ mock({ id: 1, canDisable: () => false, driveType: 'project' })
+ ]
})
expect(storeOptions.actions.createModal).toHaveBeenCalledTimes(0)
@@ -92,7 +98,9 @@ describe('disable', () => {
const { wrapper, mocks } = getWrapper({
setup: async ({ disableSpaces }, { storeOptions, clientService }) => {
clientService.graphAuthenticated.drives.disableDrive.mockResolvedValue(mockAxiosResolve())
- await disableSpaces([mock({ id: 1, canDisable: () => true })])
+ await disableSpaces([
+ mock({ id: 1, canDisable: () => true, driveType: 'project' })
+ ])
expect(storeOptions.actions.hideModal).toHaveBeenCalledTimes(1)
}
@@ -104,7 +112,9 @@ describe('disable', () => {
const { wrapper } = getWrapper({
setup: async ({ actions, disableSpaces }, { storeOptions, clientService }) => {
clientService.graphAuthenticated.drives.disableDrive.mockRejectedValue(new Error())
- await disableSpaces([mock({ id: 1, canDisable: () => true })])
+ await disableSpaces([
+ mock({ id: 1, canDisable: () => true, driveType: 'project' })
+ ])
expect(storeOptions.actions.showErrorMessage).toHaveBeenCalledTimes(1)
}
diff --git a/packages/web-pkg/tests/unit/composables/actions/spaces/useSpaceActionsEditQuota.spec.ts b/packages/web-pkg/tests/unit/composables/actions/spaces/useSpaceActionsEditQuota.spec.ts
index b7c557d8493..1649b572356 100644
--- a/packages/web-pkg/tests/unit/composables/actions/spaces/useSpaceActionsEditQuota.spec.ts
+++ b/packages/web-pkg/tests/unit/composables/actions/spaces/useSpaceActionsEditQuota.spec.ts
@@ -23,7 +23,8 @@ describe('editQuota', () => {
quota: {},
root: {
permissions: [{ roles: ['manager'], grantedToIdentities: [{ user: { id: 1 } }] }]
- }
+ },
+ driveType: 'project'
}
const { wrapper } = getWrapper({
canEditSpaceQuota: true,
@@ -38,7 +39,8 @@ describe('editQuota', () => {
quota: {},
root: {
permissions: [{ roles: ['manager'], grantedToIdentities: [{ user: { id: 1 } }] }]
- }
+ },
+ driveType: 'project'
}
const { wrapper } = getWrapper({
canEditSpaceQuota: false,
diff --git a/packages/web-pkg/tests/unit/composables/actions/spaces/useSpaceActionsRestore.spec.ts b/packages/web-pkg/tests/unit/composables/actions/spaces/useSpaceActionsRestore.spec.ts
index a6df3cee281..1a2b60eecd0 100644
--- a/packages/web-pkg/tests/unit/composables/actions/spaces/useSpaceActionsRestore.spec.ts
+++ b/packages/web-pkg/tests/unit/composables/actions/spaces/useSpaceActionsRestore.spec.ts
@@ -25,7 +25,8 @@ describe('restore', () => {
id: '1',
root: {
permissions: [{ roles: ['manager'], grantedToIdentities: [{ user: { id: 1 } }] }]
- }
+ },
+ driveType: 'project'
}
const { wrapper } = getWrapper({
setup: async ({ actions }, { storeOptions }) => {
@@ -39,7 +40,8 @@ describe('restore', () => {
root: {
permissions: [{ roles: ['manager'], grantedToIdentities: [{ user: { id: 1 } }] }],
deleted: { state: 'trashed' }
- }
+ },
+ driveType: 'project'
}
const { wrapper } = getWrapper({
setup: async ({ actions }, { storeOptions }) => {
@@ -53,7 +55,8 @@ describe('restore', () => {
root: {
permissions: [{ roles: ['viewer'], grantedToIdentities: [{ user: { id: 1 } }] }],
deleted: { state: 'trashed' }
- }
+ },
+ driveType: 'project'
}
const { wrapper } = getWrapper({
setup: async ({ actions }, { storeOptions }) => {
@@ -68,7 +71,9 @@ describe('restore', () => {
const { wrapper } = getWrapper({
setup: async ({ actions }, { storeOptions }) => {
await unref(actions)[0].handler({
- resources: [mock({ id: 1, canRestore: () => true })]
+ resources: [
+ mock({ id: 1, canRestore: () => true, driveType: 'project' })
+ ]
})
expect(storeOptions.actions.createModal).toHaveBeenCalledTimes(1)