@@ -10,18 +10,20 @@ export default function Component({ service }) {
10
10
}
11
11
12
12
const MAX_ALLOWED_FIELDS = 4 ;
13
- if ( widget . fields ? .length > MAX_ALLOWED_FIELDS ) {
13
+ if ( widget . fields . length > MAX_ALLOWED_FIELDS ) {
14
14
widget . fields = widget . fields . slice ( 0 , MAX_ALLOWED_FIELDS ) ;
15
15
}
16
16
17
17
const { data : appsData , error : appsError } = useWidgetAPI ( widget , "applications" ) ;
18
18
19
- const appCounts = widget . fields ? .map ( ( status ) => {
19
+ const appCounts = widget . fields . map ( ( status ) => {
20
20
if ( status === "apps" ) {
21
21
return { status, count : appsData ?. items ?. length } ;
22
22
}
23
23
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 ( ) ,
25
27
) . length ;
26
28
return { status, count } ;
27
29
} ) ;
@@ -33,7 +35,7 @@ export default function Component({ service }) {
33
35
if ( ! appsData ) {
34
36
return (
35
37
< Container service = { service } >
36
- { appCounts ? .map ( ( a ) => (
38
+ { appCounts . map ( ( a ) => (
37
39
< Block label = { `argocd.${ a . status } ` } key = { a . status } />
38
40
) ) }
39
41
</ Container >
@@ -42,7 +44,7 @@ export default function Component({ service }) {
42
44
43
45
return (
44
46
< Container service = { service } >
45
- { appCounts ? .map ( ( a ) => (
47
+ { appCounts . map ( ( a ) => (
46
48
< Block label = { `argocd.${ a . status } ` } key = { a . status } value = { a . count } />
47
49
) ) }
48
50
</ Container >
0 commit comments