Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/web-app-files/src/composables/actions/files/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
export * from './useFileActionsCopyPermanentLink'
export * from './useFileActionsCopy'
export * from './useFileActionsCreateLink'
export * from './useFileActionsCreateNewFile'
export * from './useFileActionsCreateNewFolder'
export * from './useFileActionsCreateNewShortcut'
export * from './useFileActionsCreateSpaceFromResource'
export * from './useFileActionsDisableSync'
export * from './useFileActionsDownloadArchive'
export * from './useFileActionsEmptyTrashBin'
export * from './useFileActionsEnableSync'
export * from './useFileActionsFavorite'
export * from './useFileActionsMove'
export * from './useFileActionsOpenShortcut'
export * from './useFileActionsPaste'
export * from './useFileActionsRename'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import {
isLocationCommonActive,
isLocationPublicActive,
isLocationSpacesActive
} from '../../../router'
import { isProjectSpaceResource } from '@opencloud-eu/web-client'
import { computed, unref } from 'vue'

import { useGettext } from 'vue3-gettext'
import { FileAction, FileActionOptions } from '../types'
import { isProjectSpaceResource } from '@opencloud-eu/web-client'
import { useRouter } from '../../router'
import { useClipboardStore, useResourcesStore } from '../../piniaStores'
import { storeToRefs } from 'pinia'
import { isMacOs } from '../../../helpers'
import {
FileAction,
FileActionOptions,
isLocationCommonActive,
isLocationPublicActive,
isLocationSpacesActive,
isMacOs,
useClipboardStore,
useResourcesStore,
useRouter
} from '@opencloud-eu/web-pkg'

export const useFileActionsCopy = () => {
const router = useRouter()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { isProjectSpaceResource, isPublicSpaceResource, Resource } from '@opencloud-eu/web-client'
import { computed, unref } from 'vue'
import { useGettext } from 'vue3-gettext'
import {
FileAction,
FileActionOptions,
formatFileSize,
isLocationCommonActive,
isLocationPublicActive,
isLocationSharesActive,
isLocationSpacesActive
} from '../../../router'
import { useIsFilesAppActive } from '../helpers'
import { isProjectSpaceResource, isPublicSpaceResource, Resource } from '@opencloud-eu/web-client'
import { computed, unref } from 'vue'
import { useRouter } from '../../router'

import { FileAction, FileActionOptions } from '../types'
import { useGettext } from 'vue3-gettext'
import { useArchiverService } from '../../archiverService'
import { formatFileSize } from '../../../helpers/filesize'
import { useAuthStore, useMessages } from '../../piniaStores'
isLocationSpacesActive,
useArchiverService,
useAuthStore,
useIsFilesAppActive,
useMessages,
useRouter
} from '@opencloud-eu/web-pkg'

export const useFileActionsDownloadArchive = () => {
const { showErrorMessage } = useMessages()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { canBeMoved } from '../../../helpers/permissions'
import { Resource } from '@opencloud-eu/web-client'
import { computed, unref } from 'vue'
import { useGettext } from 'vue3-gettext'
import { storeToRefs } from 'pinia'
import {
ActionOptions,
canBeMoved,
FileAction,
isLocationCommonActive,
isLocationPublicActive,
isLocationSpacesActive
} from '../../../router'
import { useGettext } from 'vue3-gettext'
import { ActionOptions, FileAction } from '../types'
import { computed, unref } from 'vue'
import { useRouter } from '../../router'
import { useClipboardStore, useResourcesStore } from '../../piniaStores'
import { Resource } from '@opencloud-eu/web-client'
import { storeToRefs } from 'pinia'
import { isMacOs } from '../../../helpers'
isLocationSpacesActive,
isMacOs,
useClipboardStore,
useResourcesStore,
useRouter
} from '@opencloud-eu/web-pkg'

export const useFileActionsMove = () => {
const router = useRouter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ import {
resourceTableActionsExtensionPoint
} from '../../extensionPoints'
import {
useFileActionsCopy,
useFileActionsCopyPermanentLink,
useFileActionsCreateSpaceFromResource,
useFileActionsDisableSync,
useFileActionsDownloadArchive,
useFileActionsFavorite,
useFileActionsEnableSync,
useFileActionsMove,
useFileActionsPaste,
useFileActionsOpenShortcut,
useSpaceActionsSetImage,
Expand All @@ -27,12 +30,15 @@ const adminSettingsSpacesContextActionsExtensionPointId =
'app.admin-settings.spaces.context-actions'

export const useFileActions = (): ActionExtension[] => {
const { actions: copyActions } = useFileActionsCopy()
const { actions: downloadArchiveActions } = useFileActionsDownloadArchive()
const { actions: openShortcutActions } = useFileActionsOpenShortcut()
const { actions: showSharesActions } = useFileActionsShowShares()
const { actions: permanentLinkActions } = useFileActionsCopyPermanentLink()
const { actions: createSpaceFromResourceActions } = useFileActionsCreateSpaceFromResource()
const { actions: disableSyncActions } = useFileActionsDisableSync()
const { actions: enableSyncActions } = useFileActionsEnableSync()
const { actions: moveActions } = useFileActionsMove()
const { actions: pasteActions } = useFileActionsPaste()
const { actions: renameActions } = useFileActionsRename()
const { actions: favoriteActions } = useFileActionsFavorite()
Expand All @@ -41,6 +47,45 @@ export const useFileActions = (): ActionExtension[] => {
const { actions: toggleHideShareActions } = useFileActionsToggleHideShare()

return [
{
id: 'com.github.opencloud-eu.web.files.context-action.download-archive',
extensionPointIds: [
contextActionsExtensionPoint.id,
batchActionsExtensionPoint.id,
fileSideBarActionsExtensionPoint.id
],
type: 'action',
action: {
...unref(downloadArchiveActions)[0],
category: 'tertiary'
}
},
{
id: 'com.github.opencloud-eu.web.files.context-action.move',
extensionPointIds: [
contextActionsExtensionPoint.id,
batchActionsExtensionPoint.id,
fileSideBarActionsExtensionPoint.id
],
type: 'action',
action: {
...unref(moveActions)[0],
category: 'tertiary'
}
},
{
id: 'com.github.opencloud-eu.web.files.context-action.copy',
extensionPointIds: [
contextActionsExtensionPoint.id,
batchActionsExtensionPoint.id,
fileSideBarActionsExtensionPoint.id
],
type: 'action',
action: {
...unref(copyActions)[0],
category: 'tertiary'
}
},
{
id: 'com.github.opencloud-eu.web.files.context-action.open-shortcut',
extensionPointIds: [contextActionsExtensionPoint.id],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
getComposableWrapper
} from '@opencloud-eu/web-test-helpers'
import { useFileActionsCopy } from '../../../../../src/composables/actions/files'
import { useClipboardStore } from '../../../../../src/composables/piniaStores'
import { useClipboardStore } from '@opencloud-eu/web-pkg'
import { describe } from 'vitest'

describe('copy', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { mock } from 'vitest-mock-extended'
import { unref } from 'vue'
import { useFileActionsDownloadArchive } from '../../../../../src/composables/actions'
import { Resource, SpaceResource } from '@opencloud-eu/web-client'
import {
defaultComponentMocks,
RouteLocation,
getComposableWrapper
} from '@opencloud-eu/web-test-helpers'
import { useArchiverService } from '../../../../../src/composables'
import { ArchiverService } from '../../../../../src'
import { ArchiverService, useArchiverService } from '@opencloud-eu/web-pkg'
import { useFileActionsDownloadArchive } from '../../../../../src/composables/actions/files'

vi.mock('../../../../../src/composables/archiverService/useArchiverService')
vi.mock('@opencloud-eu/web-pkg', async (importOriginal) => ({
...(await importOriginal<any>()),
useArchiverService: vi.fn()
}))

describe('downloadArchive', () => {
describe('search context', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { mock, mockDeep } from 'vitest-mock-extended'
import { unref } from 'vue'
import { useFileActionsMove } from '../../../../../src/composables/actions'
import { Resource, SpaceResource } from '@opencloud-eu/web-client'
import {
RouteLocation,
defaultComponentMocks,
getComposableWrapper
} from '@opencloud-eu/web-test-helpers'
import { useFileActionsMove } from '../../../../../src/composables/actions/files'

describe('move', () => {
describe('computed property "actions"', () => {
Expand Down
17 changes: 3 additions & 14 deletions packages/web-pkg/src/components/AppBar/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,8 @@ import ViewOptions from '../ViewOptions.vue'
import { isLocationCommonActive, isLocationTrashActive } from '../../router'
import { FolderView } from '../../ui/types'
import {
useFileActionsCopy,
useFileActionsDelete,
useFileActionsDownloadArchive,
useFileActionsDownloadFile,
useFileActionsMove,
useFileActionsRestore
} from '../../composables/actions'
import {
Expand Down Expand Up @@ -159,11 +156,8 @@ export default defineComponent({

const space = computed(() => props.space)

const { actions: copyActions } = useFileActionsCopy()
const { actions: deleteActions } = useFileActionsDelete()
const { actions: downloadArchiveActions } = useFileActionsDownloadArchive()
const { actions: downloadFileActions } = useFileActionsDownloadFile()
const { actions: moveActions } = useFileActionsMove()
const { actions: restoreActions } = useFileActionsRestore()

const breadcrumbMaxWidth = ref<number>(0)
Expand All @@ -174,14 +168,7 @@ export default defineComponent({
)

const batchActions = computed(() => {
let actions: FileAction[] = [
...unref(downloadArchiveActions),
...unref(downloadFileActions),
...unref(moveActions),
...unref(copyActions),
...unref(deleteActions),
...unref(restoreActions)
]
let actions: FileAction[] = [...unref(downloadFileActions)]

const actionExtensions = requestExtensions<ActionExtension>({
id: 'global.files.batch-actions',
Expand All @@ -191,6 +178,8 @@ export default defineComponent({
actions = [...actions, ...actionExtensions.map((e) => e.action)]
}

actions = [...actions, ...unref(deleteActions), ...unref(restoreActions)]

return actions.filter((item) =>
item.isVisible({ space: unref(space), resources: resourcesStore.selectedResources })
)
Expand Down
12 changes: 0 additions & 12 deletions packages/web-pkg/src/components/FilesList/ContextActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ import {
FileActionOptions,
useExtensionRegistry,
useFileActions,
useFileActionsCopy,
useFileActionsDelete,
useFileActionsDownloadArchive,
useFileActionsDownloadFile,
useFileActionsMove,
useFileActionsOpenWithDefault,
useFileActionsRestore
} from '../../composables'
Expand All @@ -35,11 +32,8 @@ export default defineComponent({
const { $gettext } = useGettext()

const { actions: openWithDefaultActions } = useFileActionsOpenWithDefault()
const { actions: copyActions } = useFileActionsCopy()
const { actions: deleteActions } = useFileActionsDelete()
const { actions: downloadArchiveActions } = useFileActionsDownloadArchive()
const { actions: downloadFileActions } = useFileActionsDownloadFile()
const { actions: moveActions } = useFileActionsMove()
const { actions: restoreActions } = useFileActionsRestore()

const extensionRegistry = useExtensionRegistry()
Expand Down Expand Up @@ -69,9 +63,6 @@ export default defineComponent({

const menuItemsBatchTertiary = computed(() =>
[
...unref(downloadArchiveActions),
...unref(moveActions),
...unref(copyActions),
...unref(deleteActions),
...unref(restoreActions),
...unref(extensionsContextActions).filter((a) => !a.category || a.category === 'tertiary')
Expand Down Expand Up @@ -104,11 +95,8 @@ export default defineComponent({

const menuItemsTertiary = computed(() => {
return [
...unref(downloadArchiveActions),
...unref(downloadFileActions),
...unref(deleteActions),
...unref(moveActions),
...unref(copyActions),
...unref(restoreActions),
...unref(extensionsContextActions).filter((a) => !a.category || a.category === 'tertiary')
].filter((item) => item.isVisible(unref(actionOptions)))
Expand Down
3 changes: 0 additions & 3 deletions packages/web-pkg/src/composables/actions/files/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
export * from './useFileActions'
export * from './useFileActionsCopy'
export * from './useFileActionsDelete'
export * from './useFileActionsDownloadArchive'
export * from './useFileActionsDownloadFile'
export * from './useFileActionsMove'
export * from './useFileActionsNavigate'
export * from './useFileActionsOpenWithDefault'
export * from './useFileActionsOpenWithApp'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ import {
} from '../../actions'

import {
useFileActionsCopy,
useFileActionsDelete,
useFileActionsDownloadArchive,
useFileActionsDownloadFile,
useFileActionsMove,
useFileActionsNavigate,
useFileActionsRestore
} from './index'
Expand Down Expand Up @@ -55,21 +52,15 @@ export const useFileActions = () => {
const configStore = useConfigStore()
const { options } = storeToRefs(configStore)

const { actions: copyActions } = useFileActionsCopy()
const { actions: deleteActions } = useFileActionsDelete()
const { actions: downloadArchiveActions } = useFileActionsDownloadArchive()
const { actions: downloadFileActions } = useFileActionsDownloadFile()
const { actions: fallbackToDownloadAction } = useFileActionFallbackToDownload()
const { actions: moveActions } = useFileActionsMove()
const { actions: navigateActions } = useFileActionsNavigate()
const { actions: restoreActions } = useFileActionsRestore()

const systemActions = computed<FileAction<any>[]>(() => [
...unref(downloadArchiveActions),
...unref(downloadFileActions),
...unref(deleteActions),
...unref(moveActions),
...unref(copyActions),
...unref(restoreActions)
])

Expand Down
1 change: 1 addition & 0 deletions packages/web-pkg/src/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export * from './filesize'
export * from './fuse'
export * from './locale'
export * from './path'
export * from './permissions'
export * from './store'
export * from './binary'
export * from './platform'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { mock } from 'vitest-mock-extended'
import { Resource, SpaceResource } from '@opencloud-eu/web-client'
import ContextActions from '../../../../src/components/FilesList/ContextActions.vue'

import { useFileActionsCopy, useFileActionsDelete } from '../../../../src/composables'
import { useFileActionsDelete } from '../../../../src/composables'
import { computed } from 'vue'
import { Action } from '../../../../src/composables/actions'

Expand All @@ -25,7 +25,7 @@ describe.skip('ContextActions', () => {
})

it('render enabled actions', () => {
const enabledComposables = [useFileActionsDelete, useFileActionsCopy]
const enabledComposables = [useFileActionsDelete]
for (const composable of enabledComposables) {
vi.mocked(composable).mockImplementation(() => ({
actions: computed(() => [mock<Action>({ isVisible: () => true })])
Expand Down
Loading