这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions console/src/components/Error/ErrorBoundary.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import {
loadInconsistentObjects,
redirectToMetadataStatus,
isMetadataStatusPage,
} from '../Services/Metadata/Actions';
import Spinner from '../Common/Spinner/Spinner';

Expand All @@ -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 {
Expand All @@ -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 (
<div>
Expand All @@ -54,7 +64,11 @@ class ErrorBoundary extends React.Component {
<h1>Error</h1>
<br />
<div>
Something went wrong. Head back <Link to="/">Home</Link>.
Something went wrong. Head back{' '}
<Link to="/" onClick={this.resetState}>
Home
</Link>
.
</div>
<br />
<div>
Expand Down
6 changes: 5 additions & 1 deletion console/src/components/Services/Metadata/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ export const dropInconsistentObjects = () => {
};
};

export const isMetadataStatusPage = () => {
return window.location.pathname.includes('/metadata/status');
};

export const redirectToMetadataStatus = () => {
return dispatch => {
return dispatch(
Expand Down Expand Up @@ -469,7 +473,7 @@ export const metadataReducer = (state = defaultState, action) => {
...state,
allowedQueries: [
...state.allowedQueries.map(q =>
(q.name === action.data.queryName ? action.data.newQuery : q)
q.name === action.data.queryName ? action.data.newQuery : q
),
],
};
Expand Down