@@ -28,7 +28,16 @@ import {
28
28
ErrorBar ,
29
29
aggregateNodes ,
30
30
stopPropagation ,
31
+ Button ,
32
+ Icon ,
33
+ ButtonVariantType ,
34
+ ButtonStyleType ,
35
+ ComponentSizeType ,
31
36
} from '@devtron-labs/devtron-fe-common-lib'
37
+ import { importComponentFromFELibrary } from '@Components/common'
38
+ import { getAppTypeCategory } from '@Components/app/details/appDetails/utils'
39
+
40
+ const ExplainWithAIButton = importComponentFromFELibrary ( 'ExplainWithAIButton' , null , 'function' )
32
41
33
42
const AppStatusDetailModal = ( {
34
43
close,
@@ -41,6 +50,11 @@ const AppStatusDetailModal = ({
41
50
} : AppStatusDetailType ) => {
42
51
const _appDetails = IndexStore . getAppDetails ( )
43
52
53
+ const debugNode = _appDetails . resourceTree ?. nodes ?. find (
54
+ ( node ) => node . kind === 'Deployment' || node . kind === 'Rollout' ,
55
+ )
56
+ const debugObject = `${ debugNode ?. kind } /${ debugNode ?. name } `
57
+
44
58
const nodes : AggregatedNodes = useMemo ( ( ) => {
45
59
return aggregateNodes ( _appDetails . resourceTree ?. nodes || [ ] , _appDetails . resourceTree ?. podMetadata || [ ] )
46
60
} , [ _appDetails ] )
@@ -104,9 +118,32 @@ const AppStatusDetailModal = ({
104
118
{ appStatusText || _appDetails . resourceTree ?. status ?. toUpperCase ( ) || _appDetails . appStatus }
105
119
</ div >
106
120
</ div >
107
- < span className = "cursor" onClick = { close } data-testid = "app-status-details-cross" >
108
- < Close className = "icon-dim-24" />
109
- </ span >
121
+ < div className = "flex dc__gap-12" >
122
+ { _appDetails && ExplainWithAIButton && _appDetails . appStatus ?. toLowerCase ( ) !== 'healthy' && (
123
+ < ExplainWithAIButton
124
+ intelligenceConfig = { {
125
+ clusterId : _appDetails . clusterId ,
126
+ metadata : {
127
+ ...( debugNode ? { object : debugObject } : { message } ) ,
128
+ namespace : _appDetails . namespace ,
129
+ status : _appDetails . appStatus ,
130
+ } ,
131
+ prompt : `Debug ${ message ?? 'error' } ${ debugNode ? `of ${ debugObject } ` : '' } in ${ _appDetails . namespace } ` ,
132
+ analyticsCategory : `AI_${ getAppTypeCategory ( _appDetails . appType ) } _APP_STATUS` ,
133
+ } }
134
+ />
135
+ ) }
136
+ < Button
137
+ dataTestId = "app-status-details-cross"
138
+ icon = { < Icon name = "ic-close-small" color = { null } /> }
139
+ ariaLabel = "close drawer"
140
+ showAriaLabelInTippy = { false }
141
+ variant = { ButtonVariantType . borderLess }
142
+ style = { ButtonStyleType . negativeGrey }
143
+ onClick = { close }
144
+ size = { ComponentSizeType . xs }
145
+ />
146
+ </ div >
110
147
</ div >
111
148
112
149
< div className = "app-status-detail__body" >
0 commit comments