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> {