Adds option to prevent saving changes to disk (#485)

This commit is contained in:
Alicia Sykes 2022-02-11 09:59:53 +00:00
parent 61bbfcb885
commit 76e5a1b77b
3 changed files with 19 additions and 3 deletions

View File

@ -99,7 +99,7 @@ export default {
},
allowWriteToDisk() {
const { appConfig } = this.config;
return appConfig.allowConfigEdit !== false && isUserAdmin();
return !appConfig.preventWriteToDisk && appConfig.allowConfigEdit !== false && isUserAdmin();
},
initialSaveMode() {
return this.allowWriteToDisk ? 'file' : 'local';

View File

@ -51,7 +51,9 @@ import Button from '@/components/FormElements/Button';
import RebuildIcon from '@/assets/interface-icons/application-rebuild.svg';
import ReloadIcon from '@/assets/interface-icons/application-reload.svg';
import LoadingAnimation from '@/assets/interface-icons/loader.svg';
import ErrorHandler from '@/utils/ErrorHandler';
import { modalNames, serviceEndpoints } from '@/utils/defaults';
import { isUserAdmin } from '@/utils/Auth';
export default {
name: 'RebuildApp',
@ -79,6 +81,10 @@ export default {
methods: {
/* Calls to the rebuild endpoint, to kickoff the app build */
startBuild() {
if (!this.allowRebuild) { // Double check user is allowed
ErrorHandler('Unable to trigger rebuild, insufficient permission');
return;
}
const baseUrl = process.env.VUE_APP_DOMAIN || window.location.origin;
const endpoint = `${baseUrl}${serviceEndpoints.rebuild}`;
this.loading = true;
@ -116,7 +122,10 @@ export default {
},
},
mounted() {
if (this.appConfig.allowConfigEdit === false) {
// Disable rebuild functionality if user not allowed
if (this.appConfig.allowConfigEdit === false
|| this.appConfig.preventWriteToDisk
|| !isUserAdmin()) {
this.allowRebuild = false;
}
},

View File

@ -110,7 +110,10 @@ export default {
},
allowWriteToDisk() {
const { appConfig } = this.config;
return appConfig.allowConfigEdit !== false && isUserAdmin();
if (appConfig.preventWriteToDisk) return false;
if (appConfig.allowConfigEdit === false) return false;
if (!isUserAdmin()) return false; // If auth configured, but user NOT admin
return true;
},
},
data() {
@ -161,6 +164,10 @@ export default {
this.$store.commit(StoreKeys.SET_EDIT_MODE, false);
},
writeToDisk() {
if (this.config.appConfig.preventWriteToDisk) {
ErrorHandler('Unable to write changed to disk, as this functionality is disabled');
return;
}
// 1. Convert JSON into YAML
const yamlOptions = {};
const yaml = jsYaml.dump(this.config, yamlOptions);