From ac1a2c3b15ec69e1750fc07c5b23e1e9171d3f6a Mon Sep 17 00:00:00 2001 From: Richard Steinmetz Date: Wed, 23 Dec 2020 18:37:35 +0100 Subject: Update frontend code Introduce webpack to bundle required dependencies instead of relying on global libraries. Those global libraries are deprecated and will be removed soon. I tried to change the existing code as little as possible. However, the diff is huge because I fixed the indentation (tabs and spaces were mixed). Additionally, I tried to keep package.json and webpack.common.js as minimal as possible and took some inspiration from other official nextcloud apps. Npm scripts: - Production build: `npm run build` - Development build: `npm run dev` - Build and watch for changes: `npm run watch` The build script should be run before pushing a release. The source files (inside src/), installed packages (inside node_modules/) and various js configs (webpack.*.js, package*.json and babel.config.json) can be omitted from a release. Webpack will output the generated code to js/. Signed-off-by: Richard Steinmetz --- lib/AppInfo/Application.php | 8 ++--- lib/Listener/LoadAdditionalScriptsListener.php | 41 -------------------------- lib/Listener/LoadSidebarListener.php | 41 ++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 45 deletions(-) delete mode 100644 lib/Listener/LoadAdditionalScriptsListener.php create mode 100644 lib/Listener/LoadSidebarListener.php (limited to 'lib') diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 9feaf47..89c9a5e 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -23,8 +23,8 @@ declare(strict_types=1); namespace OCA\Checksum\AppInfo; -use OCA\Checksum\Listener\LoadAdditionalScriptsListener; -use OCA\Files\Event\LoadAdditionalScriptsEvent; +use OCA\Checksum\Listener\LoadSidebarListener; +use OCA\Files\Event\LoadSidebar; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; @@ -40,8 +40,8 @@ class Application extends App implements IBootstrap { public function register(IRegistrationContext $context): void { // Load scripts for sidebar. $context->registerEventListener( - LoadAdditionalScriptsEvent::class, - LoadAdditionalScriptsListener::class + LoadSidebar::class, + LoadSidebarListener::class ); } diff --git a/lib/Listener/LoadAdditionalScriptsListener.php b/lib/Listener/LoadAdditionalScriptsListener.php deleted file mode 100644 index 9a28498..0000000 --- a/lib/Listener/LoadAdditionalScriptsListener.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * @author Richard Steinmetz - * - * 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 . - */ - -namespace OCA\Checksum\Listener; - -use OCA\Files\Event\LoadAdditionalScriptsEvent; -use OCP\EventDispatcher\Event; -use OCP\EventDispatcher\IEventListener; -use OCP\Util; - -class LoadAdditionalScriptsListener implements IEventListener { - - public function handle(Event $event): void { - if (!($event instanceof LoadAdditionalScriptsEvent)) { - return; - } - - Util::addScript('checksum', 'checksum.tabview'); - Util::addScript('checksum', 'checksum.plugin'); - } -} diff --git a/lib/Listener/LoadSidebarListener.php b/lib/Listener/LoadSidebarListener.php new file mode 100644 index 0000000..381d735 --- /dev/null +++ b/lib/Listener/LoadSidebarListener.php @@ -0,0 +1,41 @@ + + * + * @author Richard Steinmetz + * + * 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 . + */ + +namespace OCA\Checksum\Listener; + +use OCA\Checksum\AppInfo\Application; +use OCA\Files\Event\LoadSidebar; +use OCP\EventDispatcher\Event; +use OCP\EventDispatcher\IEventListener; +use OCP\Util; + +class LoadSidebarListener implements IEventListener { + + public function handle(Event $event): void { + if (!($event instanceof LoadSidebar)) { + return; + } + + Util::addScript(Application::APP_ID, 'checksum.main'); + } +} -- cgit v1.2.3