mirror of
https://github.com/Lissy93/dashy.git
synced 2026-01-21 23:31:46 +01:00
Add hideFromWorkspace support at section level in ConfigSchema and SideBar component
Co-authored-by: JDB321Sailor <212125521+JDB321Sailor@users.noreply.github.com>
This commit is contained in:
parent
e072a2fffc
commit
4bde34c3b1
3 changed files with 24 additions and 5 deletions
|
|
@ -318,6 +318,7 @@ For more info, see the **[Authentication Docs](/docs/authentication.md)**
|
|||
**`hideForGuests`** | `boolean` | _Optional_ | Current section will be visible for logged in users, but not for guests (see `appConfig.enableGuestAccess`). Defaults to `false`
|
||||
**`hideForKeycloakUsers`** | `object` | _Optional_ | Current section will be visible to all keycloak users, except for those configured via these groups and roles. See `hideForKeycloakUsers`
|
||||
**`showForKeycloakUsers`** | `object` | _Optional_ | Current section will be hidden from all keycloak users, except for those configured via these groups and roles. See `showForKeycloakUsers`
|
||||
**`hideFromWorkspace`** | `boolean` | _Optional_ | Current section will be visible in the default view but not in the Workspace view sidebar. Defaults to `false`
|
||||
|
||||
**[⬆️ Back to Top](#configuring)**
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<nav class="side-bar">
|
||||
<div v-for="(section, index) in sections" :key="index" class="side-bar-section">
|
||||
<div v-for="(section, index) in filteredSections" :key="index" class="side-bar-section">
|
||||
<!-- Section button -->
|
||||
<div @click="openSection(index)" class="side-bar-item-container">
|
||||
<SideBarItem
|
||||
|
|
@ -46,9 +46,19 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
isOpen: new Array(this.sections.length).fill(false),
|
||||
isOpen: [],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
/* Return a list of sections that should be visible in workspace */
|
||||
filteredSections() {
|
||||
if (!this.sections) return [];
|
||||
return this.sections.filter((section) => {
|
||||
const hideFromWorkspace = section.displayData?.hideFromWorkspace || false;
|
||||
return !hideFromWorkspace;
|
||||
});
|
||||
},
|
||||
},
|
||||
components: {
|
||||
SideBarItem,
|
||||
SideBarSection,
|
||||
|
|
@ -59,7 +69,7 @@ export default {
|
|||
/* Toggles the section clicked, and closes all other sections */
|
||||
openSection(index) {
|
||||
this.isOpen = this.isOpen.map((val, ind) => (ind !== index ? false : !val));
|
||||
if (this.sections[index].widgets) this.$emit('launch-widget', this.sections[index].widgets);
|
||||
if (this.filteredSections[index].widgets) this.$emit('launch-widget', this.filteredSections[index].widgets);
|
||||
},
|
||||
/* When item clicked, emit a launch event */
|
||||
launchApp(options) {
|
||||
|
|
@ -70,7 +80,7 @@ export default {
|
|||
if (!this.initUrl) return;
|
||||
const process = (url) => (url ? url.replace(/[^\w\s]/gi, '').toLowerCase() : undefined);
|
||||
const compare = (item) => (process(item.url) === process(this.initUrl));
|
||||
this.sections.forEach((section, secIndx) => {
|
||||
this.filteredSections.forEach((section, secIndx) => {
|
||||
if (!section.items) return; // Cancel if no items
|
||||
if (section.items.findIndex(compare) !== -1) this.openSection(secIndx);
|
||||
section.items.forEach((item) => { // Do the same for sub-items, if set
|
||||
|
|
@ -92,7 +102,9 @@ export default {
|
|||
},
|
||||
},
|
||||
mounted() {
|
||||
if (this.sections.length === 1) { // If only 1 section, go ahead and open it
|
||||
// Initialize isOpen array based on filteredSections length
|
||||
this.isOpen = new Array(this.filteredSections.length).fill(false);
|
||||
if (this.filteredSections.length === 1) { // If only 1 section, go ahead and open it
|
||||
this.openSection(0);
|
||||
} else { // Otherwise, see if user set a default section, and open that
|
||||
this.openDefaultSection();
|
||||
|
|
|
|||
|
|
@ -924,6 +924,12 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"hideFromWorkspace": {
|
||||
"title": "Hide from Workspace",
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "If set to true, section will be visible in the default view but not in the Workspace view sidebar"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue