You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

files_sharing_tab.js 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /**
  2. * @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
  3. *
  4. * @author John Molakvoæ <skjnldsv@protonmail.com>
  5. * @author Julius Härtl <jus@bitgrid.net>
  6. *
  7. * @license AGPL-3.0-or-later
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. import Vue from 'vue'
  24. import { translate as t, translatePlural as n } from '@nextcloud/l10n'
  25. import SharingTab from './views/SharingTab.vue'
  26. import ShareSearch from './services/ShareSearch.js'
  27. import ExternalLinkActions from './services/ExternalLinkActions.js'
  28. import ExternalShareActions from './services/ExternalShareActions.js'
  29. import TabSections from './services/TabSections.js'
  30. // eslint-disable-next-line node/no-missing-import, import/no-unresolved
  31. import ShareVariant from '@mdi/svg/svg/share-variant.svg?raw'
  32. // Init Sharing Tab Service
  33. if (!window.OCA.Sharing) {
  34. window.OCA.Sharing = {}
  35. }
  36. Object.assign(window.OCA.Sharing, { ShareSearch: new ShareSearch() })
  37. Object.assign(window.OCA.Sharing, { ExternalLinkActions: new ExternalLinkActions() })
  38. Object.assign(window.OCA.Sharing, { ExternalShareActions: new ExternalShareActions() })
  39. Object.assign(window.OCA.Sharing, { ShareTabSections: new TabSections() })
  40. Vue.prototype.t = t
  41. Vue.prototype.n = n
  42. // Init Sharing tab component
  43. const View = Vue.extend(SharingTab)
  44. let TabInstance = null
  45. window.addEventListener('DOMContentLoaded', function() {
  46. if (OCA.Files && OCA.Files.Sidebar) {
  47. OCA.Files.Sidebar.registerTab(new OCA.Files.Sidebar.Tab({
  48. id: 'sharing',
  49. name: t('files_sharing', 'Sharing'),
  50. iconSvg: ShareVariant,
  51. async mount(el, fileInfo, context) {
  52. if (TabInstance) {
  53. TabInstance.$destroy()
  54. }
  55. TabInstance = new View({
  56. // Better integration with vue parent component
  57. parent: context,
  58. })
  59. // Only mount after we have all the info we need
  60. await TabInstance.update(fileInfo)
  61. TabInstance.$mount(el)
  62. },
  63. update(fileInfo) {
  64. TabInstance.update(fileInfo)
  65. },
  66. destroy() {
  67. TabInstance.$destroy()
  68. TabInstance = null
  69. },
  70. }))
  71. }
  72. })