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:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2020-02-05 23:08:32 +0300
committerGitHub <noreply@github.com>2020-02-05 23:08:32 +0300
commit9fd015353ce244fd7875bbccf3dca87a1a09b0ec (patch)
tree359bae7693cb9ef8d26de873e2e7c67058fb50e5 /apps/files/src
parent6e876fad65cd6d0e2f3020723bccaa7fea0d210c (diff)
parentb074be1b1d6ab6cef6a26684ce51a8ae6b1e9d23 (diff)
Merge pull request #19089 from nextcloud/backport/18929/enh/sidebar/promise
[stable18] 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 3a777419643..560db8862ec 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 e734f12c03b..7935ca5544b 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">
@@ -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)
- }
- }
},
},
@@ -280,10 +251,6 @@ export default {
canDisplay(tab) {
return tab.isEnabled(this.fileInfo)
},
- onClose() {
- this.resetData()
- OCA.Files.Sidebar.close()
- },
resetData() {
this.error = null
this.fileInfo = null
@@ -406,7 +373,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>