// @flow import React from "react"; import type { Permission } from "../../types/Permissions"; import { Checkbox, InputField } from "../../../components/forms/index"; import { DeleteButton, SubmitButton } from "../../../components/buttons/index"; import { translate } from "react-i18next"; import { Select } from "../../../components/forms/index"; type Props = { submitForm: Permission => void, permission: Permission, t: string => string }; type State = { permission: Permission }; class PermissionRowEditable extends React.Component { constructor(props: Props) { super(props); this.state = { permission: { name: "", type: "READ", groupPermission: false, _links: {} } }; } componentDidMount() { const { permission } = this.props; if (permission) { this.setState({ permission: { name: permission.name, type: permission.type, groupPermission: permission.groupPermission, _links: permission._links } }); } } submit = (event: Event) => { event.preventDefault(); this.props.submitForm(this.state.permission); }; render() { const { permission } = this.state; const { t } = this.props; const types = ["READ", "OWNER", "GROUP"]; const deleteButton = this.props.permission._links.delete ? ( ) : null; return (