diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2020-09-05 13:40:29 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2020-09-05 13:40:29 +0200 |
commit | fb9fe6da2b2fb3f06b7e7a36b6f6c1f0d6cc6db4 (patch) | |
tree | 0391f56d33829cb6c95906574bd6e53c7954123b /src/files-action.js | |
parent | b0e1808b1be4873fa58e310c84b82d99794d7812 (diff) |
Fix files-actions script name
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src/files-action.js')
-rw-r--r-- | src/files-action.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/files-action.js b/src/files-action.js new file mode 100644 index 00000000..08365744 --- /dev/null +++ b/src/files-action.js @@ -0,0 +1,44 @@ +/** + * @copyright Copyright (c) 2020 John Molakvoæ <skjnldsv@protonmail.com> + * + * @author John Molakvoæ <skjnldsv@protonmail.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +import { generateUrl } from '@nextcloud/router' + +const mime = 'text/vcard' +const name = 'contacts-import' + +window.addEventListener('DOMContentLoaded', () => { + if (OCA.Files && OCA.Files.fileActions) { + OCA.Files.fileActions.registerAction({ + name, + displayName: t('contacts', 'Import'), + mime, + permissions: OC.PERMISSION_READ, + iconClass: 'icon-contacts', + actionHandler(fileName, context) { + const absPath = `${context.dir === '/' ? '' : context.dir}/${fileName}` + window.location = generateUrl(`/apps/contacts/import?file=${absPath}`) + }, + }) + OCA.Files.fileActions.setDefault(mime, name) + return + } + console.error('Unable to register vcf import action') +}) |