Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable29] fix: load script on init step #3137

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/Listeners/LoadAdditionalScriptsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
8 changes: 4 additions & 4 deletions src/actions/openGroupfolderAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
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: () => '',
Expand All @@ -44,4 +44,4 @@ registerFileAction(new FileAction({
default: DefaultType.DEFAULT,
// Before openFolderAction
order: -1000,
}))
})
7 changes: 5 additions & 2 deletions src/main.ts → src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -34,6 +35,8 @@ declare global {
const appName: string
}

registerFileAction(openGroupfolderAction)

const Navigation = getNavigation()
Navigation.register(new View({
id: appName,
Expand Down
18 changes: 10 additions & 8 deletions webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down
Loading