🛂 Disallow save local/ disk in JSON editr (#485)

This commit is contained in:
Alicia Sykes 2022-02-12 21:24:23 +00:00
parent eb377d287e
commit 0b07abeb18
1 changed files with 14 additions and 7 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="json-editor-outer"> <div class="json-editor-outer" v-if="allowViewConfig">
<!-- Main JSON editor --> <!-- Main JSON editor -->
<v-jsoneditor v-model="jsonData" :options="options" /> <v-jsoneditor v-model="jsonData" :options="options" />
<!-- Options raido, and save button --> <!-- Options raido, and save button -->
@ -46,6 +46,7 @@
</p> </p>
<p class="note">{{ $t('config.backup-note') }}</p> <p class="note">{{ $t('config.backup-note') }}</p>
</div> </div>
<AccessError v-else />
</template> </template>
<script> <script>
@ -58,9 +59,9 @@ import ErrorHandler, { InfoHandler, InfoKeys } from '@/utils/ErrorHandler';
import configSchema from '@/utils/ConfigSchema.json'; import configSchema from '@/utils/ConfigSchema.json';
import StoreKeys from '@/utils/StoreMutations'; import StoreKeys from '@/utils/StoreMutations';
import { localStorageKeys, serviceEndpoints, modalNames } from '@/utils/defaults'; import { localStorageKeys, serviceEndpoints, modalNames } from '@/utils/defaults';
import { isUserAdmin } from '@/utils/Auth';
import Button from '@/components/FormElements/Button'; import Button from '@/components/FormElements/Button';
import Radio from '@/components/FormElements/Radio'; import Radio from '@/components/FormElements/Radio';
import AccessError from '@/components/Configuration/AccessError';
export default { export default {
name: 'JsonEditor', name: 'JsonEditor',
@ -68,6 +69,7 @@ export default {
VJsoneditor, VJsoneditor,
Button, Button,
Radio, Radio,
AccessError,
}, },
data() { data() {
return { return {
@ -97,13 +99,18 @@ export default {
isValid() { isValid() {
return this.errorMessages.length < 1; return this.errorMessages.length < 1;
}, },
permissions() {
// Returns: { allowWriteToDisk, allowSaveLocally, allowViewConfig }
return this.$store.getters.permissions;
},
allowWriteToDisk() { allowWriteToDisk() {
const { appConfig } = this.config; return this.permissions.allowWriteToDisk;
return !appConfig.preventWriteToDisk && appConfig.allowConfigEdit !== false && isUserAdmin();
}, },
allowSaveLocally() { allowSaveLocally() {
if (this.config.appConfig.preventLocalSave) return false; return this.permissions.allowSaveLocally;
return true; },
allowViewConfig() {
return this.permissions.allowViewConfig;
}, },
initialSaveMode() { initialSaveMode() {
if (this.allowWriteToDisk) return 'file'; if (this.allowWriteToDisk) return 'file';
@ -287,7 +294,7 @@ p.response-output {
} }
p.no-permission-note { p.no-permission-note {
color: var(--config-settings-color); color: var(--warning);
} }
.btn-container { .btn-container {