diff --git a/ui/src/CheckDataNodes.js b/ui/src/CheckDataNodes.js index d69bd6a3d5..a3a44f5f09 100644 --- a/ui/src/CheckDataNodes.js +++ b/ui/src/CheckDataNodes.js @@ -1,5 +1,5 @@ import React, {PropTypes} from 'react'; -import NoClusterError from 'shared/components/NoClusterError'; +import {withRouter} from 'react-router'; import {getSources} from 'src/shared/apis'; const {bool, number, string, node, func, shape} = PropTypes; @@ -14,6 +14,9 @@ const CheckDataNodes = React.createClass({ params: PropTypes.shape({ sourceID: PropTypes.string, }).isRequired, + router: PropTypes.shape({ + push: PropTypes.func.isRequired, + }).isRequired, }, contextTypes: { @@ -28,14 +31,21 @@ const CheckDataNodes = React.createClass({ getInitialState() { return { isFetching: true, - sources: [], + source: null, }; }, componentDidMount() { getSources().then(({data: {sources}}) => { + const {sourceID} = this.props.params; + const source = sources.find((s) => s.id === sourceID); + + if (!source) { // would be great to check source.status or similar here + return this.props.router.push(`/?error="bad id: ${sourceID}"`); + } + this.setState({ - sources, + source, isFetching: false, }); }).catch((err) => { @@ -49,19 +59,10 @@ const CheckDataNodes = React.createClass({ return
; } - const {sourceID} = this.props.params; - const {sources} = this.state; - const source = sources.find((s) => s.id === sourceID); - if (!source) { - // the id in the address bar doesn't match a source we know about - // ask paul? go to source selection page? - returnbad id bro
: null}