From 17b5dc0e9c54a639b6a7391c4c6e0f614c6c156d Mon Sep 17 00:00:00 2001 From: IMRAN KHAN <30754328+strongSoda@users.noreply.github.com> Date: Fri, 31 May 2019 17:57:49 +0530 Subject: [PATCH] fix head to home console error from error page (#2304) --- console/src/components/Error/ErrorBoundary.js | 20 ++++++++++++++++--- .../components/Services/Metadata/Actions.js | 6 +++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/console/src/components/Error/ErrorBoundary.js b/console/src/components/Error/ErrorBoundary.js index 950deeb67d0..35b4e67c884 100644 --- a/console/src/components/Error/ErrorBoundary.js +++ b/console/src/components/Error/ErrorBoundary.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import { loadInconsistentObjects, redirectToMetadataStatus, + isMetadataStatusPage, } from '../Services/Metadata/Actions'; import Spinner from '../Common/Spinner/Spinner'; @@ -12,17 +13,25 @@ import Helmet from 'react-helmet'; class ErrorBoundary extends React.Component { constructor(props) { super(props); + this.state = { hasError: false, info: null, error: null }; } + resetState = () => { + this.setState({ hasError: false, info: null, error: null }); + }; + componentDidCatch(error, info) { this.setState({ hasError: true, info: info, error: error }); + // TODO logErrorToMyService(error, info); + const { dispatch } = this.props; + dispatch(loadInconsistentObjects(true)).then(() => { if (this.props.metadata.inconsistentObjects.length > 0) { - if (!window.location.pathname.includes('/metadata/status')) { - this.setState({ hasError: false, info: null, error: null }); + if (!isMetadataStatusPage()) { + this.resetState(); this.props.dispatch(redirectToMetadataStatus()); } } else { @@ -35,6 +44,7 @@ class ErrorBoundary extends React.Component { const errorImage = require('./error-logo.png'); const styles = require('./ErrorPage.scss'); const { metadata } = this.props; + if (this.state.hasError && metadata.ongoingRequest) { return (