From 4de6e807714560329e55c3ed09d6ff029a1eb6df Mon Sep 17 00:00:00 2001 From: "John Molakvoæ (skjnldsv)" Date: Sun, 4 Oct 2020 13:49:57 +0200 Subject: Upgrade lifecycle and vue parent context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) Signed-off-by: npmbuildbot[bot] --- apps/files/src/components/SidebarTab.vue | 56 +++++++++++++++++----- apps/files/src/models/Tab.js | 36 ++++++++++---- apps/files/src/sidebar.js | 2 + apps/files/src/views/Sidebar.vue | 81 +++++++++++++------------------- 4 files changed, 106 insertions(+), 69 deletions(-) (limited to 'apps/files/src') diff --git a/apps/files/src/components/SidebarTab.vue b/apps/files/src/components/SidebarTab.vue index ecf04e9c9b3..1fc93486bc0 100644 --- a/apps/files/src/components/SidebarTab.vue +++ b/apps/files/src/components/SidebarTab.vue @@ -23,21 +23,28 @@ diff --git a/apps/files/src/models/Tab.js b/apps/files/src/models/Tab.js index 753b9c9c282..2c587e5f70a 100644 --- a/apps/files/src/models/Tab.js +++ b/apps/files/src/models/Tab.js @@ -25,7 +25,9 @@ export default class Tab { #id #name #icon - #render + #mount + #update + #destroy #enabled /** @@ -35,10 +37,12 @@ export default class Tab { * @param {string} options.id the unique id of this tab * @param {string} options.name the translated tab name * @param {string} options.icon the vue component - * @param {Function} options.render function to render the tab + * @param {Function} options.mount function to mount the tab + * @param {Function} options.update function to update the tab + * @param {Function} options.destroy function to destroy the tab * @param {Function} [options.enabled] define conditions whether this tab is active. Must returns a boolean */ - constructor({ id, name, icon, render, enabled }) { + constructor({ id, name, icon, mount, update, destroy, enabled } = {}) { if (enabled === undefined) { enabled = () => true } @@ -53,8 +57,14 @@ export default class Tab { if (typeof icon !== 'string' || icon.trim() === '') { throw new Error('The icon argument is not a valid string') } - if (typeof render !== 'function') { - throw new Error('The render argument should be a function') + if (typeof mount !== 'function') { + throw new Error('The mount argument should be a function') + } + if (typeof update !== 'function') { + throw new Error('The update argument should be a function') + } + if (typeof destroy !== 'function') { + throw new Error('The destroy argument should be a function') } if (typeof enabled !== 'function') { throw new Error('The enabled argument should be a function') @@ -63,7 +73,9 @@ export default class Tab { this.#id = id this.#name = name this.#icon = icon - this.#render = render + this.#mount = mount + this.#update = update + this.#destroy = destroy this.#enabled = enabled } @@ -80,8 +92,16 @@ export default class Tab { return this.#icon } - get render() { - return this.#render + get mount() { + return this.#mount + } + + get update() { + return this.#update + } + + get destroy() { + return this.#destroy } get enabled() { diff --git a/apps/files/src/sidebar.js b/apps/files/src/sidebar.js index 508093465d4..54293bd24c8 100644 --- a/apps/files/src/sidebar.js +++ b/apps/files/src/sidebar.js @@ -21,6 +21,8 @@ */ import Vue from 'vue' +import { translate as t } from '@nextcloud/l10n' + import SidebarView from './views/Sidebar.vue' import Sidebar from './services/Sidebar' import Tab from './models/Tab' diff --git a/apps/files/src/views/Sidebar.vue b/apps/files/src/views/Sidebar.vue index 6fa5c35dca2..664bc6f4075 100644 --- a/apps/files/src/views/Sidebar.vue +++ b/apps/files/src/views/Sidebar.vue @@ -52,33 +52,38 @@ -
-
-

{{ error }}

-
+ + {{ error }} + - -