mirror of https://github.com/Lissy93/dashy.git
🛂 Adds access control options to interatvie editor menu (#485)
This commit is contained in:
parent
20f231c632
commit
d5f0c19fbf
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<!-- Intro Info -->
|
<!-- Intro Info -->
|
||||||
<div class="edit-mode-bottom-banner">
|
<div class="edit-mode-bottom-banner">
|
||||||
<div class="edit-banner-section intro-container">
|
<div class="edit-banner-section intro-container" v-if="showEditMsg">
|
||||||
<p class="section-sub-title edit-mode-intro l-1">
|
<p class="section-sub-title edit-mode-intro l-1">
|
||||||
{{ $t('interactive-editor.menu.edit-mode-subtitle') }}
|
{{ $t('interactive-editor.menu.edit-mode-subtitle') }}
|
||||||
</p>
|
</p>
|
||||||
|
@ -9,6 +9,9 @@
|
||||||
{{ $t('interactive-editor.menu.edit-mode-description') }}
|
{{ $t('interactive-editor.menu.edit-mode-description') }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="edit-banner-section intro-container" v-else>
|
||||||
|
<AccessError class="no-permission" />
|
||||||
|
</div>
|
||||||
<div class="edit-banner-section empty-space"></div>
|
<div class="edit-banner-section empty-space"></div>
|
||||||
<!-- Save Buttons -->
|
<!-- Save Buttons -->
|
||||||
<div class="edit-banner-section save-buttons-container">
|
<div class="edit-banner-section save-buttons-container">
|
||||||
|
@ -17,7 +20,7 @@
|
||||||
</p>
|
</p>
|
||||||
<Button
|
<Button
|
||||||
:click="saveLocally"
|
:click="saveLocally"
|
||||||
:disallow="!allowSaveLocally"
|
:disallow="!permissions.allowSaveLocally"
|
||||||
v-tooltip="tooltip($t('interactive-editor.menu.save-locally-tooltip'))"
|
v-tooltip="tooltip($t('interactive-editor.menu.save-locally-tooltip'))"
|
||||||
>
|
>
|
||||||
{{ $t('interactive-editor.menu.save-locally-btn') }}
|
{{ $t('interactive-editor.menu.save-locally-btn') }}
|
||||||
|
@ -25,7 +28,7 @@
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
:click="writeToDisk"
|
:click="writeToDisk"
|
||||||
:disallow="!allowWriteToDisk"
|
:disallow="!permissions.allowWriteToDisk"
|
||||||
v-tooltip="tooltip($t('interactive-editor.menu.save-disk-tooltip'))"
|
v-tooltip="tooltip($t('interactive-editor.menu.save-disk-tooltip'))"
|
||||||
>
|
>
|
||||||
{{ $t('interactive-editor.menu.save-disk-btn') }}
|
{{ $t('interactive-editor.menu.save-disk-btn') }}
|
||||||
|
@ -33,6 +36,7 @@
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
:click="openExportConfigMenu"
|
:click="openExportConfigMenu"
|
||||||
|
:disallow="!permissions.allowViewConfig"
|
||||||
v-tooltip="tooltip($t('interactive-editor.menu.export-config-tooltip'))"
|
v-tooltip="tooltip($t('interactive-editor.menu.export-config-tooltip'))"
|
||||||
>
|
>
|
||||||
{{ $t('interactive-editor.menu.export-config-btn') }}
|
{{ $t('interactive-editor.menu.export-config-btn') }}
|
||||||
|
@ -53,6 +57,7 @@
|
||||||
</p>
|
</p>
|
||||||
<Button
|
<Button
|
||||||
:click="openEditPageInfo"
|
:click="openEditPageInfo"
|
||||||
|
:disallow="!permissions.allowViewConfig"
|
||||||
v-tooltip="tooltip($t('interactive-editor.menu.edit-page-info-tooltip'))"
|
v-tooltip="tooltip($t('interactive-editor.menu.edit-page-info-tooltip'))"
|
||||||
>
|
>
|
||||||
{{ $t('interactive-editor.menu.edit-page-info-btn') }}
|
{{ $t('interactive-editor.menu.edit-page-info-btn') }}
|
||||||
|
@ -60,6 +65,7 @@
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
:click="openEditAppConfig"
|
:click="openEditAppConfig"
|
||||||
|
:disallow="!permissions.allowViewConfig"
|
||||||
v-tooltip="tooltip($t('interactive-editor.menu.edit-app-config-tooltip'))"
|
v-tooltip="tooltip($t('interactive-editor.menu.edit-app-config-tooltip'))"
|
||||||
>
|
>
|
||||||
{{ $t('interactive-editor.menu.edit-app-config-btn') }}
|
{{ $t('interactive-editor.menu.edit-app-config-btn') }}
|
||||||
|
@ -83,7 +89,7 @@ import EditPageInfo from '@/components/InteractiveEditor/EditPageInfo';
|
||||||
import EditAppConfig from '@/components/InteractiveEditor/EditAppConfig';
|
import EditAppConfig from '@/components/InteractiveEditor/EditAppConfig';
|
||||||
import { modalNames, localStorageKeys, serviceEndpoints } from '@/utils/defaults';
|
import { modalNames, localStorageKeys, serviceEndpoints } from '@/utils/defaults';
|
||||||
import ErrorHandler, { InfoHandler } from '@/utils/ErrorHandler';
|
import ErrorHandler, { InfoHandler } from '@/utils/ErrorHandler';
|
||||||
import { isUserAdmin } from '@/utils/Auth';
|
import AccessError from '@/components/Configuration/AccessError';
|
||||||
|
|
||||||
import SaveLocallyIcon from '@/assets/interface-icons/interactive-editor-save-locally.svg';
|
import SaveLocallyIcon from '@/assets/interface-icons/interactive-editor-save-locally.svg';
|
||||||
import SaveToDiskIcon from '@/assets/interface-icons/interactive-editor-save-disk.svg';
|
import SaveToDiskIcon from '@/assets/interface-icons/interactive-editor-save-disk.svg';
|
||||||
|
@ -104,21 +110,18 @@ export default {
|
||||||
AppConfigIcon,
|
AppConfigIcon,
|
||||||
PageInfoIcon,
|
PageInfoIcon,
|
||||||
EditAppConfig,
|
EditAppConfig,
|
||||||
|
AccessError,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
config() {
|
config() {
|
||||||
return this.$store.state.config;
|
return this.$store.state.config;
|
||||||
},
|
},
|
||||||
allowWriteToDisk() {
|
permissions() {
|
||||||
const { appConfig } = this.config;
|
// Returns: { allowWriteToDisk, allowSaveLocally, allowViewConfig }
|
||||||
if (appConfig.preventWriteToDisk) return false;
|
return this.$store.getters.permissions;
|
||||||
if (appConfig.allowConfigEdit === false) return false;
|
|
||||||
if (!isUserAdmin()) return false; // If auth configured, but user NOT admin
|
|
||||||
return true;
|
|
||||||
},
|
},
|
||||||
allowSaveLocally() {
|
showEditMsg() {
|
||||||
if (this.config.appConfig.preventLocalSave) return false;
|
return this.permissions.allowWriteToDisk || this.permissions.allowSaveLocally;
|
||||||
return true;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
@ -157,7 +160,7 @@ export default {
|
||||||
localStorage.removeItem(localStorageKeys.CONF_SECTIONS);
|
localStorage.removeItem(localStorageKeys.CONF_SECTIONS);
|
||||||
},
|
},
|
||||||
saveLocally() {
|
saveLocally() {
|
||||||
if (!this.allowSaveLocally) {
|
if (!this.permissions.allowSaveLocally) {
|
||||||
ErrorHandler('Unable to save changes locally, this feature has been disabled');
|
ErrorHandler('Unable to save changes locally, this feature has been disabled');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -244,11 +247,16 @@ div.edit-mode-bottom-banner {
|
||||||
}
|
}
|
||||||
/* Intro-text container */
|
/* Intro-text container */
|
||||||
&.intro-container {
|
&.intro-container {
|
||||||
p.edit-mode-intro {
|
p.edit-mode-intro {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
color: var(--interactive-editor-color);
|
color: var(--interactive-editor-color);
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
.no-permission {
|
||||||
|
margin: 0;
|
||||||
|
width: auto;
|
||||||
|
padding: 0 0.5rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Button containers */
|
/* Button containers */
|
||||||
&.edit-site-config-buttons,
|
&.edit-site-config-buttons,
|
||||||
|
|
Loading…
Reference in New Issue