From ab2374ab3ae3c72ca1c10e73e3dddc7bb392cb0e Mon Sep 17 00:00:00 2001 From: akuitybot <105087302+akuitybot@users.noreply.github.com> Date: Fri, 19 Jul 2024 11:07:28 -0700 Subject: [PATCH] chore(backport release-0.8): fix(ui): don't fetch freight/promo information if name is null (#2317) Co-authored-by: Remington Breeze --- .../list/project-item/stage-popover.tsx | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/ui/src/features/project/list/project-item/stage-popover.tsx b/ui/src/features/project/list/project-item/stage-popover.tsx index 8c3391472..bcf36ee68 100644 --- a/ui/src/features/project/list/project-item/stage-popover.tsx +++ b/ui/src/features/project/list/project-item/stage-popover.tsx @@ -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 + }; } ) }); @@ -47,7 +56,7 @@ export const StagePopover = ({ project, stage }: { project?: string; stage?: Sta <_label>CURRENT FREIGHT - {Object.values(stage?.status?.freightHistory[0] || {}).map((_, i) => ( + {Object.values(stage?.status?.freightHistory[0].items || {}).map((_, i) => (
{getAlias(freightData[i]?.data?.result?.value as Freight)}