Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

🍱 Updates settings icons for greater consistency

Alicia Sykes0524046be076
diff --git a/src/assets/interface-icons/config-editor.svg b/src/assets/interface-icons/config-editor.svg
index 3cb87c22..f6eaaaa7 100644
--- a/src/assets/interface-icons/config-editor.svg
+++ b/src/assets/interface-icons/config-editor.svg
@@ -1 +1 @@
-<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="wrench" class="svg-inline--fa fa-wrench fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M507.73 109.1c-2.24-9.03-13.54-12.09-20.12-5.51l-74.36 74.36-67.88-11.31-11.31-67.88 74.36-74.36c6.62-6.62 3.43-17.9-5.66-20.16-47.38-11.74-99.55.91-136.58 37.93-39.64 39.64-50.55 97.1-34.05 147.2L18.74 402.76c-24.99 24.99-24.99 65.51 0 90.5 24.99 24.99 65.51 24.99 90.5 0l213.21-213.21c50.12 16.71 107.47 5.68 147.37-34.22 37.07-37.07 49.7-89.32 37.91-136.73zM64 472c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24z"></path></svg>
\ No newline at end of file
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><path fill="currentColor" d="M415.9 274.5C428.1 271.2 440.9 277 446.4 288.3L465 325.9C475.3 327.3 485.4 330.1 494.9 334L529.9 310.7C540.4 303.7 554.3 305.1 563.2 314L582.4 333.2C591.3 342.1 592.7 356.1 585.7 366.5L562.4 401.4C564.3 406.1 566 411 567.4 416.1C568.8 421.2 569.7 426.2 570.4 431.3L608.1 449.9C619.4 455.5 625.2 468.3 621.9 480.4L614.9 506.6C611.6 518.7 600.3 526.9 587.7 526.1L545.7 523.4C539.4 531.5 532.1 539 523.8 545.4L526.5 587.3C527.3 599.9 519.1 611.3 507 614.5L480.8 621.5C468.6 624.8 455.9 619 450.3 607.7L431.7 570.1C421.4 568.7 411.3 565.9 401.8 562L366.8 585.3C356.3 592.3 342.4 590.9 333.5 582L314.3 562.8C305.4 553.9 304 540 311 529.5L334.3 494.5C332.4 489.8 330.7 484.9 329.3 479.8C327.9 474.7 327 469.6 326.3 464.6L288.6 446C277.3 440.4 271.6 427.6 274.8 415.5L281.8 389.3C285.1 377.2 296.4 369 309 369.8L350.9 372.5C357.2 364.4 364.5 356.9 372.8 350.5L370.1 308.7C369.3 296.1 377.5 284.7 389.6 281.5L415.8 274.5zM448.4 404C424.1 404 404.4 423.7 404.5 448.1C404.5 472.4 424.2 492 448.5 492C472.8 492 492.5 472.3 492.5 448C492.4 423.6 472.7 404 448.4 404zM224.9 18.5L251.1 25.5C263.2 28.8 271.4 40.2 270.6 52.7L267.9 94.5C276.2 100.9 283.5 108.3 289.8 116.5L331.8 113.8C344.3 113 355.7 121.2 359 133.3L366 159.5C369.2 171.6 363.5 184.4 352.2 190L314.5 208.6C313.8 213.7 312.8 218.8 311.5 223.8C310.2 228.8 308.4 233.8 306.5 238.5L329.8 273.5C336.8 284 335.4 297.9 326.5 306.8L307.3 326C298.4 334.9 284.5 336.3 274 329.3L239 306C229.5 309.9 219.4 312.7 209.1 314.1L190.5 351.7C184.9 363 172.1 368.7 160 365.5L133.8 358.5C121.6 355.2 113.5 343.8 114.3 331.3L117 289.4C108.7 283 101.4 275.6 95.1 267.4L53.1 270.1C40.6 270.9 29.2 262.7 25.9 250.6L18.9 224.4C15.7 212.3 21.4 199.5 32.7 193.9L70.4 175.3C71.1 170.2 72.1 165.2 73.4 160.1C74.8 155 76.4 150.1 78.4 145.4L55.1 110.5C48.1 100 49.5 86.1 58.4 77.2L77.6 58C86.5 49.1 100.4 47.7 110.9 54.7L145.9 78C155.4 74.1 165.5 71.3 175.8 69.9L194.4 32.3C200 21 212.7 15.3 224.9 18.5zM192.4 148C168.1 148 148.4 167.7 148.4 192C148.4 216.3 168.1 236 192.4 236C216.7 236 236.4 216.3 236.4 192C236.4 167.7 216.7 148 192.4 148z"/></svg>
diff --git a/src/assets/interface-icons/config-open-settings.svg b/src/assets/interface-icons/config-open-settings.svg
index 3da196fa..26a56abd 100644
--- a/src/assets/interface-icons/config-open-settings.svg
+++ b/src/assets/interface-icons/config-open-settings.svg
@@ -1 +1 @@
-<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="sliders-h" class="svg-inline--fa fa-sliders-h fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M496 384H160v-16c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v16H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h80v16c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-16h336c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm0-160h-80v-16c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v16H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h336v16c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-16h80c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm0-160H288V48c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v16H16C7.2 64 0 71.2 0 80v32c0 8.8 7.2 16 16 16h208v16c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-16h208c8.8 0 16-7.2 16-16V80c0-8.8-7.2-16-16-16z"></path></svg>
\ No newline at end of file
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><path fill="currentColor" d="M541.4 162.6C549 155 561.7 156.9 565.5 166.9C572.3 184.6 576 203.9 576 224C576 312.4 504.4 384 416 384C398.5 384 381.6 381.2 365.8 376L178.9 562.9C150.8 591 105.2 591 77.1 562.9C49 534.8 49 489.2 77.1 461.1L264 274.2C258.8 258.4 256 241.6 256 224C256 135.6 327.6 64 416 64C436.1 64 455.4 67.7 473.1 74.5C483.1 78.3 484.9 91 477.4 98.6L388.7 187.3C385.7 190.3 384 194.4 384 198.6L384 240C384 248.8 391.2 256 400 256L441.4 256C445.6 256 449.7 254.3 452.7 251.3L541.4 162.6z"/></svg>
diff --git a/src/assets/interface-icons/ellipse.svg b/src/assets/interface-icons/ellipse.svg
new file mode 100644
index 00000000..02f4cc1f
--- /dev/null
+++ b/src/assets/interface-icons/ellipse.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><path fill="currentColor" d="M320 208C289.1 208 264 182.9 264 152C264 121.1 289.1 96 320 96C350.9 96 376 121.1 376 152C376 182.9 350.9 208 320 208zM320 432C350.9 432 376 457.1 376 488C376 518.9 350.9 544 320 544C289.1 544 264 518.9 264 488C264 457.1 289.1 432 320 432zM376 320C376 350.9 350.9 376 320 376C289.1 376 264 350.9 264 320C264 289.1 289.1 264 320 264C350.9 264 376 289.1 376 320z"/></svg>
diff --git a/src/assets/locales/en.json b/src/assets/locales/en.json
index 69ba43c8..0b074ad4 100644
--- a/src/assets/locales/en.json
+++ b/src/assets/locales/en.json
@@ -128,11 +128,13 @@
"item-size-small": "Small",
"item-size-medium": "Medium",
"item-size-large": "Large",
+ "language-label": "Language",
"config-launcher-label": "Config",
"config-launcher-tooltip": "Update Configuration",
"sign-out-tooltip": "Sign Out",
"sign-in-tooltip": "Log In",
"sign-in-welcome": "Hello {username}!",
+ "please-login": "Log in for full access",
"hide": "Hide",
"open": "Open",
"options-title": "Options",
diff --git a/src/components/LinkItems/Collapsable.vue b/src/components/LinkItems/Collapsable.vue
index 94cb3f6b..a315e3ba 100644
--- a/src/components/LinkItems/Collapsable.vue
+++ b/src/components/LinkItems/Collapsable.vue
@@ -24,7 +24,7 @@
<h3>{{ title }}</h3>
<EditModeIcon v-if="isEditMode" @click="openEditModal"
v-tooltip="editTooltip()" class="header-action" />
- <OpenIcon @click.prevent.stop="openContextMenu" @contextmenu.prevent
+ <EllipseIcon @click.prevent.stop="openContextMenu" @contextmenu.prevent
v-tooltip="optionsTooltip()" class="header-action" />
</div>
<div class="collapsible-content">
@@ -40,7 +40,7 @@ import longPress from '@/directives/LongPress';
import { localStorageKeys } from '@/utils/config/defaults';
import Icon from '@/components/LinkItems/ItemIcon.vue';
import EditModeIcon from '@/assets/interface-icons/interactive-editor-edit-mode.svg';
-import OpenIcon from '@/assets/interface-icons/config-open-settings.svg';
+import EllipseIcon from '@/assets/interface-icons/ellipse.svg';
export default {
name: 'CollapsableContainer',
@@ -58,7 +58,7 @@ export default {
components: {
Icon,
EditModeIcon,
- OpenIcon,
+ EllipseIcon,
},
directives: {
longPress,
diff --git a/src/components/LinkItems/SectionContextMenu.vue b/src/components/LinkItems/SectionContextMenu.vue
index 7faaf666..e6de565b 100644
--- a/src/components/LinkItems/SectionContextMenu.vue
+++ b/src/components/LinkItems/SectionContextMenu.vue
@@ -8,14 +8,17 @@
<SameTabOpenIcon />
<span>{{ $t('context-menus.section.open-section') }}</span>
</li>
- <li @click="openEditSectionMenu">
- <EditIcon />
- <span>{{ $t('context-menus.section.edit-section') }}</span>
- </li>
<li @click="expandCollapseSection">
<ExpandCollapseIcon />
<span>{{ $t('context-menus.section.expand-collapse') }}</span>
</li>
+ </ul>
+ <!-- Edit Options -->
+ <ul class="menu-section" :class="{ disabled: !isEditAllowed }">
+ <li @click="openEditSectionMenu">
+ <EditIcon />
+ <span>{{ $t('context-menus.section.edit-section') }}</span>
+ </li>
<li v-if="isEditMode" @click="removeSection">
<BinIcon />
<span>{{ $t('context-menus.section.remove-section') }}</span>
@@ -52,6 +55,9 @@ export default {
isEditMode() {
return this.$store.state.editMode;
},
+ isEditAllowed() {
+ return this.$store.getters.permissions.allowViewConfig;
+ },
},
methods: {
/* Called on item click, emits an event up to Item */
@@ -60,13 +66,13 @@ export default {
this.$emit('navigateToSection');
},
openEditSectionMenu() {
- this.$emit('openEditSection');
+ if (this.isEditAllowed) this.$emit('openEditSection');
},
expandCollapseSection() {
this.$emit('expandCollapseSection');
},
removeSection() {
- this.$emit('removeSection');
+ if (this.isEditAllowed) this.$emit('removeSection');
},
calcPosition() {
const bounds = this.$parent.$el.getBoundingClientRect();
@@ -114,6 +120,10 @@ div.context-menu {
margin-right: 0.5rem;
}
}
+ &.disabled li {
+ cursor: not-allowed;
+ opacity: var(--dimming-factor);
+ }
}
}
diff --git a/src/components/PageStrcture/Nav.vue b/src/components/PageStrcture/Nav.vue
index 748728e6..818f793c 100644
--- a/src/components/PageStrcture/Nav.vue
+++ b/src/components/PageStrcture/Nav.vue
@@ -47,6 +47,7 @@ export default {
/* Get links to sub-pages, and combine with nav-links. Sub-page links honor the
* current view (home/minimal/workspace) so users stay in the view they chose. */
allLinks() {
+ void this.$store.state.authRevision; // Re-filter pages when auth state changes
const view = viewFromPath(this.$route.path);
const subPages = this.$store.getters.pages.filter((page) => checkPageVisibility(page))
.map((subPage) => ({
diff --git a/src/components/Settings/AuthButtons.vue b/src/components/Settings/AuthButtons.vue
index 14750497..59068151 100644
--- a/src/components/Settings/AuthButtons.vue
+++ b/src/components/Settings/AuthButtons.vue
@@ -1,6 +1,13 @@
<template>
- <div class="auth-buttons" v-if="authLabel">
+ <IconLogout
+ v-if="iconOnly && authLabel"
+ @click="run"
+ v-tooltip="tooltip($t(authLabel))"
+ tabindex="-2"
+ />
+ <div v-else-if="authLabel" class="auth-buttons">
<span v-if="greeting" class="user-type-note">{{ greeting }}</span>
+ <span v-else-if="isGuest" class="user-type-note">{{ $t('settings.please-login') }}</span>
<button
type="button"
class="auth-btn"
@@ -16,6 +23,7 @@
<script>
import router from '@/router';
+import Keys from '@/utils/StoreMutations';
import { logout as registerLogout } from '@/utils/auth/Auth';
import { getKeycloakAuth, isKeycloakEnabled } from '@/utils/auth/KeycloakAuth';
import { getOidcAuth, isOidcEnabled } from '@/utils/auth/OidcAuth';
@@ -33,6 +41,7 @@ export default {
components: { IconLogout },
props: {
userType: Number,
+ iconOnly: Boolean, // If true, render just the icon (used by ConfigLauncher)
},
computed: {
authLabel() {
@@ -45,6 +54,9 @@ export default {
const username = localStorage[localStorageKeys.USERNAME];
return username ? this.$t('settings.sign-in-welcome', { username }) : '';
},
+ isGuest() {
+ return this.userType === userStateEnum.guestAccess;
+ },
},
methods: {
run() {
@@ -58,6 +70,7 @@ export default {
},
logout() {
registerLogout();
+ this.$store.commit(Keys.AUTH_CHANGED);
this.$toast(this.$t('login.logout-message'));
setTimeout(() => router.push({ path: '/login' }), 500);
},
@@ -115,7 +128,7 @@ export default {
color: var(--settings-text-color);
border: 1px solid currentColor;
border-radius: var(--curve-factor);
- font-size: 0.8rem;
+ font-size: 1rem;
cursor: pointer;
transition: background-color 0.15s ease, color 0.15s ease;
diff --git a/src/components/Settings/ConfigLauncher.vue b/src/components/Settings/ConfigLauncher.vue
index bb1f6402..e7e8e663 100644
--- a/src/components/Settings/ConfigLauncher.vue
+++ b/src/components/Settings/ConfigLauncher.vue
@@ -10,6 +10,7 @@
:class="(isEditMode || !isEditAllowed) ? 'disabled' : ''" />
<IconViewMode @click="openChangeViewMenu()" tabindex="-2"
v-tooltip="tooltip($t('alternate-views.alternate-view-heading'))" />
+ <AuthButtons :userType="userState" iconOnly />
</div>
<!-- Modal containing all the configuration options -->
@@ -33,6 +34,7 @@
// Import components, and store-key identifiers
import ConfigContainer from '@/components/Configuration/ConfigContainer';
import LanguageSwitcher from '@/components/Settings/LanguageSwitcher';
+import AuthButtons from '@/components/Settings/AuthButtons';
import Keys from '@/utils/StoreMutations';
import { topLevelConfKeys, localStorageKeys, modalNames } from '@/utils/config/defaults';
import ViewSwitcher from '@/components/Settings/ViewSwitcher';
@@ -52,6 +54,7 @@ export default {
components: {
ConfigContainer,
LanguageSwitcher,
+ AuthButtons,
ViewSwitcher,
IconSpanner,
IconInteractiveEditor,
@@ -73,6 +76,9 @@ export default {
isEditAllowed() {
return this.$store.getters.permissions.allowViewConfig;
},
+ userState() {
+ return this.$store.getters.userState;
+ },
/* Tooltip text for Edit Mode button, to change depending on it in edit mode */
enterEditModeTooltip() {
if (!this.isEditAllowed) return 'Config editor not available';
diff --git a/src/components/Settings/LanguageSwitcher.vue b/src/components/Settings/LanguageSwitcher.vue
index 63648c74..ee6e0818 100644
--- a/src/components/Settings/LanguageSwitcher.vue
+++ b/src/components/Settings/LanguageSwitcher.vue
@@ -1,7 +1,8 @@
<template>
- <div class="language-switcher">
- <h3 class="title">{{ $t('language-switcher.title') }}</h3>
- <p class="intro">{{ $t('language-switcher.dropdown-label') }}:</p>
+ <div class="language-switcher" :class="{ mini: miniView }">
+ <h3 v-if="!miniView" class="title">{{ $t('language-switcher.title') }}</h3>
+ <p v-if="!miniView" class="intro">{{ $t('language-switcher.dropdown-label') }}:</p>
+ <span v-if="miniView" class="options-label">{{ $t('settings.language-label') }}</span>
<v-select
v-model="language"
:selectOnTab="true"
@@ -9,18 +10,21 @@
class="language-dropdown"
label="friendlyName"
@input="applyLanguageLocally"
+ @option:selected="onOptionSelected"
/>
- <Button class="save-button" :click="saveLanguage" :disallow="!language">
- {{ $t('language-switcher.save-button') }}
- <SaveConfigIcon />
- </Button>
- <p v-if="language" class="current-lang">
- 🌐 {{ language.flag }} {{ language.name }}
- </p>
- <p v-if="$i18n.availableLocales.length <= 1" class="sad-times">
- There are not currently any additional languages supported,
- but stay tuned as more are on their way!
- </p>
+ <template v-if="!miniView">
+ <Button class="save-button" :click="saveLanguage" :disallow="!language">
+ {{ $t('language-switcher.save-button') }}
+ <SaveConfigIcon />
+ </Button>
+ <p v-if="language" class="current-lang">
+ 🌐 {{ language.flag }} {{ language.name }}
+ </p>
+ <p v-if="$i18n.availableLocales.length <= 1" class="sad-times">
+ There are not currently any additional languages supported,
+ but stay tuned as more are on their way!
+ </p>
+ </template>
</div>
</template>
@@ -39,6 +43,9 @@ export default {
Button,
SaveConfigIcon,
},
+ props: {
+ miniView: Boolean, // If true, render only the dropdown and auto-save on select
+ },
data() {
return {
language: '', // The currently selected language
@@ -95,12 +102,16 @@ export default {
const successMsg = `${selectedLanguage.flag} `
+ `${this.$t('language-switcher.success-msg')} ${selectedLanguage.name}`;
this.$toast.success(successMsg);
- this.$modal.hide(this.modalName);
+ if (!this.miniView) this.$modal.hide(this.modalName);
} else {
this.$toast.error('Unable to update language');
ErrorHandler('Unable to apply language');
}
},
+ /* In miniView, commit immediately on selection (no save button) */
+ onOptionSelected() {
+ if (this.miniView) this.saveLanguage();
+ },
},
};
</script>
@@ -137,6 +148,12 @@ export default {
width: 100%;
bottom: 0;
}
+ &.mini {
+ height: auto;
+ padding: 0;
+ background: transparent;
+ flex: 1;
+ }
}
</style>
@@ -155,6 +172,24 @@ export default {
div, input {
cursor: pointer;
}
+ button.vs__clear {
+ display: none;
+ }
+}
+
+.language-switcher.mini .language-dropdown {
+ margin: 0;
+ width: 100%;
+ div.vs__dropdown-toggle {
+ border-color: var(--primary);
+ border-radius: var(--curve-factor);
+ height: 1.8rem;
+ font-size: 0.85rem;
+ }
+ span.vs__selected { margin: 0.1rem 0 0.5rem 0; }
+ svg.vs__open-indicator {
+ fill: var(--primary);
+ }
}
</style>
diff --git a/src/components/Settings/OptionsPanel.vue b/src/components/Settings/OptionsPanel.vue
index a6c5a167..2066003f 100644
--- a/src/components/Settings/OptionsPanel.vue
+++ b/src/components/Settings/OptionsPanel.vue
@@ -17,13 +17,13 @@
</button>
</header>
- <section class="section actions-row">
+ <section v-if="canEdit" class="section actions-row">
<button
type="button"
class="action-btn"
- :class="{ 'is-primary': !isEditMode && canEdit }"
+ :class="{ 'is-primary': !isEditMode }"
@click="startEdit"
- :disabled="!canEdit || isEditMode"
+ :disabled="isEditMode"
v-tooltip="editTooltip"
>
<IconEdit />
@@ -40,6 +40,10 @@
</button>
</section>
+ <section v-else class="section language-row">
+ <LanguageSwitcher miniView />
+ </section>
+
<section class="section theme-section">
<ThemeSelector />
</section>
@@ -74,6 +78,7 @@
import ThemeSelector from '@/components/Settings/ThemeSelector';
import LayoutSelector from '@/components/Settings/LayoutSelector';
import ItemSizeSelector from '@/components/Settings/ItemSizeSelector';
+import LanguageSwitcher from '@/components/Settings/LanguageSwitcher';
import AuthButtons from '@/components/Settings/AuthButtons';
import Keys from '@/utils/StoreMutations';
import { modalNames } from '@/utils/config/defaults';
@@ -92,6 +97,7 @@ export default {
ThemeSelector,
LayoutSelector,
ItemSizeSelector,
+ LanguageSwitcher,
AuthButtons,
IconClose,
IconEdit,
@@ -106,7 +112,6 @@ export default {
canEdit() { return this.$store.getters.permissions.allowViewConfig; },
userState() { return getUserState(); },
editTooltip() {
- if (!this.canEdit) return this.$t('interactive-editor.menu.config-unavailable');
const key = this.isEditMode ? 'edit-mode-subtitle' : 'start-editing-tooltip';
return this.$t(`interactive-editor.menu.${key}`);
},
@@ -134,7 +139,7 @@ export default {
this.close();
},
startEdit() {
- if (this.isEditMode || !this.canEdit) return;
+ if (this.isEditMode) return;
this.$store.commit(Keys.SET_EDIT_MODE, true);
this.close();
},
@@ -151,7 +156,7 @@ export default {
.options-panel {
position: absolute;
- top: calc(100% + 0.5rem);
+ top: 100%;
right: 0.5rem;
z-index: 5;
width: 22rem;
diff --git a/src/components/Settings/SettingsContainer.vue b/src/components/Settings/SettingsContainer.vue
index 553327b1..c7bdb635 100644
--- a/src/components/Settings/SettingsContainer.vue
+++ b/src/components/Settings/SettingsContainer.vue
@@ -123,7 +123,7 @@ section {
width: 2rem;
height: 2rem;
padding: 0.3rem;
- background: none;
+ background: var(--background-darker);
border: 1px solid transparent;
border-radius: var(--curve-factor);
color: var(--settings-text-color);
diff --git a/src/store.js b/src/store.js
index f81a8dd4..2ea0d8b5 100644
--- a/src/store.js
+++ b/src/store.js
@@ -7,7 +7,12 @@ import { makePageName, formatConfigPath, componentVisibility } from '@/utils/con
import { applyItemId } from '@/utils/config/SectionHelpers';
import filterUserSections from '@/utils/CheckSectionVisibility';
import ErrorHandler, { InfoHandler, InfoKeys } from '@/utils/logging/ErrorHandler';
-import { isUserAdmin, makeBasicAuthHeaders, isLoggedInAsGuest } from '@/utils/auth/Auth';
+import {
+ isUserAdmin,
+ makeBasicAuthHeaders,
+ isLoggedInAsGuest,
+ getUserState,
+} from '@/utils/auth/Auth';
import { localStorageKeys, theme as defaultTheme } from '@/utils/config/defaults';
const {
@@ -38,6 +43,7 @@ const {
UPDATE_CUSTOM_CSS,
CONF_MENU_INDEX,
CRITICAL_ERROR_MSG,
+ AUTH_CHANGED,
} = Keys;
const emptyConfig = {
@@ -90,6 +96,7 @@ const store = createStore({
isUsingLocalConfig: false, // If true, will use local config instead of fetched
criticalError: null, // Will store a message, if a critical error occurs
navigateConfToTab: undefined, // Used to switch active tab in config modal
+ authRevision: 0, // Bumped on login/logout so auth-dependent getters re-run
},
getters: {
config(state) {
@@ -104,6 +111,7 @@ const store = createStore({
return state.config.appConfig || {};
},
sections(state) {
+ void state.authRevision; // Re-filter sections when auth state changes
return filterUserSections(state.config.sections || []);
},
pages(state) {
@@ -132,6 +140,7 @@ const store = createStore({
},
/* Make config read/ write permissions object */
permissions(state, getters) {
+ void state.authRevision; // Re-evaluate when auth state changes
const appConfig = getters.appConfig;
const perms = {
allowWriteToDisk: true,
@@ -146,10 +155,6 @@ const store = createStore({
if (appConfig.preventWriteToDisk || !isUserAdmin()) {
perms.allowWriteToDisk = false;
}
- // Legacy Option: Will be removed in V 2.1.0
- if (appConfig.allowConfigEdit === false) {
- perms.allowWriteToDisk = false;
- }
// Disable everything
if (appConfig.disableConfiguration
|| (appConfig.disableConfigurationForNonAdmin && !isUserAdmin())
@@ -160,6 +165,10 @@ const store = createStore({
}
return perms;
},
+ userState(state) {
+ void state.authRevision; // Re-evaluate when auth state changes
+ return getUserState();
+ },
// eslint-disable-next-line arrow-body-style
getSectionByIndex: (state, getters) => (index) => {
return getters.sections[index];
@@ -377,6 +386,9 @@ const store = createStore({
[CONF_MENU_INDEX](state, index) {
state.navigateConfToTab = index;
},
+ [AUTH_CHANGED](state) {
+ state.authRevision += 1;
+ },
/* Set config to rootConfig, by calling initialize with no params */
async [USE_MAIN_CONFIG]() {
this.dispatch(Keys.INITIALIZE_CONFIG);
diff --git a/src/utils/StoreMutations.js b/src/utils/StoreMutations.js
index c918b6fc..b3e009f2 100644
--- a/src/utils/StoreMutations.js
+++ b/src/utils/StoreMutations.js
@@ -29,6 +29,7 @@ const KEY_NAMES = [
'UPDATE_CUSTOM_CSS',
'CONF_MENU_INDEX',
'CRITICAL_ERROR_MSG',
+ 'AUTH_CHANGED',
];
// Convert array of key names into an object, and export
diff --git a/src/views/Login.vue b/src/views/Login.vue
index c0c2bcb2..ee9c8168 100644
--- a/src/views/Login.vue
+++ b/src/views/Login.vue
@@ -75,6 +75,7 @@
import router from '@/router';
import Button from '@/components/FormElements/Button';
import Input from '@/components/FormElements/Input';
+import Keys from '@/utils/StoreMutations';
import { localStorageKeys } from '@/utils/config/defaults';
import { InfoHandler, WarningInfoHandler, InfoKeys } from '@/utils/logging/ErrorHandler';
import {
@@ -158,6 +159,7 @@ export default {
this.status = response.correct ? 'success' : 'error';
if (response.correct) { // Yay, credentials were correct :)
login(this.username, this.password, timeout); // Login, to set the cookie
+ this.$store.commit(Keys.AUTH_CHANGED); // Trigger reactive auth-dependent getters
this.goHome();
InfoHandler(`Succesfully signed in as ${this.username}`, InfoKeys.AUTH);
} else {