Browse Source

Fix files app LoadSidebar event (#18213)

Fix files app LoadSidebar event
pull/18121/head
John Molakvoæ 6 years ago
committed by GitHub
parent
commit
bfb9ccec1f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      apps/files/appinfo/app.php
  2. 1
      apps/files/composer/composer/autoload_classmap.php
  3. 1
      apps/files/composer/composer/autoload_static.php
  4. 8
      apps/files/js/dist/sidebar.js
  5. 2
      apps/files/js/dist/sidebar.js.map
  6. 1
      apps/files/js/merged-index.json
  7. 5
      apps/files/lib/AppInfo/Application.php
  8. 42
      apps/files/lib/Listener/LoadSidebarListener.php
  9. 8
      apps/files/src/sidebar.js
  10. 37
      apps/files/src/views/Sidebar.vue
  11. 4
      apps/files_sharing/js/dist/files_sharing_tab.js
  12. 2
      apps/files_sharing/js/dist/files_sharing_tab.js.map
  13. 12
      apps/files_sharing/src/files_sharing_tab.js

3
apps/files/appinfo/app.php

@ -26,6 +26,9 @@
*/
use OC\Search\Provider\File;
use OCA\Files\AppInfo\Application;
$app = \OC::$server->query(Application::class);
// required for translation purpose
// t('Files')

1
apps/files/composer/composer/autoload_classmap.php

@ -44,6 +44,7 @@ return array(
'OCA\\Files\\Exception\\TransferOwnershipException' => $baseDir . '/../lib/Exception/TransferOwnershipException.php',
'OCA\\Files\\Helper' => $baseDir . '/../lib/Helper.php',
'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => $baseDir . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php',
'OCA\\Files\\Listener\\LoadSidebarListener' => $baseDir . '/../lib/Listener/LoadSidebarListener.php',
'OCA\\Files\\Migration\\Version11301Date20191113195931' => $baseDir . '/../lib/Migration/Version11301Date20191113195931.php',
'OCA\\Files\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php',
'OCA\\Files\\Service\\DirectEditingService' => $baseDir . '/../lib/Service/DirectEditingService.php',

1
apps/files/composer/composer/autoload_static.php

@ -59,6 +59,7 @@ class ComposerStaticInitFiles
'OCA\\Files\\Exception\\TransferOwnershipException' => __DIR__ . '/..' . '/../lib/Exception/TransferOwnershipException.php',
'OCA\\Files\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php',
'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => __DIR__ . '/..' . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php',
'OCA\\Files\\Listener\\LoadSidebarListener' => __DIR__ . '/..' . '/../lib/Listener/LoadSidebarListener.php',
'OCA\\Files\\Migration\\Version11301Date20191113195931' => __DIR__ . '/..' . '/../lib/Migration/Version11301Date20191113195931.php',
'OCA\\Files\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php',
'OCA\\Files\\Service\\DirectEditingService' => __DIR__ . '/..' . '/../lib/Service/DirectEditingService.php',

8
apps/files/js/dist/sidebar.js
File diff suppressed because it is too large
View File

2
apps/files/js/dist/sidebar.js.map
File diff suppressed because it is too large
View File

1
apps/files/js/merged-index.json

@ -1,5 +1,4 @@
[
"dist/sidebar.js",
"app.js",
"breadcrumb.js",
"detailfileinfoview.js",

5
apps/files/lib/AppInfo/Application.php

@ -27,14 +27,14 @@
namespace OCA\Files\AppInfo;
use OCA\Files\Activity\Helper;
use OCA\Files\Capabilities;
use OCA\Files\Collaboration\Resources\Listener;
use OCA\Files\Collaboration\Resources\ResourceProvider;
use OCA\Files\Controller\ApiController;
use OCA\Files\Controller\ViewController;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Files\Event\LoadSidebar;
use OCA\Files\Listener\LegacyLoadAdditionalScriptsAdapter;
use OCA\Files\Listener\LoadSidebarListener;
use OCA\Files\Notification\Notifier;
use OCA\Files\Service\TagService;
use OCP\AppFramework\App;
@ -97,6 +97,7 @@ class Application extends App {
/** @var IEventDispatcher $dispatcher */
$dispatcher = $container->query(IEventDispatcher::class);
$dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LegacyLoadAdditionalScriptsAdapter::class);
$dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class);
/** @var \OCP\Notification\IManager $notifications */
$notifications = $container->query(\OCP\Notification\IManager::class);

42
apps/files/lib/Listener/LoadSidebarListener.php

@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019, John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @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\Listener;
use OCA\Files\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, 'dist/sidebar');
}
}

8
apps/files/src/sidebar.js

@ -31,11 +31,13 @@ Vue.use(VueClipboard)
Vue.prototype.t = t
window.addEventListener('DOMContentLoaded', () => {
// Init Sidebar Service
if (window.OCA && window.OCA.Files) {
Object.assign(window.OCA.Files, { Sidebar: new Sidebar() })
Object.assign(window.OCA.Files.Sidebar, { Tab })
if (!window.OCA.Files) {
window.OCA.Files = {}
}
Object.assign(window.OCA.Files, { Sidebar: new Sidebar() })
Object.assign(window.OCA.Files.Sidebar, { Tab })
// Make sure we have a proper layout
if (document.getElementById('content')) {

37
apps/files/src/views/Sidebar.vue

@ -199,6 +199,8 @@ export default {
defaultAction() {
return this.fileInfo
&& OCA.Files && OCA.Files.App && OCA.Files.App.fileList
&& OCA.Files.App.fileList.fileActions
&& OCA.Files.App.fileList.fileActions.getDefaultFileAction
&& OCA.Files.App.fileList
.fileActions.getDefaultFileAction(this.fileInfo.mimetype, this.fileInfo.type, OC.PERMISSION_READ)
@ -239,7 +241,7 @@ export default {
})
} catch (error) {
this.error = t('files', 'Error while loading the file data')
console.error('Error while loading the file data')
console.error('Error while loading the file data', error)
}
}
}
@ -272,11 +274,42 @@ export default {
}
})
},
getPreviewIfAny(fileInfo) {
if (fileInfo.hasPreview) {
return OC.generateUrl(`/core/preview?fileId=${fileInfo.id}&x=${screen.width}&y=${screen.height}&a=true`)
}
return OCA.Files.App.fileList._getIconUrl(fileInfo)
return this.getIconUrl(fileInfo)
},
/**
* Copied from https://github.com/nextcloud/server/blob/16e0887ec63591113ee3f476e0c5129e20180cde/apps/files/js/filelist.js#L1377
* TODO: We also need this as a standalone library
*
* @param {Object} fileInfo the fileinfo
* @returns {string} Url to the icon for mimeType
*/
getIconUrl(fileInfo) {
var mimeType = fileInfo.mimetype || 'application/octet-stream'
if (mimeType === 'httpd/unix-directory') {
// use default folder icon
if (fileInfo.mountType === 'shared' || fileInfo.mountType === 'shared-root') {
return OC.MimeType.getIconUrl('dir-shared')
} else if (fileInfo.mountType === 'external-root') {
return OC.MimeType.getIconUrl('dir-external')
} else if (fileInfo.mountType !== undefined && fileInfo.mountType !== '') {
return OC.MimeType.getIconUrl('dir-' + fileInfo.mountType)
} else if (fileInfo.shareTypes && (
fileInfo.shareTypes.indexOf(OC.Share.SHARE_TYPE_LINK) > -1
|| fileInfo.shareTypes.indexOf(OC.Share.SHARE_TYPE_EMAIL) > -1)
) {
return OC.MimeType.getIconUrl('dir-public')
} else if (fileInfo.shareTypes && fileInfo.shareTypes.length > 0) {
return OC.MimeType.getIconUrl('dir-shared')
}
return OC.MimeType.getIconUrl('dir')
}
return OC.MimeType.getIconUrl(mimeType)
},
tabComponent(tab) {

4
apps/files_sharing/js/dist/files_sharing_tab.js
File diff suppressed because it is too large
View File

2
apps/files_sharing/js/dist/files_sharing_tab.js.map
File diff suppressed because it is too large
View File

12
apps/files_sharing/src/files_sharing_tab.js

@ -26,14 +26,12 @@ import ExternalLinkActions from './services/ExternalLinkActions'
import TabSections from './services/TabSections'
if (window.OCA && window.OCA.Sharing) {
Object.assign(window.OCA.Sharing, { ShareSearch: new ShareSearch() })
// Init Sharing Tab Service
if (!window.OCA.Sharing) {
window.OCA.Sharing = {}
}
if (window.OCA && window.OCA.Sharing) {
Object.assign(window.OCA.Sharing, { ExternalLinkActions: new ExternalLinkActions() })
}
Object.assign(window.OCA.Sharing, { ShareSearch: new ShareSearch() })
Object.assign(window.OCA.Sharing, { ExternalLinkActions: new ExternalLinkActions() })
Object.assign(window.OCA.Sharing, { ShareTabSections: new TabSections() })
window.addEventListener('DOMContentLoaded', () => {

Loading…
Cancel
Save