script gen post action (#3480)
This commit is contained in:
@@ -273,6 +273,7 @@ function RunWorkflowForm({
|
||||
cacheKey,
|
||||
cacheKeyValue,
|
||||
workflowPermanentId,
|
||||
status: "published",
|
||||
});
|
||||
|
||||
const [runWithCodeIsEnabled, setRunWithCodeIsEnabled] = useState(false);
|
||||
|
||||
@@ -214,6 +214,7 @@ function Workspace({
|
||||
cacheKey,
|
||||
cacheKeyValue,
|
||||
workflowPermanentId,
|
||||
status: "published",
|
||||
});
|
||||
|
||||
const { data: cacheKeyValues, isLoading: cacheKeyValuesLoading } =
|
||||
|
||||
@@ -8,6 +8,8 @@ type Props = {
|
||||
cacheKeyValue?: string;
|
||||
workflowPermanentId?: string;
|
||||
pollIntervalMs?: number;
|
||||
status?: string;
|
||||
workflowRunId?: string;
|
||||
};
|
||||
|
||||
function useBlockScriptsQuery({
|
||||
@@ -15,6 +17,8 @@ function useBlockScriptsQuery({
|
||||
cacheKeyValue,
|
||||
workflowPermanentId,
|
||||
pollIntervalMs,
|
||||
status,
|
||||
workflowRunId,
|
||||
}: Props) {
|
||||
const credentialGetter = useCredentialGetter();
|
||||
|
||||
@@ -25,6 +29,8 @@ function useBlockScriptsQuery({
|
||||
cacheKey,
|
||||
cacheKeyValue,
|
||||
pollIntervalMs,
|
||||
status,
|
||||
workflowRunId,
|
||||
],
|
||||
queryFn: async () => {
|
||||
const client = await getClient(credentialGetter, "sans-api-v1");
|
||||
@@ -33,6 +39,8 @@ function useBlockScriptsQuery({
|
||||
.post<ScriptBlocksResponse>(`/scripts/${workflowPermanentId}/blocks`, {
|
||||
cache_key: cacheKey ?? "",
|
||||
cache_key_value: cacheKeyValue ?? "",
|
||||
status: status ?? "published",
|
||||
workflow_run_id: workflowRunId ?? null,
|
||||
})
|
||||
.then((response) => response.data);
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@ function WorkflowRunCode(props?: Props) {
|
||||
cacheKeyValue,
|
||||
workflowPermanentId,
|
||||
pollIntervalMs: !isFinalized ? 3000 : undefined,
|
||||
status: "draft",
|
||||
workflowRunId: workflowRun?.workflow_run_id,
|
||||
});
|
||||
const orderedBlockLabels = getOrderedBlockLabels(workflow);
|
||||
const code = getCode(orderedBlockLabels, blockScripts).join("").trim();
|
||||
@@ -79,7 +81,15 @@ function WorkflowRunCode(props?: Props) {
|
||||
|
||||
useEffect(() => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["block-scripts", workflowPermanentId, cacheKey, cacheKeyValue],
|
||||
queryKey: [
|
||||
"block-scripts",
|
||||
workflowPermanentId,
|
||||
cacheKey,
|
||||
cacheKeyValue,
|
||||
undefined,
|
||||
"draft",
|
||||
workflowRun?.workflow_run_id,
|
||||
],
|
||||
});
|
||||
}, [queryClient, workflowRun, workflowPermanentId, cacheKey, cacheKeyValue]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user