Jon/sky 6375 alter how show all code works (#3445)

This commit is contained in:
Jonathan Dobson
2025-09-16 16:32:15 -04:00
committed by GitHub
parent d57fccfaaf
commit f2146080ce
6 changed files with 273 additions and 172 deletions

View File

@@ -1,5 +1,6 @@
import { useLocation } from "react-router-dom";
import type { WorkflowParameter } from "./types/workflowTypes";
import { WorkflowApiResponse } from "@/routes/workflows/types/workflowTypes";
type Location = ReturnType<typeof useLocation>;
@@ -77,3 +78,49 @@ export const formatDuration = (duration: Duration): string => {
return `${duration.second}s`;
}
};
export const getOrderedBlockLabels = (workflow?: WorkflowApiResponse) => {
if (!workflow) {
return [];
}
const blockLabels = workflow.workflow_definition.blocks.map(
(block) => block.label,
);
return blockLabels;
};
const getCommentForBlockWithoutCode = (blockLabel: string) => {
return `
# block '${blockLabel}' code goes here
`;
};
export const getCode = (
orderedBlockLabels: string[],
blockScripts?: {
[blockName: string]: string;
},
): string[] => {
const blockCode: string[] = [];
const startBlockCode = blockScripts?.__start_block__;
if (startBlockCode) {
blockCode.push(startBlockCode);
}
for (const blockLabel of orderedBlockLabels) {
const code = blockScripts?.[blockLabel];
if (!code) {
blockCode.push(getCommentForBlockWithoutCode(blockLabel));
continue;
}
blockCode.push(`${code}
`);
}
return blockCode;
};