From 84985b245a899e695d10cff0898721daf37ed89e Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 26 Sep 2024 11:37:48 +0200 Subject: [PATCH] fix: disabled forms for analysts --- src/lib/elements/forms/button.svelte | 4 +++- src/lib/stores/roles.ts | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/elements/forms/button.svelte b/src/lib/elements/forms/button.svelte index fc643e0af3..0e299c66e1 100644 --- a/src/lib/elements/forms/button.svelte +++ b/src/lib/elements/forms/button.svelte @@ -4,6 +4,7 @@ import { readable } from 'svelte/store'; import type { FormContext } from './form.svelte'; import { multiAction, type MultiActionArray } from '$lib/actions/multi-actions'; + import { isAnalyst } from '$lib/stores/roles'; export let submit = false; export let secondary = false; @@ -26,11 +27,12 @@ export let actions: MultiActionArray = []; export let submissionLoader = false; + const inForm = hasContext('form') && submit; const isSubmitting = hasContext('form') ? getContext('form').isSubmitting : readable(false); - $: internalDisabled = (submit && $isSubmitting) || disabled; + $: internalDisabled = (submit && $isSubmitting) || disabled || (inForm && $isAnalyst); function track() { if (!event) { diff --git a/src/lib/stores/roles.ts b/src/lib/stores/roles.ts index b7b79f5008..df6ba3ad66 100644 --- a/src/lib/stores/roles.ts +++ b/src/lib/stores/roles.ts @@ -7,6 +7,7 @@ export const scopes = derived(page, ($page) => $page.data?.scopes ?? []); export const isDeveloper = derived(roles, ($roles) => $roles.includes('developer')); export const isBilling = derived(roles, ($roles) => $roles.includes('billing')); export const isOwner = derived(roles, ($roles) => $roles.includes('owner')); +export const isAnalyst = derived(roles, ($roles) => $roles.includes('analyst')); export const canWriteDatabases = derived(scopes, ($scopes) => $scopes.includes('databases.write')); export const canWriteProjects = derived(scopes, ($scopes) => $scopes.includes('projects.write'));