diff --git a/src/files-action.js b/src/files-action.js index a5d5e56e7..270cce72d 100644 --- a/src/files-action.js +++ b/src/files-action.js @@ -25,7 +25,9 @@ import { registerFileAction, FileAction } from '@nextcloud/files' const mime = 'text/vcard' const name = 'contacts-import' -registerFileAction(new FileAction({ +window.addEventListener('DOMContentLoaded', () => { + if (!nextcloudVersion >= 26 && OCA.Files && OCA?.Files?.fileActions) { + OCA.Files.fileActions.registerAction({ name, displayName: t('contacts', 'Import'), mime, @@ -36,8 +38,26 @@ registerFileAction(new FileAction({ window.location = generateUrl(`/apps/contacts/import?file=${absPath}`) }, }) - // to be changed OCA.Files.fileActions.setDefault(mime, name) return + } console.error('Unable to register vcf import action') -) +}) + +if (nextcloudVersion >= 26) { + registerFileAction(new FileAction({ + name, + displayName() { + return t('contacts', 'Import') + }, + default: 'default', + mime, + permissions: OC.PERMISSION_READ, + iconClass: 'icon-contacts-dark', + actionHandler(fileName, context) { + const absPath = `${context.dir === '/' ? '' : context.dir}/${fileName}` + window.location = generateUrl(`/apps/contacts/import?file=${absPath}`) + }, + }), + ) +}