Skip to content

Commit

Permalink
fix(KFLUXBUGS-1683): use status.managedProcessing to get the pipeline…
Browse files Browse the repository at this point in the history
…Run for Release
  • Loading branch information
testcara committed Dec 2, 2024
1 parent ed4ee3e commit f4ccba1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/components/Releases/ReleaseOverviewTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,22 @@ import { useReleaseStatus } from '../../hooks/useReleaseStatus';
import { useWorkspaceResource } from '../../hooks/useWorkspaceResource';
import { RouterParams } from '../../routes/utils';
import { Timestamp } from '../../shared/components/timestamp/Timestamp';
import { ReleaseKind } from '../../types/release';
import { calculateDuration } from '../../utils/pipeline-utils';
import MetadataList from '../MetadataList';
import { StatusIconWithText } from '../StatusIcon/StatusIcon';
import { useWorkspaceInfo } from '../Workspace/useWorkspaceInfo';

const getPipelineRunFromRelease = (release: ReleaseKind): string => {
// backward compatibility until https://issues.redhat.com/browse/RELEASE-1109 is released.
return release.status?.processing?.pipelineRun ?? release.status?.managedProcessing?.pipelineRun;
};

const ReleaseOverviewTab: React.FC = () => {
const { releaseName } = useParams<RouterParams>();
const { namespace, workspace } = useWorkspaceInfo();
const [release] = useRelease(workspace, namespace, releaseName);
const [pipelineRun, prWorkspace] = useWorkspaceResource(release.status?.processing?.pipelineRun);
const [pipelineRun, prWorkspace] = useWorkspaceResource(getPipelineRunFromRelease(release));
const [releasePlan, releasePlanLoaded] = useReleasePlan(
namespace,
workspace,
Expand Down Expand Up @@ -128,12 +134,6 @@ const ReleaseOverviewTab: React.FC = () => {
<>{release.status?.target ?? '-'}</>
</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Release Strategy</DescriptionListTerm>
<DescriptionListDescription>
{release.status?.processing?.releaseStrategy?.split('/')[1] ?? '-'}
</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Pipeline Run</DescriptionListTerm>
<DescriptionListDescription>
Expand Down
10 changes: 9 additions & 1 deletion src/components/Releases/__tests__/ReleaseOverviewTab.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render, screen } from '@testing-library/react';
import { createK8sWatchResourceMock, createUseWorkspaceInfoMock } from '../../../utils/test-utils';
import { mockReleases } from '../__data__/mock-release-data';
import { mockReleases, mockReleaseWithManagedProcessing } from '../__data__/mock-release-data';
import ReleaseOverviewTab from '../ReleaseOverviewTab';

jest.mock('react-router-dom', () => ({
Expand Down Expand Up @@ -55,4 +55,12 @@ describe('ReleaseOverviewTab', () => {
'/workspaces/target-ws/applications/test-app/pipelineruns/test-pipelinerun',
);
});

it('should render correct details if managedProcessing', () => {
render(<ReleaseOverviewTab release={mockReleaseWithManagedProcessing} />);
expect(screen.getByText('Pipeline Run')).toBeVisible();
expect(screen.getByRole('link', { name: 'test-pipelinerun' }).getAttribute('href')).toBe(
'/workspaces/target-ws/applications/test-app/pipelineruns/test-pipelinerun',
);
});
});
7 changes: 7 additions & 0 deletions src/types/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ export type ReleaseKind = K8sResourceCommon & {
startTime?: string;
completionTime?: string;
automated?: boolean;
managedProcessing?: {
completionTime?: string;
pipelineRun?: string;
startTime?: string;
roleBinding?: string;
};
// keep this for backward compatibility
processing?: {
target?: string;
pipelineRun?: string;
Expand Down

0 comments on commit f4ccba1

Please sign in to comment.