[CHORE] Get rid of redundant FetchStatus enum
This commit is contained in:
parent
384c0a5d17
commit
b06ee13268
8 changed files with 20 additions and 30 deletions
|
@ -16,13 +16,6 @@ export * from './broker';
|
|||
export * from './consumerGroup';
|
||||
export * from './loader';
|
||||
|
||||
export enum FetchStatus {
|
||||
notFetched = 'notFetched',
|
||||
fetching = 'fetching',
|
||||
fetched = 'fetched',
|
||||
errorFetching = 'errorFetching',
|
||||
}
|
||||
|
||||
export interface RootState {
|
||||
topics: TopicsState;
|
||||
clusters: ClusterState;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { FetchStatus } from 'redux/interfaces/index';
|
||||
|
||||
export interface LoaderState {
|
||||
[key: string]: FetchStatus;
|
||||
[key: string]: 'notFetched' | 'fetching' | 'fetched' | 'errorFetching';
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { createSelector } from 'reselect';
|
||||
import { RootState, FetchStatus, BrokersState } from 'redux/interfaces';
|
||||
import { RootState, BrokersState } from 'redux/interfaces';
|
||||
import { createFetchingSelector } from 'redux/reducers/loader/selectors';
|
||||
|
||||
const brokersState = ({ brokers }: RootState): BrokersState => brokers;
|
||||
|
@ -8,7 +8,7 @@ const getBrokerListFetchingStatus = createFetchingSelector('GET_BROKERS');
|
|||
|
||||
export const getIsBrokerListFetched = createSelector(
|
||||
getBrokerListFetchingStatus,
|
||||
(status) => status === FetchStatus.fetched
|
||||
(status) => status === 'fetched'
|
||||
);
|
||||
|
||||
export const getBrokerCount = createSelector(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { createSelector } from 'reselect';
|
||||
import { RootState, FetchStatus } from 'redux/interfaces';
|
||||
import { RootState } from 'redux/interfaces';
|
||||
import { createFetchingSelector } from 'redux/reducers/loader/selectors';
|
||||
import { Cluster, ServerStatus } from 'generated-sources';
|
||||
|
||||
|
@ -9,7 +9,7 @@ const getClusterListFetchingStatus = createFetchingSelector('GET_CLUSTERS');
|
|||
|
||||
export const getIsClusterListFetched = createSelector(
|
||||
getClusterListFetchingStatus,
|
||||
(status) => status === FetchStatus.fetched
|
||||
(status) => status === 'fetched'
|
||||
);
|
||||
|
||||
export const getClusterList = createSelector(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { createSelector } from 'reselect';
|
||||
import { RootState, FetchStatus } from 'redux/interfaces';
|
||||
import { RootState } from 'redux/interfaces';
|
||||
import { createFetchingSelector } from 'redux/reducers/loader/selectors';
|
||||
import {
|
||||
ConsumerGroupID,
|
||||
|
@ -24,12 +24,12 @@ const getConsumerGroupDetailsFetchingStatus = createFetchingSelector(
|
|||
|
||||
export const getIsConsumerGroupsListFetched = createSelector(
|
||||
getConsumerGroupsListFetchingStatus,
|
||||
(status) => status === FetchStatus.fetched
|
||||
(status) => status === 'fetched'
|
||||
);
|
||||
|
||||
export const getIsConsumerGroupDetailsFetched = createSelector(
|
||||
getConsumerGroupDetailsFetchingStatus,
|
||||
(status) => status === FetchStatus.fetched
|
||||
(status) => status === 'fetched'
|
||||
);
|
||||
|
||||
export const getConsumerGroupsList = createSelector(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { FetchStatus, Action, LoaderState } from 'redux/interfaces';
|
||||
import { Action, LoaderState } from 'redux/interfaces';
|
||||
|
||||
export const initialState: LoaderState = {};
|
||||
|
||||
|
@ -15,17 +15,17 @@ const reducer = (state = initialState, action: Action): LoaderState => {
|
|||
case 'REQUEST':
|
||||
return {
|
||||
...state,
|
||||
[requestName]: FetchStatus.fetching,
|
||||
[requestName]: 'fetching',
|
||||
};
|
||||
case 'SUCCESS':
|
||||
return {
|
||||
...state,
|
||||
[requestName]: FetchStatus.fetched,
|
||||
[requestName]: 'fetched',
|
||||
};
|
||||
case 'FAILURE':
|
||||
return {
|
||||
...state,
|
||||
[requestName]: FetchStatus.errorFetching,
|
||||
[requestName]: 'errorFetching',
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { RootState, FetchStatus } from 'redux/interfaces';
|
||||
import { RootState } from 'redux/interfaces';
|
||||
|
||||
export const createFetchingSelector = (action: string) => (state: RootState) =>
|
||||
state.loader[action] || FetchStatus.notFetched;
|
||||
state.loader[action] || 'notFetched';
|
||||
|
|
|
@ -2,7 +2,6 @@ import { createSelector } from 'reselect';
|
|||
import {
|
||||
RootState,
|
||||
TopicName,
|
||||
FetchStatus,
|
||||
TopicsState,
|
||||
TopicConfigByName,
|
||||
} from 'redux/interfaces';
|
||||
|
@ -29,32 +28,32 @@ const getTopicUpdateStatus = createFetchingSelector('PATCH_TOPIC');
|
|||
|
||||
export const getIsTopicListFetched = createSelector(
|
||||
getTopicListFetchingStatus,
|
||||
(status) => status === FetchStatus.fetched
|
||||
(status) => status === 'fetched'
|
||||
);
|
||||
|
||||
export const getIsTopicDetailsFetched = createSelector(
|
||||
getTopicDetailsFetchingStatus,
|
||||
(status) => status === FetchStatus.fetched
|
||||
(status) => status === 'fetched'
|
||||
);
|
||||
|
||||
export const getIsTopicMessagesFetched = createSelector(
|
||||
getTopicMessagesFetchingStatus,
|
||||
(status) => status === FetchStatus.fetched
|
||||
(status) => status === 'fetched'
|
||||
);
|
||||
|
||||
export const getTopicConfigFetched = createSelector(
|
||||
getTopicConfigFetchingStatus,
|
||||
(status) => status === FetchStatus.fetched
|
||||
(status) => status === 'fetched'
|
||||
);
|
||||
|
||||
export const getTopicCreated = createSelector(
|
||||
getTopicCreationStatus,
|
||||
(status) => status === FetchStatus.fetched
|
||||
(status) => status === 'fetched'
|
||||
);
|
||||
|
||||
export const getTopicUpdated = createSelector(
|
||||
getTopicUpdateStatus,
|
||||
(status) => status === FetchStatus.fetched
|
||||
(status) => status === 'fetched'
|
||||
);
|
||||
|
||||
export const getTopicList = createSelector(
|
||||
|
|
Loading…
Add table
Reference in a new issue