From c8ad80b79c38381f1a2ba8cb8609d9341f224b2d Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sat, 12 Feb 2022 20:05:14 +0000 Subject: [PATCH] :passport_control: Adds access control checks in editor forms (#455) --- src/components/InteractiveEditor/EditAppConfig.vue | 8 +++++++- src/components/InteractiveEditor/EditItem.vue | 11 +++++++++-- src/components/InteractiveEditor/EditPageInfo.vue | 8 +++++++- src/components/InteractiveEditor/EditSection.vue | 8 +++++++- .../InteractiveEditor/ExportConfigMenu.vue | 13 +++++++++++-- src/components/InteractiveEditor/MoveItemTo.vue | 8 +++++++- 6 files changed, 48 insertions(+), 8 deletions(-) diff --git a/src/components/InteractiveEditor/EditAppConfig.vue b/src/components/InteractiveEditor/EditAppConfig.vue index 40fe430c..74f424b7 100644 --- a/src/components/InteractiveEditor/EditAppConfig.vue +++ b/src/components/InteractiveEditor/EditAppConfig.vue @@ -7,7 +7,7 @@ classes="dashy-modal edit-app-config" @closed="modalClosed" > -
+

{{ $t('interactive-editor.menu.edit-app-config-btn') }}

@@ -35,6 +35,7 @@
+ @@ -43,6 +44,7 @@ import FormSchema from '@formschema/native'; import DashySchema from '@/utils/ConfigSchema'; import StoreKeys from '@/utils/StoreMutations'; import { modalNames } from '@/utils/defaults'; +import AccessError from '@/components/Configuration/AccessError'; import SaveCancelButtons from '@/components/InteractiveEditor/SaveCancelButtons'; export default { @@ -58,6 +60,7 @@ export default { components: { FormSchema, SaveCancelButtons, + AccessError, }, mounted() { this.formData = this.appConfig; @@ -66,6 +69,9 @@ export default { appConfig() { return this.$store.getters.appConfig; }, + allowViewConfig() { + return this.$store.getters.permissions.allowViewConfig; + }, }, methods: { /* When form submitteed, update VueX store with new appConfig, and close modal */ diff --git a/src/components/InteractiveEditor/EditItem.vue b/src/components/InteractiveEditor/EditItem.vue index 5be36839..2c89bf57 100644 --- a/src/components/InteractiveEditor/EditItem.vue +++ b/src/components/InteractiveEditor/EditItem.vue @@ -7,7 +7,7 @@ classes="dashy-modal edit-item" @closed="modalClosed" > -
+

Edit Item

Editing {{item.title}} (ID: {{itemId}})

@@ -67,6 +67,7 @@
+ @@ -74,6 +75,7 @@ import AddIcon from '@/assets/interface-icons/interactive-editor-add.svg'; import BinIcon from '@/assets/interface-icons/interactive-editor-remove.svg'; import SaveCancelButtons from '@/components/InteractiveEditor/SaveCancelButtons'; +import AccessError from '@/components/Configuration/AccessError'; import Input from '@/components/FormElements/Input'; import Radio from '@/components/FormElements/Radio'; import Select from '@/components/FormElements/Select'; @@ -101,13 +103,18 @@ export default { isNew: Boolean, parentSectionTitle: String, // If adding new item, which section to add it under }, - computed: {}, + computed: { + allowViewConfig() { + return this.$store.getters.permissions.allowViewConfig; + }, + }, components: { Input, Radio, Select, AddIcon, BinIcon, + AccessError, SaveCancelButtons, }, mounted() { diff --git a/src/components/InteractiveEditor/EditPageInfo.vue b/src/components/InteractiveEditor/EditPageInfo.vue index 71f978da..1cce90a5 100644 --- a/src/components/InteractiveEditor/EditPageInfo.vue +++ b/src/components/InteractiveEditor/EditPageInfo.vue @@ -4,7 +4,7 @@ :resizable="true" width="50%" height="80%" classes="dashy-modal edit-page-info" > -
+

{{ $t('interactive-editor.menu.edit-page-info-btn') }}

+ @@ -29,6 +30,7 @@ import StoreKeys from '@/utils/StoreMutations'; import { modalNames } from '@/utils/defaults'; import Button from '@/components/FormElements/Button'; import SaveIcon from '@/assets/interface-icons/save-config.svg'; +import AccessError from '@/components/Configuration/AccessError'; export default { name: 'EditPageInfo', @@ -43,6 +45,7 @@ export default { FormSchema, Button, SaveIcon, + AccessError, }, mounted() { this.formData = this.pageInfo; @@ -51,6 +54,9 @@ export default { pageInfo() { return this.$store.getters.pageInfo; }, + allowViewConfig() { + return this.$store.getters.permissions.allowViewConfig; + }, }, methods: { /* When form submitteed, update VueX store with new pageInfo, and close modal */ diff --git a/src/components/InteractiveEditor/EditSection.vue b/src/components/InteractiveEditor/EditSection.vue index 7e9b2635..7222a7a7 100644 --- a/src/components/InteractiveEditor/EditSection.vue +++ b/src/components/InteractiveEditor/EditSection.vue @@ -4,7 +4,7 @@ :resizable="true" width="50%" height="80%" classes="dashy-modal edit-section" > -
+

{{ $t(`interactive-editor.edit-section.${isAddNew ? 'add' : 'edit'}-section-title`) }}

@@ -19,6 +19,7 @@ :cancelClick="modalClosed" />
+ @@ -28,6 +29,7 @@ import StoreKeys from '@/utils/StoreMutations'; import DashySchema from '@/utils/ConfigSchema'; import { modalNames } from '@/utils/defaults'; import SaveCancelButtons from '@/components/InteractiveEditor/SaveCancelButtons'; +import AccessError from '@/components/Configuration/AccessError'; export default { name: 'EditSection', @@ -38,6 +40,7 @@ export default { components: { SaveCancelButtons, FormSchema, + AccessError, }, data() { return { @@ -71,6 +74,9 @@ export default { }, }; }, + allowViewConfig() { + return this.$store.getters.permissions.allowViewConfig; + }, }, mounted() { this.sectionData = this.$store.getters.getSectionByIndex(this.sectionIndex); diff --git a/src/components/InteractiveEditor/ExportConfigMenu.vue b/src/components/InteractiveEditor/ExportConfigMenu.vue index 1032e8bb..3b1bdf10 100644 --- a/src/components/InteractiveEditor/ExportConfigMenu.vue +++ b/src/components/InteractiveEditor/ExportConfigMenu.vue @@ -4,10 +4,10 @@ :resizable="true" width="50%" height="80%" - classes="dashy-modal edit-item" + classes="dashy-modal export-modal" @closed="modalClosed" > -
+

{{ $t('interactive-editor.export.export-title') }}

@@ -26,6 +26,7 @@

{{ $t('interactive-editor.export.view-title') }}

+ @@ -34,6 +35,7 @@ import JsYaml from 'js-yaml'; import Button from '@/components/FormElements/Button'; import StoreKeys from '@/utils/StoreMutations'; import { modalNames } from '@/utils/defaults'; +import AccessError from '@/components/Configuration/AccessError'; import DownloadConfigIcon from '@/assets/interface-icons/config-download-file.svg'; import CopyConfigIcon from '@/assets/interface-icons/interactive-editor-copy-clipboard.svg'; import { InfoHandler, InfoKeys } from '@/utils/ErrorHandler'; @@ -42,6 +44,7 @@ export default { name: 'ExportConfigMenu', components: { Button, + AccessError, CopyConfigIcon, DownloadConfigIcon, }, @@ -55,6 +58,9 @@ export default { config() { return this.$store.state.config; }, + allowViewConfig() { + return this.$store.getters.permissions.allowViewConfig; + }, }, methods: { convertJsonToYaml() { @@ -123,5 +129,8 @@ export default { } } } +.export-modal { + background: var(--interactive-editor-background); +} diff --git a/src/components/InteractiveEditor/MoveItemTo.vue b/src/components/InteractiveEditor/MoveItemTo.vue index 990d7d37..4633d2a2 100644 --- a/src/components/InteractiveEditor/MoveItemTo.vue +++ b/src/components/InteractiveEditor/MoveItemTo.vue @@ -2,7 +2,7 @@ -
+

Move or Copy Item

Editing {{ itemId }}

@@ -30,6 +30,7 @@
+ @@ -37,6 +38,7 @@ import Select from '@/components/FormElements/Select'; import Radio from '@/components/FormElements/Radio'; import SaveCancelButtons from '@/components/InteractiveEditor/SaveCancelButtons'; +import AccessError from '@/components/Configuration/AccessError'; import StoreKeys from '@/utils/StoreMutations'; import { modalNames } from '@/utils/defaults'; @@ -45,6 +47,7 @@ export default { components: { Select, Radio, + AccessError, SaveCancelButtons, }, props: { @@ -83,6 +86,9 @@ export default { }); return sectionName; }, + allowViewConfig() { + return this.$store.getters.permissions.allowViewConfig; + }, }, mounted() { this.selectedSection = this.currentSection;