gotoplugin.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-License-Identifier: AGPL-3.0-or-later
  4. */
  5. (function (OCA) {
  6. OCA.Files = OCA.Files || {};
  7. /**
  8. * @namespace OCA.Files.GotoPlugin
  9. *
  10. */
  11. OCA.Files.GotoPlugin = {
  12. name: 'Goto',
  13. disallowedLists: [
  14. 'files',
  15. 'trashbin'
  16. ],
  17. attach: function (fileList) {
  18. if (this.disallowedLists.indexOf(fileList.id) !== -1) {
  19. return;
  20. }
  21. // lists where the "Open" default action is disabled should
  22. // also have the goto action disabled
  23. if (fileList._defaultFileActionsDisabled) {
  24. return
  25. }
  26. var fileActions = fileList.fileActions;
  27. fileActions.registerAction({
  28. name: 'Goto',
  29. displayName: t('files', 'View in folder'),
  30. mime: 'all',
  31. permissions: OC.PERMISSION_ALL,
  32. iconClass: 'icon-goto nav-icon-extstoragemounts',
  33. type: OCA.Files.FileActions.TYPE_DROPDOWN,
  34. actionHandler: function (fileName, context) {
  35. var fileModel = context.fileInfoModel;
  36. OCA.Files.Sidebar.close();
  37. OCA.Files.App.setActiveView('files', { silent: true });
  38. OCA.Files.App.fileList.changeDirectory(fileModel.get('path'), true, true).then(function() {
  39. OCA.Files.App.fileList.scrollTo(fileModel.get('name'));
  40. });
  41. },
  42. render: function (actionSpec, isDefault, context) {
  43. return fileActions._defaultRenderAction.call(fileActions, actionSpec, isDefault, context)
  44. .removeClass('permanent');
  45. }
  46. });
  47. }
  48. };
  49. })(OCA);
  50. OC.Plugins.register('OCA.Files.FileList', OCA.Files.GotoPlugin);