Files
SCM-Manager/scm-ui-components/packages/ui-components/src/ErrorNotification.js

38 lines
986 B
JavaScript
Raw Normal View History

//@flow
import React from "react";
import { translate } from "react-i18next";
import Notification from "./Notification";
2018-12-12 13:35:58 +01:00
import {UNAUTHORIZED_ERROR} from "./apiclient";
type Props = {
t: string => string,
error?: Error
};
class ErrorNotification extends React.Component<Props> {
2018-12-12 13:35:58 +01:00
render() {
const { t, error } = this.props;
if (error) {
2018-12-12 13:35:58 +01:00
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>
);
}
}
2018-11-19 10:31:01 +01:00
return null;
}
}
export default translate("commons")(ErrorNotification);