commit
79b9be7ebf
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -3650,8 +3650,9 @@
|
||||||
registerTabView: function(tabView) {
|
registerTabView: function(tabView) {
|
||||||
console.warn('registerTabView is deprecated! It will be removed in nextcloud 20.');
|
console.warn('registerTabView is deprecated! It will be removed in nextcloud 20.');
|
||||||
const name = tabView.getLabel()
|
const name = tabView.getLabel()
|
||||||
|
const enabled = tabView.canDisplay || undefined
|
||||||
if (name) {
|
if (name) {
|
||||||
OCA.Files.Sidebar.registerTab(new OCA.Files.Sidebar.Tab(name, tabView, true))
|
OCA.Files.Sidebar.registerTab(new OCA.Files.Sidebar.Tab(name, tabView, enabled, true))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -22,20 +22,27 @@
|
||||||
|
|
||||||
export default class Tab {
|
export default class Tab {
|
||||||
|
|
||||||
#component;
|
#component
|
||||||
#legacy;
|
#legacy
|
||||||
#name;
|
#name
|
||||||
|
#enabled
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new tab instance
|
* Create a new tab instance
|
||||||
*
|
*
|
||||||
* @param {string} name the name of this tab
|
* @param {string} name the name of this tab
|
||||||
* @param {Object} component the vue component
|
* @param {Object} component the vue component
|
||||||
|
* @param {Function} [enabled] function that returns if the tab should be shown or not
|
||||||
* @param {boolean} [legacy] is this a legacy tab
|
* @param {boolean} [legacy] is this a legacy tab
|
||||||
*/
|
*/
|
||||||
constructor(name, component, legacy) {
|
constructor(name, component, enabled = () => true, legacy) {
|
||||||
|
if (typeof enabled !== 'function') {
|
||||||
|
throw new Error('The enabled argument should be a function')
|
||||||
|
}
|
||||||
|
|
||||||
this.#name = name
|
this.#name = name
|
||||||
this.#component = component
|
this.#component = component
|
||||||
|
this.#enabled = enabled
|
||||||
this.#legacy = legacy === true
|
this.#legacy = legacy === true
|
||||||
|
|
||||||
if (this.#legacy) {
|
if (this.#legacy) {
|
||||||
|
@ -52,6 +59,10 @@ export default class Tab {
|
||||||
return this.#component
|
return this.#component
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isEnabled() {
|
||||||
|
return this.#enabled
|
||||||
|
}
|
||||||
|
|
||||||
get isLegacyTab() {
|
get isLegacyTab() {
|
||||||
return this.#legacy === true
|
return this.#legacy === true
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,11 +255,7 @@ export default {
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
canDisplay(tab) {
|
canDisplay(tab) {
|
||||||
if (tab.isLegacyTab) {
|
return tab.isEnabled(this.fileInfo)
|
||||||
return this.fileInfo && tab.component.canDisplay && tab.component.canDisplay(this.fileInfo)
|
|
||||||
}
|
|
||||||
// if the tab does not have an enabled method, we assume it's always available
|
|
||||||
return tab.enabled ? tab.enabled(this.fileInfo) : true
|
|
||||||
},
|
},
|
||||||
onClose() {
|
onClose() {
|
||||||
this.resetData()
|
this.resetData()
|
||||||
|
|
Loading…
Reference in New Issue