added baseUrl for info link

This commit is contained in:
Florian Scholdei
2019-05-09 15:11:55 +02:00
parent 7db1e4aad0
commit b8d73b91ea
4 changed files with 24 additions and 15 deletions

View File

@@ -4,6 +4,7 @@ import { Link } from "react-router-dom";
import type { Role } from "@scm-manager/ui-types"; import type { Role } from "@scm-manager/ui-types";
type Props = { type Props = {
baseUrl: string,
role: Role role: Role
}; };
@@ -13,8 +14,8 @@ class PermissionRoleRow extends React.Component<Props> {
} }
render() { render() {
const { role } = this.props; const { baseUrl, role } = this.props;
const to = `./${encodeURIComponent(role.name)}/info`; const to = `${baseUrl}/${encodeURIComponent(role.name)}/info`;
return ( return (
<tr> <tr>
<td>{this.renderLink(to, role.name)}</td> <td>{this.renderLink(to, role.name)}</td>

View File

@@ -5,6 +5,7 @@ import type { Role } from "@scm-manager/ui-types";
import PermissionRoleRow from "./PermissionRoleRow"; import PermissionRoleRow from "./PermissionRoleRow";
type Props = { type Props = {
baseUrl: string,
roles: Role[], roles: Role[],
t: string => string t: string => string
@@ -12,7 +13,7 @@ type Props = {
class PermissionRoleTable extends React.Component<Props> { class PermissionRoleTable extends React.Component<Props> {
render() { render() {
const { roles, t } = this.props; const { baseUrl, roles, t } = this.props;
return ( return (
<table className="card-table table is-hoverable is-fullwidth"> <table className="card-table table is-hoverable is-fullwidth">
<thead> <thead>
@@ -22,7 +23,9 @@ class PermissionRoleTable extends React.Component<Props> {
</thead> </thead>
<tbody> <tbody>
{roles.map((role, index) => { {roles.map((role, index) => {
return <PermissionRoleRow key={index} role={role} />; return (
<PermissionRoleRow key={index} baseUrl={baseUrl} role={role} />
);
})} })}
</tbody> </tbody>
</table> </table>

View File

@@ -51,7 +51,11 @@ class Config extends React.Component<Props> {
<Route <Route
path={`${url}/roles`} path={`${url}/roles`}
exact exact
component={GlobalPermissionRoles} render={() => (
<GlobalPermissionRoles
baseUrl={`${url}/roles`}
/>
)}
/> />
<ExtensionPoint <ExtensionPoint
name="config.route" name="config.route"

View File

@@ -1,6 +1,7 @@
// @flow // @flow
import React from "react"; import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import {withRouter} from "react-router-dom";
import { translate } from "react-i18next"; import { translate } from "react-i18next";
import type { History } from "history"; import type { History } from "history";
import type { Role, PagedCollection } from "@scm-manager/ui-types"; import type { Role, PagedCollection } from "@scm-manager/ui-types";
@@ -22,8 +23,8 @@ import {
} from "@scm-manager/ui-components"; } from "@scm-manager/ui-components";
import PermissionRoleTable from "../components/table/PermissionRoleTable"; import PermissionRoleTable from "../components/table/PermissionRoleTable";
import { getRolesLink } from "../../modules/indexResource"; import { getRolesLink } from "../../modules/indexResource";
type Props = { type Props = {
baseUrl: string,
roles: Role[], roles: Role[],
loading: boolean, loading: boolean,
error: Error, error: Error,
@@ -63,11 +64,11 @@ class GlobalPermissionRoles extends React.Component<Props> {
} }
renderPermissionsTable() { renderPermissionsTable() {
const { roles, list, page, t } = this.props; const { baseUrl, roles, list, page, t } = this.props;
if (roles && roles.length > 0) { if (roles && roles.length > 0) {
return ( return (
<> <>
<PermissionRoleTable roles={roles} /> <PermissionRoleTable baseUrl={baseUrl} roles={roles} />
<LinkPaginator collection={list} page={page} /> <LinkPaginator collection={list} page={page} />
</> </>
); );
@@ -115,7 +116,7 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default connect( export default withRouter(connect(
mapStateToProps, mapStateToProps,
mapDispatchToProps mapDispatchToProps
)(translate("config")(GlobalPermissionRoles)); )(translate("config")(GlobalPermissionRoles)));