Skip to content

Commit

Permalink
fix: unblock component list loading from pipeline runs
Browse files Browse the repository at this point in the history
  • Loading branch information
sahil143 committed Dec 30, 2024
1 parent e265f47 commit e9dd53c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
26 changes: 15 additions & 11 deletions src/components/Components/ComponentsListView/ComponentListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,16 @@ const ComponentListView: React.FC<React.PropsWithChildren<ComponentListViewProps
const componentPACStates = usePACStatesForComponents(components);

const componentsWithLatestBuild = React.useMemo(() => {
if (!componentsLoaded || componentsError || !pipelineRunsLoaded || pipelineRunsError) {
if (!componentsLoaded || componentsError) {
return [];
}
return components.map((c) => ({
...c,
latestBuildPipelineRun: pipelineRuns.find(
latestBuildPipelineRun: pipelineRuns?.find(
(plr) => plr.metadata?.labels?.[PipelineRunLabel.COMPONENT] === c.metadata.name,
),
}));
}, [
components,
componentsError,
componentsLoaded,
pipelineRuns,
pipelineRunsError,
pipelineRunsLoaded,
]);
}, [components, componentsError, componentsLoaded, pipelineRuns]);

const statusFilters = React.useMemo(
() => (statusFiltersParam ? statusFiltersParam.split(',') : []),
Expand Down Expand Up @@ -207,6 +200,16 @@ const ComponentListView: React.FC<React.PropsWithChildren<ComponentListViewProps
that run together form an application.
</Text>
</TextContent>
{pipelineRunsLoaded && pipelineRunsError ? (
<Alert
className="pf-v5-u-mt-md"
variant={AlertVariant.warning}
isInline
title="Error while fetching pipeline runs"
>
{(pipelineRunsError as { message: string })?.message}{' '}
</Alert>
) : null}
{gettingStartedCard}
{componentsLoaded && pipelineRunsLoaded && pendingCount > 0 && !mergeAlertHidden ? (
<Alert
Expand Down Expand Up @@ -253,7 +256,8 @@ const ComponentListView: React.FC<React.PropsWithChildren<ComponentListViewProps
aria-label="Components List"
Header={ComponentsListHeader}
Row={ComponentsListRow}
loaded={componentsLoaded && pipelineRunsLoaded}
loaded={componentsLoaded}
customData={{ pipelineRunsLoaded }}
getRowProps={(obj: ComponentKind) => ({
id: `${obj.metadata.name}-component-list-item`,
'aria-label': obj.metadata.name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { Link } from 'react-router-dom';
import { Button, Flex, FlexItem } from '@patternfly/react-core';
import { Button, Flex, FlexItem, Skeleton } from '@patternfly/react-core';
import { PacStatesForComponents } from '../../../hooks/usePACStatesForComponents';
import { RowFunctionArgs, TableData } from '../../../shared';
import ActionMenu from '../../../shared/components/action-menu/ActionMenu';
Expand All @@ -27,7 +27,7 @@ export const getContainerImageLink = (url: string) => {

const ComponentsListRow: React.FC<
RowFunctionArgs<ComponentWithLatestBuildPipeline, PacStatesForComponents>
> = ({ obj: component }) => {
> = ({ obj: component, customData }) => {
const { workspace } = useWorkspaceInfo();
const applicationName = component.spec.application;
const name = component.metadata.name;
Expand Down Expand Up @@ -81,7 +81,11 @@ const ComponentsListRow: React.FC<
</TableData>
<TableData className={componentsTableColumnClasses.latestBuild}>
<div className="component-list-view__build-completion">
<PipelineRunStatus pipelineRun={component.latestBuildPipelineRun} />
{component.latestBuildPipelineRun || customData.pipelineRunsLoaded ? (
<PipelineRunStatus pipelineRun={component.latestBuildPipelineRun} />
) : (
<Skeleton />
)}
<div>
{commit ? (
<>
Expand Down

0 comments on commit e9dd53c

Please sign in to comment.