Unverified Commit 8ddd13ee authored by Alireza Heidari's avatar Alireza Heidari Committed by mvdbeek
Browse files

Prevents workflow execution when credentials are missing

Disables the run button and displays informative tooltip when required tool credentials are not provided by the user.

Ensures workflows cannot be executed with incomplete credential configuration, preventing runtime errors and improving user experience through clear feedback.
parent 56d485f6
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -21,7 +21,8 @@
                <ButtonSpinner
                    id="run-workflow"
                    title="Run Workflow"
                    :disabled="!canRunOnHistory"
                    :tooltip="runButtonTooltip"
                    :disabled="!canRunOnHistory || hasCredentialErrors"
                    :wait="showExecuting"
                    @onClick="onExecute" />
            </div>
@@ -96,6 +97,7 @@ import FormDisplay from "components/Form/FormDisplay";
import FormElement from "components/Form/FormElement";
import { mapState } from "pinia";

import { useUserMultiToolCredentials } from "@/composables/userMultiToolCredentials";
import { useHistoryStore } from "@/stores/historyStore";
import { useToolsServiceCredentialsDefinitionsStore } from "@/stores/toolsServiceCredentialsDefinitionsStore";
import { useUserStore } from "@/stores/userStore";
@@ -212,6 +214,21 @@ export default {
        canRunOnHistory() {
            return this.shouldRunOnNewHistory || this.canMutateCurrentHistory;
        },
        hasCredentialErrors() {
            if (this.credentialTools.length) {
                const { hasUserProvidedAllRequiredToolsServiceCredentials } = useUserMultiToolCredentials(
                    this.credentialTools,
                );
                return !hasUserProvidedAllRequiredToolsServiceCredentials.value;
            }
            return false;
        },
        runButtonTooltip() {
            if (this.hasCredentialErrors) {
                return "Please provide all required credentials before running the workflow.";
            }
            return "Run workflow";
        },
    },
    methods: {
        getReplaceParams(inputs) {
+12 −1
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ import { isWorkflowInput } from "@/components/Workflow/constants";
import { useConfig } from "@/composables/config";
import { usePersistentToggle } from "@/composables/persistentToggle";
import { usePanels } from "@/composables/usePanels";
import { useUserMultiToolCredentials } from "@/composables/userMultiToolCredentials";
import { useWorkflowInstance } from "@/composables/useWorkflowInstance";
import { provideScopedWorkflowStores } from "@/composables/workflowStores";
import { useHistoryStore } from "@/stores/historyStore";
@@ -357,6 +358,16 @@ const credentialTools = computed<ToolIdentifier[]>(() => {
    return toolIdentifiers;
});

const hasCredentialErrors = computed(() => {
    if (credentialTools.value.length) {
        const { hasUserProvidedAllRequiredToolsServiceCredentials } = useUserMultiToolCredentials(
            credentialTools.value,
        );
        return !hasUserProvidedAllRequiredToolsServiceCredentials.value;
    }
    return false;
});

onBeforeMount(() => {
    const credentialSteps = props.model.steps.filter(
        (step: any) => step.step_type === "tool" && step.credentials?.length,
@@ -386,7 +397,7 @@ onBeforeMount(() => {
            <div class="mb-2">
                <WorkflowNavigationTitle
                    :workflow-id="model.runData.workflow_id"
                    :run-disabled="hasValidationErrors || !canRunOnHistory"
                    :run-disabled="hasValidationErrors || !canRunOnHistory || hasCredentialErrors"
                    :run-waiting="waitingForRequest"
                    :valid-rerun="isValidRerun"
                    @on-execute="onExecute">