// @flow import React from "react"; import { Button, Checkbox, SubmitButton } from "@scm-manager/ui-components"; import { translate } from "react-i18next"; type Props = { availableVerbs: string[], selectedVerbs: string[], onSubmit: (string[]) => void, onClose: () => void, // context props t: string => string }; type State = { verbs: any }; class AdvancedPermissionsDialog extends React.Component { constructor(props: Props) { super(props); const verbs = {}; props.availableVerbs.forEach( verb => (verbs[verb] = props.selectedVerbs.includes(verb)) ); this.state = { verbs }; } render() { const { t, onClose } = this.props; const { verbs } = this.state; const verbSelectBoxes = Object.entries(verbs).map(e => ( )); return (

{t("permission.advanced.dialog.title")}

{verbSelectBoxes}
); } handleChange = (value: boolean, name: string) => { const { verbs } = this.state; const newVerbs = { ...verbs, [name]: value }; this.setState({ verbs: newVerbs }); }; onSubmit = () => { this.props.onSubmit( Object.entries(this.state.verbs) .filter(e => e[1]) .map(e => e[0]) ); }; } export default translate("repos")(AdvancedPermissionsDialog);