use icons for permission type and for delete function

This commit is contained in:
Maren Süwer
2019-02-01 15:31:14 +01:00
parent fe837b816c
commit 65b1ca477a
7 changed files with 37 additions and 26 deletions

View File

@@ -22,8 +22,7 @@ class Radio extends React.Component<Props> {
render() {
return (
<div className="field is-grouped">
<div className="control">
<label className="radio" disabled={this.props.disabled}>
<input
type="radio"
@@ -36,8 +35,6 @@ class Radio extends React.Component<Props> {
{this.props.label}
{this.renderHelp()}
</label>
</div>
</div>
);
}
}

View File

@@ -93,7 +93,6 @@
"error-subtitle": "Unbekannter Fehler bei Berechtigung",
"name": "Benutzer oder Gruppe",
"role": "Rolle",
"type": "Typ",
"permissions": "Berechtigung",
"group-permission": "Gruppenberechtigung",
"user-permission": "Benutzerberechtigung",

View File

@@ -93,7 +93,6 @@
"error-subtitle": "Unknown permissions error",
"name": "User or group",
"role": "Role",
"type": "Type",
"permissions": "Permissions",
"group-permission": "Group Permission",
"user-permission": "User Permission",

View File

@@ -2,7 +2,7 @@
import React from "react";
import { translate } from "react-i18next";
import type { Permission } from "@scm-manager/ui-types";
import { confirmAlert, DeleteButton } from "@scm-manager/ui-components";
import { confirmAlert } from "@scm-manager/ui-components";
type Props = {
permission: Permission,
@@ -54,18 +54,18 @@ class DeletePermissionButton extends React.Component<Props> {
};
render() {
const { confirmDialog, loading, t } = this.props;
const { confirmDialog } = this.props;
const action = confirmDialog ? this.confirmDelete : this.deletePermission;
if (!this.isDeletable()) {
return null;
}
return (
<DeleteButton
label={t("permission.delete-permission-button.label")}
action={action}
loading={loading}
/>
<a className="level-item" onClick={action}>
<span className="icon is-small">
<i className="fas fa-trash" />
</span>
</a>
);
}
}

View File

@@ -96,6 +96,7 @@ class CreatePermissionForm extends React.Component<Props, State> {
const { t } = this.props;
if (this.state.groupPermission) {
return (
<Autocomplete
loadSuggestions={this.loadGroupAutocompletion}
valueSelected={this.groupOrUserSelected}
@@ -159,6 +160,9 @@ class CreatePermissionForm extends React.Component<Props, State> {
</h2>
{advancedDialog}
<form onSubmit={this.submit}>
<div className="field is-grouped">
<div className="control">
<Radio
name="permission_scope"
value="USER_PERMISSION"
@@ -173,7 +177,7 @@ class CreatePermissionForm extends React.Component<Props, State> {
label={t("permission.group-permission")}
onChange={this.permissionScopeChanged}
/>
</div></div>
<div className="columns">
<div className="column is-two-thirds">
{this.renderAutocompletionField()}

View File

@@ -152,12 +152,6 @@ class Permissions extends React.Component<Props> {
helpText={t("permission.help.nameHelpText")}
/>
</th>
<th className="is-hidden-mobile">
<LabelWithHelpIcon
label={t("permission.type")}
helpText={t("permission.help.groupPermissionHelpText")}
/>
</th>
<th>
<LabelWithHelpIcon
label={t("permission.role")}

View File

@@ -14,10 +14,12 @@ import {
} from "../modules/permissions";
import { connect } from "react-redux";
import type { History } from "history";
import { Button, Checkbox } from "@scm-manager/ui-components";
import { Button } from "@scm-manager/ui-components";
import DeletePermissionButton from "../components/buttons/DeletePermissionButton";
import RoleSelector from "../components/RoleSelector";
import AdvancedPermissionsDialog from "./AdvancedPermissionsDialog";
import classNames from "classnames";
import injectSheet from "react-jss";
type Props = {
availablePermissions: AvailableRepositoryPermissions,
@@ -39,7 +41,8 @@ type Props = {
namespace: string,
name: string
) => void,
deleteLoading: boolean
deleteLoading: boolean,
classes: any
};
type State = {
@@ -48,6 +51,12 @@ type State = {
showAdvancedDialog: boolean
};
const styles = {
iconColor: {
color: "#9a9a9a"
}
};
class SinglePermission extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
@@ -104,7 +113,8 @@ class SinglePermission extends React.Component<Props, State> {
availablePermissions,
loading,
namespace,
repoName
repoName,
classes
} = this.props;
const availableRoleNames = availablePermissions.availableRoles.map(
r => r.name
@@ -138,10 +148,18 @@ class SinglePermission extends React.Component<Props, State> {
? t("permission.group")
: t("permission.user");
const iconType =
permission && permission.groupPermission ? (
<i className={classNames("fas fa-user-friends", classes.iconColor)} />
) : (
<i className={classNames("fas fa-user", classes.iconColor)} />
);
return (
<tr>
<td>{permission.name}</td>
<td>{type}</td>
<td>
{iconType} {permission.name}
</td>
{roleSelector}
<td>
<Button
@@ -261,4 +279,4 @@ const mapDispatchToProps = dispatch => {
export default connect(
mapStateToProps,
mapDispatchToProps
)(translate("repos")(SinglePermission));
)(translate("repos")(injectSheet(styles)(SinglePermission)));