From 1db6545167bfb734be0336f8a4fecfe55e52f649 Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Wed, 12 Aug 2020 11:07:59 +0200 Subject: [PATCH] show error and helpful message if plugin loading failed --- CHANGELOG.md | 1 + .../ui-webapp/src/containers/PluginLoader.tsx | 44 +++++++++++++++++-- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 410d0f533e..0807f017f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Repository names may not end with ".git" ([#1277](https://github.com/scm-manager/scm-manager/pull/1277)) +- Show error message if plugin loading failed ([#1289](https://github.com/scm-manager/scm-manager/pull/1289)) ## [2.3.1] - 2020-08-04 ### Added diff --git a/scm-ui/ui-webapp/src/containers/PluginLoader.tsx b/scm-ui/ui-webapp/src/containers/PluginLoader.tsx index b5d06c62b8..93aa327d47 100644 --- a/scm-ui/ui-webapp/src/containers/PluginLoader.tsx +++ b/scm-ui/ui-webapp/src/containers/PluginLoader.tsx @@ -22,10 +22,11 @@ * SOFTWARE. */ import React, { ReactNode } from "react"; -import { apiClient, Loading } from "@scm-manager/ui-components"; +import { apiClient, Loading, ErrorNotification, ErrorBoundary, Icon } from "@scm-manager/ui-components"; import { getUiPluginsLink } from "../modules/indexResource"; import { connect } from "react-redux"; import loadBundle from "./loadBundle"; +import styled from "styled-components"; type Props = { loaded: boolean; @@ -36,6 +37,8 @@ type Props = { type State = { message: string; + errorMessage?: string; + error?: Error; }; type Plugin = { @@ -43,6 +46,22 @@ type Plugin = { bundles: string[]; }; +const BigIcon = styled(Icon)` + font-size: 10rem; +`; + +const Centered = styled.div` + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-between; +`; + +const ErrorMessage = styled.span` + font-size: 20px; + margin: 1.5rem 0; +`; + class PluginLoader extends React.Component { constructor(props: Props) { super(props); @@ -96,14 +115,33 @@ class PluginLoader extends React.Component { const promises = []; for (const bundle of plugin.bundles) { - promises.push(loadBundle(bundle)); + promises.push( + loadBundle(bundle).catch(error => this.setState({ error, errorMessage: `loading ${plugin.name} failed` })) + ); } return Promise.all(promises); }; render() { const { loaded } = this.props; - const { message } = this.state; + const { message, error, errorMessage } = this.state; + + if (error) { + return ( +
+
+ + + + {errorMessage} + + + +
+
+ ); + } + if (loaded) { return
{this.props.children}
; }