From d88b93c919b6bf7db1853ec91a68996e07a75ba4 Mon Sep 17 00:00:00 2001 From: "John Molakvoæ (skjnldsv)" Date: Thu, 10 Oct 2019 11:26:15 +0200 Subject: Add LoadSidebar event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/files/composer/composer/autoload_classmap.php | 1 + apps/files/composer/composer/autoload_static.php | 1 + apps/files/js/filelist.js | 9 +++++-- apps/files/lib/Controller/ViewController.php | 4 +++ apps/files/lib/Event/LoadSidebar.php | 31 ++++++++++++++++++++++ 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 apps/files/lib/Event/LoadSidebar.php (limited to 'apps/files') diff --git a/apps/files/composer/composer/autoload_classmap.php b/apps/files/composer/composer/autoload_classmap.php index 3aa59c88b74..e241d34225c 100644 --- a/apps/files/composer/composer/autoload_classmap.php +++ b/apps/files/composer/composer/autoload_classmap.php @@ -33,6 +33,7 @@ return array( 'OCA\\Files\\Controller\\ApiController' => $baseDir . '/../lib/Controller/ApiController.php', 'OCA\\Files\\Controller\\ViewController' => $baseDir . '/../lib/Controller/ViewController.php', 'OCA\\Files\\Event\\LoadAdditionalScriptsEvent' => $baseDir . '/../lib/Event/LoadAdditionalScriptsEvent.php', + 'OCA\\Files\\Event\\LoadSidebar' => $baseDir . '/../lib/Event/LoadSidebar.php', 'OCA\\Files\\Helper' => $baseDir . '/../lib/Helper.php', 'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => $baseDir . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php', 'OCA\\Files\\Service\\TagService' => $baseDir . '/../lib/Service/TagService.php', diff --git a/apps/files/composer/composer/autoload_static.php b/apps/files/composer/composer/autoload_static.php index 07df2f173f8..c4944e7b980 100644 --- a/apps/files/composer/composer/autoload_static.php +++ b/apps/files/composer/composer/autoload_static.php @@ -48,6 +48,7 @@ class ComposerStaticInitFiles 'OCA\\Files\\Controller\\ApiController' => __DIR__ . '/..' . '/../lib/Controller/ApiController.php', 'OCA\\Files\\Controller\\ViewController' => __DIR__ . '/..' . '/../lib/Controller/ViewController.php', 'OCA\\Files\\Event\\LoadAdditionalScriptsEvent' => __DIR__ . '/..' . '/../lib/Event/LoadAdditionalScriptsEvent.php', + 'OCA\\Files\\Event\\LoadSidebar' => __DIR__ . '/..' . '/../lib/Event/LoadSidebar.php', 'OCA\\Files\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php', 'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => __DIR__ . '/..' . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php', 'OCA\\Files\\Service\\TagService' => __DIR__ . '/..' . '/../lib/Service/TagService.php', diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 8cca43d5749..0424ba2006b 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -636,9 +636,14 @@ fileName = '' } + // this is the old (terrible) way of getting the context. + // don't use it anywhere else. Just provide the full path + // of the file to the sidebar service + var tr = this.findFileEl(fileName) + var model = this.getModelForFile(tr) + var path = model.attributes.path + '/' + model.attributes.name + // open sidebar and set file - const dir = `${this.dirInfo.path}/${this.dirInfo.name}` - const path = `${dir}/${fileName}` OCA.Files.Sidebar.file = path.replace('//', '/') }, diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 518bbc1bf08..17caf06b480 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -9,6 +9,7 @@ * @author Thomas Müller * @author Vincent Petry * @author Felix Nüsse + * @author John Molakvoæ * * @license AGPL-3.0 * @@ -30,6 +31,7 @@ namespace OCA\Files\Controller; use OCA\Files\Activity\Helper; use OCA\Files\Event\LoadAdditionalScriptsEvent; +use OCA\Files\Event\LoadSidebar; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\ContentSecurityPolicy; use OCP\AppFramework\Http\RedirectResponse; @@ -269,6 +271,8 @@ class ViewController extends Controller { $event = new LoadAdditionalScriptsEvent(); $this->eventDispatcher->dispatch(LoadAdditionalScriptsEvent::class, $event); + $this->eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar()); + $params = []; $params['usedSpacePercent'] = (int) $storageInfo['relative']; $params['owner'] = $storageInfo['owner']; diff --git a/apps/files/lib/Event/LoadSidebar.php b/apps/files/lib/Event/LoadSidebar.php new file mode 100644 index 00000000000..8892bbe0f5b --- /dev/null +++ b/apps/files/lib/Event/LoadSidebar.php @@ -0,0 +1,31 @@ + + * + * @author Roeland Jago Douma + * + * @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 . + * + */ + +namespace OCA\Files\Event; + +use OCP\EventDispatcher\Event; + +class LoadSidebar extends Event { + +} -- cgit v1.2.3