feature/14-cleanup
This commit is contained in:
parent
1109240169
commit
0e7f75bf21
12 changed files with 9 additions and 113 deletions
|
@ -1,2 +1,2 @@
|
||||||
# Kafka REST API
|
# Kafka REST API
|
||||||
REACT_APP_API_URL=http://localhost:3004/api
|
REACT_APP_API_URL=http://localhost:8080/api
|
||||||
|
|
|
@ -5,7 +5,6 @@ const brokerMetrics = require('./payload/brokerMetrics.json');
|
||||||
const topics = require('./payload/topics.json');
|
const topics = require('./payload/topics.json');
|
||||||
const topicDetails = require('./payload/topicDetails.json');
|
const topicDetails = require('./payload/topicDetails.json');
|
||||||
const topicConfigs = require('./payload/topicConfigs.json');
|
const topicConfigs = require('./payload/topicConfigs.json');
|
||||||
const topicsCustomParams = require('./payload/topicsCustomParams.json');
|
|
||||||
|
|
||||||
const db = {
|
const db = {
|
||||||
clusters,
|
clusters,
|
||||||
|
@ -14,7 +13,6 @@ const db = {
|
||||||
topics: topics.map((topic) => ({...topic, id: topic.name})),
|
topics: topics.map((topic) => ({...topic, id: topic.name})),
|
||||||
topicDetails,
|
topicDetails,
|
||||||
topicConfigs,
|
topicConfigs,
|
||||||
topicsCustomParams,
|
|
||||||
};
|
};
|
||||||
const server = jsonServer.create();
|
const server = jsonServer.create();
|
||||||
const router = jsonServer.router(db);
|
const router = jsonServer.router(db);
|
||||||
|
@ -32,7 +30,6 @@ server.use(
|
||||||
jsonServer.rewriter({
|
jsonServer.rewriter({
|
||||||
'/api/*': '/$1',
|
'/api/*': '/$1',
|
||||||
'/clusters/:clusterName/metrics/broker': '/brokerMetrics/:clusterName',
|
'/clusters/:clusterName/metrics/broker': '/brokerMetrics/:clusterName',
|
||||||
'/clusters/:clusterName/topics/custom_params': '/topicsCustomParams',
|
|
||||||
'/clusters/:clusterName/topics/:id': '/topicDetails',
|
'/clusters/:clusterName/topics/:id': '/topicDetails',
|
||||||
'/clusters/:clusterName/topics/:id/config': '/topicConfigs',
|
'/clusters/:clusterName/topics/:id/config': '/topicConfigs',
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "topic.custom.param.name-1",
|
|
||||||
"value": "topic.custom.param.value-1",
|
|
||||||
"defaultValue": "topic.custom.param.defValue-1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "topic.custom.param.name-2",
|
|
||||||
"value": "topic.custom.param.value-2",
|
|
||||||
"defaultValue": "topic.custom.param.defValue-2"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "topic.custom.param.name-3",
|
|
||||||
"value": "topic.custom.param.value-3",
|
|
||||||
"defaultValue": "topic.custom.param.defValue-3"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "topic.custom.param.name-4",
|
|
||||||
"value": "topic.custom.param.value-4",
|
|
||||||
"defaultValue": "topic.custom.param.defValue-4"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "topic.custom.param.name-5",
|
|
||||||
"value": "topic.custom.param.value-5",
|
|
||||||
"defaultValue": "topic.custom.param.defValue-5"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "topic.custom.param.name-6",
|
|
||||||
"value": "topic.custom.param.value-6",
|
|
||||||
"defaultValue": "topic.custom.param.defValue-6"
|
|
||||||
}
|
|
||||||
]
|
|
|
@ -20,9 +20,7 @@ const CustomParamSelect: React.FC<Props> = ({
|
||||||
const optInputName = `${index}[name]`;
|
const optInputName = `${index}[name]`;
|
||||||
|
|
||||||
React.useEffect(
|
React.useEffect(
|
||||||
() => {
|
() => { if (isFirstParam(index)) { unregister(optInputName) } },
|
||||||
if (isFirstParam(index)) { unregister(optInputName) }
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const selectedMustBeUniq = (selected: string) => {
|
const selectedMustBeUniq = (selected: string) => {
|
||||||
|
|
|
@ -32,9 +32,7 @@ const CustomParamValue: React.FC<Props> = ({
|
||||||
);
|
);
|
||||||
|
|
||||||
React.useEffect(
|
React.useEffect(
|
||||||
() => {
|
() => { if (isFirstParam(index)) { unregister(valInputName) } },
|
||||||
if (isFirstParam(index)) { unregister(valInputName) }
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -39,8 +39,6 @@ const New: React.FC<Props> = ({
|
||||||
);
|
);
|
||||||
|
|
||||||
const onSubmit = async (data: TopicFormData) => {
|
const onSubmit = async (data: TopicFormData) => {
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
//TODO: need to fix loader. After success loading the first time, we won't wait for creation any more, because state is
|
//TODO: need to fix loader. After success loading the first time, we won't wait for creation any more, because state is
|
||||||
//loaded, and we will try to get entity immediately after pressing the button, and we will receive null
|
//loaded, and we will try to get entity immediately after pressing the button, and we will receive null
|
||||||
//going to object page on the second creation. Resetting loaded state is workaround, need to tweak loader logic
|
//going to object page on the second creation. Resetting loaded state is workaround, need to tweak loader logic
|
||||||
|
|
|
@ -23,13 +23,7 @@ export enum ActionType {
|
||||||
GET_TOPIC_CONFIG__SUCCESS = 'GET_TOPIC_CONFIG__SUCCESS',
|
GET_TOPIC_CONFIG__SUCCESS = 'GET_TOPIC_CONFIG__SUCCESS',
|
||||||
GET_TOPIC_CONFIG__FAILURE = 'GET_TOPIC_CONFIG__FAILURE',
|
GET_TOPIC_CONFIG__FAILURE = 'GET_TOPIC_CONFIG__FAILURE',
|
||||||
|
|
||||||
GET_TOPICS_CUSTOM_PARAMS__REQUEST = 'GET_TOPICS_CUSTOM_PARAMS__REQUEST',
|
|
||||||
GET_TOPICS_CUSTOM_PARAMS__SUCCESS = 'GET_TOPICS_CUSTOM_PARAMS__SUCCESS',
|
|
||||||
GET_TOPICS_CUSTOM_PARAMS__FAILURE = 'GET_TOPICS_CUSTOM_PARAMS__FAILURE',
|
|
||||||
|
|
||||||
POST_TOPIC__REQUEST = 'POST_TOPIC__REQUEST',
|
POST_TOPIC__REQUEST = 'POST_TOPIC__REQUEST',
|
||||||
POST_TOPIC__SUCCESS = 'POST_TOPIC__SUCCESS',
|
POST_TOPIC__SUCCESS = 'POST_TOPIC__SUCCESS',
|
||||||
POST_TOPIC__FAILURE = 'POST_TOPIC__FAILURE',
|
POST_TOPIC__FAILURE = 'POST_TOPIC__FAILURE',
|
||||||
|
|
||||||
ADD_TOPIC_CUSTOM_PARAM = 'ADD_TOPIC_CUSTOM_PARAM',
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,7 +8,6 @@ import {
|
||||||
TopicConfig,
|
TopicConfig,
|
||||||
TopicDetails,
|
TopicDetails,
|
||||||
TopicName,
|
TopicName,
|
||||||
TopicCustomParam,
|
|
||||||
} from 'redux/interfaces';
|
} from 'redux/interfaces';
|
||||||
|
|
||||||
export const fetchBrokersAction = createAsyncAction(
|
export const fetchBrokersAction = createAsyncAction(
|
||||||
|
@ -35,12 +34,6 @@ export const fetchTopicListAction = createAsyncAction(
|
||||||
ActionType.GET_TOPICS__FAILURE,
|
ActionType.GET_TOPICS__FAILURE,
|
||||||
)<undefined, Topic[], undefined>();
|
)<undefined, Topic[], undefined>();
|
||||||
|
|
||||||
export const fetchTopicsCustomParamsAction = createAsyncAction(
|
|
||||||
ActionType.GET_TOPICS_CUSTOM_PARAMS__REQUEST,
|
|
||||||
ActionType.GET_TOPICS_CUSTOM_PARAMS__SUCCESS,
|
|
||||||
ActionType.GET_TOPICS_CUSTOM_PARAMS__FAILURE,
|
|
||||||
)<undefined, TopicCustomParam[], undefined>();
|
|
||||||
|
|
||||||
export const fetchTopicDetailsAction = createAsyncAction(
|
export const fetchTopicDetailsAction = createAsyncAction(
|
||||||
ActionType.GET_TOPIC_DETAILS__REQUEST,
|
ActionType.GET_TOPIC_DETAILS__REQUEST,
|
||||||
ActionType.GET_TOPIC_DETAILS__SUCCESS,
|
ActionType.GET_TOPIC_DETAILS__SUCCESS,
|
||||||
|
|
|
@ -48,16 +48,6 @@ export const fetchTopicList = (clusterName: ClusterName): PromiseThunk<void> =>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fetchTopicsCustomParams = (clusterName: ClusterName): PromiseThunk<void> => async (dispatch) => {
|
|
||||||
dispatch(actions.fetchTopicsCustomParamsAction.request());
|
|
||||||
try {
|
|
||||||
const customParams = await api.getTopicsCustomParams(clusterName);
|
|
||||||
dispatch(actions.fetchTopicsCustomParamsAction.success(customParams));
|
|
||||||
} catch (e) {
|
|
||||||
dispatch(actions.fetchTopicsCustomParamsAction.failure());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const fetchTopicDetails = (clusterName: ClusterName, topicName: TopicName): PromiseThunk<void> => async (dispatch) => {
|
export const fetchTopicDetails = (clusterName: ClusterName, topicName: TopicName): PromiseThunk<void> => async (dispatch) => {
|
||||||
dispatch(actions.fetchTopicDetailsAction.request());
|
dispatch(actions.fetchTopicDetailsAction.request());
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import {
|
||||||
TopicDetails,
|
TopicDetails,
|
||||||
TopicConfig,
|
TopicConfig,
|
||||||
TopicFormData,
|
TopicFormData,
|
||||||
TopicCustomParam,
|
|
||||||
} from 'redux/interfaces';
|
} from 'redux/interfaces';
|
||||||
import {
|
import {
|
||||||
BASE_URL,
|
BASE_URL,
|
||||||
|
@ -24,11 +23,6 @@ export const getTopics = (clusterName: ClusterName): Promise<Topic[]> =>
|
||||||
fetch(`${BASE_URL}/clusters/${clusterName}/topics`, { ...BASE_PARAMS })
|
fetch(`${BASE_URL}/clusters/${clusterName}/topics`, { ...BASE_PARAMS })
|
||||||
.then(res => res.json());
|
.then(res => res.json());
|
||||||
|
|
||||||
// TODO: the url needs to be reconsiled
|
|
||||||
export const getTopicsCustomParams = (clusterName: ClusterName): Promise<TopicCustomParam[]> =>
|
|
||||||
fetch(`${BASE_URL}/clusters/${clusterName}/topics/custom_params`, { ...BASE_PARAMS })
|
|
||||||
.then(res => res.json());
|
|
||||||
|
|
||||||
export const postTopic = (clusterName: ClusterName, form: TopicFormData): Promise<Topic> => {
|
export const postTopic = (clusterName: ClusterName, form: TopicFormData): Promise<Topic> => {
|
||||||
const {
|
const {
|
||||||
name,
|
name,
|
||||||
|
|
|
@ -23,11 +23,6 @@ export interface TopicPartition {
|
||||||
replicas: TopicReplica[];
|
replicas: TopicReplica[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// extend from option
|
|
||||||
export interface TopicCustomParam extends TopicCustomParamOption {
|
|
||||||
value: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TopicCustomParamOption {
|
export interface TopicCustomParamOption {
|
||||||
name: string;
|
name: string;
|
||||||
defaultValue: string;
|
defaultValue: string;
|
||||||
|
@ -49,28 +44,23 @@ export interface Topic {
|
||||||
partitions: TopicPartition[];
|
partitions: TopicPartition[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TopicFormCustomParam {
|
||||||
|
name: string;
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface TopicFormCustomParams {
|
export interface TopicFormCustomParams {
|
||||||
byIndex: { [paramIndex: string]: TopicFormCustomParam };
|
byIndex: { [paramIndex: string]: TopicFormCustomParam };
|
||||||
allIndexes: string[];
|
allIndexes: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TopicFormCustomParam {
|
|
||||||
name: string,
|
|
||||||
value: string,
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TopicWithDetailedInfo extends Topic, TopicDetails {
|
export interface TopicWithDetailedInfo extends Topic, TopicDetails {
|
||||||
config?: TopicConfig[];
|
config?: TopicConfig[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TopicCustomParamName = string;
|
|
||||||
|
|
||||||
export interface TopicsState {
|
export interface TopicsState {
|
||||||
byName: { [topicName: string]: TopicWithDetailedInfo };
|
byName: { [topicName: string]: TopicWithDetailedInfo };
|
||||||
allNames: TopicName[];
|
allNames: TopicName[];
|
||||||
customParams: {
|
|
||||||
byName: { [paramName: string]: TopicCustomParam }
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TopicFormData {
|
export interface TopicFormData {
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
import { Action, TopicsState, Topic, TopicCustomParam } from 'redux/interfaces';
|
import { Action, TopicsState, Topic } from 'redux/interfaces';
|
||||||
import { ActionType } from 'redux/actionType';
|
import { ActionType } from 'redux/actionType';
|
||||||
|
|
||||||
export const initialState: TopicsState = {
|
export const initialState: TopicsState = {
|
||||||
byName: {},
|
byName: {},
|
||||||
allNames: [],
|
allNames: [],
|
||||||
customParams: {
|
|
||||||
byName: {},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateTopicList = (state: TopicsState, payload: Topic[]): TopicsState => {
|
const updateTopicList = (state: TopicsState, payload: Topic[]): TopicsState => {
|
||||||
|
@ -30,25 +27,6 @@ const updateTopicList = (state: TopicsState, payload: Topic[]): TopicsState => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const setTopicsCustomParams = (state: TopicsState, payload: TopicCustomParam[]): TopicsState => {
|
|
||||||
const initialMemo: TopicsState = {
|
|
||||||
...state,
|
|
||||||
customParams: {
|
|
||||||
...state.customParams,
|
|
||||||
byName: {},
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return payload.reduce(
|
|
||||||
(memo: TopicsState, topicCustomParam) => {
|
|
||||||
memo.customParams.byName[topicCustomParam.name] = topicCustomParam;
|
|
||||||
|
|
||||||
return memo;
|
|
||||||
},
|
|
||||||
initialMemo,
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const addToTopicList = (state: TopicsState, payload: Topic): TopicsState => {
|
const addToTopicList = (state: TopicsState, payload: Topic): TopicsState => {
|
||||||
const newState: TopicsState = {
|
const newState: TopicsState = {
|
||||||
...state
|
...state
|
||||||
|
@ -86,8 +64,6 @@ const reducer = (state = initialState, action: Action): TopicsState => {
|
||||||
};
|
};
|
||||||
case ActionType.POST_TOPIC__SUCCESS:
|
case ActionType.POST_TOPIC__SUCCESS:
|
||||||
return addToTopicList(state, action.payload);
|
return addToTopicList(state, action.payload);
|
||||||
case ActionType.GET_TOPICS_CUSTOM_PARAMS__SUCCESS:
|
|
||||||
return setTopicsCustomParams(state, action.payload);
|
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue