Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React to sidebar events from nextcloud-bus #913

Merged
merged 1 commit into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions js/viewer-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer-main.js.map

Large diffs are not rendered by default.

106 changes: 91 additions & 15 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@nextcloud/auth": "^1.3.0",
"@nextcloud/axios": "^1.6.0",
"@nextcloud/dialogs": "^3.1.2",
"@nextcloud/event-bus": "^2.0.0",
"@nextcloud/paths": "^2.0.0",
"@nextcloud/router": "^2.0.0",
"@nextcloud/vue": "^3.9.0",
Expand Down
52 changes: 27 additions & 25 deletions src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ import Vue from 'vue'
import axios from '@nextcloud/axios'
import '@nextcloud/dialogs/styles/toast.scss'
import { showError } from '@nextcloud/dialogs'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'

import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
import ActionLink from '@nextcloud/vue/dist/Components/ActionLink'
Expand Down Expand Up @@ -307,13 +308,6 @@ export default {
}
}
},

sidebarFile(file) {
// TODO: implement sidebar event bus
if (file === '') {
this.hideAppsSidebar()
}
},
},

beforeMount() {
Expand Down Expand Up @@ -344,10 +338,22 @@ export default {
}
},

mounted() {
// React to Files' Sidebar events.
subscribe('files:sidebar:opened', this.handleAppSidebarOpen)
subscribe('files:sidebar:closed', this.handleAppSidebarClose)
},

beforeDestroy() {
window.removeEventListener('resize', this.onResize)
},

destroyed() {
// Unsubscribe to Files' Sidebar events.
unsubscribe('files:sidebar:opened', this.handleAppSidebarOpen)
unsubscribe('files:sidebar:closed', this.handleAppSidebarClose)
},

methods: {
/**
* Open the view and display the clicked file
Expand All @@ -359,6 +365,10 @@ export default {
this.cancelRequestFile()
this.cancelRequestFolder()

if (OCA.Files.Sidebar) {
OCA.Files.Sidebar.setFullScreenMode(true)
}

// do not open the same file again
if (path === this.currentFile.path) {
return
Expand Down Expand Up @@ -637,6 +647,10 @@ export default {
// This will set file to ''
// which then triggers cleanup.
OCA.Viewer.close()

if (OCA.Files.Sidebar) {
OCA.Files.Sidebar.setFullScreenMode(false)
}
},

cleanup() {
Expand All @@ -645,7 +659,6 @@ export default {
this.currentModal = null
this.fileList = []
this.initiated = false
this.hideAppsSidebar()

// cancel requests
this.cancelRequestFile()
Expand Down Expand Up @@ -722,25 +735,22 @@ export default {
async showSidebar() {
// Open the sidebar sharing tab
// TODO: also hide figure, needs a proper method for it in server Sidebar
await OCA.Files.Sidebar.open(this.currentFile.filename)
setTimeout(this.showAppsSidebar, 100) // we have to wait the animation of the sidebar

if (OCA.Files.Sidebar) {
await OCA.Files.Sidebar.open(this.currentFile.filename)
}
},

showAppsSidebar() {
handleAppSidebarOpen() {
this.isSidebarShown = true
const sidebar = document.querySelector('aside.app-sidebar')
if (sidebar) {
sidebar.classList.add('app-sidebar--full')
this.sidebarWidth = sidebar.offsetWidth
}
},

hideAppsSidebar() {
handleAppSidebarClose() {
this.isSidebarShown = false
const sidebar = document.querySelector('aside.app-sidebar')
if (sidebar) {
sidebar.classList.remove('app-sidebar--full')
}
},

onResize(event) {
Expand Down Expand Up @@ -854,14 +864,6 @@ export default {
background-image: url('../assets/menu-sidebar-white.svg');
}

// Override vue components scss
.app-sidebar.app-sidebar--full {
position: fixed !important;
z-index: 2025 !important;
top: 0 !important;
height: 100% !important;
}

// put autocomplete over full sidebar
// TODO: remove when new sharing sidebar (18)
// is the min-version of viewer
Expand Down