Translate verbs of permissions

This commit is contained in:
René Pfeuffer
2019-01-25 13:10:04 +01:00
parent 39a9615189
commit 9cee1957f7
3 changed files with 70 additions and 4 deletions

View File

@@ -0,0 +1,27 @@
// @flow
import React from "react";
import { translate } from "react-i18next";
import { Checkbox } from "@scm-manager/ui-components";
type Props = {
t: (string) => string,
name: string,
checked: boolean,
onChange?: (value: boolean, name?: string) => void
};
class PermissionCheckbox extends React.Component<Props> {
render() {
const { t } = this.props;
return (<Checkbox
key={this.props.name}
name={this.props.name}
helpText={t("verbs.repository." + this.props.name + ".description")}
label={t("verbs.repository." + this.props.name + ".displayName")}
checked={this.props.checked}
onChange={this.props.onChange}
/>);
}
}
export default translate("plugins")(PermissionCheckbox);

View File

@@ -1,8 +1,9 @@
// @flow // @flow
import React from "react"; import React from "react";
import { Button, Checkbox, SubmitButton } from "@scm-manager/ui-components"; import { Button, SubmitButton } from "@scm-manager/ui-components";
import { translate } from "react-i18next"; import { translate } from "react-i18next";
import PermissionCheckbox from "../components/PermissionCheckbox";
type Props = { type Props = {
availableVerbs: string[], availableVerbs: string[],
@@ -35,10 +36,8 @@ class AdvancedPermissionsDialog extends React.Component<Props, State> {
const { verbs } = this.state; const { verbs } = this.state;
const verbSelectBoxes = Object.entries(verbs).map(e => ( const verbSelectBoxes = Object.entries(verbs).map(e => (
<Checkbox <PermissionCheckbox
key={e[0]}
name={e[0]} name={e[0]}
label={e[0]}
checked={e[1]} checked={e[1]}
onChange={this.handleChange} onChange={this.handleChange}
/> />

View File

@@ -37,5 +37,45 @@
} }
}, },
"unknown": "Unknown permission" "unknown": "Unknown permission"
},
"verbs": {
"repository": {
"read": {
"displayName": "read",
"description": "May see the repository inside the SCM-Manager"
},
"modify": {
"displayName": "modify",
"description": "May modify the properties of the repository"
},
"delete": {
"displayName": "delete",
"description": "May delete the repository"
},
"pull": {
"displayName": "pull/checkout",
"description": "May pull/checkout the repository"
},
"push": {
"displayName": "push/commit",
"description": "May change the content of the repository (push/commit)"
},
"permissionRead": {
"displayName": "read permissions",
"description": "May see the permissions of the repository"
},
"permissionWrite": {
"displayName": "modify permissions",
"description": "May modify the permissions of the repository"
},
"healthCheck": {
"displayName": "health check",
"description": "May run the health check for the repository"
},
"*": {
"displayName": "overall",
"description": "May change everything for the repository (includes all other permissions)"
}
}
} }
} }