From af3343e15aa3842ed24356f81c1d319dfc212534 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sat, 12 Feb 2022 15:17:23 +0000 Subject: [PATCH] :passport_control: Adds permissions object to Store --- src/store.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/store.js b/src/store.js index fe455e51..fd55f686 100644 --- a/src/store.js +++ b/src/store.js @@ -1,4 +1,4 @@ -/* eslint-disable no-param-reassign */ +/* eslint-disable no-param-reassign, prefer-destructuring */ import Vue from 'vue'; import Vuex from 'vuex'; import Keys from '@/utils/StoreMutations'; @@ -63,6 +63,30 @@ const store = new Vuex.Store({ visibleComponents(state, getters) { return componentVisibility(getters.appConfig); }, + /* Make config read/ write permissions object */ + permissions(state, getters) { + const appConfig = getters.appConfig; + const perms = { + allowWriteToDisk: true, + allowSaveLocally: true, + allowViewConfig: true, + }; + // Disable saving changes locally, only + if (appConfig.preventLocalSave) { + perms.allowSaveLocally = false; + } + // Disable saving changes to disk, only + if (appConfig.preventWriteToDisk) { + perms.allowWriteToDisk = false; + } + // Disable everything + if (appConfig.disableConfiguration) { + perms.allowWriteToDisk = false; + perms.allowSaveLocally = false; + perms.allowViewConfig = false; + } + return perms; + }, // eslint-disable-next-line arrow-body-style getSectionByIndex: (state, getters) => (index) => { return getters.sections[index];