Change workflow queries to use API to get global workflows (#1688)
This commit is contained in:
@@ -4,6 +4,7 @@ import { useCredentialGetter } from "@/hooks/useCredentialGetter";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { WorkflowApiResponse } from "./types/workflowTypes";
|
||||
import { apiPathPrefix } from "@/util/env";
|
||||
import { useGlobalWorkflowsQuery } from "./hooks/useGlobalWorkflowsQuery";
|
||||
|
||||
type Props = {
|
||||
workflowPermanentId: string;
|
||||
@@ -11,6 +12,7 @@ type Props = {
|
||||
|
||||
function WorkflowTitle({ workflowPermanentId }: Props) {
|
||||
const credentialGetter = useCredentialGetter();
|
||||
const { data: globalWorkflows } = useGlobalWorkflowsQuery();
|
||||
|
||||
const {
|
||||
data: workflow,
|
||||
@@ -20,10 +22,18 @@ function WorkflowTitle({ workflowPermanentId }: Props) {
|
||||
queryKey: ["workflow", workflowPermanentId],
|
||||
queryFn: async () => {
|
||||
const client = await getClient(credentialGetter);
|
||||
const isGlobalWorkflow = globalWorkflows?.some(
|
||||
(workflow) => workflow.workflow_permanent_id === workflowPermanentId,
|
||||
);
|
||||
const params = new URLSearchParams();
|
||||
if (isGlobalWorkflow) {
|
||||
params.set("template", "true");
|
||||
}
|
||||
return client
|
||||
.get(`${apiPathPrefix}/workflows/${workflowPermanentId}`)
|
||||
.get(`${apiPathPrefix}/workflows/${workflowPermanentId}`, { params })
|
||||
.then((response) => response.data);
|
||||
},
|
||||
enabled: !!globalWorkflows && !!workflowPermanentId,
|
||||
});
|
||||
|
||||
if (isLoading) {
|
||||
|
||||
Reference in New Issue
Block a user