1
1
import React from 'react' ;
2
2
import { Button , ButtonVariant , Modal , ModalVariant } from '@patternfly/react-core' ;
3
3
import { pluralize } from 'humanize-plus' ;
4
- import { CpuArchitecture , DownloadIso , ErrorState , isSNO , ToolbarButton } from '../../../common' ;
4
+ import {
5
+ AI_CISCO_INTERSIGHT_TAG ,
6
+ CpuArchitecture ,
7
+ DownloadIso ,
8
+ ErrorState ,
9
+ isSNO ,
10
+ ToolbarButton ,
11
+ } from '../../../common' ;
5
12
import DiscoveryImageForm from './DiscoveryImageForm' ;
6
13
import { useModalDialogsContext } from '../hosts/ModalDialogsContext' ;
7
14
import useInfraEnvImageUrl from '../../hooks/useInfraEnvImageUrl' ;
8
15
import useInfraEnvIpxeImageUrl from '../../hooks/useInfraEnvIpxeImageUrl' ;
9
16
import DownloadIpxeScript from '../../../common/components/clusterConfiguration/DownloadIpxeScript' ;
10
17
import './DiscoveryImageModal.css' ;
11
18
import { Cluster } from '@openshift-assisted/types/assisted-installer-service' ;
19
+ import { ClustersService } from '../../services' ;
20
+ import { useDispatch } from 'react-redux' ;
21
+ import { updateCluster } from '../../store/slices/current-cluster/slice' ;
12
22
13
23
type DiscoveryImageModalButtonProps = {
14
24
ButtonComponent ?: typeof Button | typeof ToolbarButton ;
@@ -49,6 +59,8 @@ export const DiscoveryImageModal = () => {
49
59
const { getIsoImageUrl } = useInfraEnvImageUrl ( ) ;
50
60
const { getIpxeImageUrl } = useInfraEnvIpxeImageUrl ( ) ;
51
61
62
+ const dispatch = useDispatch ( ) ;
63
+
52
64
const onImageReady = React . useCallback ( async ( ) => {
53
65
// We need to retrieve the Iso for the only infraEnv on Day1, hence we don't specify the architecture
54
66
const { url, error } = await getIsoImageUrl ( cluster . id , CpuArchitecture . USE_DAY1_ARCHITECTURE ) ;
@@ -73,6 +85,16 @@ export const DiscoveryImageModal = () => {
73
85
setIpxeSelected ( true ) ;
74
86
} , [ ] ) ;
75
87
88
+ const updateTagsForCiscoIntersight = async ( cluster : Cluster ) => {
89
+ try {
90
+ const { data : updatedCluster } = await ClustersService . update ( cluster . id , cluster . tags , {
91
+ tags : AI_CISCO_INTERSIGHT_TAG ,
92
+ } ) ;
93
+
94
+ dispatch ( updateCluster ( updatedCluster ) ) ;
95
+ } catch ( e ) { }
96
+ } ;
97
+
76
98
if ( ! cluster ) {
77
99
return null ;
78
100
}
@@ -98,6 +120,7 @@ export const DiscoveryImageModal = () => {
98
120
isSNO = { isSNOCluster }
99
121
onReset = { onReset }
100
122
onClose = { close }
123
+ updateTagsForCiscoIntersight = { ( ) => updateTagsForCiscoIntersight ( cluster ) }
101
124
/>
102
125
) : ipxeDownloadUrl ? (
103
126
< DownloadIpxeScript
0 commit comments