Skip to content

Commit

Permalink
chore(backport release-0.8): fix(ui): don't fetch freight/promo infor…
Browse files Browse the repository at this point in the history
…mation if name is null (#2317)

Co-authored-by: Remington Breeze <remington@breeze.software>
  • Loading branch information
akuitybot and rbreeze authored Jul 19, 2024
1 parent 433ef87 commit ab2374a
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions ui/src/features/project/list/project-item/stage-popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,27 @@ import {
import { Freight, FreightReference, Promotion, Stage } from '@ui/gen/v1alpha1/generated_pb';

export const StagePopover = ({ project, stage }: { project?: string; stage?: Stage }) => {
const { data: promotionData } = useQuery(getPromotion, {
name: stage?.status?.lastPromotion?.name,
project
});
const { data: promotionData } = useQuery(
getPromotion,
{
name: stage?.status?.lastPromotion?.name,
project
},
{
enabled: !!stage?.status?.lastPromotion?.name
}
);
const promotion = useMemo(() => promotionData?.result?.value as Promotion, [promotionData]);

const transport = useTransport();

const freightData = useQueries({
queries: Object.values(stage?.status?.freightHistory[0] || {}).map(
queries: Object.values(stage?.status?.freightHistory[0].items || {}).map(
(freight: FreightReference) => {
return createQueryOptions(getFreight, { project, name: freight.name }, { transport });
return {
...createQueryOptions(getFreight, { project, name: freight.name }, { transport }),
enabled: !!freight.name
};
}
)
});
Expand All @@ -47,7 +56,7 @@ export const StagePopover = ({ project, stage }: { project?: string; stage?: Sta
</div>
</div>
<_label>CURRENT FREIGHT</_label>
{Object.values(stage?.status?.freightHistory[0] || {}).map((_, i) => (
{Object.values(stage?.status?.freightHistory[0].items || {}).map((_, i) => (
<div className='flex items-center mb-2' key={i}>
<FontAwesomeIcon icon={faBox} className='mr-2' />
<div>{getAlias(freightData[i]?.data?.result?.value as Freight)}</div>
Expand Down

0 comments on commit ab2374a

Please sign in to comment.