Browse Source

feature/14-cleanup

Azat Gataullin 5 years ago
parent
commit
0e7f75bf21

+ 1 - 1
kafka-ui-react-app/.env

@@ -1,2 +1,2 @@
 # Kafka REST API
-REACT_APP_API_URL=http://localhost:3004/api
+REACT_APP_API_URL=http://localhost:8080/api

+ 0 - 3
kafka-ui-react-app/mock/index.js

@@ -5,7 +5,6 @@ const brokerMetrics = require('./payload/brokerMetrics.json');
 const topics = require('./payload/topics.json');
 const topicDetails = require('./payload/topicDetails.json');
 const topicConfigs = require('./payload/topicConfigs.json');
-const topicsCustomParams = require('./payload/topicsCustomParams.json');
 
 const db = {
     clusters,
@@ -14,7 +13,6 @@ const db = {
     topics: topics.map((topic) => ({...topic, id: topic.name})),
     topicDetails,
     topicConfigs,
-    topicsCustomParams,
 };
 const server = jsonServer.create();
 const router = jsonServer.router(db);
@@ -32,7 +30,6 @@ server.use(
   jsonServer.rewriter({
     '/api/*': '/$1',
     '/clusters/:clusterName/metrics/broker': '/brokerMetrics/:clusterName',
-    '/clusters/:clusterName/topics/custom_params': '/topicsCustomParams',
     '/clusters/:clusterName/topics/:id': '/topicDetails',
     '/clusters/:clusterName/topics/:id/config': '/topicConfigs',
   })

+ 0 - 32
kafka-ui-react-app/mock/payload/topicsCustomParams.json

@@ -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"
-  }
-]

+ 1 - 3
kafka-ui-react-app/src/components/Topics/New/CustomParams/CustomParamSelect.tsx

@@ -20,9 +20,7 @@ const CustomParamSelect: React.FC<Props> = ({
   const optInputName = `${index}[name]`;
 
   React.useEffect(
-    () => {
-      if (isFirstParam(index)) { unregister(optInputName) }
-    },
+    () => { if (isFirstParam(index)) { unregister(optInputName) } },
   );
 
   const selectedMustBeUniq = (selected: string) => {

+ 1 - 3
kafka-ui-react-app/src/components/Topics/New/CustomParams/CustomParamValue.tsx

@@ -32,9 +32,7 @@ const CustomParamValue: React.FC<Props> = ({
   );
 
   React.useEffect(
-    () => {
-      if (isFirstParam(index)) { unregister(valInputName) }
-    },
+    () => { if (isFirstParam(index)) { unregister(valInputName) } },
   );
 
   return (

+ 0 - 2
kafka-ui-react-app/src/components/Topics/New/New.tsx

@@ -39,8 +39,6 @@ const New: React.FC<Props> = ({
   );
 
   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
     //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

+ 0 - 6
kafka-ui-react-app/src/redux/actionType.ts

@@ -23,13 +23,7 @@ export enum ActionType {
   GET_TOPIC_CONFIG__SUCCESS = 'GET_TOPIC_CONFIG__SUCCESS',
   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__SUCCESS = 'POST_TOPIC__SUCCESS',
   POST_TOPIC__FAILURE = 'POST_TOPIC__FAILURE',
-
-  ADD_TOPIC_CUSTOM_PARAM = 'ADD_TOPIC_CUSTOM_PARAM',
 };

+ 0 - 7
kafka-ui-react-app/src/redux/actions/actions.ts

@@ -8,7 +8,6 @@ import {
   TopicConfig,
   TopicDetails,
   TopicName,
-  TopicCustomParam,
 } from 'redux/interfaces';
 
 export const fetchBrokersAction = createAsyncAction(
@@ -35,12 +34,6 @@ export const fetchTopicListAction = createAsyncAction(
   ActionType.GET_TOPICS__FAILURE,
 )<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(
   ActionType.GET_TOPIC_DETAILS__REQUEST,
   ActionType.GET_TOPIC_DETAILS__SUCCESS,

+ 0 - 10
kafka-ui-react-app/src/redux/actions/thunks.ts

@@ -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) => {
   dispatch(actions.fetchTopicDetailsAction.request());
   try {

+ 0 - 6
kafka-ui-react-app/src/redux/api/topics.ts

@@ -5,7 +5,6 @@ import {
   TopicDetails,
   TopicConfig,
   TopicFormData,
-  TopicCustomParam,
 } from 'redux/interfaces';
 import {
   BASE_URL,
@@ -24,11 +23,6 @@ export const getTopics = (clusterName: ClusterName): Promise<Topic[]> =>
   fetch(`${BASE_URL}/clusters/${clusterName}/topics`, { ...BASE_PARAMS })
     .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> => {
   const {
     name,

+ 5 - 15
kafka-ui-react-app/src/redux/interfaces/topic.ts

@@ -23,11 +23,6 @@ export interface TopicPartition {
   replicas: TopicReplica[];
 }
 
-// extend from option
-export interface TopicCustomParam extends TopicCustomParamOption {
-  value: string;
-}
-
 export interface TopicCustomParamOption {
   name: string;
   defaultValue: string;
@@ -49,28 +44,23 @@ export interface Topic {
   partitions: TopicPartition[];
 }
 
+export interface TopicFormCustomParam {
+  name: string;
+  value: string;
+}
+
 export interface TopicFormCustomParams {
   byIndex: { [paramIndex: string]: TopicFormCustomParam };
   allIndexes: string[];
 }
 
-export interface TopicFormCustomParam {
-  name: string,
-  value: string,
-}
-
 export interface TopicWithDetailedInfo extends Topic, TopicDetails {
   config?: TopicConfig[];
 }
 
-export type TopicCustomParamName = string;
-
 export interface TopicsState {
   byName: { [topicName: string]: TopicWithDetailedInfo };
   allNames: TopicName[];
-  customParams: {
-    byName: { [paramName: string]: TopicCustomParam }
-  };
 }
 
 export interface TopicFormData {

+ 1 - 25
kafka-ui-react-app/src/redux/reducers/topics/reducer.ts

@@ -1,12 +1,9 @@
-import { Action, TopicsState, Topic, TopicCustomParam } from 'redux/interfaces';
+import { Action, TopicsState, Topic } from 'redux/interfaces';
 import { ActionType } from 'redux/actionType';
 
 export const initialState: TopicsState = {
   byName: {},
   allNames: [],
-  customParams: {
-    byName: {},
-  },
 };
 
 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 newState: TopicsState = {
     ...state
@@ -86,8 +64,6 @@ const reducer = (state = initialState, action: Action): TopicsState => {
       };
     case ActionType.POST_TOPIC__SUCCESS:
       return addToTopicList(state, action.payload);
-    case ActionType.GET_TOPICS_CUSTOM_PARAMS__SUCCESS:
-      return setTopicsCustomParams(state, action.payload);
     default:
       return state;
   }