diff --git a/open-in-swan/src/index.ts b/open-in-swan/src/index.ts index d8d6e97..b50370d 100644 --- a/open-in-swan/src/index.ts +++ b/open-in-swan/src/index.ts @@ -10,36 +10,38 @@ const getPath = (space, resource) => { return `/${space.driveAlias}${resource.path}` } -const extension = computed(() => ({ - id: 'com.github.cernbox.web-extensions.open-in-swan', - scopes: ['resource'], - type: 'action', - extensionPointIds: ['global.files.context-actions'], - action: { - name: 'open-in-swan', - img: svg, - category: 'context', - label: () => 'Open in SWAN', - isVisible: ({ space, resources }) => { - if (resources.length !== 1) { - return false - } - if (resources[0].extension.toLowerCase() === 'ipynb'){ - const path = getPath(space, resources) - return path.startsWith('/eos/') +export default defineWebApplication({ + setup({ applicationConfig }) { + const { url = 'https://cern.ch/swanserver/cgi-bin/go' } = applicationConfig || {} + + const extension = computed(() => ({ + id: 'com.github.cernbox.web-extensions.open-in-swan', + scopes: ['resource'], + type: 'action', + extensionPointIds: ['global.files.context-actions'], + action: { + name: 'open-in-swan', + img: svg, + category: 'context', + label: () => 'Open in SWAN', + isVisible: ({ space, resources }) => { + if (resources.length !== 1) { + return false + } + if (resources[0].extension.toLowerCase() === 'ipynb'){ + const path = getPath(space, resources) + return path.startsWith('/eos/') + } + return false + }, + handler: ({ space, resources }) => { + const path = getPath(space, resources[0]) + console.debug('Opening in SWAN...', path) + window.open(`${url}?projurl=file:/${path}`, '_blank') + } } - return false - }, - handler: ({ space, resources }) => { - const path = getPath(space, resources[0]) - console.debug('Opening in SWAN...', path) - window.open(`https://cern.ch/swanserver/cgi-bin/go?projurl=file:/${path}`, '_blank') - } - } -})) + })) -export default defineWebApplication({ - setup() { return { appInfo: { name: 'SWAN',