Skip to content

Commit

Permalink
Fix for direct link and samba path (cern only config)
Browse files Browse the repository at this point in the history
changelog
  • Loading branch information
diocas committed Feb 17, 2023
1 parent b8ae8ae commit ade8cf5
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 31 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/enhancement-cern-links
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
/>
</td>
</tr>
<tr v-if="runningOnEos">
<tr v-if="runningOnEos && !isPublicLinkContext">
<th scope="col" class="oc-pr-s" v-text="eosPathLabel" />
<td>
<div class="oc-flex oc-flex-middle oc-flex-between oc-width-1-1">
Expand Down Expand Up @@ -113,6 +113,34 @@
</div>
</td>
</tr>
<tr v-if="cernFeatures && getSambaPath(resource.path) && !isPublicLinkContext">
<th scope="col" class="oc-pr-s" v-text="sambaPathLabel" />
<td>
<div class="oc-flex oc-flex-middle oc-flex-between oc-width-1-1">
<p
ref="sambaFilePath"
v-oc-tooltip="getSambaPath(resource.path)"
class="oc-my-rm oc-text-truncate"
v-text="getSambaPath(resource.path)"
/>
<oc-button
v-oc-tooltip="copySambaPathLabel"
:aria-label="copySambaPathLabel"
appearance="raw"
:variation="copiedSamba ? 'success' : 'passive'"
@click="copySambaPathToClipboard"
>
<oc-icon
v-if="copiedSamba"
key="oc-copy-to-clipboard-copied"
name="checkbox-circle"
class="_clipboard-success-animation"
/>
<oc-icon v-else key="oc-copy-to-clipboard-copy" name="clipboard" />
</oc-button>
</div>
</td>
</tr>
<tr v-if="runningOnEos">
<th scope="col" class="oc-pr-s" v-text="directLinkLabel" />
<td>
Expand Down Expand Up @@ -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',
Expand All @@ -194,6 +223,7 @@ export default defineComponent({
const copiedDirect = ref(false)
const copiedEos = ref(false)
const copiedSamba = ref(false)
const {
copy,
copied,
Expand All @@ -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)
Expand Down Expand Up @@ -269,6 +316,8 @@ export default defineComponent({
copiedEos,
preview,
copyEosPathToClipboard,
copySambaPathToClipboard,
getSambaPath,
copiedDirect,
copyDirectLinkToClipboard,
isClipboardCopySupported,
Expand All @@ -293,6 +342,9 @@ export default defineComponent({
runningOnEos() {
return !!this.configuration?.options?.runningOnEos
},
cernFeatures() {
return !!this.configuration?.options?.cernFeatures
},
hasContent() {
return (
this.hasTimestamp ||
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions packages/web-app-files/src/helpers/path/pathMappings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
user: '\\\\cernbox-smb\\eos\\user\\',
project: '\\\\eosproject-smb\\eos\\project\\',
public: '\\\\eospublic-smb\\eos\\',
media: '\\\\eosmedia-smb\\eos\\'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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', () => {
Expand All @@ -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()
})
})
Expand All @@ -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()
})
})
Expand All @@ -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()
})

Expand Down Expand Up @@ -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()
})
})
Expand All @@ -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()
})
})
Expand All @@ -165,6 +175,7 @@ function createWrapper(
testResource,
publicLinkContext = false,
runningOnEos = false,
cernFeatures = false,
isUserContextReady = true
) {
const storeOptions = {
Expand All @@ -177,7 +188,8 @@ function createWrapper(
configuration: function () {
return {
options: {
runningOnEos
runningOnEos,
cernFeatures
}
}
}
Expand Down
Loading

0 comments on commit ade8cf5

Please sign in to comment.