diff --git a/lib/Listeners/LoadAdditionalScriptsListener.php b/lib/Listeners/LoadAdditionalScriptsListener.php index a5b1f8e36..7fc659390 100644 --- a/lib/Listeners/LoadAdditionalScriptsListener.php +++ b/lib/Listeners/LoadAdditionalScriptsListener.php @@ -35,7 +35,7 @@ */ class LoadAdditionalScriptsListener implements IEventListener { public function handle(Event $event): void { + \OCP\Util::addInitScript('groupfolders', 'groupfolders-init'); \OCP\Util::addScript('groupfolders', 'groupfolders-files'); - \OCP\Util::addScript('groupfolders', 'groupfolders-main'); } } diff --git a/src/actions/openGroupfolderAction.ts b/src/actions/openGroupfolderAction.ts index a8acad76c..c2c8aa823 100644 --- a/src/actions/openGroupfolderAction.ts +++ b/src/actions/openGroupfolderAction.ts @@ -19,12 +19,12 @@ * along with this program. If not, see . * */ -import { translate as t } from '@nextcloud/l10n' import type { Node } from '@nextcloud/files' -import { registerFileAction, FileAction, DefaultType } from '@nextcloud/files' +import { FileAction, DefaultType } from '@nextcloud/files' +import { translate as t } from '@nextcloud/l10n' -registerFileAction(new FileAction({ +export const action = new FileAction({ id: 'open-group-folders', displayName: () => t('files', 'Open group folder'), iconSvgInline: () => '', @@ -44,4 +44,4 @@ registerFileAction(new FileAction({ default: DefaultType.DEFAULT, // Before openFolderAction order: -1000, -})) +}) diff --git a/src/main.ts b/src/init.ts similarity index 88% rename from src/main.ts rename to src/init.ts index 466cf0c60..bd62ae99b 100644 --- a/src/main.ts +++ b/src/init.ts @@ -21,10 +21,11 @@ */ /* eslint-disable */ import { translate as t } from '@nextcloud/l10n' -import { View, getNavigation } from '@nextcloud/files' +import { View, getNavigation, registerFileAction } from '@nextcloud/files' import FolderSvg from '@mdi/svg/svg/folder-account.svg?raw' + import { getContents } from './services/groupfolders' -import './actions/openGroupfolderAction' +import { action as openGroupfolderAction} from './actions/openGroupfolderAction' declare global { interface Window { @@ -34,6 +35,8 @@ declare global { const appName: string } +registerFileAction(openGroupfolderAction) + const Navigation = getNavigation() Navigation.register(new View({ id: appName, diff --git a/webpack.js b/webpack.js index 255504c59..710f863d3 100644 --- a/webpack.js +++ b/webpack.js @@ -3,14 +3,16 @@ const path = require('path') const webpackConfig = require('@nextcloud/webpack-vue-config') const webpackRules = require('@nextcloud/webpack-vue-config/rules') -webpackConfig.entry.main = path.resolve(path.join('src', 'main.ts')) -webpackConfig.entry.settings = [ - 'whatwg-fetch', - './src/settings/index.tsx', -] -webpackConfig.entry.files = [ - './src/files.js', -] +webpackConfig.entry = { + init: path.resolve(path.join('src', 'init.ts')), + files: [ + './src/files.js', + ], + settings: [ + 'whatwg-fetch', + './src/settings/index.tsx', + ], +} webpackConfig.resolve.extensions = [...webpackConfig.resolve.extensions, '.jsx', '.ts', '.tsx']