Skip to content

Commit

Permalink
Emit sidebar events
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge committed May 31, 2021
1 parent b908db7 commit d5575a2
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 36 deletions.
4 changes: 2 additions & 2 deletions apps/files/js/dist/files-app-settings.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions apps/files/js/dist/personal-settings.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/files/js/dist/personal-settings.js.map

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions apps/files/js/dist/sidebar.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/files/js/dist/sidebar.js.map

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions apps/files/js/dist/templates.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/files/js/dist/templates.js.map

Large diffs are not rendered by default.

27 changes: 26 additions & 1 deletion apps/files/src/views/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
-->

<template>
<!--
For the 'handleClosed' event listener, we need to listen to the 'hook:destroyed' event instead of the 'closed' event.
This is necessary because with v-if, the 'closed' event is emitted after the destruction of AppSidebar, and all the event listeners are unbound and won't be triggered.
-->
<AppSidebar
v-if="file"
ref="sidebar"
Expand All @@ -29,7 +33,11 @@
@close="close"
@update:active="setActiveTab"
@update:starred="toggleStarred"
@[defaultActionListener].stop.prevent="onDefaultAction">
@[defaultActionListener].stop.prevent="onDefaultAction"
@opening="handleOpening"
@opened="handleOpened"
@closing="handleClosing"
@hook:destroyed="handleClosed">
<!-- TODO: create a standard to allow multiple elements here? -->
<template v-if="fileInfo" #description>
<LegacyView v-for="view in views"
Expand Down Expand Up @@ -78,6 +86,7 @@
import { encodePath } from '@nextcloud/paths'
import $ from 'jquery'
import axios from '@nextcloud/axios'
import { emit } from '@nextcloud/event-bus'
import AppSidebar from '@nextcloud/vue/dist/Components/AppSidebar'
import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
import EmptyContent from '@nextcloud/vue/dist/Components/EmptyContent'
Expand Down Expand Up @@ -422,6 +431,22 @@ export default {
this.Sidebar.file = ''
this.resetData()
},

/**
* Emit SideBar events.
*/
handleOpening() {
emit('files:sidebar:opening')
},
handleOpened() {
emit('files:sidebar:opened')
},
handleClosing() {
emit('files:sidebar:closing')
},
handleClosed() {
emit('files:sidebar:closed')
},
},
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@nextcloud/axios": "^1.6.0",
"@nextcloud/capabilities": "^1.0.4",
"@nextcloud/dialogs": "^3.1.2",
"@nextcloud/event-bus": "^1.2.0",
"@nextcloud/event-bus": "^1.3.0",
"@nextcloud/files": "^1.1.0",
"@nextcloud/initial-state": "^1.2.0",
"@nextcloud/l10n": "^1.4.1",
Expand Down

0 comments on commit d5575a2

Please sign in to comment.