Get rid of redundant enums (#186)

* [CHORE] Get rid of redundant ActionType enum

* [CHORE] Get rid of redundant FetchStatus enum

* [CHORE] Get rid of redundant CustomParamButtonType enum
This commit is contained in:
Oleg Shur 2021-02-11 16:29:18 +03:00 committed by GitHub
parent ba4e1748ee
commit ddc784559d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 77 additions and 155 deletions

View file

@ -1,8 +1,6 @@
import React from 'react'; import React from 'react';
import { TopicMessage } from 'generated-sources'; import { TopicMessage } from 'generated-sources';
import CustomParamButton, { import CustomParamButton from 'components/Topics/shared/Form/CustomParams/CustomParamButton';
CustomParamButtonType,
} from '../../shared/Form/CustomParams/CustomParamButton';
import MessageItem from './MessageItem'; import MessageItem from './MessageItem';
interface MessagesTableProp { interface MessagesTableProp {
@ -44,7 +42,7 @@ const MessagesTable: React.FC<MessagesTableProp> = ({ messages, onNext }) => {
<div className="column is-full"> <div className="column is-full">
<CustomParamButton <CustomParamButton
className="is-link is-pulled-right" className="is-link is-pulled-right"
type={CustomParamButtonType.chevronRight} type="fa-chevron-right"
onClick={onNext} onClick={onNext}
btnText="Next" btnText="Next"
/> />

View file

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import CustomParamButton, { CustomParamButtonType } from './CustomParamButton'; import CustomParamButton from './CustomParamButton';
interface Props { interface Props {
index: string; index: string;
@ -11,7 +11,7 @@ const CustomParamAction: React.FC<Props> = ({ index, onRemove }) => (
<label className="label">&nbsp;</label> <label className="label">&nbsp;</label>
<CustomParamButton <CustomParamButton
className="is-danger" className="is-danger"
type={CustomParamButtonType.minus} type="fa-minus"
onClick={() => onRemove(index)} onClick={() => onRemove(index)}
/> />
</> </>

View file

@ -1,15 +1,9 @@
import React from 'react'; import React from 'react';
export enum CustomParamButtonType {
plus = 'fa-plus',
minus = 'fa-minus',
chevronRight = 'fa-chevron-right',
}
interface Props { interface Props {
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void; onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
className: string; className: string;
type: CustomParamButtonType; type: 'fa-plus' | 'fa-minus' | 'fa-chevron-right';
btnText?: string; btnText?: string;
} }

View file

@ -7,7 +7,7 @@ import {
TopicConfigByName, TopicConfigByName,
TopicConfigParams, TopicConfigParams,
} from 'redux/interfaces'; } from 'redux/interfaces';
import CustomParamButton, { CustomParamButtonType } from './CustomParamButton'; import CustomParamButton from './CustomParamButton';
import CustomParamField from './CustomParamField'; import CustomParamField from './CustomParamField';
export const INDEX_PREFIX = 'customParams'; export const INDEX_PREFIX = 'customParams';
@ -79,7 +79,7 @@ const CustomParams: React.FC<Props> = ({ isSubmitting, config }) => {
<div className="column"> <div className="column">
<CustomParamButton <CustomParamButton
className="is-success" className="is-success"
type={CustomParamButtonType.plus} type="fa-plus"
onClick={onAdd} onClick={onAdd}
btnText="Add Custom Parameter" btnText="Add Custom Parameter"
/> />

View file

@ -1,55 +0,0 @@
enum ActionType {
GET_CLUSTERS__REQUEST = 'GET_CLUSTERS__REQUEST',
GET_CLUSTERS__SUCCESS = 'GET_CLUSTERS__SUCCESS',
GET_CLUSTERS__FAILURE = 'GET_CLUSTERS__FAILURE',
GET_CLUSTER_STATS__REQUEST = 'GET_CLUSTER_STATUS__REQUEST',
GET_CLUSTER_STATS__SUCCESS = 'GET_CLUSTER_STATUS__SUCCESS',
GET_CLUSTER_STATS__FAILURE = 'GET_CLUSTER_STATUS__FAILURE',
GET_CLUSTER_METRICS__REQUEST = 'GET_CLUSTER_METRICS__REQUEST',
GET_CLUSTER_METRICS__SUCCESS = 'GET_CLUSTER_METRICS__SUCCESS',
GET_CLUSTER_METRICS__FAILURE = 'GET_CLUSTER_METRICS__FAILURE',
GET_BROKERS__REQUEST = 'GET_BROKERS__REQUEST',
GET_BROKERS__SUCCESS = 'GET_BROKERS__SUCCESS',
GET_BROKERS__FAILURE = 'GET_BROKERS__FAILURE',
GET_BROKER_METRICS__REQUEST = 'GET_BROKER_METRICS__REQUEST',
GET_BROKER_METRICS__SUCCESS = 'GET_BROKER_METRICS__SUCCESS',
GET_BROKER_METRICS__FAILURE = 'GET_BROKER_METRICS__FAILURE',
GET_TOPICS__REQUEST = 'GET_TOPICS__REQUEST',
GET_TOPICS__SUCCESS = 'GET_TOPICS__SUCCESS',
GET_TOPICS__FAILURE = 'GET_TOPICS__FAILURE',
GET_TOPIC_MESSAGES__REQUEST = 'GET_TOPIC_MESSAGES__REQUEST',
GET_TOPIC_MESSAGES__SUCCESS = 'GET_TOPIC_MESSAGES__SUCCESS',
GET_TOPIC_MESSAGES__FAILURE = 'GET_TOPIC_MESSAGES__FAILURE',
GET_TOPIC_DETAILS__REQUEST = 'GET_TOPIC_DETAILS__REQUEST',
GET_TOPIC_DETAILS__SUCCESS = 'GET_TOPIC_DETAILS__SUCCESS',
GET_TOPIC_DETAILS__FAILURE = 'GET_TOPIC_DETAILS__FAILURE',
GET_TOPIC_CONFIG__REQUEST = 'GET_TOPIC_CONFIG__REQUEST',
GET_TOPIC_CONFIG__SUCCESS = 'GET_TOPIC_CONFIG__SUCCESS',
GET_TOPIC_CONFIG__FAILURE = 'GET_TOPIC_CONFIG__FAILURE',
POST_TOPIC__REQUEST = 'POST_TOPIC__REQUEST',
POST_TOPIC__SUCCESS = 'POST_TOPIC__SUCCESS',
POST_TOPIC__FAILURE = 'POST_TOPIC__FAILURE',
PATCH_TOPIC__REQUEST = 'PATCH_TOPIC__REQUEST',
PATCH_TOPIC__SUCCESS = 'PATCH_TOPIC__SUCCESS',
PATCH_TOPIC__FAILURE = 'PATCH_TOPIC__FAILURE',
GET_CONSUMER_GROUPS__REQUEST = 'GET_CONSUMER_GROUPS__REQUEST',
GET_CONSUMER_GROUPS__SUCCESS = 'GET_CONSUMER_GROUPS__SUCCESS',
GET_CONSUMER_GROUPS__FAILURE = 'GET_CONSUMER_GROUPS__FAILURE',
GET_CONSUMER_GROUP_DETAILS__REQUEST = 'GET_CONSUMER_GROUP_DETAILS__REQUEST',
GET_CONSUMER_GROUP_DETAILS__SUCCESS = 'GET_CONSUMER_GROUP_DETAILS__SUCCESS',
GET_CONSUMER_GROUP_DETAILS__FAILURE = 'GET_CONSUMER_GROUP_DETAILS__FAILURE',
}
export default ActionType;

View file

@ -1,5 +1,4 @@
import { createAsyncAction } from 'typesafe-actions'; import { createAsyncAction } from 'typesafe-actions';
import ActionType from 'redux/actionType';
import { TopicName, ConsumerGroupID } from 'redux/interfaces'; import { TopicName, ConsumerGroupID } from 'redux/interfaces';
import { import {
@ -17,81 +16,81 @@ import {
} from 'generated-sources'; } from 'generated-sources';
export const fetchClusterStatsAction = createAsyncAction( export const fetchClusterStatsAction = createAsyncAction(
ActionType.GET_CLUSTER_STATS__REQUEST, 'GET_CLUSTER_STATUS__REQUEST',
ActionType.GET_CLUSTER_STATS__SUCCESS, 'GET_CLUSTER_STATUS__SUCCESS',
ActionType.GET_CLUSTER_STATS__FAILURE 'GET_CLUSTER_STATUS__FAILURE'
)<undefined, ClusterStats, undefined>(); )<undefined, ClusterStats, undefined>();
export const fetchClusterMetricsAction = createAsyncAction( export const fetchClusterMetricsAction = createAsyncAction(
ActionType.GET_CLUSTER_METRICS__REQUEST, 'GET_CLUSTER_METRICS__REQUEST',
ActionType.GET_CLUSTER_METRICS__SUCCESS, 'GET_CLUSTER_METRICS__SUCCESS',
ActionType.GET_CLUSTER_METRICS__FAILURE 'GET_CLUSTER_METRICS__FAILURE'
)<undefined, ClusterMetrics, undefined>(); )<undefined, ClusterMetrics, undefined>();
export const fetchBrokersAction = createAsyncAction( export const fetchBrokersAction = createAsyncAction(
ActionType.GET_BROKERS__REQUEST, 'GET_BROKERS__REQUEST',
ActionType.GET_BROKERS__SUCCESS, 'GET_BROKERS__SUCCESS',
ActionType.GET_BROKERS__FAILURE 'GET_BROKERS__FAILURE'
)<undefined, Broker[], undefined>(); )<undefined, Broker[], undefined>();
export const fetchBrokerMetricsAction = createAsyncAction( export const fetchBrokerMetricsAction = createAsyncAction(
ActionType.GET_BROKER_METRICS__REQUEST, 'GET_BROKER_METRICS__REQUEST',
ActionType.GET_BROKER_METRICS__SUCCESS, 'GET_BROKER_METRICS__SUCCESS',
ActionType.GET_BROKER_METRICS__FAILURE 'GET_BROKER_METRICS__FAILURE'
)<undefined, BrokerMetrics, undefined>(); )<undefined, BrokerMetrics, undefined>();
export const fetchClusterListAction = createAsyncAction( export const fetchClusterListAction = createAsyncAction(
ActionType.GET_CLUSTERS__REQUEST, 'GET_CLUSTERS__REQUEST',
ActionType.GET_CLUSTERS__SUCCESS, 'GET_CLUSTERS__SUCCESS',
ActionType.GET_CLUSTERS__FAILURE 'GET_CLUSTERS__FAILURE'
)<undefined, Cluster[], undefined>(); )<undefined, Cluster[], undefined>();
export const fetchTopicsListAction = createAsyncAction( export const fetchTopicsListAction = createAsyncAction(
ActionType.GET_TOPICS__REQUEST, 'GET_TOPICS__REQUEST',
ActionType.GET_TOPICS__SUCCESS, 'GET_TOPICS__SUCCESS',
ActionType.GET_TOPICS__FAILURE 'GET_TOPICS__FAILURE'
)<undefined, Topic[], undefined>(); )<undefined, Topic[], undefined>();
export const fetchTopicMessagesAction = createAsyncAction( export const fetchTopicMessagesAction = createAsyncAction(
ActionType.GET_TOPIC_MESSAGES__REQUEST, 'GET_TOPIC_MESSAGES__REQUEST',
ActionType.GET_TOPIC_MESSAGES__SUCCESS, 'GET_TOPIC_MESSAGES__SUCCESS',
ActionType.GET_TOPIC_MESSAGES__FAILURE 'GET_TOPIC_MESSAGES__FAILURE'
)<undefined, TopicMessage[], undefined>(); )<undefined, TopicMessage[], undefined>();
export const fetchTopicDetailsAction = createAsyncAction( export const fetchTopicDetailsAction = createAsyncAction(
ActionType.GET_TOPIC_DETAILS__REQUEST, 'GET_TOPIC_DETAILS__REQUEST',
ActionType.GET_TOPIC_DETAILS__SUCCESS, 'GET_TOPIC_DETAILS__SUCCESS',
ActionType.GET_TOPIC_DETAILS__FAILURE 'GET_TOPIC_DETAILS__FAILURE'
)<undefined, { topicName: TopicName; details: TopicDetails }, undefined>(); )<undefined, { topicName: TopicName; details: TopicDetails }, undefined>();
export const fetchTopicConfigAction = createAsyncAction( export const fetchTopicConfigAction = createAsyncAction(
ActionType.GET_TOPIC_CONFIG__REQUEST, 'GET_TOPIC_CONFIG__REQUEST',
ActionType.GET_TOPIC_CONFIG__SUCCESS, 'GET_TOPIC_CONFIG__SUCCESS',
ActionType.GET_TOPIC_CONFIG__FAILURE 'GET_TOPIC_CONFIG__FAILURE'
)<undefined, { topicName: TopicName; config: TopicConfig[] }, undefined>(); )<undefined, { topicName: TopicName; config: TopicConfig[] }, undefined>();
export const createTopicAction = createAsyncAction( export const createTopicAction = createAsyncAction(
ActionType.POST_TOPIC__REQUEST, 'POST_TOPIC__REQUEST',
ActionType.POST_TOPIC__SUCCESS, 'POST_TOPIC__SUCCESS',
ActionType.POST_TOPIC__FAILURE 'POST_TOPIC__FAILURE'
)<undefined, Topic, undefined>(); )<undefined, Topic, undefined>();
export const updateTopicAction = createAsyncAction( export const updateTopicAction = createAsyncAction(
ActionType.PATCH_TOPIC__REQUEST, 'PATCH_TOPIC__REQUEST',
ActionType.PATCH_TOPIC__SUCCESS, 'PATCH_TOPIC__SUCCESS',
ActionType.PATCH_TOPIC__FAILURE 'PATCH_TOPIC__FAILURE'
)<undefined, Topic, undefined>(); )<undefined, Topic, undefined>();
export const fetchConsumerGroupsAction = createAsyncAction( export const fetchConsumerGroupsAction = createAsyncAction(
ActionType.GET_CONSUMER_GROUPS__REQUEST, 'GET_CONSUMER_GROUPS__REQUEST',
ActionType.GET_CONSUMER_GROUPS__SUCCESS, 'GET_CONSUMER_GROUPS__SUCCESS',
ActionType.GET_CONSUMER_GROUPS__FAILURE 'GET_CONSUMER_GROUPS__FAILURE'
)<undefined, ConsumerGroup[], undefined>(); )<undefined, ConsumerGroup[], undefined>();
export const fetchConsumerGroupDetailsAction = createAsyncAction( export const fetchConsumerGroupDetailsAction = createAsyncAction(
ActionType.GET_CONSUMER_GROUP_DETAILS__REQUEST, 'GET_CONSUMER_GROUP_DETAILS__REQUEST',
ActionType.GET_CONSUMER_GROUP_DETAILS__SUCCESS, 'GET_CONSUMER_GROUP_DETAILS__SUCCESS',
ActionType.GET_CONSUMER_GROUP_DETAILS__FAILURE 'GET_CONSUMER_GROUP_DETAILS__FAILURE'
)< )<
undefined, undefined,
{ consumerGroupID: ConsumerGroupID; details: ConsumerGroupDetails }, { consumerGroupID: ConsumerGroupID; details: ConsumerGroupDetails },

View file

@ -16,13 +16,6 @@ export * from './broker';
export * from './consumerGroup'; export * from './consumerGroup';
export * from './loader'; export * from './loader';
export enum FetchStatus {
notFetched = 'notFetched',
fetching = 'fetching',
fetched = 'fetched',
errorFetching = 'errorFetching',
}
export interface RootState { export interface RootState {
topics: TopicsState; topics: TopicsState;
clusters: ClusterState; clusters: ClusterState;

View file

@ -1,5 +1,3 @@
import { FetchStatus } from 'redux/interfaces/index';
export interface LoaderState { export interface LoaderState {
[key: string]: FetchStatus; [key: string]: 'notFetched' | 'fetching' | 'fetched' | 'errorFetching';
} }

View file

@ -1,6 +1,5 @@
import { Action, BrokersState, ZooKeeperStatus } from 'redux/interfaces'; import { Action, BrokersState, ZooKeeperStatus } from 'redux/interfaces';
import { ClusterStats } from 'generated-sources'; import { ClusterStats } from 'generated-sources';
import ActionType from 'redux/actionType';
export const initialState: BrokersState = { export const initialState: BrokersState = {
items: [], items: [],
@ -36,14 +35,14 @@ const updateBrokerSegmentSize = (
const reducer = (state = initialState, action: Action): BrokersState => { const reducer = (state = initialState, action: Action): BrokersState => {
switch (action.type) { switch (action.type) {
case ActionType.GET_BROKERS__REQUEST: case 'GET_BROKERS__REQUEST':
return initialState; return initialState;
case ActionType.GET_BROKERS__SUCCESS: case 'GET_BROKERS__SUCCESS':
return { return {
...state, ...state,
items: action.payload, items: action.payload,
}; };
case ActionType.GET_CLUSTER_STATS__SUCCESS: case 'GET_CLUSTER_STATUS__SUCCESS':
return updateBrokerSegmentSize(state, action.payload); return updateBrokerSegmentSize(state, action.payload);
default: default:
return state; return state;

View file

@ -1,5 +1,5 @@
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { RootState, FetchStatus, BrokersState } from 'redux/interfaces'; import { RootState, BrokersState } from 'redux/interfaces';
import { createFetchingSelector } from 'redux/reducers/loader/selectors'; import { createFetchingSelector } from 'redux/reducers/loader/selectors';
const brokersState = ({ brokers }: RootState): BrokersState => brokers; const brokersState = ({ brokers }: RootState): BrokersState => brokers;
@ -8,7 +8,7 @@ const getBrokerListFetchingStatus = createFetchingSelector('GET_BROKERS');
export const getIsBrokerListFetched = createSelector( export const getIsBrokerListFetched = createSelector(
getBrokerListFetchingStatus, getBrokerListFetchingStatus,
(status) => status === FetchStatus.fetched (status) => status === 'fetched'
); );
export const getBrokerCount = createSelector( export const getBrokerCount = createSelector(

View file

@ -1,12 +1,11 @@
import { Action } from 'redux/interfaces'; import { Action } from 'redux/interfaces';
import { Cluster } from 'generated-sources'; import { Cluster } from 'generated-sources';
import ActionType from 'redux/actionType';
export const initialState: Cluster[] = []; export const initialState: Cluster[] = [];
const reducer = (state = initialState, action: Action): Cluster[] => { const reducer = (state = initialState, action: Action): Cluster[] => {
switch (action.type) { switch (action.type) {
case ActionType.GET_CLUSTERS__SUCCESS: case 'GET_CLUSTERS__SUCCESS':
return action.payload; return action.payload;
default: default:
return state; return state;

View file

@ -1,5 +1,5 @@
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { RootState, FetchStatus } from 'redux/interfaces'; import { RootState } from 'redux/interfaces';
import { createFetchingSelector } from 'redux/reducers/loader/selectors'; import { createFetchingSelector } from 'redux/reducers/loader/selectors';
import { Cluster, ServerStatus } from 'generated-sources'; import { Cluster, ServerStatus } from 'generated-sources';
@ -9,7 +9,7 @@ const getClusterListFetchingStatus = createFetchingSelector('GET_CLUSTERS');
export const getIsClusterListFetched = createSelector( export const getIsClusterListFetched = createSelector(
getClusterListFetchingStatus, getClusterListFetchingStatus,
(status) => status === FetchStatus.fetched (status) => status === 'fetched'
); );
export const getClusterList = createSelector( export const getClusterList = createSelector(

View file

@ -1,6 +1,5 @@
import { Action, ConsumerGroupsState } from 'redux/interfaces'; import { Action, ConsumerGroupsState } from 'redux/interfaces';
import { ConsumerGroup } from 'generated-sources'; import { ConsumerGroup } from 'generated-sources';
import ActionType from 'redux/actionType';
export const initialState: ConsumerGroupsState = { export const initialState: ConsumerGroupsState = {
byID: {}, byID: {},
@ -34,9 +33,9 @@ const updateConsumerGroupsList = (
const reducer = (state = initialState, action: Action): ConsumerGroupsState => { const reducer = (state = initialState, action: Action): ConsumerGroupsState => {
switch (action.type) { switch (action.type) {
case ActionType.GET_CONSUMER_GROUPS__SUCCESS: case 'GET_CONSUMER_GROUPS__SUCCESS':
return updateConsumerGroupsList(state, action.payload); return updateConsumerGroupsList(state, action.payload);
case ActionType.GET_CONSUMER_GROUP_DETAILS__SUCCESS: case 'GET_CONSUMER_GROUP_DETAILS__SUCCESS':
return { return {
...state, ...state,
byID: { byID: {

View file

@ -1,5 +1,5 @@
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { RootState, FetchStatus } from 'redux/interfaces'; import { RootState } from 'redux/interfaces';
import { createFetchingSelector } from 'redux/reducers/loader/selectors'; import { createFetchingSelector } from 'redux/reducers/loader/selectors';
import { import {
ConsumerGroupID, ConsumerGroupID,
@ -24,12 +24,12 @@ const getConsumerGroupDetailsFetchingStatus = createFetchingSelector(
export const getIsConsumerGroupsListFetched = createSelector( export const getIsConsumerGroupsListFetched = createSelector(
getConsumerGroupsListFetchingStatus, getConsumerGroupsListFetchingStatus,
(status) => status === FetchStatus.fetched (status) => status === 'fetched'
); );
export const getIsConsumerGroupDetailsFetched = createSelector( export const getIsConsumerGroupDetailsFetched = createSelector(
getConsumerGroupDetailsFetchingStatus, getConsumerGroupDetailsFetchingStatus,
(status) => status === FetchStatus.fetched (status) => status === 'fetched'
); );
export const getConsumerGroupsList = createSelector( export const getConsumerGroupsList = createSelector(

View file

@ -1,4 +1,4 @@
import { FetchStatus, Action, LoaderState } from 'redux/interfaces'; import { Action, LoaderState } from 'redux/interfaces';
export const initialState: LoaderState = {}; export const initialState: LoaderState = {};
@ -15,17 +15,17 @@ const reducer = (state = initialState, action: Action): LoaderState => {
case 'REQUEST': case 'REQUEST':
return { return {
...state, ...state,
[requestName]: FetchStatus.fetching, [requestName]: 'fetching',
}; };
case 'SUCCESS': case 'SUCCESS':
return { return {
...state, ...state,
[requestName]: FetchStatus.fetched, [requestName]: 'fetched',
}; };
case 'FAILURE': case 'FAILURE':
return { return {
...state, ...state,
[requestName]: FetchStatus.errorFetching, [requestName]: 'errorFetching',
}; };
default: default:
return state; return state;

View file

@ -1,4 +1,4 @@
import { RootState, FetchStatus } from 'redux/interfaces'; import { RootState } from 'redux/interfaces';
export const createFetchingSelector = (action: string) => (state: RootState) => export const createFetchingSelector = (action: string) => (state: RootState) =>
state.loader[action] || FetchStatus.notFetched; state.loader[action] || 'notFetched';

View file

@ -1,7 +1,6 @@
import { v4 } from 'uuid'; import { v4 } from 'uuid';
import { Topic, TopicMessage } from 'generated-sources'; import { Topic, TopicMessage } from 'generated-sources';
import { Action, TopicsState } from 'redux/interfaces'; import { Action, TopicsState } from 'redux/interfaces';
import ActionType from 'redux/actionType';
export const initialState: TopicsState = { export const initialState: TopicsState = {
byName: {}, byName: {},
@ -68,9 +67,9 @@ const transformTopicMessages = (
const reducer = (state = initialState, action: Action): TopicsState => { const reducer = (state = initialState, action: Action): TopicsState => {
switch (action.type) { switch (action.type) {
case ActionType.GET_TOPICS__SUCCESS: case 'GET_TOPICS__SUCCESS':
return updateTopicList(state, action.payload); return updateTopicList(state, action.payload);
case ActionType.GET_TOPIC_DETAILS__SUCCESS: case 'GET_TOPIC_DETAILS__SUCCESS':
return { return {
...state, ...state,
byName: { byName: {
@ -81,9 +80,9 @@ const reducer = (state = initialState, action: Action): TopicsState => {
}, },
}, },
}; };
case ActionType.GET_TOPIC_MESSAGES__SUCCESS: case 'GET_TOPIC_MESSAGES__SUCCESS':
return transformTopicMessages(state, action.payload); return transformTopicMessages(state, action.payload);
case ActionType.GET_TOPIC_CONFIG__SUCCESS: case 'GET_TOPIC_CONFIG__SUCCESS':
return { return {
...state, ...state,
byName: { byName: {
@ -97,7 +96,7 @@ const reducer = (state = initialState, action: Action): TopicsState => {
}, },
}, },
}; };
case ActionType.POST_TOPIC__SUCCESS: case 'POST_TOPIC__SUCCESS':
return addToTopicList(state, action.payload); return addToTopicList(state, action.payload);
default: default:
return state; return state;

View file

@ -2,7 +2,6 @@ import { createSelector } from 'reselect';
import { import {
RootState, RootState,
TopicName, TopicName,
FetchStatus,
TopicsState, TopicsState,
TopicConfigByName, TopicConfigByName,
} from 'redux/interfaces'; } from 'redux/interfaces';
@ -29,32 +28,32 @@ const getTopicUpdateStatus = createFetchingSelector('PATCH_TOPIC');
export const getIsTopicListFetched = createSelector( export const getIsTopicListFetched = createSelector(
getTopicListFetchingStatus, getTopicListFetchingStatus,
(status) => status === FetchStatus.fetched (status) => status === 'fetched'
); );
export const getIsTopicDetailsFetched = createSelector( export const getIsTopicDetailsFetched = createSelector(
getTopicDetailsFetchingStatus, getTopicDetailsFetchingStatus,
(status) => status === FetchStatus.fetched (status) => status === 'fetched'
); );
export const getIsTopicMessagesFetched = createSelector( export const getIsTopicMessagesFetched = createSelector(
getTopicMessagesFetchingStatus, getTopicMessagesFetchingStatus,
(status) => status === FetchStatus.fetched (status) => status === 'fetched'
); );
export const getTopicConfigFetched = createSelector( export const getTopicConfigFetched = createSelector(
getTopicConfigFetchingStatus, getTopicConfigFetchingStatus,
(status) => status === FetchStatus.fetched (status) => status === 'fetched'
); );
export const getTopicCreated = createSelector( export const getTopicCreated = createSelector(
getTopicCreationStatus, getTopicCreationStatus,
(status) => status === FetchStatus.fetched (status) => status === 'fetched'
); );
export const getTopicUpdated = createSelector( export const getTopicUpdated = createSelector(
getTopicUpdateStatus, getTopicUpdateStatus,
(status) => status === FetchStatus.fetched (status) => status === 'fetched'
); );
export const getTopicList = createSelector( export const getTopicList = createSelector(