Skip to content

Commit

Permalink
Fix #10 - Infinite loop when no services are found (#27)
Browse files Browse the repository at this point in the history
* Fixes #10: Infinite loop when no services are found

* Add no service deps message
  • Loading branch information
saminzadeh authored May 23, 2017
1 parent 5c6e639 commit 0a2f1c5
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions src/components/DependencyGraph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,40 +53,38 @@ export default class DependencyGraphPage extends Component {
};
}
componentDidMount() {
this.ensureDependenciesFetched();
}

componentDidUpdate() {
const { nodes, links } = this.props;

if (!nodes || !links) {
this.ensureDependenciesFetched();
}
}

ensureDependenciesFetched() {
const { fetchDependencies, nodes, links, loading, error } = this.props;

if (!(nodes && links) && !(loading || error)) {
fetchDependencies();
}
this.props.fetchDependencies();
}

handleGraphTypeChange(graphType) {
this.setState({ graphType });
}

render() {
const { nodes, links, error, dependencies } = this.props;
const { nodes, links, error, dependencies, loading } = this.props;
const { graphType } = this.state;
const serviceCalls = dependencies.toJS();

if (loading) {
return (
<div className="m1">
<div className="ui active centered inline loader" />
</div>
);
}
if (error) {
return <NotFound error={error} />;
}

if (!nodes || !links) {
return <section />;
return (
<div className="m1">
<div className="ui warning message">
<div className="header">
No service dependencies found.
</div>
</div>
</div>
);
}

const GRAPH_TYPE_OPTIONS = [
Expand Down

0 comments on commit 0a2f1c5

Please sign in to comment.