Review feedback on loading-indicator

This commit is contained in:
Simon Howe
2016-08-02 22:09:08 +02:00
parent 6e3bec8c70
commit 19f08ee81f
3 changed files with 14 additions and 9 deletions

View File

@@ -14,7 +14,6 @@ const LOADING_TEMPLATES = [
'Locating THINGS',
'Optimizing THINGS',
'Transporting THINGS',
'Double checking THINGS',
];

View File

@@ -73,7 +73,7 @@ class Nodes extends React.Component {
return (
<div className="nodes-wrapper">
<DelayedShow delay={1000} show={!topologiesLoaded}>
<DelayedShow delay={1000} show={!topologiesLoaded || (topologiesLoaded && !nodesLoaded)}>
<Loading itemType="topologies" show={!topologiesLoaded} />
<Loading
itemType={getNodeType(topology, topologies)}

View File

@@ -7,18 +7,16 @@ export class DelayedShow extends React.Component {
this.state = {
show: false
};
}
if (props.show) {
componentWillMount() {
if (this.props.show) {
this.scheduleShow();
}
}
scheduleShow() {
this.showTimeout = setTimeout(() => this.setState({ show: true }), this.props.delay);
}
cancelShow() {
clearTimeout(this.showTimeout);
componentWillUnmount() {
this.cancelShow();
}
componentWillReceiveProps(nextProps) {
@@ -34,6 +32,14 @@ export class DelayedShow extends React.Component {
}
}
scheduleShow() {
this.showTimeout = setTimeout(() => this.setState({ show: true }), this.props.delay);
}
cancelShow() {
clearTimeout(this.showTimeout);
}
render() {
const { children } = this.props;
const { show } = this.state;