@@ -20,18 +20,17 @@ import { useParams } from 'react-router-dom'
20
20
import moment from 'moment'
21
21
22
22
import { ShowMoreText } from '@Shared/Components/ShowMoreText'
23
- import { AppType } from '@Shared/types'
23
+ import { AppType , TIMELINE_STATUS } from '@Shared/types'
24
24
25
25
import { ReactComponent as DropDownIcon } from '../../../Assets/Icon/ic-chevron-down.svg'
26
26
import { DATE_TIME_FORMATS , showError } from '../../../Common'
27
- import { ComponentSizeType , DEPLOYMENT_STATUS , statusIcon , TIMELINE_STATUS } from '../../constants'
27
+ import { ComponentSizeType , DEPLOYMENT_STATUS , statusIcon } from '../../constants'
28
28
import { AppStatusContent } from '../AppStatusModal'
29
29
import { Button , ButtonStyleType , ButtonVariantType } from '../Button'
30
30
import { APP_HEALTH_DROP_DOWN_LIST , MANIFEST_STATUS_HEADERS , TERMINAL_STATUS_MAP } from './constants'
31
- import { ErrorInfoStatusBar } from './ErrorInfoStatusBar'
32
31
import { getManualSync } from './service'
33
32
import { DeploymentStatusDetailRowType } from './types'
34
- import { renderIcon } from './utils'
33
+ import { getDeploymentTimelineBGColorFromIcon , renderDeploymentTimelineIcon } from './utils'
35
34
36
35
export const DeploymentStatusDetailRow = ( {
37
36
type,
@@ -43,19 +42,22 @@ export const DeploymentStatusDetailRow = ({
43
42
// Can't use appDetails directly as in case of deployment history, appDetails will be null
44
43
const { appId : paramAppId , envId : paramEnvId } = useParams < { appId : string ; envId : string } > ( )
45
44
45
+ const [ isManualSyncLoading , setIsManualSyncLoading ] = useState < boolean > ( false )
46
+
46
47
const statusBreakDownType = deploymentDetailedData . deploymentStatusBreakdown [ type ]
47
- const [ collapsed , toggleCollapsed ] = useState < boolean > ( statusBreakDownType . isCollapsed )
48
+ const [ isCollapsed , setIsCollapsed ] = useState < boolean > ( statusBreakDownType . isCollapsed )
48
49
49
50
const isHelmManifestPushFailed =
50
51
type === TIMELINE_STATUS . HELM_MANIFEST_PUSHED_TO_HELM_REPO &&
51
52
deploymentDetailedData . deploymentStatus === statusIcon . failed
52
53
53
54
useEffect ( ( ) => {
54
- toggleCollapsed ( statusBreakDownType . isCollapsed )
55
+ setIsCollapsed ( statusBreakDownType . isCollapsed )
55
56
} , [ statusBreakDownType . isCollapsed ] )
56
57
57
58
const manualSyncData = async ( ) => {
58
59
try {
60
+ setIsManualSyncLoading ( true )
59
61
const { appId : appDetailsAppId , appType, environmentId : appDetailsEnvId , installedAppId } = appDetails || { }
60
62
const parsedAppIdFromAppDetails = appType === AppType . DEVTRON_HELM_CHART ? installedAppId : appDetailsAppId
61
63
@@ -65,10 +67,12 @@ export const DeploymentStatusDetailRow = ({
65
67
await getManualSync ( { appId, envId } )
66
68
} catch ( error ) {
67
69
showError ( error )
70
+ } finally {
71
+ setIsManualSyncLoading ( false )
68
72
}
69
73
}
70
74
const toggleDropdown = ( ) => {
71
- toggleCollapsed ( ! collapsed )
75
+ setIsCollapsed ( ! isCollapsed )
72
76
}
73
77
74
78
const renderDetailedData = ( ) => {
@@ -78,16 +82,15 @@ export const DeploymentStatusDetailRow = ({
78
82
79
83
return (
80
84
< div className = "px-8 py-12" >
81
- < div className = "" >
82
- { deploymentDetailedData . deploymentStatusBreakdown [ TIMELINE_STATUS . KUBECTL_APPLY ] . kubeList ?. map (
83
- ( items , index ) => (
84
- // eslint-disable-next-line react/no-array-index-key
85
- < div className = "flex left lh-20 mb-8" key = { `item-${ index } ` } >
86
- { renderIcon ( items . icon ) }
87
- < span className = "ml-12" > { items . message } </ span >
88
- </ div >
89
- ) ,
90
- ) }
85
+ < div >
86
+ { /* TODO: Can be statusBreakDownType */ }
87
+ { statusBreakDownType . subSteps ?. map ( ( items , index ) => (
88
+ // eslint-disable-next-line react/no-array-index-key
89
+ < div className = "flex left lh-20 mb-8" key = { `item-${ index } ` } >
90
+ { renderDeploymentTimelineIcon ( items . icon ) }
91
+ < span className = "ml-12" > { items . message } </ span >
92
+ </ div >
93
+ ) ) }
91
94
</ div >
92
95
{ statusBreakDownType . resourceDetails ?. length ? (
93
96
< div className = "pl-32" >
@@ -129,24 +132,30 @@ export const DeploymentStatusDetailRow = ({
129
132
)
130
133
}
131
134
132
- const renderErrorInfoBar = ( ) => (
133
- < ErrorInfoStatusBar
134
- type = { TIMELINE_STATUS . HELM_MANIFEST_PUSHED_TO_HELM_REPO }
135
- lastFailedStatusType = { deploymentDetailedData . nonDeploymentError }
136
- errorMessage = { deploymentDetailedData . deploymentError }
137
- hideVerticalConnector
138
- hideErrorIcon
139
- />
140
- )
135
+ const renderErrorInfoBar = ( ) => {
136
+ if ( deploymentDetailedData . lastFailedStatusType !== TIMELINE_STATUS . HELM_MANIFEST_PUSHED_TO_HELM_REPO ) {
137
+ return null
138
+ }
139
+
140
+ return (
141
+ < div className = "bcr-1 fs-13 p-8" >
142
+ < span className = "dc__word-break lh-20" > { deploymentDetailedData . deploymentError } </ span >
143
+ < ol className = "m-0 pl-20" >
144
+ < li > Ensure provided repository path is valid</ li >
145
+ < li > Check if credentials provided for OCI registry are valid and have PUSH permission</ li >
146
+ </ ol >
147
+ </ div >
148
+ )
149
+ }
141
150
142
151
const isAccordion =
143
- ( type === TIMELINE_STATUS . KUBECTL_APPLY && statusBreakDownType . kubeList ?. length ) ||
152
+ statusBreakDownType . subSteps ?. length ||
144
153
( type === TIMELINE_STATUS . APP_HEALTH && APP_HEALTH_DROP_DOWN_LIST . includes ( statusBreakDownType . icon ) ) ||
145
154
( ( type === TIMELINE_STATUS . GIT_COMMIT || type === TIMELINE_STATUS . ARGOCD_SYNC ) &&
146
155
statusBreakDownType . icon === 'failed' )
147
156
148
157
const renderAccordionDetails = ( ) => {
149
- if ( ! isAccordion || ! collapsed ) {
158
+ if ( isCollapsed ) {
150
159
return null
151
160
}
152
161
@@ -158,9 +167,7 @@ export const DeploymentStatusDetailRow = ({
158
167
statusBreakDownType . icon !== 'inprogress' ? 'bcr-1' : 'bcy-2'
159
168
} `}
160
169
>
161
- { type === TIMELINE_STATUS . APP_HEALTH
162
- ? statusBreakDownType . timelineStatus
163
- : deploymentDetailedData . deploymentStatusBreakdown [ type ] . timelineStatus }
170
+ { statusBreakDownType . timelineStatus }
164
171
165
172
{ ( deploymentDetailedData . deploymentStatus === DEPLOYMENT_STATUS . TIMED_OUT ||
166
173
deploymentDetailedData . deploymentStatus === DEPLOYMENT_STATUS . UNABLE_TO_FETCH ) && (
@@ -170,6 +177,7 @@ export const DeploymentStatusDetailRow = ({
170
177
variant = { ButtonVariantType . text }
171
178
size = { ComponentSizeType . xxs }
172
179
onClick = { manualSyncData }
180
+ isLoading = { isManualSyncLoading }
173
181
/>
174
182
) }
175
183
</ div >
@@ -190,10 +198,10 @@ export const DeploymentStatusDetailRow = ({
190
198
< >
191
199
< div className = "bw-1 en-2" >
192
200
< div
193
- className = { `flexbox dc__align-items-center dc__content-space dc__gap-12 py-8 px-8 bg__primary ${ collapsed ? ( ! isHelmManifestPushFailed ? 'br-4' : '' ) : 'border-collapse' } ` }
201
+ className = { `flexbox dc__align-items-center dc__content-space dc__gap-12 py-8 px-8 bg__primary ${ isCollapsed ? ( ! isHelmManifestPushFailed ? 'br-4' : '' ) : 'border-collapse' } ` }
194
202
>
195
203
< div className = "flexbox dc__align-items-center dc__gap-12 flex-grow-1" >
196
- { renderIcon ( statusBreakDownType . icon ) }
204
+ { renderDeploymentTimelineIcon ( statusBreakDownType . icon ) }
197
205
< span className = "fs-13 flexbox dc__gap-6" >
198
206
< span data-testid = "deployment-status-step-name" className = "dc__truncate" >
199
207
{ statusBreakDownType . displayText }
@@ -208,9 +216,9 @@ export const DeploymentStatusDetailRow = ({
208
216
{ statusBreakDownType . time !== '' && statusBreakDownType . icon !== 'inprogress' && (
209
217
< span
210
218
data-testid = "deployment-status-kubernetes-dropdown dc__no-shrink"
211
- className = { `px-8 py-4 br-12 ${
212
- statusBreakDownType . icon === 'failed' ? 'bcr-1 cr-5' : 'bcg-1 cg-7'
213
- } `}
219
+ className = { `px-8 py-4 br-12 ${ getDeploymentTimelineBGColorFromIcon (
220
+ statusBreakDownType . icon ,
221
+ ) } `}
214
222
>
215
223
{ moment ( statusBreakDownType . time , 'YYYY-MM-DDTHH:mm:ssZ' ) . format (
216
224
DATE_TIME_FORMATS . TWELVE_HOURS_FORMAT ,
@@ -229,7 +237,7 @@ export const DeploymentStatusDetailRow = ({
229
237
< DropDownIcon
230
238
style = { {
231
239
marginLeft : 'auto' ,
232
- [ '--rotateBy' as any ] : `${ 180 * Number ( ! ! collapsed ) } deg` ,
240
+ [ '--rotateBy' as any ] : `${ 180 * Number ( ! isCollapsed ) } deg` ,
233
241
} }
234
242
className = "rotate"
235
243
/>
0 commit comments