Skip to content

Commit

Permalink
feat: remove action for copying quick links
Browse files Browse the repository at this point in the history
Removes the action in favour of the new action for copying permanent links.
  • Loading branch information
Jannik Stehle committed Sep 11, 2024
1 parent 2e7f8a6 commit 2b076b5
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 391 deletions.
6 changes: 3 additions & 3 deletions packages/web-pkg/src/components/AppTemplates/AppWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import {
useConfigStore,
useResourcesStore,
FileContentOptions,
useFileActionsCopyQuickLink,
useFileActionsCopyPermanentLink,
useFileActionsDownloadFile,
useFileActionsShowDetails,
useFileActionsShowShares,
Expand Down Expand Up @@ -141,7 +141,7 @@ export default defineComponent({
const { actions: openWithAppActions } = useFileActionsOpenWithApp({
appId: props.applicationId
})
const { actions: createQuickLinkActions } = useFileActionsCopyQuickLink()
const { actions: copyPermanentLinkActions } = useFileActionsCopyPermanentLink()
const { actions: downloadFileActions } = useFileActionsDownloadFile()
const { actions: showDetailsActions } = useFileActionsShowDetails()
const { actions: showSharesActions } = useFileActionsShowShares()
Expand Down Expand Up @@ -484,7 +484,7 @@ export default defineComponent({
)
})
const menuItemsShare = computed(() => {
return [...unref(showSharesActions), ...unref(createQuickLinkActions)].filter((item) =>
return [...unref(showSharesActions), ...unref(copyPermanentLinkActions)].filter((item) =>
item.isVisible(unref(actionOptions))
)
})
Expand Down
6 changes: 3 additions & 3 deletions packages/web-pkg/src/components/FilesList/ContextActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
FileActionOptions,
useExtensionRegistry,
useFileActionsToggleHideShare,
useFileActionsCopyQuickLink,
useFileActionsCopyPermanentLink,
useFileActionsPaste,
useFileActionsShowDetails,
useFileActionsShowShares,
Expand Down Expand Up @@ -47,7 +47,7 @@ export default defineComponent({
const { actions: enableSyncActions } = useFileActionsEnableSync()
const { actions: hideShareActions } = useFileActionsToggleHideShare()
const { actions: copyActions } = useFileActionsCopy()
const { actions: createQuickLinkActions } = useFileActionsCopyQuickLink()
const { actions: copyPermanentLinkActions } = useFileActionsCopyPermanentLink()
const { actions: disableSyncActions } = useFileActionsDisableSync()
const { actions: deleteActions } = useFileActionsDelete()
const { actions: downloadArchiveActions } = useFileActionsDownloadArchive()
Expand Down Expand Up @@ -120,7 +120,7 @@ export default defineComponent({
const menuItemsShare = computed(() => {
return [
...unref(showSharesActions),
...unref(createQuickLinkActions),
...unref(copyPermanentLinkActions),
...unref(extensionsContextActions).filter((a) => a.category === 'share')
].filter((item) => item.isVisible(unref(actionOptions)))
})
Expand Down
3 changes: 1 addition & 2 deletions packages/web-pkg/src/composables/actions/files/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export * from './useFileActions'
export * from './useFileActionsEnableSync'
export * from './useFileActionsToggleHideShare'
export * from './useFileActionsCopy'
export * from './useFileActionsCopyQuicklink'
export * from './useFileActionsCopyPermanentLink'
export * from './useFileActionsDisableSync'
export * from './useFileActionsDelete'
export * from './useFileActionsDownloadArchive'
Expand All @@ -25,4 +25,3 @@ export * from './useFileActionsCreateNewShortcut'
export * from './useFileActionsOpenShortcut'
export * from './useFileActionsCreateLink'
export * from './useFileActionsOpenWithApp'
export * from './useFileActionsCopyPermanentLink'

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ContextActions from '../../../../src/components/FilesList/ContextActions.

import {
useFileActionsEnableSync,
useFileActionsCopyQuickLink,
useFileActionsCopyPermanentLink,
useFileActionsRename,
useFileActionsCopy
} from '../../../../src/composables'
Expand All @@ -27,7 +27,7 @@ describe.skip('ContextActions', () => {
it('render enabled actions', () => {
const enabledComposables = [
useFileActionsEnableSync,
useFileActionsCopyQuickLink,
useFileActionsCopyPermanentLink,
useFileActionsRename,
useFileActionsCopy
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { unref } from 'vue'
import { useFileActionsCopyPermanentLink } from '../../../../../src/composables/actions/files'
import { defaultComponentMocks, getComposableWrapper } from 'web-test-helpers'
import { mock } from 'vitest-mock-extended'
import { Resource, SpaceResource } from '@ownclouders/web-client'
import { useClipboard } from '../../../../../src/composables/clipboard'

vi.mock('../../../../../src/composables/clipboard', () => ({
useClipboard: vi.fn()
}))

describe('useFileActionsCopyPermanentLink', () => {
describe('isVisible property', () => {
it('should return false if no resource selected', () => {
getWrapper({
setup: ({ actions }) => {
expect(unref(actions)[0].isVisible({ space: null, resources: [] })).toBeFalsy()
}
})
})
it('should return true if one resource selected', () => {
getWrapper({
setup: ({ actions }) => {
expect(
unref(actions)[0].isVisible({ resources: [mock<Resource>()], space: undefined })
).toBeTruthy()
}
})
})
})
describe('handler', () => {
it('calls the copyToClipboard method with the private link of the resource', () => {
getWrapper({
setup: async ({ actions }, { mocks }) => {
const privateLink = 'https://example.com'
await unref(actions)[0].handler({
resources: [mock<Resource>({ privateLink })],
space: mock<SpaceResource>()
})
expect(mocks.copyToClipboardMock).toHaveBeenCalledWith(privateLink)
}
})
})
})
})

function getWrapper({
setup
}: {
setup: (
instance: ReturnType<typeof useFileActionsCopyPermanentLink>,
mocks: Record<string, any>
) => void
}) {
const copyToClipboardMock = vi.fn()
vi.mocked(useClipboard).mockReturnValue({ copyToClipboard: copyToClipboardMock })
const mocks = { ...defaultComponentMocks(), copyToClipboardMock }

return {
wrapper: getComposableWrapper(
() => {
const instance = useFileActionsCopyPermanentLink()
setup(instance, { mocks })
},
{
mocks,
provide: mocks
}
)
}
}
Loading

0 comments on commit 2b076b5

Please sign in to comment.