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 b84c025120..1cd7a526a4 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 fd1abc3d79..dec65ae2ea 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 e1b0998b05..717b3114fd 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 d330860268..e44c2df3b8 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'} -
+
- - - - - - - - - - {partitions.map(({ partition, leader }) => ( +
+
Partition IDBroker leader
+ - - + + - ))} - -
{partition}{leader}Partition IDBroker 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 c07dfc6ff9..839f28f4a3 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} -

+
+ + + + + + + + + + {config.map((item, index) => )} + +
KeyValueDefault Value
+
); } diff --git a/frontend/src/components/Topics/Details/Settings/SettingsContainer.ts b/frontend/src/components/Topics/Details/Settings/SettingsContainer.ts index cfa1967c0b..32805cf08b 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 c678c56952..9b3b0ac5a7 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 e096671819..0ca652295b 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 addce4d4bd..d37cd7cddf 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 (