From d650c66602dabf237a7a663f40c1a298363a412a 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 ++ .../__snapshots__/FileDetails.spec.ts.snap | 24 +++--- 4 files changed, 89 insertions(+), 20 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/__snapshots__/FileDetails.spec.ts.snap b/packages/web-app-files/tests/unit/components/SideBar/Details/__snapshots__/FileDetails.spec.ts.snap index a0809e7230e..f6032e37f19 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 @@ -238,11 +238,11 @@ exports[`Details SideBar Panel displays a resource of type file on a private pag - EOS Path + FUSE Path

/Shares/123.png

- +
@@ -250,7 +250,7 @@ exports[`Details SideBar Panel displays a resource of type file on a private pag Direct link
-

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

+

undefinedfiles/spaces/Shares/123.png

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

/Shares/123.png

- +
@@ -362,7 +362,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/Shares/123.png

@@ -503,11 +503,11 @@ exports[`Details SideBar Panel displays a resource of type folder on a private p - EOS Path + FUSE Path

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

undefinedfiles/spaces/personal/home

+

undefinedfiles/spaces

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

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

undefinedfiles/spaces/personal/home

+

undefinedfiles/spaces