From cc98afca0df3db7fd10e3feb27ddd8b1ae25c55b Mon Sep 17 00:00:00 2001
From: Oleg Shuralev
Date: Sun, 12 Jan 2020 21:39:43 +0300
Subject: [PATCH] [UI] Details
---
frontend/src/components/Nav/Nav.tsx | 2 +-
.../src/components/Topics/Details/Details.tsx | 2 -
.../Topics/Details/DetailsContainer.ts | 7 +--
.../Topics/Details/Overview/Overview.tsx | 37 ++++++------
.../Topics/Details/Settings/Settings.tsx | 59 +++++++++++++++++--
.../Details/Settings/SettingsContainer.ts | 19 ++++--
frontend/src/components/Topics/List/List.tsx | 10 ++--
.../src/components/Topics/List/ListItem.tsx | 4 +-
.../common/Breadcrumb/Breadcrumb.tsx | 4 +-
frontend/src/lib/api/topics.ts | 4 +-
.../src/redux/reducers/topics/actionType.ts | 4 ++
frontend/src/redux/reducers/topics/actions.ts | 8 ++-
frontend/src/redux/reducers/topics/reducer.ts | 11 ++++
.../src/redux/reducers/topics/selectors.ts | 12 +++-
frontend/src/redux/reducers/topics/thunks.ts | 12 ++++
frontend/src/types/topic.ts | 12 +++-
16 files changed, 155 insertions(+), 52 deletions(-)
diff --git a/frontend/src/components/Nav/Nav.tsx b/frontend/src/components/Nav/Nav.tsx
index b84c0251202dc0ea78f7a43a3f7801e27412ed31..1cd7a526a49192a93540f7d55ae709ab21f758c1 100644
--- a/frontend/src/components/Nav/Nav.tsx
+++ b/frontend/src/components/Nav/Nav.tsx
@@ -31,7 +31,7 @@ const Nav: React.FC = ({
{!isClusterListFetched && }
- {isClusterListFetched && clusters.map((cluster) => )}
+ {isClusterListFetched && clusters.map((cluster, index) => )}
);
diff --git a/frontend/src/components/Topics/Details/Details.tsx b/frontend/src/components/Topics/Details/Details.tsx
index fd1abc3d791a013d3f98d5387e14f53ddab6c872..dec65ae2ea444c35750d04b84f88df3a77088c8b 100644
--- a/frontend/src/components/Topics/Details/Details.tsx
+++ b/frontend/src/components/Topics/Details/Details.tsx
@@ -1,5 +1,4 @@
import React from 'react';
-import cx from 'classnames';
import { ClusterId, Topic, TopicDetails, TopicName } from 'types';
import Breadcrumb from 'components/common/Breadcrumb/Breadcrumb';
import { NavLink, Switch, Route } from 'react-router-dom';
@@ -11,7 +10,6 @@ import SettingsContainer from './Settings/SettingsContainer';
interface Props extends Topic, TopicDetails {
clusterId: ClusterId;
topicName: TopicName;
- fetchTopicDetails: (clusterId: ClusterId, topicName: TopicName) => void;
}
const Details: React.FC = ({
diff --git a/frontend/src/components/Topics/Details/DetailsContainer.ts b/frontend/src/components/Topics/Details/DetailsContainer.ts
index e1b0998b05abdd98363b9aab43c623e15267c3bc..717b3114fd49368b79d02543925dd73ab66a531f 100644
--- a/frontend/src/components/Topics/Details/DetailsContainer.ts
+++ b/frontend/src/components/Topics/Details/DetailsContainer.ts
@@ -1,10 +1,6 @@
import { connect } from 'react-redux';
-import {
- fetchTopicDetails,
-} from 'redux/reducers/topics/thunks';
import Details from './Details';
-import { RootState, TopicName, ClusterId } from 'types';
-import { getTopicByName } from 'redux/reducers/topics/selectors';
+import { RootState } from 'types';
import { withRouter, RouteComponentProps } from 'react-router-dom';
interface RouteProps {
@@ -17,7 +13,6 @@ interface OwnProps extends RouteComponentProps { }
const mapStateToProps = (state: RootState, { match: { params: { topicName, clusterId } } }: OwnProps) => ({
clusterId,
topicName,
- ...getTopicByName(state, topicName),
});
export default withRouter(
diff --git a/frontend/src/components/Topics/Details/Overview/Overview.tsx b/frontend/src/components/Topics/Details/Overview/Overview.tsx
index d330860268dbbf72a1dde26202b7de75b60def93..e44c2df3b8c192571abfbfce784089fd6c5405dc 100644
--- a/frontend/src/components/Topics/Details/Overview/Overview.tsx
+++ b/frontend/src/components/Topics/Details/Overview/Overview.tsx
@@ -34,7 +34,7 @@ const Overview: React.FC = ({
return (
<>
-
+
{partitionCount}
@@ -49,28 +49,29 @@ const Overview: React.FC = ({
of {replicas}
-
+
{internal ? 'Internal' : 'External'}
-
+
-
-
-
-
- Partition ID |
- Broker leader |
-
-
-
- {partitions.map(({ partition, leader }) => (
+
+
+
- {partition} |
- {leader} |
+ Partition ID |
+ Broker leader |
- ))}
-
-
+
+
+ {partitions.map(({ partition, leader }) => (
+
+ {partition} |
+ {leader} |
+
+ ))}
+
+
+
>
);
}
diff --git a/frontend/src/components/Topics/Details/Settings/Settings.tsx b/frontend/src/components/Topics/Details/Settings/Settings.tsx
index c07dfc6ff96eca56dcad1fd989973731ee6c52b7..839f28f4a368e6ddde516f4cfe85ee5543c5a23c 100644
--- a/frontend/src/components/Topics/Details/Settings/Settings.tsx
+++ b/frontend/src/components/Topics/Details/Settings/Settings.tsx
@@ -1,19 +1,70 @@
import React from 'react';
-import { ClusterId, TopicName } from 'types';
+import { ClusterId, TopicName, TopicConfig } from 'types';
interface Props {
clusterId: ClusterId;
topicName: TopicName;
+ config?: TopicConfig[];
+ isFetched: boolean;
+ fetchTopicConfig: (clusterId: ClusterId, topicName: TopicName) => void;
+}
+
+const ConfigListItem: React.FC = ({
+ name,
+ value,
+ defaultValue,
+}) => {
+ const hasCustomValue = value !== defaultValue;
+
+ return (
+
+
+ {name}
+ |
+
+ {value}
+ |
+
+ {hasCustomValue && defaultValue}
+ |
+
+ )
}
const Sertings: React.FC = ({
clusterId,
topicName,
+ isFetched,
+ fetchTopicConfig,
+ config,
}) => {
+ React.useEffect(
+ () => { fetchTopicConfig(clusterId, topicName); },
+ [fetchTopicConfig, clusterId, topicName],
+ );
+
+ if (!isFetched || !config) {
+ return (null);
+ }
+
return (
-
- Settings {clusterId}/{topicName}
-
+
+
+
+
+ Key |
+ Value |
+ Default Value |
+
+
+
+ {config.map((item, index) => )}
+
+
+
);
}
diff --git a/frontend/src/components/Topics/Details/Settings/SettingsContainer.ts b/frontend/src/components/Topics/Details/Settings/SettingsContainer.ts
index cfa1967c0b6fe01fea53f89928c004984b85ea3b..32805cf08b649d37af84bd0cd0f41f8bdef80cc4 100644
--- a/frontend/src/components/Topics/Details/Settings/SettingsContainer.ts
+++ b/frontend/src/components/Topics/Details/Settings/SettingsContainer.ts
@@ -1,10 +1,15 @@
import { connect } from 'react-redux';
+import { RootState, ClusterId, TopicName } from 'types';
+import { withRouter, RouteComponentProps } from 'react-router-dom';
import {
- fetchTopicDetails,
+ fetchTopicConfig,
} from 'redux/reducers/topics/thunks';
import Settings from './Settings';
-import { RootState } from 'types';
-import { withRouter, RouteComponentProps } from 'react-router-dom';
+import {
+ getTopicConfig,
+ getTopicConfigFetched,
+} from 'redux/reducers/topics/selectors';
+
interface RouteProps {
clusterId: string;
@@ -16,8 +21,14 @@ interface OwnProps extends RouteComponentProps { }
const mapStateToProps = (state: RootState, { match: { params: { topicName, clusterId } } }: OwnProps) => ({
clusterId,
topicName,
+ config: getTopicConfig(state, topicName),
+ isFetched: getTopicConfigFetched(state),
});
+const mapDispatchToProps = {
+ fetchTopicConfig: (clusterId: ClusterId, topicName: TopicName) => fetchTopicConfig(clusterId, topicName),
+}
+
export default withRouter(
- connect(mapStateToProps)(Settings)
+ connect(mapStateToProps, mapDispatchToProps)(Settings)
);
diff --git a/frontend/src/components/Topics/List/List.tsx b/frontend/src/components/Topics/List/List.tsx
index c678c5695246e9d48a460ff0e86faf8e4ac23807..9b3b0ac5a75c98e0a0e1bf56da921c1f2b5e3f44 100644
--- a/frontend/src/components/Topics/List/List.tsx
+++ b/frontend/src/components/Topics/List/List.tsx
@@ -1,11 +1,11 @@
import React from 'react';
-import { Topic, TopicDetails } from 'types';
+import { TopicWithDetailedInfo } from 'types';
import ListItem from './ListItem';
import Breadcrumb from 'components/common/Breadcrumb/Breadcrumb';
interface Props {
- topics: (Topic & TopicDetails)[];
- externalTopics: (Topic & TopicDetails)[];
+ topics: (TopicWithDetailedInfo)[];
+ externalTopics: (TopicWithDetailedInfo)[];
}
const List: React.FC = ({
@@ -48,9 +48,9 @@ const List: React.FC = ({
- {items.map((topic) => (
+ {items.map((topic, index) => (
))}
diff --git a/frontend/src/components/Topics/List/ListItem.tsx b/frontend/src/components/Topics/List/ListItem.tsx
index e0966718198cf65eaa168b14f655f51b66e0832c..0ca652295b6c6f02ccb92297d45ea2837295c1fa 100644
--- a/frontend/src/components/Topics/List/ListItem.tsx
+++ b/frontend/src/components/Topics/List/ListItem.tsx
@@ -1,9 +1,9 @@
import React from 'react';
import cx from 'classnames';
import { NavLink } from 'react-router-dom';
-import { Topic, TopicDetails } from 'types';
+import { TopicWithDetailedInfo } from 'types';
-const ListItem: React.FC = ({
+const ListItem: React.FC = ({
name,
internal,
partitions,
diff --git a/frontend/src/components/common/Breadcrumb/Breadcrumb.tsx b/frontend/src/components/common/Breadcrumb/Breadcrumb.tsx
index addce4d4bd88e400b588d6b0019f0be60d7c570d..d37cd7cddf8e22462e552a273935cc24af02ad91 100644
--- a/frontend/src/components/common/Breadcrumb/Breadcrumb.tsx
+++ b/frontend/src/components/common/Breadcrumb/Breadcrumb.tsx
@@ -17,8 +17,8 @@ const Breadcrumb: React.FC = ({
return (