1- import { createRequestActionTypes , createApiRequest } from '../utils' ;
2- import '../../services/api' ;
1+ import type { Reducer } from 'redux' ;
32
4- const FETCH_CLUSTER = createRequestActionTypes ( 'cluster' , 'FETCH_CLUSTER' ) ;
3+ import '../../../services/api' ;
4+ import { createRequestActionTypes , createApiRequest } from '../../utils' ;
5+ import type { ClusterAction , ClusterState } from './types' ;
6+
7+ export const FETCH_CLUSTER = createRequestActionTypes ( 'cluster' , 'FETCH_CLUSTER' ) ;
58
69const initialState = { loading : true , wasLoaded : false } ;
710
8- const cluster = function ( state = initialState , action ) {
11+ const cluster : Reducer < ClusterState , ClusterAction > = ( state = initialState , action ) => {
912 switch ( action . type ) {
1013 case FETCH_CLUSTER . REQUEST : {
1114 return {
@@ -14,17 +17,9 @@ const cluster = function (state = initialState, action) {
1417 } ;
1518 }
1619 case FETCH_CLUSTER . SUCCESS : {
17- const { data} = action ;
18- const clusterInfo = data . cluster ? data . cluster . cluster : data ;
19- const clusterName = data . cluster ?. title || data . Name ;
2020 return {
2121 ...state ,
22- data : {
23- ...clusterInfo ,
24- balancer : data . cluster ?. balancer ,
25- solomon : data . cluster ?. solomon ,
26- Name : clusterName ,
27- } ,
22+ data : action . data ,
2823 loading : false ,
2924 wasLoaded : true ,
3025 error : undefined ,
@@ -42,7 +37,7 @@ const cluster = function (state = initialState, action) {
4237 }
4338} ;
4439
45- export function getClusterInfo ( clusterName ) {
40+ export function getClusterInfo ( clusterName ?: string ) {
4641 return createApiRequest ( {
4742 request : window . api . getClusterInfo ( clusterName ) ,
4843 actions : FETCH_CLUSTER ,
0 commit comments