Skip to content
Draft
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
58 changes: 30 additions & 28 deletions open-in-swan/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,38 @@ const getPath = (space, resource) => {
return `/${space.driveAlias}${resource.path}`
}

const extension = computed<ActionExtension>(() => ({
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<ActionExtension>(() => ({
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',
Expand Down