Skip to content

Commit 04ab3eb

Browse files
authored
Merge pull request #44 from testcara/KFLUXUI-190
fix(KFLUXUI-190): use status.managedProcessing to get the pipelineRun for Release
2 parents d2d5200 + 1eb39ce commit 04ab3eb

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

src/components/Releases/ReleaseOverviewTab.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,22 @@ import { useReleaseStatus } from '../../hooks/useReleaseStatus';
1717
import { useWorkspaceResource } from '../../hooks/useWorkspaceResource';
1818
import { RouterParams } from '../../routes/utils';
1919
import { Timestamp } from '../../shared/components/timestamp/Timestamp';
20+
import { ReleaseKind } from '../../types/release';
2021
import { calculateDuration } from '../../utils/pipeline-utils';
2122
import MetadataList from '../MetadataList';
2223
import { StatusIconWithText } from '../StatusIcon/StatusIcon';
2324
import { useWorkspaceInfo } from '../Workspace/useWorkspaceInfo';
2425

26+
const getPipelineRunFromRelease = (release: ReleaseKind): string => {
27+
// backward compatibility until https://issues.redhat.com/browse/RELEASE-1109 is released.
28+
return release.status?.processing?.pipelineRun ?? release.status?.managedProcessing?.pipelineRun;
29+
};
30+
2531
const ReleaseOverviewTab: React.FC = () => {
2632
const { releaseName } = useParams<RouterParams>();
2733
const { namespace, workspace } = useWorkspaceInfo();
2834
const [release] = useRelease(workspace, namespace, releaseName);
29-
const [pipelineRun, prWorkspace] = useWorkspaceResource(release.status?.processing?.pipelineRun);
35+
const [pipelineRun, prWorkspace] = useWorkspaceResource(getPipelineRunFromRelease(release));
3036
const [releasePlan, releasePlanLoaded] = useReleasePlan(
3137
namespace,
3238
workspace,
@@ -128,12 +134,6 @@ const ReleaseOverviewTab: React.FC = () => {
128134
<>{release.status?.target ?? '-'}</>
129135
</DescriptionListDescription>
130136
</DescriptionListGroup>
131-
<DescriptionListGroup>
132-
<DescriptionListTerm>Release Strategy</DescriptionListTerm>
133-
<DescriptionListDescription>
134-
{release.status?.processing?.releaseStrategy?.split('/')[1] ?? '-'}
135-
</DescriptionListDescription>
136-
</DescriptionListGroup>
137137
<DescriptionListGroup>
138138
<DescriptionListTerm>Pipeline Run</DescriptionListTerm>
139139
<DescriptionListDescription>

src/components/Releases/__tests__/ReleaseOverviewTab.spec.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { render, screen } from '@testing-library/react';
22
import { createK8sWatchResourceMock, createUseWorkspaceInfoMock } from '../../../utils/test-utils';
3-
import { mockReleases } from '../__data__/mock-release-data';
3+
import { mockReleases, mockReleaseWithManagedProcessing } from '../__data__/mock-release-data';
44
import ReleaseOverviewTab from '../ReleaseOverviewTab';
55

66
jest.mock('react-router-dom', () => ({
@@ -55,4 +55,12 @@ describe('ReleaseOverviewTab', () => {
5555
'/workspaces/target-ws/applications/test-app/pipelineruns/test-pipelinerun',
5656
);
5757
});
58+
59+
it('should render correct details if managedProcessing', () => {
60+
render(<ReleaseOverviewTab release={mockReleaseWithManagedProcessing} />);
61+
expect(screen.getByText('Pipeline Run')).toBeVisible();
62+
expect(screen.getByRole('link', { name: 'test-pipelinerun' }).getAttribute('href')).toBe(
63+
'/workspaces/target-ws/applications/test-app/pipelineruns/test-pipelinerun',
64+
);
65+
});
5866
});

src/types/release.ts

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ export type ReleaseKind = K8sResourceCommon & {
1515
startTime?: string;
1616
completionTime?: string;
1717
automated?: boolean;
18+
managedProcessing?: {
19+
completionTime?: string;
20+
pipelineRun?: string;
21+
startTime?: string;
22+
roleBinding?: string;
23+
};
24+
// keep this for backward compatibility
1825
processing?: {
1926
target?: string;
2027
pipelineRun?: string;

0 commit comments

Comments
 (0)