Skip to content

Commit

Permalink
🛂 Disallow save local/ disk in JSON editr (#485)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lissy93 committed Feb 12, 2022
1 parent eb377d2 commit 0b07abe
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/components/Configuration/JsonEditor.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="json-editor-outer">
<div class="json-editor-outer" v-if="allowViewConfig">
<!-- Main JSON editor -->
<v-jsoneditor v-model="jsonData" :options="options" />
<!-- Options raido, and save button -->
Expand Down Expand Up @@ -46,6 +46,7 @@
</p>
<p class="note">{{ $t('config.backup-note') }}</p>
</div>
<AccessError v-else />
</template>

<script>
Expand All @@ -58,16 +59,17 @@ import ErrorHandler, { InfoHandler, InfoKeys } from '@/utils/ErrorHandler';
import configSchema from '@/utils/ConfigSchema.json';
import StoreKeys from '@/utils/StoreMutations';
import { localStorageKeys, serviceEndpoints, modalNames } from '@/utils/defaults';
import { isUserAdmin } from '@/utils/Auth';
import Button from '@/components/FormElements/Button';
import Radio from '@/components/FormElements/Radio';
import AccessError from '@/components/Configuration/AccessError';
export default {
name: 'JsonEditor',
components: {
VJsoneditor,
Button,
Radio,
AccessError,
},
data() {
return {
Expand Down Expand Up @@ -97,13 +99,18 @@ export default {
isValid() {
return this.errorMessages.length < 1;
},
permissions() {
// Returns: { allowWriteToDisk, allowSaveLocally, allowViewConfig }
return this.$store.getters.permissions;
},
allowWriteToDisk() {
const { appConfig } = this.config;
return !appConfig.preventWriteToDisk && appConfig.allowConfigEdit !== false && isUserAdmin();
return this.permissions.allowWriteToDisk;
},
allowSaveLocally() {
if (this.config.appConfig.preventLocalSave) return false;
return true;
return this.permissions.allowSaveLocally;
},
allowViewConfig() {
return this.permissions.allowViewConfig;
},
initialSaveMode() {
if (this.allowWriteToDisk) return 'file';
Expand Down Expand Up @@ -287,7 +294,7 @@ p.response-output {
}
p.no-permission-note {
color: var(--config-settings-color);
color: var(--warning);
}
.btn-container {
Expand Down

0 comments on commit 0b07abe

Please sign in to comment.