From ade8cf52123dc6d24441299995bd9d7818a7cf70 Mon Sep 17 00:00:00 2001 From: Diogo Castro Date: Fri, 17 Feb 2023 14:45:51 +0100 Subject: [PATCH] Fix for direct link and samba path (cern only config) changelog --- changelog/unreleased/enhancement-cern-links | 5 ++ .../SideBar/Details/FileDetails.vue | 74 +++++++++++++++++-- .../src/helpers/path/pathMappings.ts | 6 ++ .../SideBar/Details/FileDetails.spec.ts | 26 +++++-- .../__snapshots__/FileDetails.spec.ts.snap | 68 +++++++++++++---- 5 files changed, 148 insertions(+), 31 deletions(-) create mode 100644 changelog/unreleased/enhancement-cern-links create mode 100644 packages/web-app-files/src/helpers/path/pathMappings.ts diff --git a/changelog/unreleased/enhancement-cern-links b/changelog/unreleased/enhancement-cern-links new file mode 100644 index 00000000000..daaf5ef8588 --- /dev/null +++ b/changelog/unreleased/enhancement-cern-links @@ -0,0 +1,5 @@ +Enhancement: Update CERN links + +We've updated the links displayed in the sidebar for CERN's deployment. + +https://github.com/owncloud/web/pull/8473 diff --git a/packages/web-app-files/src/components/SideBar/Details/FileDetails.vue b/packages/web-app-files/src/components/SideBar/Details/FileDetails.vue index 713ea41ef44..b98f0bfacc3 100644 --- a/packages/web-app-files/src/components/SideBar/Details/FileDetails.vue +++ b/packages/web-app-files/src/components/SideBar/Details/FileDetails.vue @@ -84,7 +84,7 @@ /> - +
@@ -113,6 +113,34 @@
+ + + +
+

+ + + + +

+ + @@ -185,6 +213,7 @@ import { configurationManager } from 'web-pkg/src/configuration' import { createFileRouteOptions } from 'web-pkg/src/helpers/router' import { useTask } from 'vue-concurrency' import { useGettext } from 'vue3-gettext' +import pathMappings from '../../../helpers/path/pathMappings' export default defineComponent({ name: 'FileDetails', @@ -194,6 +223,7 @@ export default defineComponent({ const copiedDirect = ref(false) const copiedEos = ref(false) + const copiedSamba = ref(false) const { copy, copied, @@ -207,20 +237,37 @@ export default defineComponent({ const preview = ref(undefined) const directLink = computed(() => { - return `${store.getters.configuration.server}files/spaces/personal/home${encodePath( - unref(resource).path - )}` + return !unref(isPublicLinkContext) + ? `${store.getters.configuration.server}files/spaces${encodePath(unref(resource).path)}` + : `${store.getters.configuration.server.replace(/\/+$/, '')}${unref(resource).downloadURL}` }) const copyEosPathToClipboard = () => { copy(unref(resource).path) copiedEos.value = unref(copied) store.dispatch('showMessage', { - title: $gettext('EOS path copied'), - desc: $gettext('The EOS path has been copied to your clipboard.') + title: $gettext('FUSE path copied'), + desc: $gettext('The FUSE path has been copied to your clipboard.') + }) + } + + const copySambaPathToClipboard = () => { + copy(getSambaPath(unref(resource).path)) + copiedSamba.value = unref(copied) + store.dispatch('showMessage', { + title: $gettext('Windows path copied'), + desc: $gettext('The Windows path has been copied to your clipboard.') }) } + const getSambaPath = (path) => { + const pathComponents = path?.split('/').filter(Boolean) + if (pathComponents.length > 1 && pathComponents[0] === 'eos') { + const translated = pathMappings[pathComponents[1]] + return translated && `${translated}${pathComponents.slice(2).join('\\')}` + } + } + const copyDirectLinkToClipboard = () => { copy(unref(directLink)) copiedDirect.value = unref(copied) @@ -269,6 +316,8 @@ export default defineComponent({ copiedEos, preview, copyEosPathToClipboard, + copySambaPathToClipboard, + getSambaPath, copiedDirect, copyDirectLinkToClipboard, isClipboardCopySupported, @@ -293,6 +342,9 @@ export default defineComponent({ runningOnEos() { return !!this.configuration?.options?.runningOnEos }, + cernFeatures() { + return !!this.configuration?.options?.cernFeatures + }, hasContent() { return ( this.hasTimestamp || @@ -402,10 +454,16 @@ export default defineComponent({ return this.$gettext('Copy direct link') }, eosPathLabel() { - return this.$gettext('EOS Path') + return this.$gettext('FUSE Path') }, copyEosPathLabel() { - return this.$gettext('Copy EOS path') + return this.$gettext('Copy FUSE path') + }, + sambaPathLabel() { + return this.$gettext('Windows Path') + }, + copySambaPathLabel() { + return this.$gettext('Copy Windows path') }, resourceSize() { return formatFileSize(this.resource.size, this.$language.current) diff --git a/packages/web-app-files/src/helpers/path/pathMappings.ts b/packages/web-app-files/src/helpers/path/pathMappings.ts new file mode 100644 index 00000000000..102ed33373d --- /dev/null +++ b/packages/web-app-files/src/helpers/path/pathMappings.ts @@ -0,0 +1,6 @@ +export default { + user: '\\\\cernbox-smb\\eos\\user\\', + project: '\\\\eosproject-smb\\eos\\project\\', + public: '\\\\eospublic-smb\\eos\\', + media: '\\\\eosmedia-smb\\eos\\' +} diff --git a/packages/web-app-files/tests/unit/components/SideBar/Details/FileDetails.spec.ts b/packages/web-app-files/tests/unit/components/SideBar/Details/FileDetails.spec.ts index d7f69a897c8..5602af42923 100644 --- a/packages/web-app-files/tests/unit/components/SideBar/Details/FileDetails.spec.ts +++ b/packages/web-app-files/tests/unit/components/SideBar/Details/FileDetails.spec.ts @@ -39,6 +39,11 @@ const sharedFolder = createFile({ shareTypes: [ShareTypes.user.value] }) +const sharedFolderEOS = { + ...sharedFolder, + path: '/eos/user/t/test/myfolder' +} + const simpleOwnFile = createFile({ id: '3', type: 'file', @@ -64,6 +69,11 @@ const sharedFile = createFile({ isReceivedShare: () => true }) +const sharedFileEOS = { + ...sharedFile, + path: '/eos/user/t/test/123.png' +} + describe('Details SideBar Panel', () => { describe('displays a resource of type folder', () => { describe('on a private page', () => { @@ -76,7 +86,7 @@ describe('Details SideBar Panel', () => { expect(wrapper.html()).toMatchSnapshot() }) it('with timestamp, size info, share info and share date running on eos', () => { - const { wrapper } = createWrapper(sharedFolder, false, true) + const { wrapper } = createWrapper(sharedFolderEOS, false, true, true) expect(wrapper.html()).toMatchSnapshot() }) }) @@ -86,7 +96,7 @@ describe('Details SideBar Panel', () => { expect(wrapper.html()).toMatchSnapshot() }) it('with owner, timestamp, size info and no share info running on eos', () => { - const { wrapper } = createWrapper(sharedFolder, true, true) + const { wrapper } = createWrapper(sharedFolderEOS, true, true, true) expect(wrapper.html()).toMatchSnapshot() }) }) @@ -102,7 +112,7 @@ describe('Details SideBar Panel', () => { expect(wrapper.html()).toMatchSnapshot() }) it('with timestamp, size info, share info, share date and preview running on eos', () => { - const { wrapper } = createWrapper(sharedFile, false, true) + const { wrapper } = createWrapper(sharedFileEOS, false, true) expect(wrapper.html()).toMatchSnapshot() }) @@ -140,7 +150,7 @@ describe('Details SideBar Panel', () => { expect(wrapper.html()).toMatchSnapshot() }) it('with owner, timestamp, size info, no share info and preview running on eos', () => { - const { wrapper } = createWrapper(sharedFile, true, true) + const { wrapper } = createWrapper(sharedFileEOS, true, true, true) expect(wrapper.html()).toMatchSnapshot() }) }) @@ -151,11 +161,11 @@ describe('Details SideBar Panel', () => { expect(wrapper.find('[data-testid="tags"]').exists()).toBeTruthy() }) it('should use router-link when authenticated', () => { - const { wrapper } = createWrapper(simpleOwnFolder, true, false, true) + const { wrapper } = createWrapper(simpleOwnFolder, true, false, false, true) expect(wrapper.find('[data-testid="tags"]').find('router-link-stub').exists()).toBeTruthy() }) it('should not use router-link when not authenticated', () => { - const { wrapper } = createWrapper(simpleOwnFolder, true, false, false) + const { wrapper } = createWrapper(simpleOwnFolder, true, false, false, false) expect(wrapper.find('[data-testid="tags"]').find('router-link-stub').exists()).toBeFalsy() }) }) @@ -165,6 +175,7 @@ function createWrapper( testResource, publicLinkContext = false, runningOnEos = false, + cernFeatures = false, isUserContextReady = true ) { const storeOptions = { @@ -177,7 +188,8 @@ function createWrapper( configuration: function () { return { options: { - runningOnEos + runningOnEos, + cernFeatures } } } diff --git a/packages/web-app-files/tests/unit/components/SideBar/Details/__snapshots__/FileDetails.spec.ts.snap b/packages/web-app-files/tests/unit/components/SideBar/Details/__snapshots__/FileDetails.spec.ts.snap index a0809e7230e..4e43645ad3a 100644 --- a/packages/web-app-files/tests/unit/components/SideBar/Details/__snapshots__/FileDetails.spec.ts.snap +++ b/packages/web-app-files/tests/unit/components/SideBar/Details/__snapshots__/FileDetails.spec.ts.snap @@ -47,6 +47,7 @@ exports[`Details SideBar Panel displays a resource of type file on a private pag + @@ -100,6 +101,7 @@ exports[`Details SideBar Panel displays a resource of type file on a private pag + @@ -144,6 +146,7 @@ exports[`Details SideBar Panel displays a resource of type file on a private pag + @@ -192,6 +195,7 @@ exports[`Details SideBar Panel displays a resource of type file on a private pag + @@ -238,19 +242,20 @@ exports[`Details SideBar Panel displays a resource of type file on a private pag - EOS Path + FUSE Path
-

/Shares/123.png

- +

/eos/user/t/test/123.png

+
+ Direct link
-

undefinedfiles/spaces/personal/home/Shares/123.png

+

undefinedfiles/spaces/eos/user/t/test/123.png

@@ -304,6 +309,7 @@ exports[`Details SideBar Panel displays a resource of type file on a public page + @@ -350,11 +356,20 @@ exports[`Details SideBar Panel displays a resource of type file on a public page - EOS Path + FUSE Path + +
+

/eos/user/t/test/123.png

+ +
+ + + + Windows Path
-

/Shares/123.png

- +

\\\\cernbox-smb\\eos\\user\\t\\test\\123.png

+
@@ -362,7 +377,7 @@ exports[`Details SideBar Panel displays a resource of type file on a public page Direct link
-

undefinedfiles/spaces/personal/home/Shares/123.png

+

undefinedfiles/spaces/eos/user/t/test/123.png

@@ -406,6 +421,7 @@ exports[`Details SideBar Panel displays a resource of type folder on a private p + Tags @@ -462,6 +478,7 @@ exports[`Details SideBar Panel displays a resource of type folder on a private p + @@ -503,11 +520,20 @@ exports[`Details SideBar Panel displays a resource of type folder on a private p - EOS Path + FUSE Path
-

- +

/eos/user/t/test/myfolder

+ +
+ + + + Windows Path + +
+

\\\\cernbox-smb\\eos\\user\\t\\test\\myfolder

+
@@ -515,7 +541,7 @@ exports[`Details SideBar Panel displays a resource of type folder on a private p Direct link
-

undefinedfiles/spaces/personal/home

+

undefinedfiles/spaces/eos/user/t/test/myfolder

@@ -564,6 +590,7 @@ exports[`Details SideBar Panel displays a resource of type folder on a public pa + @@ -605,11 +632,20 @@ exports[`Details SideBar Panel displays a resource of type folder on a public pa - EOS Path + FUSE Path + +
+

/eos/user/t/test/myfolder

+ +
+ + + + Windows Path
-

- +

\\\\cernbox-smb\\eos\\user\\t\\test\\myfolder

+
@@ -617,7 +653,7 @@ exports[`Details SideBar Panel displays a resource of type folder on a public pa Direct link
-

undefinedfiles/spaces/personal/home

+

undefinedfiles/spaces/eos/user/t/test/myfolder