From b8afffc570630e03bdde996800380edce9c1b1cf Mon Sep 17 00:00:00 2001 From: Blake Date: Wed, 18 Feb 2026 08:16:07 -0500 Subject: [PATCH] fix: use correct workflow name/version in execution breadcrumbs Previously, getTaskOrWorkflowName and getTaskOrWorkflowVersion always returned the launch plan name/version, even for workflow executions. Now they check the resource type and return workflowId fields for workflows, matching the existing isExecutionTaskOrWorkflow logic. Signed-off-by: Blake --- .../async/executionContext.test.ts | 78 +++++++++++++++++++ .../Breadcrumbs/async/executionContext.ts | 16 ++-- 2 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 packages/oss-console/src/components/Breadcrumbs/async/executionContext.test.ts diff --git a/packages/oss-console/src/components/Breadcrumbs/async/executionContext.test.ts b/packages/oss-console/src/components/Breadcrumbs/async/executionContext.test.ts new file mode 100644 index 000000000..499cf6afa --- /dev/null +++ b/packages/oss-console/src/components/Breadcrumbs/async/executionContext.test.ts @@ -0,0 +1,78 @@ +import { ResourceType } from '../../../models/Common/types'; +import { Execution } from '../../../models/Execution/types'; +import { + isExecutionTaskOrWorkflow, + getTaskOrWorkflowName, + getTaskOrWorkflowVersion, +} from './executionContext'; + +const makeExecution = (overrides: { + launchPlanResourceType: ResourceType; + launchPlanName: string; + launchPlanVersion: string; + workflowIdName: string; + workflowIdVersion: string; +}): Execution => + ({ + spec: { + launchPlan: { + resourceType: overrides.launchPlanResourceType, + name: overrides.launchPlanName, + version: overrides.launchPlanVersion, + }, + }, + closure: { + workflowId: { + name: overrides.workflowIdName, + version: overrides.workflowIdVersion, + }, + }, + }) as unknown as Execution; + +describe('executionContext helpers', () => { + const taskExecution = makeExecution({ + launchPlanResourceType: ResourceType.TASK, + launchPlanName: 'my-task', + launchPlanVersion: 'task-v1', + workflowIdName: 'my-workflow', + workflowIdVersion: 'wf-v1', + }); + + const workflowExecution = makeExecution({ + launchPlanResourceType: ResourceType.WORKFLOW, + launchPlanName: 'my-launch-plan', + launchPlanVersion: 'lp-v1', + workflowIdName: 'my-workflow', + workflowIdVersion: 'wf-v1', + }); + + describe('isExecutionTaskOrWorkflow', () => { + it('returns TASK when launchPlan resourceType is TASK', () => { + expect(isExecutionTaskOrWorkflow(taskExecution)).toBe(ResourceType.TASK); + }); + + it('returns WORKFLOW when launchPlan resourceType is WORKFLOW', () => { + expect(isExecutionTaskOrWorkflow(workflowExecution)).toBe(ResourceType.WORKFLOW); + }); + }); + + describe('getTaskOrWorkflowName', () => { + it('returns launchPlan name for task executions', () => { + expect(getTaskOrWorkflowName(taskExecution)).toBe('my-task'); + }); + + it('returns workflowId name for workflow executions', () => { + expect(getTaskOrWorkflowName(workflowExecution)).toBe('my-workflow'); + }); + }); + + describe('getTaskOrWorkflowVersion', () => { + it('returns launchPlan version for task executions', () => { + expect(getTaskOrWorkflowVersion(taskExecution)).toBe('task-v1'); + }); + + it('returns workflowId version for workflow executions', () => { + expect(getTaskOrWorkflowVersion(workflowExecution)).toBe('wf-v1'); + }); + }); +}); diff --git a/packages/oss-console/src/components/Breadcrumbs/async/executionContext.ts b/packages/oss-console/src/components/Breadcrumbs/async/executionContext.ts index 3e27034d2..4a45f3199 100644 --- a/packages/oss-console/src/components/Breadcrumbs/async/executionContext.ts +++ b/packages/oss-console/src/components/Breadcrumbs/async/executionContext.ts @@ -49,18 +49,24 @@ const getExecutionData = async (projectId: string, domainId: string, executionId return executionData; }; -const isExecutionTaskOrWorkflow = (executionData: Execution) => { +export const isExecutionTaskOrWorkflow = (executionData: Execution) => { return executionData.spec.launchPlan.resourceType === ResourceType.TASK ? ResourceType.TASK : ResourceType.WORKFLOW; }; -const getTaskOrWorkflowName = (executionData: Execution): string => { - return executionData.spec.launchPlan.name; +export const getTaskOrWorkflowName = (executionData: Execution): string => { + if (isExecutionTaskOrWorkflow(executionData) === ResourceType.TASK) { + return executionData.spec.launchPlan.name; + } + return executionData.closure.workflowId.name; }; -const getTaskOrWorkflowVersion = (executionData: Execution): string => { - return executionData.spec.launchPlan.version; +export const getTaskOrWorkflowVersion = (executionData: Execution): string => { + if (isExecutionTaskOrWorkflow(executionData) === ResourceType.TASK) { + return executionData.spec.launchPlan.version; + } + return executionData.closure.workflowId.version; }; const getExecutionValue = (location: Location) => {