Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CERN links #8473

Merged
merged 1 commit into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -87,8 +87,8 @@
/>
</td>
</tr>
<tr v-if="runningOnEos" data-testid="eosPath">
<th scope="col" class="oc-pr-s oc-font-semibold" v-text="$gettext('EOS Path')" />
<tr v-if="runningOnEos && !isPublicLinkContext" data-testid="eosPath">
<th scope="col" class="oc-pr-s oc-font-semibold" v-text="$gettext('FUSE Path')" />
<td>
<div class="oc-flex oc-flex-middle oc-flex-between oc-width-1-1">
<p
Expand Down Expand Up @@ -116,6 +116,34 @@
</div>
</td>
</tr>
<tr v-if="cernFeatures && sambaPath && !isPublicLinkContext" data-testid="sambaPath">
<th scope="col" class="oc-pr-s oc-font-semibold" v-text="$gettext('Windows Path')" />
<td>
<div class="oc-flex oc-flex-middle oc-flex-between oc-width-1-1">
<p
ref="sambaFilePath"
v-oc-tooltip="sambaPath"
class="oc-my-rm oc-text-truncate"
v-text="sambaPath"
/>
<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" data-testid="eosDirectLink">
<th scope="col" class="oc-pr-s oc-font-semibold" v-text="$gettext('Direct link')" />
<td>
Expand Down Expand Up @@ -194,6 +222,7 @@ export default defineComponent({

const copiedDirect = ref(false)
const copiedEos = ref(false)
const copiedSamba = ref(false)
const {
copy,
copied,
Expand All @@ -207,20 +236,43 @@ 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 pathMappings = {
user: '\\\\cernbox-smb\\eos\\user\\',
project: '\\\\eosproject-smb\\eos\\project\\',
public: '\\\\eospublic-smb\\eos\\',
media: '\\\\eosmedia-smb\\eos\\'
}
const pathComponents = path?.split('/').filter(Boolean)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please define the pathMappings inline here instead of having them in their own file? Completely CERN specific, so a dedicated file is probably more confusing than just having it inline here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, please let me know if it needs to be somewhere else. Also rebased to latest upstream.

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 @@ -280,6 +332,8 @@ export default defineComponent({
copiedEos,
preview,
copyEosPathToClipboard,
copySambaPathToClipboard,
getSambaPath,
copiedDirect,
copyDirectLinkToClipboard,
isClipboardCopySupported,
Expand All @@ -305,6 +359,9 @@ export default defineComponent({
runningOnEos() {
return !!this.configuration?.options?.runningOnEos
},
cernFeatures() {
return !!this.configuration?.options?.cernFeatures
},
hasContent() {
return (
this.hasTimestamp ||
Expand Down Expand Up @@ -363,7 +420,10 @@ export default defineComponent({
return this.$gettext('Copy direct link')
},
copyEosPathLabel() {
return this.$gettext('Copy EOS path')
return this.$gettext('Copy FUSE path')
},
copySambaPathLabel() {
return this.$gettext('Copy Windows path')
},
resourceSize() {
return formatFileSize(this.resource.size, this.$language.current)
Expand Down Expand Up @@ -406,6 +466,9 @@ export default defineComponent({
},
sharedByDisplayName() {
return this.resource.share?.fileOwner.displayName
},
sambaPath() {
return this.getSambaPath(this.resource.path)
}
},
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const getResourceMock = ({
tags = [],
thumbnail = null,
shareTypes = [],
share = null
share = null,
path = '/somePath/someResource'
} = {}) =>
mock<Resource>({
id: '1',
Expand All @@ -26,7 +27,7 @@ const getResourceMock = ({
mdate: 'Wed, 21 Oct 2015 07:28:00 GMT',
tags,
size: '740',
path: '/somePath/someResource',
path,
thumbnail,
shareTypes,
share
Expand All @@ -35,6 +36,7 @@ const getResourceMock = ({
const selectors = {
eosPath: '[data-testid="eosPath"]',
eosDirectLink: '[data-testid="eosDirectLink"]',
sambaPath: '[data-testid="sambaPath"]',
ownerDisplayName: '[data-testid="ownerDisplayName"]',
preview: '[data-testid="preview"]',
resourceIcon: '.details-icon',
Expand Down Expand Up @@ -138,6 +140,13 @@ describe('Details SideBar Panel', () => {
expect(wrapper.find(selectors.eosDirectLink).exists()).toBeTruthy()
})
})
describe('CERN features', () => {
it('show samba link', () => {
const resource = getResourceMock({ path: '/eos/user/t/test/123.png' })
const { wrapper } = createWrapper({ resource, cernFeatures: true })
expect(wrapper.find(selectors.sambaPath).exists()).toBeTruthy()
})
})
describe('tags', () => {
it('show if given', () => {
const resource = getResourceMock({ tags: ['moon', 'mars'] })
Expand All @@ -160,14 +169,15 @@ describe('Details SideBar Panel', () => {
function createWrapper({
resource = null,
runningOnEos = false,
cernFeatures = false,
isPublicLinkContext = false,
ancestorMetaData = {},
user = { id: 'marie' },
versions = []
} = {}) {
const storeOptions = defaultStoreMockOptions
storeOptions.getters.user.mockReturnValue(user)
storeOptions.getters.configuration.mockReturnValue({ options: { runningOnEos } })
storeOptions.getters.configuration.mockReturnValue({ options: { runningOnEos, cernFeatures } })
storeOptions.modules.Files.getters.versions.mockReturnValue(versions)
storeOptions.getters.capabilities.mockReturnValue({ files: { tags: true } })
storeOptions.modules.Files.getters.ancestorMetaData.mockReturnValue(ancestorMetaData)
Expand Down