mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 01:15:44 +01:00
add systemRoleTag for systemRoles
This commit is contained in:
35
scm-ui/src/config/components/SystemRoleTag.js
Normal file
35
scm-ui/src/config/components/SystemRoleTag.js
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
//@flow
|
||||||
|
import React from "react";
|
||||||
|
import injectSheet from "react-jss";
|
||||||
|
import classNames from "classnames";
|
||||||
|
import { translate } from "react-i18next";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
system?: boolean,
|
||||||
|
classes: any,
|
||||||
|
t: string => string
|
||||||
|
};
|
||||||
|
|
||||||
|
const styles = {
|
||||||
|
tag: {
|
||||||
|
marginLeft: "0.75rem",
|
||||||
|
verticalAlign: "inherit"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class SystemRoleTag extends React.Component<Props> {
|
||||||
|
render() {
|
||||||
|
const { system, classes, t } = this.props;
|
||||||
|
|
||||||
|
if (system) {
|
||||||
|
return (
|
||||||
|
<span className={classNames("tag is-dark", classes.tag)}>
|
||||||
|
{t("roles.system")}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default injectSheet(styles)(translate("config")(SystemRoleTag));
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import type { Role } from "@scm-manager/ui-types";
|
import type { Role } from "@scm-manager/ui-types";
|
||||||
|
import SystemRoleTag from "../SystemRoleTag";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
baseUrl: string,
|
baseUrl: string,
|
||||||
@@ -9,16 +10,23 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class PermissionRoleRow extends React.Component<Props> {
|
class PermissionRoleRow extends React.Component<Props> {
|
||||||
renderLink(to: string, label: string) {
|
renderLink(to: string, label: string, system?: boolean) {
|
||||||
|
if (!system) {
|
||||||
return <Link to={to}>{label}</Link>;
|
return <Link to={to}>{label}</Link>;
|
||||||
}
|
}
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{label} <SystemRoleTag system={system} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { baseUrl, role } = this.props;
|
const { baseUrl, role } = this.props;
|
||||||
const to = `${baseUrl}/${encodeURIComponent(role.name)}/edit`;
|
const to = `${baseUrl}/${encodeURIComponent(role.name)}/edit`;
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
<td>{this.renderLink(to, role.name)}</td>
|
<td>{this.renderLink(to, role.name, !role._links.update)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user