@@ -12,11 +12,14 @@ import {
1212 getAppDefaultSyncRevisionExtra ,
1313 getAppOperationState ,
1414 HydrateOperationPhaseIcon ,
15- hydrationStatusMessage
15+ hydrationStatusMessage ,
16+ getProgressiveSyncStatusColor ,
17+ getProgressiveSyncStatusIcon
1618} from '../utils' ;
1719import { getConditionCategory , HealthStatusIcon , OperationState , syncStatusMessage , getAppDefaultSyncRevision , getAppDefaultOperationSyncRevision } from '../utils' ;
1820import { RevisionMetadataPanel } from './revision-metadata-panel' ;
1921import * as utils from '../utils' ;
22+ import { COLORS } from '../../../shared/components/colors' ;
2023
2124import './application-status-panel.scss' ;
2225
@@ -55,7 +58,74 @@ const sectionHeader = (info: SectionInfo, onClick?: () => any) => {
5558 ) ;
5659} ;
5760
61+ const hasRollingSyncEnabled = ( application : models . Application ) : boolean => {
62+ return application . metadata . ownerReferences ?. some ( ref => ref . kind === 'ApplicationSet' ) || false ;
63+ } ;
64+
65+ const ProgressiveSyncStatus = ( { application} : { application : models . Application } ) => {
66+ if ( ! hasRollingSyncEnabled ( application ) ) {
67+ return null ;
68+ }
69+
70+ const appSetRef = application . metadata . ownerReferences . find ( ref => ref . kind === 'ApplicationSet' ) ;
71+ if ( ! appSetRef ) {
72+ return null ;
73+ }
74+
75+ return (
76+ < DataLoader
77+ input = { application }
78+ load = { async ( ) => {
79+ const appSet = await services . applications . getApplicationSet ( appSetRef . name , application . metadata . namespace ) ;
80+ return appSet ?. spec ?. strategy ?. type === 'RollingSync' ? appSet : null ;
81+ } } >
82+ { ( appSet : models . ApplicationSet ) => {
83+ if ( ! appSet ) {
84+ return (
85+ < div className = 'application-status-panel__item' >
86+ { sectionHeader ( {
87+ title : 'PROGRESSIVE SYNC' ,
88+ helpContent : 'Shows the current status of progressive sync for applications managed by an ApplicationSet with RollingSync strategy.'
89+ } ) }
90+ < div className = 'application-status-panel__item-value' >
91+ < i className = 'fa fa-question-circle' style = { { color : COLORS . sync . unknown } } /> Unknown
92+ </ div >
93+ </ div >
94+ ) ;
95+ }
96+
97+ // Get the current application's status from the ApplicationSet resources
98+ const appResource = appSet . status ?. applicationStatus ?. find ( status => status . application === application . metadata . name ) ;
99+
100+ return (
101+ < div className = 'application-status-panel__item' >
102+ { sectionHeader ( {
103+ title : 'PROGRESSIVE SYNC' ,
104+ helpContent : 'Shows the current status of progressive sync for applications managed by an ApplicationSet with RollingSync strategy.'
105+ } ) }
106+ < div className = 'application-status-panel__item-value' style = { { color : getProgressiveSyncStatusColor ( appResource . status ) } } >
107+ { getProgressiveSyncStatusIcon ( { status : appResource . status } ) } { appResource . status }
108+ </ div >
109+ < div className = 'application-status-panel__item-value' > Wave: { appResource . step } </ div >
110+ < div className = 'application-status-panel__item-name' style = { { marginBottom : '0.5em' } } >
111+ Last Transition: < br />
112+ < Timestamp date = { appResource . lastTransitionTime } />
113+ </ div >
114+ { appResource . message && < div className = 'application-status-panel__item-name' > { appResource . message } </ div > }
115+ </ div >
116+ ) ;
117+ } }
118+ </ DataLoader >
119+ ) ;
120+ } ;
121+
58122export const ApplicationStatusPanel = ( { application, showDiff, showOperation, showHydrateOperation, showConditions, showExtension, showMetadataInfo} : Props ) => {
123+ const [ showProgressiveSync , setShowProgressiveSync ] = React . useState ( false ) ;
124+
125+ React . useEffect ( ( ) => {
126+ setShowProgressiveSync ( hasRollingSyncEnabled ( application ) ) ;
127+ } , [ application ] ) ;
128+
59129 const today = new Date ( ) ;
60130
61131 let daysSinceLastSynchronized = 0 ;
@@ -82,6 +152,7 @@ export const ApplicationStatusPanel = ({application, showDiff, showOperation, sh
82152 const errors = cntByCategory . get ( 'error' ) ;
83153 const source = getAppDefaultSource ( application ) ;
84154 const hasMultipleSources = application . spec . sources ?. length > 0 ;
155+
85156 return (
86157 < div className = 'application-status-panel row' >
87158 < div className = 'application-status-panel__item' >
@@ -261,6 +332,7 @@ export const ApplicationStatusPanel = ({application, showDiff, showOperation, sh
261332 </ React . Fragment >
262333 ) }
263334 </ DataLoader >
335+ { showProgressiveSync && < ProgressiveSyncStatus application = { application } /> }
264336 { statusExtensions && statusExtensions . map ( ext => < ext . component key = { ext . title } application = { application } openFlyout = { ( ) => showExtension && showExtension ( ext . id ) } /> ) }
265337 </ div >
266338 ) ;
0 commit comments