@@ -33,6 +33,9 @@ export const HostsClusterDetailTabContent = ({
33
33
const [ day2Cluster , setDay2Cluster ] = useStateSafely < Cluster | null > ( null ) ;
34
34
const pullSecret = usePullSecret ( ) ;
35
35
36
+ // eslint-disable-next-line react-hooks/exhaustive-deps
37
+ const ocmClusterMemo = React . useMemo ( ( ) => ocmCluster , [ ] ) ;
38
+
36
39
const handleClickTryAgainLink = React . useCallback ( ( ) => {
37
40
setError ( undefined ) ;
38
41
setDay2Cluster ( null ) ;
@@ -53,19 +56,20 @@ export const HostsClusterDetailTabContent = ({
53
56
setDay2Cluster ( null ) ;
54
57
return ;
55
58
}
56
- const day1ClusterHostCount = ocmCluster ?. metrics ?. nodes ?. total || 0 ;
57
- const openshiftClusterId = Day2ClusterService . getOpenshiftClusterId ( ocmCluster ) ;
59
+
60
+ const day1ClusterHostCount = ocmClusterMemo ?. metrics ?. nodes ?. total || 0 ;
61
+ const openshiftClusterId = Day2ClusterService . getOpenshiftClusterId ( ocmClusterMemo ) ;
58
62
if ( day1ClusterHostCount === 0 || ! openshiftClusterId ) {
59
63
setError ( < UnableToAddHostsError onTryAgain = { handleClickTryAgainLink } /> ) ;
60
64
}
61
65
62
66
if ( ! day2Cluster && pullSecret ) {
63
- const { apiVipDnsname, errorType } = getApiVipDnsName ( ocmCluster ) ;
67
+ const { apiVipDnsname, errorType } = getApiVipDnsName ( ocmClusterMemo ) ;
64
68
if ( errorType ) {
65
69
const wrongUrlMessage =
66
70
errorType === 'console'
67
- ? `Cluster Console URL is not valid (${ ocmCluster . console ?. url || '' } )`
68
- : `Cluster API URL is not valid (${ ocmCluster . api ?. url || '' } )` ;
71
+ ? `Cluster Console URL is not valid (${ ocmClusterMemo . console ?. url || '' } )`
72
+ : `Cluster API URL is not valid (${ ocmClusterMemo . api ?. url || '' } )` ;
69
73
setError (
70
74
< >
71
75
{ wrongUrlMessage } , you can{ ' ' }
@@ -85,11 +89,11 @@ export const HostsClusterDetailTabContent = ({
85
89
86
90
const loadDay2Cluster = async ( ) => {
87
91
try {
88
- const day2Cluster = await Day2ClusterService . fetchCluster ( ocmCluster , pullSecret ) ;
92
+ const day2Cluster = await Day2ClusterService . fetchCluster ( ocmClusterMemo , pullSecret ) ;
89
93
90
94
const aiCluster = Day2ClusterService . completeAiClusterWithOcmCluster (
91
95
day2Cluster ,
92
- ocmCluster ,
96
+ ocmClusterMemo ,
93
97
) ;
94
98
setDay2Cluster ( aiCluster ?? null ) ;
95
99
} catch ( e ) {
@@ -103,13 +107,12 @@ export const HostsClusterDetailTabContent = ({
103
107
/> ,
104
108
) ;
105
109
}
106
- return ;
107
110
}
108
111
} ;
109
112
110
113
void loadDay2Cluster ( ) ;
111
114
}
112
- } , [ ocmCluster , pullSecret , day2Cluster , setDay2Cluster , isVisible , handleClickTryAgainLink ] ) ;
115
+ } , [ pullSecret , day2Cluster , setDay2Cluster , isVisible , handleClickTryAgainLink , ocmClusterMemo ] ) ;
113
116
114
117
const refreshCluster = React . useCallback ( async ( ) => {
115
118
if ( ! day2Cluster ?. id ) {
0 commit comments