mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 17:05:43 +01:00
added form-route and matching path
This commit is contained in:
@@ -3,15 +3,15 @@ import React from "react";
|
|||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
import { Route } from "react-router";
|
import { Route } from "react-router";
|
||||||
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
||||||
|
|
||||||
import type { Links } from "@scm-manager/ui-types";
|
|
||||||
import { Page, Navigation, NavLink, Section } from "@scm-manager/ui-components";
|
|
||||||
import GlobalConfig from "./GlobalConfig";
|
|
||||||
import GlobalPermissionRoles from "./GlobalPermissionRoles";
|
|
||||||
import type { History } from "history";
|
import type { History } from "history";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { compose } from "redux";
|
import { compose } from "redux";
|
||||||
|
import type { Links } from "@scm-manager/ui-types";
|
||||||
|
import { Page, Navigation, NavLink, Section } from "@scm-manager/ui-components";
|
||||||
import { getLinks } from "../../modules/indexResource";
|
import { getLinks } from "../../modules/indexResource";
|
||||||
|
import GlobalConfig from "./GlobalConfig";
|
||||||
|
import GlobalPermissionRoles from "./GlobalPermissionRoles";
|
||||||
|
import GlobalPermissionRoleForm from "./GlobalPermissionRoleForm";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
links: Links,
|
links: Links,
|
||||||
@@ -34,6 +34,12 @@ class Config extends React.Component<Props> {
|
|||||||
return this.stripEndingSlash(this.props.match.url);
|
return this.stripEndingSlash(this.props.match.url);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
matchesRoles = (route: any) => {
|
||||||
|
const url = this.matchedUrl();
|
||||||
|
const regex = new RegExp(`${url}/role/.+/edit`);
|
||||||
|
return route.location.pathname.match(regex);
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { links, t } = this.props;
|
const { links, t } = this.props;
|
||||||
|
|
||||||
@@ -53,10 +59,11 @@ class Config extends React.Component<Props> {
|
|||||||
exact
|
exact
|
||||||
render={() => (
|
render={() => (
|
||||||
<GlobalPermissionRoles
|
<GlobalPermissionRoles
|
||||||
baseUrl={`${url}/roles`}
|
baseUrl={`${url}/role`}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
<Route path={`${url}/role`} component={GlobalPermissionRoleForm} />
|
||||||
<ExtensionPoint
|
<ExtensionPoint
|
||||||
name="config.route"
|
name="config.route"
|
||||||
props={extensionProps}
|
props={extensionProps}
|
||||||
@@ -73,6 +80,7 @@ class Config extends React.Component<Props> {
|
|||||||
<NavLink
|
<NavLink
|
||||||
to={`${url}/roles`}
|
to={`${url}/roles`}
|
||||||
label={t("roles.navLink")}
|
label={t("roles.navLink")}
|
||||||
|
activeWhenMatch={this.matchesRoles}
|
||||||
/>
|
/>
|
||||||
<ExtensionPoint
|
<ExtensionPoint
|
||||||
name="config.navigation"
|
name="config.navigation"
|
||||||
|
|||||||
Reference in New Issue
Block a user