aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/src
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2020-01-22 14:44:32 +0100
committerGitHub <noreply@github.com>2020-01-22 14:44:32 +0100
commita6a224e7a14faa8814e9ce783f626666828b96db (patch)
tree8b0a2c731559fb3262e82b50d8b4f9929eea4465 /apps/files/src
parentb3ea5ca3d41c12eb7bb8198b95ef54c65f2072af (diff)
parent2e52bdda210dbce59a65854792e83ee8fbd182b2 (diff)
downloadnextcloud-server-a6a224e7a14faa8814e9ce783f626666828b96db.tar.gz
nextcloud-server-a6a224e7a14faa8814e9ce783f626666828b96db.zip
Merge pull request #18929 from nextcloud/enh/sidebar/promise
Allow to await the sidebar
Diffstat (limited to 'apps/files/src')
-rw-r--r--apps/files/src/services/Sidebar.js19
-rw-r--r--apps/files/src/sidebar.js7
-rw-r--r--apps/files/src/views/Sidebar.vue84
3 files changed, 53 insertions, 57 deletions
diff --git a/apps/files/src/services/Sidebar.js b/apps/files/src/services/Sidebar.js
index f2a1f8f2124..42243b9de82 100644
--- a/apps/files/src/services/Sidebar.js
+++ b/apps/files/src/services/Sidebar.js
@@ -76,25 +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
- */
- close() {
- this.#state.file = ''
- }
-
- /**
* Return current opened file
*
* @memberof Sidebar
diff --git a/apps/files/src/sidebar.js b/apps/files/src/sidebar.js
index 16e2035190f..258f2313657 100644
--- a/apps/files/src/sidebar.js
+++ b/apps/files/src/sidebar.js
@@ -51,10 +51,11 @@ 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
+ window.OCA.Files.Sidebar.close = AppSidebar.close
})
diff --git a/apps/files/src/views/Sidebar.vue b/apps/files/src/views/Sidebar.vue
index 81c4e728380..5f07138ea80 100644
--- a/apps/files/src/views/Sidebar.vue
+++ b/apps/files/src/views/Sidebar.vue
@@ -26,7 +26,7 @@
ref="sidebar"
v-bind="appSidebar"
:force-menu="true"
- @close="onClose"
+ @close="close"
@update:active="setActiveTab"
@update:starred="toggleStarred"
@[defaultActionListener].stop.prevent="onDefaultAction">
@@ -237,35 +237,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)
- }
- }
},
},
@@ -279,10 +250,6 @@ export default {
canDisplay(tab) {
return tab.isEnabled(this.fileInfo)
},
- onClose() {
- this.resetData()
- OCA.Files.Sidebar.close()
- },
resetData() {
this.error = null
this.fileInfo = null
@@ -405,7 +372,54 @@ export default {
if (OCA.SystemTags && OCA.SystemTags.View) {
OCA.SystemTags.View.toggle()
}
- }
+ },
+
+ /**
+ * Open the sidebar for the given file
+ *
+ * @param {string} path the file path to load
+ * @returns {Promise}
+ * @throws {Error} loading failure
+ */
+ 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)
+ }
+ }
+ },
+
+ /**
+ * Close the sidebar
+ */
+ close() {
+ this.Sidebar.file = ''
+ this.resetData()
+ },
},
}
</script>