mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 22:15:45 +01:00
Add error notification for errors from extensions
This commit is contained in:
@@ -2,7 +2,12 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
import type { File, Repository } from "@scm-manager/ui-types";
|
import type { File, Repository } from "@scm-manager/ui-types";
|
||||||
import { DateFromNow, ButtonGroup, FileSize } from "@scm-manager/ui-components";
|
import {
|
||||||
|
DateFromNow,
|
||||||
|
ButtonGroup,
|
||||||
|
FileSize,
|
||||||
|
ErrorNotification
|
||||||
|
} from "@scm-manager/ui-components";
|
||||||
import injectSheet from "react-jss";
|
import injectSheet from "react-jss";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import FileButtonGroup from "../components/content/FileButtonGroup";
|
import FileButtonGroup from "../components/content/FileButtonGroup";
|
||||||
@@ -14,7 +19,6 @@ import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
loading: boolean,
|
loading: boolean,
|
||||||
error: Error,
|
|
||||||
file: File,
|
file: File,
|
||||||
repository: Repository,
|
repository: Repository,
|
||||||
revision: string,
|
revision: string,
|
||||||
@@ -25,7 +29,8 @@ type Props = {
|
|||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
collapsed: boolean,
|
collapsed: boolean,
|
||||||
showHistory: boolean
|
showHistory: boolean,
|
||||||
|
errorFromExtension?: Error
|
||||||
};
|
};
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
@@ -67,6 +72,10 @@ class Content extends React.Component<Props, State> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleExtensionError = (error: Error) => {
|
||||||
|
this.setState({ errorFromExtension: error });
|
||||||
|
};
|
||||||
|
|
||||||
showHeader() {
|
showHeader() {
|
||||||
const { file, revision, classes } = this.props;
|
const { file, revision, classes } = this.props;
|
||||||
const { showHistory, collapsed } = this.state;
|
const { showHistory, collapsed } = this.state;
|
||||||
@@ -100,7 +109,11 @@ class Content extends React.Component<Props, State> {
|
|||||||
<ButtonGroup>
|
<ButtonGroup>
|
||||||
<ExtensionPoint
|
<ExtensionPoint
|
||||||
name="repos.sources.content.actionbar"
|
name="repos.sources.content.actionbar"
|
||||||
props={{ file, revision }}
|
props={{
|
||||||
|
file,
|
||||||
|
revision,
|
||||||
|
handleExtensionError: this.handleExtensionError
|
||||||
|
}}
|
||||||
renderAll={true}
|
renderAll={true}
|
||||||
/>
|
/>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
@@ -167,7 +180,7 @@ class Content extends React.Component<Props, State> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { file, revision, repository, path } = this.props;
|
const { file, revision, repository, path } = this.props;
|
||||||
const { showHistory } = this.state;
|
const { showHistory, errorFromExtension } = this.state;
|
||||||
|
|
||||||
const header = this.showHeader();
|
const header = this.showHeader();
|
||||||
const content =
|
const content =
|
||||||
@@ -190,6 +203,7 @@ class Content extends React.Component<Props, State> {
|
|||||||
{moreInformation}
|
{moreInformation}
|
||||||
{content}
|
{content}
|
||||||
</div>
|
</div>
|
||||||
|
{errorFromExtension && <ErrorNotification error={errorFromExtension} />}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user