From 2e7f8a6e4306e45ffe8ca6843b51f3356f6df2bb Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Mon, 9 Sep 2024 15:59:00 +0200 Subject: [PATCH 1/2] feat: remove internal link type Removes the internal link type since the permanent link makes it obsolete. Existing internal links still resolve correctly to ensure backwards compatibility. --- .../enhancement-internal-link-removal | 6 +++ .../components/SideBar/Shares/FileLinks.vue | 22 +++++---- .../SideBar/Shares/Links/DetailsAndEdit.vue | 2 - .../composables/extensions/useFileActions.ts | 6 +-- .../components/FilesList/QuickActions.spec.ts | 12 ++--- .../SideBar/Shares/FileLinks.spec.ts | 16 ++---- .../src/components/CreateLinkModal.vue | 42 ++-------------- .../src/composables/actions/files/index.ts | 1 + .../files/useFileActionsCopyPermanentLink.ts | 45 +++++++++++++++++ .../files/useFileActionsCopyQuicklink.ts | 21 +++++++- .../actions/files/useFileActionsCreateLink.ts | 3 +- .../src/composables/links/useLinkTypes.ts | 19 ++----- .../unit/components/CreateLinkModal.spec.ts | 30 +++--------- .../files/useFileActionsCopyQuicklink.spec.ts | 26 +++++++++- .../composables/links/useLinkTypes.spec.ts | 35 ++----------- .../features/shares/internalLink.feature | 10 ++-- .../features/spaces/internalLink.feature | 49 ------------------- 17 files changed, 145 insertions(+), 200 deletions(-) create mode 100644 changelog/unreleased/enhancement-internal-link-removal create mode 100644 packages/web-pkg/src/composables/actions/files/useFileActionsCopyPermanentLink.ts delete mode 100644 tests/e2e/cucumber/features/spaces/internalLink.feature diff --git a/changelog/unreleased/enhancement-internal-link-removal b/changelog/unreleased/enhancement-internal-link-removal new file mode 100644 index 00000000000..9d30e255e4c --- /dev/null +++ b/changelog/unreleased/enhancement-internal-link-removal @@ -0,0 +1,6 @@ +Enhancement: Internal link removal + +The internal link type has been removed because the permanent link makes it obsolete. Existing internal links still resolve correctly to ensure backwards compatibility. + +https://github.com/owncloud/web/pull/11553 +https://github.com/owncloud/web/issues/11544 diff --git a/packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue b/packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue index 5858f3d6992..e7dbcc6bde3 100644 --- a/packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue +++ b/packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue @@ -5,17 +5,14 @@

-

+
- +
{ + if (!ability.can('create-all', 'PublicLink')) { + return false + } + return canShare({ space: unref(space), resource: unref(resource) }) + }) const sharesStore = useSharesStore() const { updateLink, deleteLink } = sharesStore @@ -182,7 +186,7 @@ export default defineComponent({ const canEditLink = (linkShare: LinkShare) => { return ( - canCreateLinks({ space: unref(space), resource: unref(resource) }) && + unref(canCreateLinks) && (can('create-all', 'PublicLink') || linkShare.type === SharingLinkType.Internal) ) } diff --git a/packages/web-app-files/src/components/SideBar/Shares/Links/DetailsAndEdit.vue b/packages/web-app-files/src/components/SideBar/Shares/Links/DetailsAndEdit.vue index ff6267ad783..97458a48a5a 100644 --- a/packages/web-app-files/src/components/SideBar/Shares/Links/DetailsAndEdit.vue +++ b/packages/web-app-files/src/components/SideBar/Shares/Links/DetailsAndEdit.vue @@ -149,7 +149,6 @@ import { OcDrop } from 'design-system/src/components' import { usePasswordPolicyService } from '@ownclouders/web-pkg' import { useGettext } from 'vue3-gettext' import SetLinkPasswordModal from '../../../Modals/SetLinkPasswordModal.vue' -import { storeToRefs } from 'pinia' import { SharingLinkType } from '@ownclouders/web-client/graph/generated' import DatePickerModal from '../../../Modals/DatePickerModal.vue' import ExpirationDateIndicator from '../ExpirationDateIndicator.vue' @@ -204,7 +203,6 @@ export default defineComponent({ useLinkTypes() const resourcesStore = useResourcesStore() - const { ancestorMetaData } = storeToRefs(resourcesStore) const space = inject>('space') const resource = inject>('resource') diff --git a/packages/web-app-files/src/composables/extensions/useFileActions.ts b/packages/web-app-files/src/composables/extensions/useFileActions.ts index d5c2946c798..29f5867cf94 100644 --- a/packages/web-app-files/src/composables/extensions/useFileActions.ts +++ b/packages/web-app-files/src/composables/extensions/useFileActions.ts @@ -1,6 +1,6 @@ import { ActionExtension, - useFileActionsCopyQuickLink, + useFileActionsCopyPermanentLink, useFileActionsOpenShortcut, useFileActionsShowShares } from '@ownclouders/web-pkg' @@ -14,7 +14,7 @@ import { unref } from 'vue' export const useFileActions = (): ActionExtension[] => { const { actions: openShortcutActions } = useFileActionsOpenShortcut() const { actions: showSharesActions } = useFileActionsShowShares() - const { actions: quickLinkActions } = useFileActionsCopyQuickLink() + const { actions: permanentLinkActions } = useFileActionsCopyPermanentLink() return [ { @@ -33,7 +33,7 @@ export const useFileActions = (): ActionExtension[] => { id: 'com.github.owncloud.web.files.quick-action.quicklink', extensionPointIds: [quickActionsExtensionPoint.id], type: 'action', - action: unref(quickLinkActions)[0] + action: unref(permanentLinkActions)[0] } ] } diff --git a/packages/web-app-files/tests/unit/components/FilesList/QuickActions.spec.ts b/packages/web-app-files/tests/unit/components/FilesList/QuickActions.spec.ts index ff122712f82..ea52f50bac0 100644 --- a/packages/web-app-files/tests/unit/components/FilesList/QuickActions.spec.ts +++ b/packages/web-app-files/tests/unit/components/FilesList/QuickActions.spec.ts @@ -21,13 +21,13 @@ const collaboratorAction = { label: () => 'Add people' } -const quickLinkAction = { +const permanentLinkAction = { isVisible: vi.fn(() => false), handler: vi.fn(), icon: 'link-add', - id: 'quicklink', - name: 'copy-quicklink', - label: () => 'Create and copy quicklink' + id: 'permanent-link', + name: 'copy-permanent-link', + label: () => 'Copy permanent link' } const testItem = { @@ -58,7 +58,7 @@ describe('QuickActions', () => { }) it('should not display action buttons where "displayed" is set to false', () => { - const linkActionButton = wrapper.find('.files-quick-action-copy-quicklink') + const linkActionButton = wrapper.find('.files-quick-action-copy-permanent-link') expect(linkActionButton.exists()).toBeFalsy() }) @@ -96,7 +96,7 @@ function getWrapper({ embedModeEnabled = false } = {}) { }), mock({ extensionPointIds: [quickActionsExtensionPoint.id], - action: quickLinkAction + action: permanentLinkAction }) ]) diff --git a/packages/web-app-files/tests/unit/components/SideBar/Shares/FileLinks.spec.ts b/packages/web-app-files/tests/unit/components/SideBar/Shares/FileLinks.spec.ts index c7c04f63f93..052546a9e52 100644 --- a/packages/web-app-files/tests/unit/components/SideBar/Shares/FileLinks.spec.ts +++ b/packages/web-app-files/tests/unit/components/SideBar/Shares/FileLinks.spec.ts @@ -108,7 +108,7 @@ describe('FileLinks', () => { describe('when the add-new-link button is clicked', () => { it('should call createLink', async () => { - const { wrapper, mocks } = getWrapper({ abilities: [] }) + const { wrapper, mocks } = getWrapper() await wrapper.find(selectors.linkAddButton).trigger('click') expect(mocks.createLinkMock).toHaveBeenCalledTimes(1) }) @@ -129,7 +129,7 @@ describe('FileLinks', () => { canShare: () => true }) - it('existing viewer link is not modifiable', () => { + it('existing link is not modifiable', () => { const viewerLink = defaultLinksList[0] viewerLink.type = SharingLinkType.View const { wrapper } = getWrapper({ resource, abilities: [], links: [viewerLink] }) @@ -139,15 +139,9 @@ describe('FileLinks', () => { const isModifiable = detailsAndEdit.props('isModifiable') expect(isModifiable).toBeFalsy() }) - it('existing internal link is modifiable', () => { - const internalLink = defaultLinksList[0] - internalLink.type = SharingLinkType.Internal - const { wrapper } = getWrapper({ resource, abilities: [], links: [internalLink] }) - const detailsAndEdit = wrapper.findComponent( - linkListItemDetailsAndEdit - ) - const isModifiable = detailsAndEdit.props('isModifiable') - expect(isModifiable).toBeTruthy() + it('new links cannot be created', () => { + const { wrapper } = getWrapper({ resource, abilities: [] }) + expect(wrapper.find(selectors.linkAddButton).exists()).toBeFalsy() }) }) }) diff --git a/packages/web-pkg/src/components/CreateLinkModal.vue b/packages/web-pkg/src/components/CreateLinkModal.vue index 6a0b48ab7d3..0c2ed7031d7 100644 --- a/packages/web-pkg/src/components/CreateLinkModal.vue +++ b/packages/web-pkg/src/components/CreateLinkModal.vue @@ -24,23 +24,17 @@
-