// @flow import React from "react"; import { translate } from "react-i18next"; import { Redirect, Route, Switch } from "react-router-dom"; import { ExtensionPoint } from "@scm-manager/ui-extensions"; import type { History } from "history"; import { connect } from "react-redux"; import { compose } from "redux"; import type { Links } from "@scm-manager/ui-types"; import { Page, Navigation, NavLink, Section, SubNavigation } from "@scm-manager/ui-components"; import { getLinks, getAvailablePluginsLink, getInstalledPluginsLink } from "../../modules/indexResource"; import AdminDetails from "./AdminDetails"; import PluginsOverview from "../plugins/containers/PluginsOverview"; import GlobalConfig from "./GlobalConfig"; import RepositoryRoles from "../roles/containers/RepositoryRoles"; import SingleRepositoryRole from "../roles/containers/SingleRepositoryRole"; import CreateRepositoryRole from "../roles/containers/CreateRepositoryRole"; type Props = { links: Links, availablePluginsLink: string, installedPluginsLink: string, // context objects t: string => string, match: any, history: History }; class Admin extends React.Component { stripEndingSlash = (url: string) => { if (url.endsWith("/")) { if (url.includes("role")) { return url.substring(0, url.length - 2); } return url.substring(0, url.length - 1); } return url; }; matchedUrl = () => { return this.stripEndingSlash(this.props.match.url); }; matchesRoles = (route: any) => { const url = this.matchedUrl(); const regex = new RegExp(`${url}/role/`); return route.location.pathname.match(regex); }; render() { const { links, availablePluginsLink, installedPluginsLink, t } = this.props; const url = this.matchedUrl(); const extensionProps = { links, url }; return (
( )} /> ( )} /> ( )} /> ( )} /> ( )} /> } /> ( )} /> } />
{(availablePluginsLink || installedPluginsLink) && ( {installedPluginsLink && ( )} {availablePluginsLink && ( )} )}
); } } const mapStateToProps = (state: any) => { const links = getLinks(state); const availablePluginsLink = getAvailablePluginsLink(state); const installedPluginsLink = getInstalledPluginsLink(state); return { links, availablePluginsLink, installedPluginsLink }; }; export default compose( connect(mapStateToProps), translate("admin") )(Admin);