2018-08-31 10:47:42 +02:00
|
|
|
// @flow
|
2018-08-09 10:18:12 +02:00
|
|
|
import React from "react";
|
|
|
|
|
import { translate } from "react-i18next";
|
|
|
|
|
import { Route } from "react-router";
|
2018-11-06 07:59:34 +01:00
|
|
|
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
2018-08-09 10:18:12 +02:00
|
|
|
|
2018-11-06 07:59:34 +01:00
|
|
|
import type { Links } from "@scm-manager/ui-types";
|
2018-09-05 14:32:49 +02:00
|
|
|
import { Page, Navigation, NavLink, Section } from "@scm-manager/ui-components";
|
2018-08-09 10:18:12 +02:00
|
|
|
import GlobalConfig from "./GlobalConfig";
|
|
|
|
|
import type { History } from "history";
|
2018-11-06 07:59:34 +01:00
|
|
|
import {connect} from "react-redux";
|
|
|
|
|
import {compose} from "redux";
|
|
|
|
|
import { getLinks } from "../../modules/indexResource";
|
2018-08-09 10:18:12 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
2018-11-06 07:59:34 +01:00
|
|
|
links: Links,
|
|
|
|
|
|
2018-08-09 10:18:12 +02:00
|
|
|
// context objects
|
|
|
|
|
t: string => string,
|
|
|
|
|
match: any,
|
|
|
|
|
history: History
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Config extends React.Component<Props> {
|
|
|
|
|
stripEndingSlash = (url: string) => {
|
|
|
|
|
if (url.endsWith("/")) {
|
|
|
|
|
return url.substring(0, url.length - 2);
|
|
|
|
|
}
|
|
|
|
|
return url;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
matchedUrl = () => {
|
|
|
|
|
return this.stripEndingSlash(this.props.match.url);
|
|
|
|
|
};
|
2018-08-09 09:38:55 +02:00
|
|
|
|
|
|
|
|
render() {
|
2018-11-06 07:59:34 +01:00
|
|
|
const { links, t } = this.props;
|
2018-08-09 10:18:12 +02:00
|
|
|
|
|
|
|
|
const url = this.matchedUrl();
|
2018-11-06 07:59:34 +01:00
|
|
|
const extensionProps = {
|
|
|
|
|
links,
|
|
|
|
|
url
|
|
|
|
|
};
|
2018-08-09 10:18:12 +02:00
|
|
|
|
|
|
|
|
return (
|
2018-08-09 11:34:23 +02:00
|
|
|
<Page>
|
2018-08-09 10:18:12 +02:00
|
|
|
<div className="columns">
|
|
|
|
|
<div className="column is-three-quarters">
|
2018-08-09 16:33:28 +02:00
|
|
|
<Route path={url} exact component={GlobalConfig} />
|
2018-11-06 07:59:34 +01:00
|
|
|
<ExtensionPoint name="config.route"
|
|
|
|
|
props={extensionProps}
|
|
|
|
|
renderAll={true}
|
|
|
|
|
/>
|
2018-08-09 10:18:12 +02:00
|
|
|
</div>
|
|
|
|
|
<div className="column">
|
|
|
|
|
<Navigation>
|
|
|
|
|
<Section label={t("config.navigation-title")}>
|
2018-08-09 16:33:28 +02:00
|
|
|
<NavLink
|
|
|
|
|
to={`${url}`}
|
|
|
|
|
label={t("global-config.navigation-label")}
|
|
|
|
|
/>
|
2018-11-06 07:59:34 +01:00
|
|
|
<ExtensionPoint name="config.navigation"
|
|
|
|
|
props={extensionProps}
|
|
|
|
|
renderAll={true}
|
|
|
|
|
/>
|
2018-08-09 10:18:12 +02:00
|
|
|
</Section>
|
|
|
|
|
</Navigation>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Page>
|
|
|
|
|
);
|
2018-08-09 09:38:55 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-06 07:59:34 +01:00
|
|
|
const mapStateToProps = (state: any) => {
|
|
|
|
|
const links = getLinks(state);
|
|
|
|
|
return {
|
|
|
|
|
links
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default compose(
|
|
|
|
|
connect(mapStateToProps),
|
|
|
|
|
translate("config")
|
|
|
|
|
)(Config);
|
|
|
|
|
|