@@ -18,6 +18,11 @@ import {
18
18
import { createPrometheusMetricById } from '../helpers/utils' ;
19
19
import { MetricType } from '../../../../common/types/metrics' ;
20
20
import { fetchVisualizationById } from '../../custom_panels/helpers/utils' ;
21
+ import { useDispatch , useSelector } from 'react-redux' ;
22
+ import {
23
+ fetchPanels ,
24
+ selectPanelList ,
25
+ } from '../../../../public/components/custom_panels/redux/panel_slice' ;
21
26
22
27
interface MetricsExportPanelProps {
23
28
http : CoreStart [ 'http' ] ;
@@ -49,14 +54,13 @@ export const MetricsExportPanel = ({
49
54
50
55
const [ errorResponse , setErrorResponse ] = useState ( '' ) ;
51
56
52
- const getCustomPanelList = async ( ) => {
53
- http
54
- . get ( `${ CUSTOM_PANELS_API_PREFIX } /panels` )
55
- . then ( ( res : any ) => {
56
- setOptions ( res . panels || [ ] ) ;
57
- } )
58
- . catch ( ( error : any ) => console . error ( error ) ) ;
59
- } ;
57
+ const customPanels = useSelector ( selectPanelList ) ;
58
+
59
+ const dispatch = useDispatch ( ) ;
60
+
61
+ useEffect ( ( ) => {
62
+ dispatch ( fetchPanels ( ) ) ;
63
+ } , [ ] ) ;
60
64
61
65
const fetchAllvisualizationsById = async ( ) => {
62
66
let tempVisualizationsMetaData = await Promise . all (
@@ -70,7 +74,6 @@ export const MetricsExportPanel = ({
70
74
} ;
71
75
72
76
useEffect ( ( ) => {
73
- getCustomPanelList ( ) ;
74
77
fetchAllvisualizationsById ( ) ;
75
78
} , [ ] ) ;
76
79
@@ -92,10 +95,10 @@ export const MetricsExportPanel = ({
92
95
setSelectedPanelOptions ( options ) ;
93
96
} }
94
97
selectedOptions = { selectedPanelOptions }
95
- options = { options . map ( ( option : CustomPanelOptions ) => {
98
+ options = { customPanels . map ( ( option : any ) => {
96
99
return {
97
100
panel : option ,
98
- label : option . name ,
101
+ label : option . title ,
99
102
} ;
100
103
} ) }
101
104
isClearable = { true }
0 commit comments