mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-16 18:26:16 +01:00
Refactored ErrorNotification/ErrorPage
Added i18n for error codes
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
// @flow
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import { Title, ErrorPage, Loading } from "@scm-manager/ui-components";
|
||||
import {
|
||||
Title,
|
||||
Loading,
|
||||
ErrorNotification
|
||||
} from "@scm-manager/ui-components";
|
||||
import {
|
||||
fetchConfig,
|
||||
getFetchConfigFailure,
|
||||
@@ -73,18 +77,8 @@ class GlobalConfig extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { t, error, loading, config, configUpdatePermission } = this.props;
|
||||
const { t, loading } = this.props;
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<ErrorPage
|
||||
title={t("config.errorTitle")}
|
||||
subtitle={t("config.errorSubtitle")}
|
||||
error={error}
|
||||
configUpdatePermission={configUpdatePermission}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
}
|
||||
@@ -92,16 +86,37 @@ class GlobalConfig extends React.Component<Props, State> {
|
||||
return (
|
||||
<div>
|
||||
<Title title={t("config.title")} />
|
||||
{this.renderConfigChangedNotification()}
|
||||
<ConfigForm
|
||||
submitForm={config => this.modifyConfig(config)}
|
||||
config={config}
|
||||
loading={loading}
|
||||
configUpdatePermission={configUpdatePermission}
|
||||
/>
|
||||
{this.renderError()}
|
||||
{this.renderContent()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
renderError = () => {
|
||||
const { error } = this.props;
|
||||
if (error) {
|
||||
return <ErrorNotification error={error} />;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
renderContent = () => {
|
||||
const { error, loading, config, configUpdatePermission } = this.props;
|
||||
if (!error) {
|
||||
return (
|
||||
<>
|
||||
{this.renderConfigChangedNotification()}
|
||||
<ConfigForm
|
||||
submitForm={config => this.modifyConfig(config)}
|
||||
config={config}
|
||||
loading={loading}
|
||||
configUpdatePermission={configUpdatePermission}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
SubNavigation,
|
||||
NavLink,
|
||||
Page,
|
||||
Section
|
||||
Section, ErrorPage
|
||||
} from "@scm-manager/ui-components";
|
||||
import { translate } from "react-i18next";
|
||||
import RepositoryDetails from "../components/RepositoryDetails";
|
||||
@@ -81,17 +81,12 @@ class RepositoryRoot extends React.Component<Props> {
|
||||
render() {
|
||||
const { loading, error, indexLinks, repository, t } = this.props;
|
||||
|
||||
// if (error) {
|
||||
// return <ErrorPage
|
||||
// title={t("repositoryRoot.errorTitle")}
|
||||
// subtitle={t("repositoryRoot.errorSubtitle")}
|
||||
// error={error}
|
||||
// />
|
||||
// }
|
||||
if (error) {
|
||||
return (
|
||||
<CollapsibleErrorPage title={t("repositoryRoot.errorTitle")} error={error} />
|
||||
);
|
||||
return <ErrorPage
|
||||
title={t("repositoryRoot.errorTitle")}
|
||||
subtitle={t("repositoryRoot.errorSubtitle")}
|
||||
error={error}
|
||||
/>
|
||||
}
|
||||
|
||||
if (!repository || loading) {
|
||||
|
||||
Reference in New Issue
Block a user