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

Add option to disable sidebar #1782

Merged
merged 1 commit into from
Jul 6, 2023
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.

17 changes: 16 additions & 1 deletion src/services/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default class Viewer {
this._state.file = ''
this._state.fileInfo = null
this._state.files = []
this._state.enableSidebar = true
this._state.el = null
this._state.loadMore = () => ([])
this._state.onPrev = () => {}
Expand Down Expand Up @@ -116,6 +117,16 @@ export default class Viewer {
return this._state.files
}

/**
* Whether to enable the sidebar or not
*
* @memberof Viewer
* @return {boolean} whether to enable the sidebar or not
*/
get enableSidebar() {
return this._state.enableSidebar
}

/**
* Get the element to render the current file in
*
Expand Down Expand Up @@ -216,13 +227,14 @@ export default class Viewer {
* @param {?string} options.path path of the file to open
* @param {?Fileinfo} options.fileInfo file info of the file to open
* @param {Fileinfo[]} [options.list] the list of files as objects (fileinfo) format
* @param {boolean} options.enableSidebar whether to enable the sidebar or not
* @param {Function} options.loadMore callback for loading more files
* @param {boolean} options.canLoop can the viewer loop over the array
* @param {Function} options.onPrev callback when navigating back to previous file
* @param {Function} options.onNext callback when navigation forward to next file
* @param {Function} options.onClose callback when closing the viewer
*/
open({ path, fileInfo, list = [], loadMore = () => ([]), canLoop = true, onPrev = () => {}, onNext = () => {}, onClose = () => {} } = {}) {
open({ path, fileInfo, list = [], enableSidebar = true, loadMore = () => ([]), canLoop = true, onPrev = () => {}, onNext = () => {}, onClose = () => {} } = {}) {
if (typeof arguments[0] === 'string') {
throw new Error('Opening the viewer with a single string parameter is deprecated. Please use a destructuring object instead', `OCA.Viewer.open({ path: '${path}' })`)
}
Expand Down Expand Up @@ -250,6 +262,7 @@ export default class Viewer {
}
if (!this._state.el) {
this._state.files = list
this._state.enableSidebar = enableSidebar
this._state.loadMore = loadMore
this._state.onPrev = onPrev
this._state.onNext = onNext
Expand All @@ -266,6 +279,7 @@ export default class Viewer {
* @param {object} options Options for opening the viewer
* @param {string} options.path path of the file to open
* @param {object[]} [options.list] the list of files as objects (fileinfo) format
* @param {boolean} [options.enableSidebar] Whether to enable the sidebar or not
* @param {Function} options.loadMore callback for loading more files
* @param {boolean} options.canLoop can the viewer loop over the array
* @param {Function} options.onPrev callback when navigating back to previous file
Expand All @@ -286,6 +300,7 @@ export default class Viewer {
this._state.file = ''
this._state.fileInfo = null
this._state.files = []
this._state.enableSidebar = true
this._state.canLoop = true
this._state.loadMore = () => ([])
this._state.overrideHandlerId = null
Expand Down
7 changes: 5 additions & 2 deletions src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
</template>
{{ isFullscreenMode ? t('viewer', 'Exit full screen') : t('viewer', 'Full screen') }}
</NcActionButton>
<NcActionButton v-if="Sidebar && sidebarOpenFilePath && !isSidebarShown"
<NcActionButton v-if="enableSidebar && Sidebar && sidebarOpenFilePath && !isSidebarShown"
:close-after-click="true"
icon="icon-menu-sidebar"
@click="showSidebar">
Expand Down Expand Up @@ -277,6 +277,9 @@ export default {
files() {
return this.Viewer.files
},
enableSidebar() {
return this.Viewer.enableSidebar
},
el() {
return this.Viewer.el
},
Expand Down Expand Up @@ -950,7 +953,7 @@ export default {
// Open the sidebar sharing tab
// TODO: also hide figure, needs a proper method for it in server Sidebar

if (OCA?.Files?.Sidebar) {
if (this.enableSidebar && OCA?.Files?.Sidebar) {
await OCA.Files.Sidebar.open(this.sidebarOpenFilePath)
}
},
Expand Down
Loading