Skip to content

Commit

Permalink
Issue #1375 - Error view instead of blank page in UI (#1726)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaGupta1 authored and alexec committed Jun 11, 2019
1 parent 8729c09 commit e57fa0c
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions ui/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,23 @@ requests.onError.subscribe(async (err) => {
}
});

export class App extends React.Component<{}, { popupProps: PopupProps }> {
export class App extends React.Component<{}, { popupProps: PopupProps, error: Error }> {
public static childContextTypes = {
history: PropTypes.object,
apis: PropTypes.object,
};

public static getDerivedStateFromError(error: Error) {
return { error };
}

private popupManager: PopupManager;
private notificationsManager: NotificationsManager;
private navigationManager: NavigationManager;

constructor(props: {}) {
super(props);
this.state = { popupProps: null };
this.state = { popupProps: null, error: null };
this.popupManager = new PopupManager();
this.notificationsManager = new NotificationsManager();
this.navigationManager = new NavigationManager(history);
Expand All @@ -97,6 +101,20 @@ export class App extends React.Component<{}, { popupProps: PopupProps }> {
}

public render() {
if (this.state.error != null) {
const stack = this.state.error.stack;
const url = 'https://github.com/argoproj/argo-cd/issues/new?labels=bug&template=bug_report.md';

return (
<React.Fragment>
<p>Something went wrong!</p>
<p>Consider submitting an issue <a href={url}>here</a>.</p><br />
<p>Stacktrace:</p>
<pre>{stack}</pre>
</React.Fragment>
);
}

return (
<React.Fragment>
<Helmet>
Expand Down

0 comments on commit e57fa0c

Please sign in to comment.