From 429ef27661a9255838fbe6f52a143be6364b8ff3 Mon Sep 17 00:00:00 2001 From: Jade McGough Date: Thu, 13 Apr 2017 16:33:27 -0700 Subject: [PATCH] move influx source managament table to separate component --- ui/src/sources/components/InfluxTable.js | 81 ++++++++++++++++++++++ ui/src/sources/containers/ManageSources.js | 63 ++++------------- 2 files changed, 94 insertions(+), 50 deletions(-) create mode 100644 ui/src/sources/components/InfluxTable.js diff --git a/ui/src/sources/components/InfluxTable.js b/ui/src/sources/components/InfluxTable.js new file mode 100644 index 000000000..8f24d7f03 --- /dev/null +++ b/ui/src/sources/components/InfluxTable.js @@ -0,0 +1,81 @@ +import React, {PropTypes} from 'react' +import {Link} from 'react-router' + +const InfluxTable = ({ + sources, + source, + handleDeleteSource, + kapacitors, + location, +}) => ( +
+
+ +
+
+

InfluxDB Sources

+ Add New Source +
+
+
+ + + + + + + + + + + { + sources.map((s) => { + const kapacitorName = kapacitors[s.id] ? kapacitors[s.id].name : '' + return ( + + + + + + + ) + }) + } + +
NameHostKapacitor
{s.name}{s.default ? Default : null}{s.url}{kapacitorName ? kapacitorName : "--"} + + Connect + +
+
+
+
+
+
+) + +const { + array, + func, + object, + shape, + string, +} = PropTypes + +InfluxTable.propTypes = { + sources: array.isRequired, + kapacitors: object, + location: shape({ + pathname: string.isRequired, + }).isRequired, + handleDeleteSource: func.isRequired, + source: shape({ + id: string.isRequired, + links: shape({ + proxy: string.isRequired, + self: string.isRequired, + }), + }), +} + +export default InfluxTable diff --git a/ui/src/sources/containers/ManageSources.js b/ui/src/sources/containers/ManageSources.js index 715afb06f..d5108c964 100644 --- a/ui/src/sources/containers/ManageSources.js +++ b/ui/src/sources/containers/ManageSources.js @@ -1,9 +1,11 @@ import React, {PropTypes} from 'react' -import {withRouter, Link} from 'react-router' +import {withRouter} from 'react-router' import {getKapacitor} from 'shared/apis' import {removeAndLoadSources} from 'src/shared/actions/sources' import {connect} from 'react-redux' +import InfluxTable from '../components/InfluxTable' + const { array, func, @@ -59,67 +61,28 @@ export const ManageSources = React.createClass({ }, render() { + // probably should move kapacitors to props and use redux store const {kapacitors} = this.state - const {sources} = this.props - const {pathname} = this.props.location - const numSources = sources.length - const sourcesTitle = `${numSources} ${numSources === 1 ? 'Source' : 'Sources'}` + const {sources, source, location} = this.props return (
-

InfluxDB Sources

+

Configuration

-
-
- -
-
-

{sourcesTitle}

- Add New Source -
-
-
- - - - - - - - - - - { - sources.map((source) => { - const kapacitorName = kapacitors[source.id] ? kapacitors[source.id].name : '' - return ( - - - - - - - ) - }) - } - -
NameHostKapacitor
{source.name}{source.default ? Default : null}{source.url}{kapacitorName ? kapacitorName : "--"} - - Connect - -
-
-
-
-
-
+