1
1
import * as React from 'react' ;
2
2
import AceEditor from 'react-ace' ;
3
3
import { useParams } from 'react-router-dom' ;
4
- import { useAsyncFn , useDebounce } from 'react-use' ;
5
4
6
5
import { Content } from '@backstage/core-components' ;
7
6
import { useApi } from '@backstage/core-plugin-api' ;
8
7
9
- import { CircularProgress , Grid } from '@material-ui/core' ;
8
+ import { Grid } from '@material-ui/core' ;
10
9
import jsYaml from 'js-yaml' ;
11
10
12
11
import { BreadcrumbView } from '../../components/BreadcrumbView/BreadcrumbView' ;
@@ -22,6 +21,8 @@ import 'ace-builds/src-noconflict/mode-yaml';
22
21
import 'ace-builds/src-noconflict/theme-eclipse' ;
23
22
import 'ace-builds/src-noconflict/theme-twilight' ;
24
23
24
+ import { useCallback , useEffect } from 'react' ;
25
+
25
26
import {
26
27
AceValidations ,
27
28
parseKialiValidations ,
@@ -34,7 +35,7 @@ export const IstioConfigDetailsPage = (): React.JSX.Element => {
34
35
const kialiState = React . useContext ( KialiContext ) as KialiAppState ;
35
36
const [ istioConfig , setIstioConfig ] = React . useState < IstioConfigDetails > ( ) ;
36
37
37
- const fetchIstioConfig = async ( ) => {
38
+ const fetchIstioConfig = useCallback ( ( ) => {
38
39
if ( ! namespace || ! objectType || ! object ) {
39
40
kialiState . alertUtils ! . add (
40
41
`Could not fetch Istio Config: Empty namespace, object type or object name` ,
@@ -47,26 +48,12 @@ export const IstioConfigDetailsPage = (): React.JSX.Element => {
47
48
. then ( ( istioConfigResponse : IstioConfigDetails ) => {
48
49
setIstioConfig ( istioConfigResponse ) ;
49
50
} ) ;
50
- } ;
51
+ } , [ kialiClient , kialiState . alertUtils , namespace , objectType , object ] ) ;
51
52
52
- const [ { loading } , refresh ] = useAsyncFn (
53
- async ( ) => {
54
- // Check if the config is loaded
55
- await fetchIstioConfig ( ) ;
56
- } ,
57
- [ ] ,
58
- { loading : true } ,
59
- ) ;
60
- useDebounce ( refresh , 10 ) ;
61
-
62
- React . useEffect ( ( ) => {
53
+ useEffect ( ( ) => {
63
54
fetchIstioConfig ( ) ;
64
55
} , [ fetchIstioConfig , namespace , objectType , object ] ) ;
65
56
66
- if ( loading ) {
67
- return < CircularProgress /> ;
68
- }
69
-
70
57
const fetchYaml = ( ) => {
71
58
const safeDumpOptions = {
72
59
styles : {
0 commit comments