Skip to content

Commit b4e9f09

Browse files
committed
Remove optional chaining op on widget.fields
1 parent 63e0765 commit b4e9f09

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/widgets/argocd/component.jsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@ export default function Component({ service }) {
1010
}
1111

1212
const MAX_ALLOWED_FIELDS = 4;
13-
if (widget.fields?.length > MAX_ALLOWED_FIELDS) {
13+
if (widget.fields.length > MAX_ALLOWED_FIELDS) {
1414
widget.fields = widget.fields.slice(0, MAX_ALLOWED_FIELDS);
1515
}
1616

1717
const { data: appsData, error: appsError } = useWidgetAPI(widget, "applications");
1818

19-
const appCounts = widget.fields?.map((status) => {
19+
const appCounts = widget.fields.map((status) => {
2020
if (status === "apps") {
2121
return { status, count: appsData?.items?.length };
2222
}
2323
const count = appsData?.items?.filter(
24-
(item) => item.status?.sync?.status.toLowerCase() === status.toLowerCase() || item.status?.health?.status.toLowerCase() === status.toLowerCase(),
24+
(item) =>
25+
item.status?.sync?.status.toLowerCase() === status.toLowerCase() ||
26+
item.status?.health?.status.toLowerCase() === status.toLowerCase(),
2527
).length;
2628
return { status, count };
2729
});
@@ -33,7 +35,7 @@ export default function Component({ service }) {
3335
if (!appsData) {
3436
return (
3537
<Container service={service}>
36-
{appCounts?.map((a) => (
38+
{appCounts.map((a) => (
3739
<Block label={`argocd.${a.status}`} key={a.status} />
3840
))}
3941
</Container>
@@ -42,7 +44,7 @@ export default function Component({ service }) {
4244

4345
return (
4446
<Container service={service}>
45-
{appCounts?.map((a) => (
47+
{appCounts.map((a) => (
4648
<Block label={`argocd.${a.status}`} key={a.status} value={a.count} />
4749
))}
4850
</Container>

0 commit comments

Comments
 (0)