|
| 1 | +/** |
| 2 | + * @copyright 2022 Carl Schwan <[email protected]> |
| 3 | + * @license AGPL-3.0-or-later |
| 4 | + * |
| 5 | + * This program is free software: you can redistribute it and/or modify |
| 6 | + * it under the terms of the GNU Affero General Public License as |
| 7 | + * published by the Free Software Foundation, either version 3 of the |
| 8 | + * License, or (at your option) any later version. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU Affero General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU Affero General Public License |
| 16 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | + * |
| 18 | + */ |
| 19 | + |
| 20 | +import Vue from 'vue' |
| 21 | +import { translate as t, translatePlural as n } from '@nextcloud/l10n' |
| 22 | + |
| 23 | +import VersionTab from './views/VersionTab.vue' |
| 24 | +import VTooltip from 'v-tooltip' |
| 25 | + |
| 26 | +Vue.prototype.t = t |
| 27 | +Vue.prototype.n = n |
| 28 | + |
| 29 | +Vue.use(VTooltip) |
| 30 | + |
| 31 | +// Init Sharing tab component |
| 32 | +const View = Vue.extend(VersionTab) |
| 33 | +let TabInstance = null |
| 34 | + |
| 35 | +window.addEventListener('DOMContentLoaded', function() { |
| 36 | + if (OCA.Files && OCA.Files.Sidebar) { |
| 37 | + OCA.Files.Sidebar.registerTab(new OCA.Files.Sidebar.Tab({ |
| 38 | + id: 'version_vue', |
| 39 | + name: t('files_versions', 'Version'), |
| 40 | + icon: 'icon-history', |
| 41 | + |
| 42 | + async mount(el, fileInfo, context) { |
| 43 | + if (TabInstance) { |
| 44 | + TabInstance.$destroy() |
| 45 | + } |
| 46 | + TabInstance = new View({ |
| 47 | + // Better integration with vue parent component |
| 48 | + parent: context, |
| 49 | + }) |
| 50 | + // Only mount after we have all the info we need |
| 51 | + await TabInstance.update(fileInfo) |
| 52 | + TabInstance.$mount(el) |
| 53 | + }, |
| 54 | + update(fileInfo) { |
| 55 | + TabInstance.update(fileInfo) |
| 56 | + }, |
| 57 | + destroy() { |
| 58 | + TabInstance.$destroy() |
| 59 | + TabInstance = null |
| 60 | + }, |
| 61 | + })) |
| 62 | + } |
| 63 | +}) |
0 commit comments