🛂 Adds permissions object to Store

This commit is contained in:
Alicia Sykes 2022-02-12 15:17:23 +00:00
parent e194d741ac
commit af3343e15a

View File

@ -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];