Skip to content

Commit 71a739b

Browse files
committed
feat: add explain ai button in app status drawer
1 parent 61cecf2 commit 71a739b

File tree

2 files changed

+47
-8
lines changed

2 files changed

+47
-8
lines changed

src/components/app/details/appDetails/AppStatusCard.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ const AppStatusCard = ({ appDetails, status, cardLoading, setDetailed, message }
3232
const isFluxCDApp = appDetails?.appType === AppType.EXTERNAL_FLUX_APP
3333
const isStatusHealthy = useMemo(() => status.toLowerCase() === 'healthy', [status])
3434

35-
const deploymentObject = appDetails.resourceTree?.nodes?.find((node) => node.kind === 'Deployment' || node.kind === 'Rollout')
36-
const debugObject = `${deploymentObject?.kind}/${deploymentObject?.name}`
35+
const debugNode = appDetails.resourceTree?.nodes?.find(
36+
(node) => node.kind === 'Deployment' || node.kind === 'Rollout',
37+
)
38+
const debugObject = `${debugNode?.kind}/${debugNode?.name}`
3739

3840
const showApplicationDetailedModal = (): void => {
3941
setDetailed && setDetailed(true)
@@ -54,16 +56,16 @@ const AppStatusCard = ({ appDetails, status, cardLoading, setDetailed, message }
5456
</Tippy>
5557
)}
5658
<div className="app-details-info-card__bottom-container__details fs-12 fw-6">Details</div>
57-
{!isStatusHealthy && (deploymentObject || message) && (
59+
{!isStatusHealthy && (debugNode || message) && (
5860
<ExplainWithAIButton
5961
intelligenceConfig={{
6062
clusterId: appDetails.clusterId,
6163
metadata: {
62-
...(deploymentObject ? {debugObject} : {message}),
64+
...(debugNode ? { object: debugObject } : { message }),
6365
namespace: appDetails.namespace,
6466
status,
6567
},
66-
prompt: `Debug ${message ?? 'error'} ${deploymentObject ? `of ${debugObject}`: ''} in ${appDetails.namespace}`,
68+
prompt: `Debug ${message ?? 'error'} ${debugNode ? `of ${debugObject}` : ''} in ${appDetails.namespace}`,
6769
analyticsCategory: `AI_${getAppTypeCategory(appDetails.appType)}_APP_STATUS`,
6870
}}
6971
/>

src/components/v2/appDetails/sourceInfo/environmentStatus/AppStatusDetailModal.tsx

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,16 @@ import {
2828
ErrorBar,
2929
aggregateNodes,
3030
stopPropagation,
31+
Button,
32+
Icon,
33+
ButtonVariantType,
34+
ButtonStyleType,
35+
ComponentSizeType,
3136
} 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')
3241

3342
const AppStatusDetailModal = ({
3443
close,
@@ -41,6 +50,11 @@ const AppStatusDetailModal = ({
4150
}: AppStatusDetailType) => {
4251
const _appDetails = IndexStore.getAppDetails()
4352

53+
const debugNode = _appDetails.resourceTree?.nodes?.find(
54+
(node) => node.kind === 'Deployment' || node.kind === 'Rollout',
55+
)
56+
const debugObject = `${debugNode?.kind}/${debugNode?.name}`
57+
4458
const nodes: AggregatedNodes = useMemo(() => {
4559
return aggregateNodes(_appDetails.resourceTree?.nodes || [], _appDetails.resourceTree?.podMetadata || [])
4660
}, [_appDetails])
@@ -104,9 +118,32 @@ const AppStatusDetailModal = ({
104118
{appStatusText || _appDetails.resourceTree?.status?.toUpperCase() || _appDetails.appStatus}
105119
</div>
106120
</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>
110147
</div>
111148

112149
<div className="app-status-detail__body">

0 commit comments

Comments
 (0)