Files
SCM-Manager/scm-ui-components/packages/ui-components/src/ErrorNotification.js
Florian Scholdei 6579ecfa75 added translation
2018-12-12 13:38:23 +01:00

38 lines
986 B
JavaScript

//@flow
import React from "react";
import { translate } from "react-i18next";
import Notification from "./Notification";
import {UNAUTHORIZED_ERROR} from "./apiclient";
type Props = {
t: string => string,
error?: Error
};
class ErrorNotification extends React.Component<Props> {
render() {
const { t, error } = this.props;
if (error) {
if (error === UNAUTHORIZED_ERROR) {
return (
<Notification type="danger">
<strong>{t("error-notification.prefix")}:</strong> {t("error-notification.timeout")}
{" "}
<a href="javascript:window.location.reload(true)">{t("error-notification.loginLink")}</a>
</Notification>
);
} else {
return (
<Notification type="danger">
<strong>{t("error-notification.prefix")}:</strong> {error.message}
</Notification>
);
}
}
return null;
}
}
export default translate("commons")(ErrorNotification);