prepare RepoRoleDetailsView

This commit is contained in:
Eduard Heimbuch
2019-05-15 15:21:43 +02:00
parent 77d8a3ad21
commit 8ebd720f8e
2 changed files with 16 additions and 11 deletions

View File

@@ -20,7 +20,8 @@ class PermissionRoleRow extends React.Component<Props> {
render() { render() {
const { baseUrl, role } = this.props; const { baseUrl, role } = this.props;
const to = `${baseUrl}/${encodeURIComponent(role.name)}/info`; const singleRepoRoleUrl = baseUrl.substring(0, baseUrl.length - 1);
const to = `${singleRepoRoleUrl}/${encodeURIComponent(role.name)}/info`;
return ( return (
<tr> <tr>
<td>{this.renderLink(to, role.name, !role._links.update)}</td> <td>{this.renderLink(to, role.name, !role._links.update)}</td>

View File

@@ -14,9 +14,12 @@ import type { Role } from "@scm-manager/ui-types";
import {getRepositoryRolesLink} from "../../../modules/indexResource"; import {getRepositoryRolesLink} from "../../../modules/indexResource";
import {ExtensionPoint} from "@scm-manager/ui-extensions"; import {ExtensionPoint} from "@scm-manager/ui-extensions";
import {fetchRoleByName, getFetchRoleFailure, getRoleByName, isFetchRolePending} from "../modules/roles"; import {fetchRoleByName, getFetchRoleFailure, getRoleByName, isFetchRolePending} from "../modules/roles";
import RepositoryRoleForm from "./RepositoryRoleForm";
import {withRouter} from "react-router-dom";
import PermissionRoleDetail from "../components/PermissionRoleDetail";
type Props = { type Props = {
name: string, roleName: string,
role: Role, role: Role,
loading: boolean, loading: boolean,
error: Error, error: Error,
@@ -34,7 +37,8 @@ type Props = {
class SingleRepositoryRole extends React.Component<Props> { class SingleRepositoryRole extends React.Component<Props> {
componentDidMount() { componentDidMount() {
this.props.fetchRoleByName(this.props.repositoryRolesLink, this.props.name); this.props.fetchRoleByName(this.props.repositoryRolesLink, this.props.roleName);
console.log(this.props.match)
} }
stripEndingSlash = (url: string) => { stripEndingSlash = (url: string) => {
@@ -76,7 +80,7 @@ class SingleRepositoryRole extends React.Component<Props> {
<Page title={role.displayName}> <Page title={role.displayName}>
<div className="columns"> <div className="columns">
<div className="column is-three-quarters"> <div className="column is-three-quarters">
<Route path={url} exact component={() => <RepositoryRoleDetailNavLink role={role} />} /> <Route path={url} component={() => <PermissionRoleDetail role={role} />} />
<Route <Route
path={`${url}/settings/general`} path={`${url}/settings/general`}
component={() => <EditRepositoryRoleNavLink role={role} />} component={() => <EditRepositoryRoleNavLink role={role} />}
@@ -94,14 +98,14 @@ class SingleRepositoryRole extends React.Component<Props> {
} }
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state, ownProps) => {
const name = ownProps.match.params.name; const roleName = ownProps.match.params.role;
const role = getRoleByName(state, name); const role = getRoleByName(state, roleName);
const loading = isFetchRolePending(state, name); const loading = isFetchRolePending(state, roleName);
const error = getFetchRoleFailure(state, name); const error = getFetchRoleFailure(state, roleName);
const repositoryRolesLink = getRepositoryRolesLink(state); const repositoryRolesLink = getRepositoryRolesLink(state);
return { return {
repositoryRolesLink, repositoryRolesLink,
name, roleName,
role, role,
loading, loading,
error error
@@ -116,7 +120,7 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default connect( export default withRouter(connect(
mapStateToProps, mapStateToProps,
mapDispatchToProps mapDispatchToProps
)(translate("users")(SingleRepositoryRole)); )(translate("users")(SingleRepositoryRole)));