From 3c4380c91b5d77e49c2e30159de9d691aa3642d0 Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Thu, 19 Dec 2024 10:46:45 +0100 Subject: [PATCH] permission update on querystore --- src/stores/admin/queryStore.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/stores/admin/queryStore.ts b/src/stores/admin/queryStore.ts index 3a881a5..ddc6c1a 100644 --- a/src/stores/admin/queryStore.ts +++ b/src/stores/admin/queryStore.ts @@ -5,6 +5,7 @@ import type { AxiosResponse } from "axios"; import { useQueryBuilderStore } from "./queryBuilder"; import { useModalStore } from "../modal"; import { defineAsyncComponent, markRaw } from "vue"; +import { useAbilityStore } from "../ability"; export const useQueryStoreStore = defineStore("queryStore", { state: () => { @@ -32,19 +33,20 @@ export const useQueryStoreStore = defineStore("queryStore", { triggerSave() { const queryBuilderStore = useQueryBuilderStore(); const modalStore = useModalStore(); - if (queryBuilderStore.activeQueryId == undefined) { - modalStore.openModal( - markRaw( - defineAsyncComponent(() => import("@/components/admin/settings/queryStore/CreateQueryStoreModal.vue")) - ) - ); - } else { + const abilityStore = useAbilityStore(); + if (queryBuilderStore.activeQueryId != undefined && abilityStore.can("update", "settings", "query_store")) { modalStore.openModal( markRaw( defineAsyncComponent(() => import("@/components/admin/settings/queryStore/UpdateQueryStoreModal.vue")) ), queryBuilderStore.activeQueryId ); + } else { + modalStore.openModal( + markRaw( + defineAsyncComponent(() => import("@/components/admin/settings/queryStore/CreateQueryStoreModal.vue")) + ) + ); } }, async createQueryStore(query: CreateQueryViewModel): Promise> {