]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add LoadSidebar event
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Thu, 10 Oct 2019 09:26:15 +0000 (11:26 +0200)
committerDaniel Calviño Sánchez <danxuliu@gmail.com>
Tue, 29 Oct 2019 12:20:07 +0000 (13:20 +0100)
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
apps/files/composer/composer/autoload_classmap.php
apps/files/composer/composer/autoload_static.php
apps/files/js/filelist.js
apps/files/lib/Controller/ViewController.php
apps/files/lib/Event/LoadSidebar.php [new file with mode: 0644]
apps/files_sharing/src/share.js

index 3aa59c88b745ac05f643454c20cc81521bc9d269..e241d34225cc8f7182d1dc26f93beb8d721da19b 100644 (file)
@@ -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',
index 07df2f173f842918d1a737dd7416e31337dcdfec..c4944e7b980dc7fc310335f75a1bbc0606d6bf2e 100644 (file)
@@ -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',
index 8cca43d57493bbd9f5678e0145b7e382ee8a58a2..0424ba2006b02bec5225528b257f63fd7722d3be 100644 (file)
                                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('//', '/')
                },
 
index 518bbc1bf087fc257ae737d1a37aff9f3961b92d..17caf06b480a48c408496080cc4cbec037c6cec0 100644 (file)
@@ -9,6 +9,7 @@
  * @author Thomas Müller <thomas.mueller@tmit.eu>
  * @author Vincent Petry <pvince81@owncloud.com>
  * @author Felix Nüsse <felix.nuesse@t-online.de>
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
  *
  * @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 (file)
index 0000000..8892bbe
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @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/>.
+ *
+ */
+
+namespace OCA\Files\Event;
+
+use OCP\EventDispatcher\Event;
+
+class LoadSidebar extends Event {
+
+}
index 46e46e375529c1ab188fbdef259addf691474d95..c7ef39897d077f501b1bbbd2718da053969d2f01 100644 (file)
                                }
                        })
 
+                       // register share breadcrumbs component
                        var shareTab = new OCA.Sharing.ShareTabView('sharing', {order: -20})
-                       // // detect changes and change the matching list entry
-                       // shareTab.on('sharesChanged', function(shareModel) {
-                       //      var fileInfoModel = shareModel.fileInfoModel
-                       //      var $tr = fileList.findFileEl(fileInfoModel.get('name'))
-
-                       //      // We count email shares as link share
-                       //      var hasLinkShares = shareModel.hasLinkShares();
-                       //      shareModel.get('shares').forEach(function (share) {
-                       //              if (share.share_type === OC.Share.SHARE_TYPE_EMAIL) {
-                       //                      hasLinkShares = true;
-                       //              }
-                       //      })
-
-                       //      OCA.Sharing.Util._updateFileListDataAttributes(fileList, $tr, shareModel);
-                       //      if (!OCA.Sharing.Util._updateFileActionIcon($tr, shareModel.hasUserShares(), hasLinkShares)) {
-                       //              // remove icon, if applicable
-                       //              OC.Share.markFileAsShared($tr, false, false)
-                       //      }
-
-                       //      // FIXME: this is too convoluted. We need to get rid of the above updates
-                       //      // and only ever update the model and let the events take care of rerendering
-                       //      fileInfoModel.set({
-                       //              shareTypes: shareModel.getShareTypes(),
-                       //              // in case markFileAsShared decided to change the icon,
-                       //              // we need to modify the model
-                       //              // (FIXME: yes, this is hacky)
-                       //              icon: $tr.attr('data-icon')
-                       //      })
-                       // })
-                       // fileList.registerTabView(shareTab)
 
                        var breadCrumbSharingDetailView = new OCA.Sharing.ShareBreadCrumbView({ shareTab: shareTab })
                        fileList.registerBreadCrumbDetailView(breadCrumbSharingDetailView)