Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2020-01-16 17:28:03 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2020-02-05 22:09:20 +0300
commitf4d298cc03f6823d373f6b99f196a11737adf234 (patch)
tree2da7c2e91a37bf7267fbec1a2ef847e1b6fe8496 /apps/files/src
parent344ac9c6949c433083980942823c5fa93805760c (diff)
Allow to await the sidebar
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files/src')
-rw-r--r--apps/files/src/services/Sidebar.js10
-rw-r--r--apps/files/src/sidebar.js6
-rw-r--r--apps/files/src/views/Sidebar.vue69
3 files changed, 42 insertions, 43 deletions
diff --git a/apps/files/src/services/Sidebar.js b/apps/files/src/services/Sidebar.js
index 3a777419643..974914307bf 100644
--- a/apps/files/src/services/Sidebar.js
+++ b/apps/files/src/services/Sidebar.js
@@ -76,16 +76,6 @@ export default class Sidebar {
}
/**
- * Open the sidebar for the given file
- *
- * @memberof Sidebar
- * @param {string} path the file path to load
- */
- open(path) {
- this.#state.file = path
- }
-
- /**
* Close the sidebar
*
* @memberof Sidebar
diff --git a/apps/files/src/sidebar.js b/apps/files/src/sidebar.js
index 16e2035190f..f0f6fef6b9c 100644
--- a/apps/files/src/sidebar.js
+++ b/apps/files/src/sidebar.js
@@ -51,10 +51,10 @@ window.addEventListener('DOMContentLoaded', () => {
}
// Init vue app
- const AppSidebar = new Vue({
- // eslint-disable-next-line vue/match-component-file-name
+ const View = Vue.extend(SidebarView)
+ const AppSidebar = new View({
name: 'SidebarRoot',
- render: h => h(SidebarView),
})
AppSidebar.$mount('#app-sidebar')
+ window.OCA.Files.Sidebar.open = AppSidebar.open
})
diff --git a/apps/files/src/views/Sidebar.vue b/apps/files/src/views/Sidebar.vue
index e734f12c03b..b4f35f407cf 100644
--- a/apps/files/src/views/Sidebar.vue
+++ b/apps/files/src/views/Sidebar.vue
@@ -238,35 +238,6 @@ export default {
isSystemTagsEnabled() {
return OCA && 'SystemTags' in OCA
- }
- },
-
- watch: {
- // update the sidebar data
- async file(curr, prev) {
- this.resetData()
- if (curr && curr.trim() !== '') {
- try {
- this.fileInfo = await FileInfo(this.davPath)
- // adding this as fallback because other apps expect it
- this.fileInfo.dir = this.file.split('/').slice(0, -1).join('/')
-
- // DEPRECATED legacy views
- // TODO: remove
- this.views.forEach(view => {
- view.setFileInfo(this.fileInfo)
- })
-
- this.$nextTick(() => {
- if (this.$refs.sidebar) {
- this.$refs.sidebar.updateTabs()
- }
- })
- } catch (error) {
- this.error = t('files', 'Error while loading the file data')
- console.error('Error while loading the file data', error)
- }
- }
},
},
@@ -406,7 +377,45 @@ export default {
if (OCA.SystemTags && OCA.SystemTags.View) {
OCA.SystemTags.View.toggle()
}
- }
+ },
+
+ /**
+ * Open the sidebar for the given file
+ *
+ * @memberof Sidebar
+ * @param {string} path the file path to load
+ */
+ async open(path) {
+ // update current opened file
+ this.Sidebar.file = path
+
+ // reset previous data
+ this.resetData()
+ if (path && path.trim() !== '') {
+ try {
+ this.fileInfo = await FileInfo(this.davPath)
+ // adding this as fallback because other apps expect it
+ this.fileInfo.dir = this.file.split('/').slice(0, -1).join('/')
+
+ // DEPRECATED legacy views
+ // TODO: remove
+ this.views.forEach(view => {
+ view.setFileInfo(this.fileInfo)
+ })
+
+ this.$nextTick(() => {
+ if (this.$refs.sidebar) {
+ this.$refs.sidebar.updateTabs()
+ }
+ })
+ } catch (error) {
+ this.error = t('files', 'Error while loading the file data')
+ console.error('Error while loading the file data', error)
+
+ throw new Error(error)
+ }
+ }
+ },
},
}
</script>