Add option to hide namespace sidebar

This commit is contained in:
yonkov
2022-11-16 12:53:53 +01:00
committed by Jože Fortun
parent 5738761f89
commit 22562e325c
6 changed files with 71 additions and 11 deletions
+17
View File
@@ -178,14 +178,31 @@ export default {
*/
this.$root.$on('alert', ({ message, ...params }) => this.toast(message, params))
this.$root.$on('reminder.show', this.showReminder)
this.$root.$on('check-namespace-sidebar', this.checkNamespaceSidebar)
},
beforeDestroy () {
this.$root.$off('alert')
this.$root.$off('reminder.show', this.showReminder)
this.$root.$off('check-namespace-sidebar', this.checkNamespaceSidebar)
},
methods: {
checkNamespaceSidebar (showSidebar) {
const defaultDisabledRoutes = [
'namespaces',
'namespace.list',
'namespace.edit',
'namespace.create',
'namespace.clone',
'namespace.manage',
]
const namespaceRoutes = ['page', 'pages', 'page.record', 'page.record.create', 'page.record.edit']
this.disabledRoutes = [...defaultDisabledRoutes, ...(showSidebar ? [] : namespaceRoutes)]
},
removeToast (reminderID) {
const i = this.toasts.findIndex(r => r.reminderID === reminderID)
if (i > -1) {
@@ -22,6 +22,19 @@
>
{{ $t('visit') }}
</b-button>
<b-button
v-if="namespace.canManageNamespace"
:title="$t('configure')"
data-test-id="button-visit-admin-panel"
variant="primary"
class="d-flex align-items-center"
:to="{ name: 'admin.modules', params: { slug: namespace.slug } }"
style="margin-left:2px;"
>
<font-awesome-icon
:icon="['fas', 'cogs']"
/>
</b-button>
<namespace-translator
v-if="namespace"
:namespace="namespace"
@@ -213,7 +226,7 @@
<b-form-group
:label="$t('description.label')"
class="mb-0"
class="mb-3"
>
<b-input-group>
<b-form-textarea
@@ -232,6 +245,18 @@
</b-input-group-append>
</b-input-group>
</b-form-group>
<hr>
<b-form-group
:label="$t('sidebar.configure')"
>
<b-form-checkbox
v-model="namespace.meta.hideSidebar"
data-test-id="checkbox-show-sidebar"
>
{{ $t('sidebar.hide') }}
</b-form-checkbox>
</b-form-group>
</b-form>
<template
@@ -432,6 +457,7 @@ export default {
this.namespace.meta = {
subtitle: '',
description: '',
hideSidebar: false,
...this.namespace.meta,
}
@@ -550,6 +576,7 @@ export default {
this.namespace.meta = {
subtitle: '',
description: '',
hideSidebar: false,
...this.namespace.meta,
}
},
@@ -137,6 +137,8 @@ export default {
this.$store.dispatch('chart/clearSet')
this.$store.dispatch('page/clearSet')
this.$root.$emit('check-namespace-sidebar', !this.namespace.meta.hideSidebar)
// Preload all data we need.
Promise.all([
this.$store.dispatch('module/load', p)
+1 -1
View File
@@ -12,7 +12,7 @@ interface MetaAdmin {
interface Meta {
subtitle: string;
description: string;
hideSidebar: boolean;
// Temporary icon & logo URLs
// @todo rework this when we rework attachment management
icon: string;
+18 -8
View File
@@ -226,19 +226,29 @@ export default {
watch: {
'$route.name': {
immediate: true,
handler (name) {
// If sidebar should be disabled on route, close and unpin when navigating to route
if (this.disabledRoutes.includes(name)) {
this.isPinned = false
this.isExpanded = false
} else if(this.expandOnHover){
this.defaultSidebarAppearance()
}
handler () {
this.checkSidebar()
},
},
disabledRoutes: {
handler () {
this.checkSidebar()
},
}
},
methods: {
checkSidebar () {
// If sidebar should be disabled on route, close and unpin when navigating to route
if (this.disabledRoutes.includes(this.$route.name)) {
this.isPinned = false
this.isExpanded = false
} else if(this.expandOnHover){
this.defaultSidebarAppearance()
}
},
onHover: throttle(function (expand) {
if (!this.pinned && this.expandOnHover) {
setTimeout(() => {
@@ -51,7 +51,7 @@ title: Low Code Namespaces
tooltip:
translations: Namespace translations
visit: Visit namespace
configure: Configure namespace
manage:
title: Manage namespaces
@@ -69,3 +69,7 @@ manage:
name: Name
handle: Handle
last-change: Last change
sidebar:
configure: Namespace pages
hide: Hide sidebar on namespace public pages