Use function to open a sidebar file

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2019-10-30 11:58:14 +01:00
parent d9204f61ea
commit 16e0887ec6
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
6 changed files with 29 additions and 21 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -708,7 +708,7 @@
// close sidebar on delete // close sidebar on delete
const path = context.dir + '/' + fileName const path = context.dir + '/' + fileName
if (OCA.Files.Sidebar && OCA.Files.Sidebar.file === path) { if (OCA.Files.Sidebar && OCA.Files.Sidebar.file === path) {
OCA.Files.Sidebar.file = undefined OCA.Files.Sidebar.close()
} }
} }
}); });

View File

@ -613,7 +613,7 @@
console.warn('showDetailsView is deprecated! Use OCA.Files.Sidebar.activeTab. It will be removed in nextcloud 20.'); console.warn('showDetailsView is deprecated! Use OCA.Files.Sidebar.activeTab. It will be removed in nextcloud 20.');
this._updateDetailsView(fileName); this._updateDetailsView(fileName);
if (tabId) { if (tabId) {
OCA.Files.Sidebar.activeTab = tabId; OCA.Files.Sidebar.setActiveTab(tabId);
} }
}, },
@ -630,7 +630,7 @@
} }
if (!fileName) { if (!fileName) {
OCA.Files.Sidebar.file = null OCA.Files.Sidebar.close()
return return
} else if (typeof fileName !== 'string') { } else if (typeof fileName !== 'string') {
fileName = '' fileName = ''
@ -644,7 +644,7 @@
var path = model.attributes.path + '/' + model.attributes.name var path = model.attributes.path + '/' + model.attributes.name
// open sidebar and set file // open sidebar and set file
OCA.Files.Sidebar.file = path.replace('//', '/') OCA.Files.Sidebar.open(path.replace('//', '/'))
}, },
/** /**

View File

@ -49,11 +49,10 @@ export default class Sidebar {
} }
/** /**
* @memberof Sidebar
* Register a new tab view * Register a new tab view
* *
* @param {Object} tab a new unregistered tab
* @memberof Sidebar * @memberof Sidebar
* @param {Object} tab a new unregistered tab
* @returns {Boolean} * @returns {Boolean}
*/ */
registerTab(tab) { registerTab(tab) {
@ -77,32 +76,41 @@ export default class Sidebar {
} }
/** /**
* Set the current sidebar file data * Open the sidebar for the given file
* *
* @param {string} path the file path to load
* @memberof Sidebar * @memberof Sidebar
* @param {string} path the file path to load
*/ */
set file(path) { open(path) {
this.#state.file = path this.#state.file = path
} }
/** /**
* Set the current sidebar file data * Close the sidebar
* *
* @returns {String} the current opened file
* @memberof Sidebar * @memberof Sidebar
*/ */
close() {
this.#state.file = ''
}
/**
* Return current opened file
*
* @memberof Sidebar
* @returns {String} the current opened file
*/
get file() { get file() {
return this.#state.file return this.#state.file
} }
/** /**
* Set the current sidebar tab * Set the current visible sidebar tab
* *
* @param {string} id the tab unique id
* @memberof Sidebar * @memberof Sidebar
* @param {string} id the tab unique id
*/ */
set activeTab(id) { setActiveTab(id) {
this.#state.activeTab = id this.#state.activeTab = id
} }

View File

@ -261,7 +261,7 @@ export default {
}, },
onClose() { onClose() {
this.resetData() this.resetData()
OCA.Files.Sidebar.file = '' OCA.Files.Sidebar.close()
}, },
resetData() { resetData() {
this.error = null this.error = null
@ -297,7 +297,7 @@ export default {
* @param {string} id tab unique id * @param {string} id tab unique id
*/ */
setActiveTab(id) { setActiveTab(id) {
OCA.Files.Sidebar.activeTab = id OCA.Files.Sidebar.setActiveTab(id)
}, },
/** /**