2018-08-09 10:18:12 +02:00
|
|
|
import React from "react";
|
|
|
|
|
import { translate } from "react-i18next";
|
2018-08-09 11:34:23 +02:00
|
|
|
import Title from "../../components/layout/Title";
|
2018-08-09 12:09:50 +02:00
|
|
|
import {
|
|
|
|
|
fetchConfig,
|
|
|
|
|
getFetchConfigFailure,
|
|
|
|
|
isFetchConfigPending
|
|
|
|
|
} from "../modules/config";
|
|
|
|
|
import connect from "react-redux/es/connect/connect";
|
|
|
|
|
import ErrorPage from "../../components/ErrorPage";
|
|
|
|
|
import Loading from "../../components/Loading";
|
2018-08-09 10:18:12 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
2018-08-09 12:09:50 +02:00
|
|
|
loading: boolean,
|
|
|
|
|
error: Error,
|
|
|
|
|
|
2018-08-09 10:18:12 +02:00
|
|
|
// context objects
|
2018-08-09 12:09:50 +02:00
|
|
|
t: string => string,
|
|
|
|
|
fetchConfig: void => void
|
2018-08-09 10:18:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class GlobalConfig extends React.Component<Props> {
|
2018-08-09 12:09:50 +02:00
|
|
|
componentDidMount() {
|
|
|
|
|
this.props.fetchConfig();
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-09 10:18:12 +02:00
|
|
|
render() {
|
2018-08-09 12:09:50 +02:00
|
|
|
const { t, error, loading } = this.props;
|
|
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
|
return (
|
|
|
|
|
<ErrorPage
|
|
|
|
|
title={t("global-config.error-title")}
|
|
|
|
|
subtitle={t("global-config.error-subtitle")}
|
|
|
|
|
error={error}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (loading) {
|
|
|
|
|
return <Loading />;
|
|
|
|
|
}
|
2018-08-09 10:18:12 +02:00
|
|
|
|
2018-08-09 12:09:50 +02:00
|
|
|
return <Title title={t("global-config.title")} />;
|
2018-08-09 10:18:12 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-09 12:09:50 +02:00
|
|
|
const mapDispatchToProps = dispatch => {
|
|
|
|
|
return {
|
|
|
|
|
fetchConfig: () => {
|
|
|
|
|
dispatch(fetchConfig());
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = state => {
|
|
|
|
|
const loading = isFetchConfigPending(state);
|
|
|
|
|
const error = getFetchConfigFailure(state);
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
loading,
|
|
|
|
|
error
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
|
mapStateToProps,
|
|
|
|
|
mapDispatchToProps
|
|
|
|
|
)(translate("config")(GlobalConfig));
|