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 d650c66
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 20 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 @@ -238,19 +238,19 @@ exports[`Details SideBar Panel displays a resource of type file on a private pag
</td>
</tr>
<tr>
<th class="oc-pr-s" scope="col">EOS Path</th>
<th class="oc-pr-s" scope="col">FUSE Path</th>
<td>
<div class="oc-flex oc-flex-middle oc-flex-between oc-width-1-1">
<p class="oc-my-rm oc-text-truncate">/Shares/123.png</p>
<oc-button-stub appearance="raw" arialabel="Copy EOS path" disabled="false" gapsize="medium" justifycontent="center" size="medium" submit="button" type="button" variation="passive"></oc-button-stub>
<oc-button-stub appearance="raw" arialabel="Copy FUSE path" disabled="false" gapsize="medium" justifycontent="center" size="medium" submit="button" type="button" variation="passive"></oc-button-stub>
</div>
</td>
</tr>
<tr>
<th class="oc-pr-s" scope="col">Direct link</th>
<td>
<div class="oc-flex oc-flex-middle oc-flex-between oc-width-1-1">
<p class="oc-my-rm oc-text-truncate">undefinedfiles/spaces/personal/home/Shares/123.png</p>
<p class="oc-my-rm oc-text-truncate">undefinedfiles/spaces/Shares/123.png</p>
<oc-button-stub appearance="raw" arialabel="Copy direct link" disabled="false" gapsize="medium" justifycontent="center" size="medium" submit="button" type="button" variation="passive"></oc-button-stub>
</div>
</td>
Expand Down Expand Up @@ -350,19 +350,19 @@ exports[`Details SideBar Panel displays a resource of type file on a public page
</td>
</tr>
<tr>
<th class="oc-pr-s" scope="col">EOS Path</th>
<th class="oc-pr-s" scope="col">FUSE Path</th>
<td>
<div class="oc-flex oc-flex-middle oc-flex-between oc-width-1-1">
<p class="oc-my-rm oc-text-truncate">/Shares/123.png</p>
<oc-button-stub appearance="raw" arialabel="Copy EOS path" disabled="false" gapsize="medium" justifycontent="center" size="medium" submit="button" type="button" variation="passive"></oc-button-stub>
<oc-button-stub appearance="raw" arialabel="Copy FUSE path" disabled="false" gapsize="medium" justifycontent="center" size="medium" submit="button" type="button" variation="passive"></oc-button-stub>
</div>
</td>
</tr>
<tr>
<th class="oc-pr-s" scope="col">Direct link</th>
<td>
<div class="oc-flex oc-flex-middle oc-flex-between oc-width-1-1">
<p class="oc-my-rm oc-text-truncate">undefinedfiles/spaces/personal/home/Shares/123.png</p>
<p class="oc-my-rm oc-text-truncate">undefinedfiles/spaces/Shares/123.png</p>
<oc-button-stub appearance="raw" arialabel="Copy direct link" disabled="false" gapsize="medium" justifycontent="center" size="medium" submit="button" type="button" variation="passive"></oc-button-stub>
</div>
</td>
Expand Down Expand Up @@ -503,19 +503,19 @@ exports[`Details SideBar Panel displays a resource of type folder on a private p
</tr>
<!--v-if-->
<tr>
<th class="oc-pr-s" scope="col">EOS Path</th>
<th class="oc-pr-s" scope="col">FUSE Path</th>
<td>
<div class="oc-flex oc-flex-middle oc-flex-between oc-width-1-1">
<p class="oc-my-rm oc-text-truncate"></p>
<oc-button-stub appearance="raw" arialabel="Copy EOS path" disabled="false" gapsize="medium" justifycontent="center" size="medium" submit="button" type="button" variation="passive"></oc-button-stub>
<oc-button-stub appearance="raw" arialabel="Copy FUSE path" disabled="false" gapsize="medium" justifycontent="center" size="medium" submit="button" type="button" variation="passive"></oc-button-stub>
</div>
</td>
</tr>
<tr>
<th class="oc-pr-s" scope="col">Direct link</th>
<td>
<div class="oc-flex oc-flex-middle oc-flex-between oc-width-1-1">
<p class="oc-my-rm oc-text-truncate">undefinedfiles/spaces/personal/home</p>
<p class="oc-my-rm oc-text-truncate">undefinedfiles/spaces</p>
<oc-button-stub appearance="raw" arialabel="Copy direct link" disabled="false" gapsize="medium" justifycontent="center" size="medium" submit="button" type="button" variation="passive"></oc-button-stub>
</div>
</td>
Expand Down Expand Up @@ -605,19 +605,19 @@ exports[`Details SideBar Panel displays a resource of type folder on a public pa
</tr>
<!--v-if-->
<tr>
<th class="oc-pr-s" scope="col">EOS Path</th>
<th class="oc-pr-s" scope="col">FUSE Path</th>
<td>
<div class="oc-flex oc-flex-middle oc-flex-between oc-width-1-1">
<p class="oc-my-rm oc-text-truncate"></p>
<oc-button-stub appearance="raw" arialabel="Copy EOS path" disabled="false" gapsize="medium" justifycontent="center" size="medium" submit="button" type="button" variation="passive"></oc-button-stub>
<oc-button-stub appearance="raw" arialabel="Copy FUSE path" disabled="false" gapsize="medium" justifycontent="center" size="medium" submit="button" type="button" variation="passive"></oc-button-stub>
</div>
</td>
</tr>
<tr>
<th class="oc-pr-s" scope="col">Direct link</th>
<td>
<div class="oc-flex oc-flex-middle oc-flex-between oc-width-1-1">
<p class="oc-my-rm oc-text-truncate">undefinedfiles/spaces/personal/home</p>
<p class="oc-my-rm oc-text-truncate">undefinedfiles/spaces</p>
<oc-button-stub appearance="raw" arialabel="Copy direct link" disabled="false" gapsize="medium" justifycontent="center" size="medium" submit="button" type="button" variation="passive"></oc-button-stub>
</div>
</td>
Expand Down

0 comments on commit d650c66

Please sign in to comment.