Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unblock component list loading from pipeline runs #60

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading