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!

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

Alicia Sykes76e5a1b77b58
diff --git a/src/components/Configuration/JsonEditor.vue b/src/components/Configuration/JsonEditor.vue
index 966288e1..62d0a279 100644
--- a/src/components/Configuration/JsonEditor.vue
+++ b/src/components/Configuration/JsonEditor.vue
@@ -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';
diff --git a/src/components/Configuration/RebuildApp.vue b/src/components/Configuration/RebuildApp.vue
index 7bde1fa8..e77eef53 100644
--- a/src/components/Configuration/RebuildApp.vue
+++ b/src/components/Configuration/RebuildApp.vue
@@ -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;
}
},
diff --git a/src/components/InteractiveEditor/EditModeSaveMenu.vue b/src/components/InteractiveEditor/EditModeSaveMenu.vue
index 2cf570f4..7cbdbcbc 100644
--- a/src/components/InteractiveEditor/EditModeSaveMenu.vue
+++ b/src/components/InteractiveEditor/EditModeSaveMenu.vue
@@ -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);