11import * as React from 'react' ;
22import { RouteComponentProps } from 'react-router' ;
3- import { ApplicationSetKind , ApplicationSetModel } from '../../models/ApplicationSetModel' ;
4- import {
5- Badge ,
6- PageSection ,
7- Title ,
8- DescriptionList ,
9- Flex ,
10- FlexItem ,
11- } from '@patternfly/react-core' ;
12- import BaseDetailsSummary , { DetailsDescriptionGroup } from '../shared/BaseDetailsSummary/BaseDetailsSummary' ;
13- import { getAppSetGeneratorCount , getAppSetStatus } from '../../utils/gitops' ;
14- import { useK8sWatchResource , ResourceLink } from '@openshift-console/dynamic-plugin-sdk' ;
3+
4+ import { ResourceLink , useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk' ;
5+ import { Badge , DescriptionList , Flex , FlexItem , PageSection , Title } from '@patternfly/react-core' ;
6+
157import { ApplicationKind , ApplicationModel } from '../../models/ApplicationModel' ;
16- import { Conditions } from '../../utils/components/Conditions/Conditions ' ;
8+ import { ApplicationSetKind , ApplicationSetModel } from '../../models/ApplicationSetModel ' ;
179import HealthStatus from '../../Statuses/HealthStatus' ;
10+ import { Conditions } from '../../utils/components/Conditions/Conditions' ;
11+ import { getAppSetGeneratorCount , getAppSetStatus } from '../../utils/gitops' ;
12+ import BaseDetailsSummary , {
13+ DetailsDescriptionGroup ,
14+ } from '../shared/BaseDetailsSummary/BaseDetailsSummary' ;
15+
1816import './AppSetDetailsTab.scss' ;
1917
2018type AppSetDetailsTabProps = RouteComponentProps < { ns : string ; name : string } > & {
@@ -23,30 +21,32 @@ type AppSetDetailsTabProps = RouteComponentProps<{ ns: string; name: string }> &
2321
2422const AppSetDetailsTab : React . FC < AppSetDetailsTabProps > = ( { obj } ) => {
2523 const namespace = obj ?. metadata ?. namespace ;
26- if ( ! obj ) return null ;
2724
28- const status = obj . status || { } ;
29- const spec = obj . spec || { } ;
30- const totalGenerators = getAppSetGeneratorCount ( obj ) ;
31- const appSetStatus = getAppSetStatus ( obj ) ;
32-
3325 // Get applications to count generated apps
3426 const [ applications ] = useK8sWatchResource < ApplicationKind [ ] > ( {
3527 groupVersionKind : {
3628 group : ApplicationModel . apiGroup ,
3729 version : ApplicationModel . apiVersion ,
3830 kind : ApplicationModel . kind ,
3931 } ,
40- namespace : namespace || obj . metadata ?. namespace ,
32+ namespace : namespace || obj ? .metadata ?. namespace ,
4133 isList : true ,
4234 } ) ;
4335
36+ if ( ! obj ) return null ;
37+
38+ const status = obj . status || { } ;
39+ const spec = obj . spec || { } ;
40+ const totalGenerators = getAppSetGeneratorCount ( obj ) ;
41+ const appSetStatus = getAppSetStatus ( obj ) ;
42+
4443 // Count applications owned by this ApplicationSet
45- const generatedAppsCount = applications ?. filter ( app =>
46- app . metadata ?. ownerReferences ?. some ( owner =>
47- owner . kind === obj . kind && owner . name === obj . metadata ?. name
48- )
49- ) . length || 0 ;
44+ const generatedAppsCount =
45+ applications ?. filter ( ( app ) =>
46+ app . metadata ?. ownerReferences ?. some (
47+ ( owner ) => owner . kind === obj . kind && owner . name === obj . metadata ?. name ,
48+ ) ,
49+ ) . length || 0 ;
5050
5151 return (
5252 < >
@@ -66,52 +66,60 @@ const AppSetDetailsTab: React.FC<AppSetDetailsTabProps> = ({ obj }) => {
6666 < Flex flex = { { default : 'flex_2' } } direction = { { default : 'column' } } >
6767 < FlexItem >
6868 < DescriptionList className = "pf-c-description-list" >
69- < DetailsDescriptionGroup
70- title = "Status"
71- help = "Current health status of the ApplicationSet."
72- >
73- < HealthStatus status = { appSetStatus } />
74- </ DetailsDescriptionGroup >
75-
76- < DetailsDescriptionGroup
77- title = "Generated Apps"
78- help = "Number of applications generated by this ApplicationSet."
79- >
80- < Badge isRead color = "blue" > { generatedAppsCount } application{ generatedAppsCount !== 1 ? 's' : '' } </ Badge >
81- </ DetailsDescriptionGroup >
82-
83- < DetailsDescriptionGroup
84- title = "Generators"
85- help = "Number of generators configured in this ApplicationSet."
86- >
87- < Badge isRead color = "grey" > { totalGenerators } generator{ totalGenerators !== 1 ? 's' : '' } </ Badge >
88- </ DetailsDescriptionGroup >
89-
90- < DetailsDescriptionGroup
91- title = "App Project"
92- help = "Argo CD project that this ApplicationSet belongs to."
93- >
94- < ResourceLink
95- namespace = { obj ?. metadata ?. namespace }
96- groupVersionKind = { {
97- group : 'argoproj.io' ,
98- version : 'v1alpha1' ,
99- kind : 'AppProject' ,
100- } }
101- name = { spec . template ?. spec ?. project || 'default' }
102- />
103- </ DetailsDescriptionGroup >
104-
105- { spec . template ?. spec ?. source ?. repoURL && (
106- < DetailsDescriptionGroup
107- title = "Repository"
108- help = "Git repository URL where the ApplicationSet configuration is stored."
109- >
110- < a href = { spec . template . spec . source . repoURL } target = "_blank" rel = "noopener noreferrer" >
111- { spec . template . spec . source . repoURL }
112- </ a >
113- </ DetailsDescriptionGroup >
114- ) }
69+ < DetailsDescriptionGroup
70+ title = "Status"
71+ help = "Current health status of the ApplicationSet."
72+ >
73+ < HealthStatus status = { appSetStatus } />
74+ </ DetailsDescriptionGroup >
75+
76+ < DetailsDescriptionGroup
77+ title = "Generated Apps"
78+ help = "Number of applications generated by this ApplicationSet."
79+ >
80+ < Badge isRead color = "blue" >
81+ { generatedAppsCount } application{ generatedAppsCount !== 1 ? 's' : '' }
82+ </ Badge >
83+ </ DetailsDescriptionGroup >
84+
85+ < DetailsDescriptionGroup
86+ title = "Generators"
87+ help = "Number of generators configured in this ApplicationSet."
88+ >
89+ < Badge isRead color = "grey" >
90+ { totalGenerators } generator{ totalGenerators !== 1 ? 's' : '' }
91+ </ Badge >
92+ </ DetailsDescriptionGroup >
93+
94+ < DetailsDescriptionGroup
95+ title = "App Project"
96+ help = "Argo CD project that this ApplicationSet belongs to."
97+ >
98+ < ResourceLink
99+ namespace = { obj ?. metadata ?. namespace }
100+ groupVersionKind = { {
101+ group : 'argoproj.io' ,
102+ version : 'v1alpha1' ,
103+ kind : 'AppProject' ,
104+ } }
105+ name = { spec . template ?. spec ?. project || 'default' }
106+ />
107+ </ DetailsDescriptionGroup >
108+
109+ { spec . template ?. spec ?. source ?. repoURL && (
110+ < DetailsDescriptionGroup
111+ title = "Repository"
112+ help = "Git repository URL where the ApplicationSet configuration is stored."
113+ >
114+ < a
115+ href = { spec . template . spec . source . repoURL }
116+ target = "_blank"
117+ rel = "noopener noreferrer"
118+ >
119+ { spec . template . spec . source . repoURL }
120+ </ a >
121+ </ DetailsDescriptionGroup >
122+ ) }
115123 </ DescriptionList >
116124 </ FlexItem >
117125 </ Flex >
0 commit comments