From b4e9f096f3b3ec02d9bf095f7ea6a28a9760f8d2 Mon Sep 17 00:00:00 2001 From: Felix Cornelius Date: Tue, 19 Nov 2024 22:38:18 +0100 Subject: [PATCH] Remove optional chaining op on `widget.fields` --- src/widgets/argocd/component.jsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/widgets/argocd/component.jsx b/src/widgets/argocd/component.jsx index 4421ebeb7..d3b519363 100644 --- a/src/widgets/argocd/component.jsx +++ b/src/widgets/argocd/component.jsx @@ -10,18 +10,20 @@ export default function Component({ service }) { } const MAX_ALLOWED_FIELDS = 4; - if (widget.fields?.length > MAX_ALLOWED_FIELDS) { + if (widget.fields.length > MAX_ALLOWED_FIELDS) { widget.fields = widget.fields.slice(0, MAX_ALLOWED_FIELDS); } const { data: appsData, error: appsError } = useWidgetAPI(widget, "applications"); - const appCounts = widget.fields?.map((status) => { + const appCounts = widget.fields.map((status) => { if (status === "apps") { return { status, count: appsData?.items?.length }; } const count = appsData?.items?.filter( - (item) => item.status?.sync?.status.toLowerCase() === status.toLowerCase() || item.status?.health?.status.toLowerCase() === status.toLowerCase(), + (item) => + item.status?.sync?.status.toLowerCase() === status.toLowerCase() || + item.status?.health?.status.toLowerCase() === status.toLowerCase(), ).length; return { status, count }; }); @@ -33,7 +35,7 @@ export default function Component({ service }) { if (!appsData) { return ( - {appCounts?.map((a) => ( + {appCounts.map((a) => ( ))} @@ -42,7 +44,7 @@ export default function Component({ service }) { return ( - {appCounts?.map((a) => ( + {appCounts.map((a) => ( ))}