// @flow import React from "react"; import type { Permission } from "../types/Permissions"; import { Checkbox } from "../../components/forms/index"; import { DeleteButton } from "../../components/buttons/index"; import { translate } from "react-i18next"; import { Select } from "../../components/forms/index"; import { modifyPermission, isModifyPermissionPending, getModifyPermissionFailure, modifyPermissionReset } from "../modules/permissions"; import connect from "react-redux/es/connect/connect"; import { withRouter } from "react-router-dom"; import type { History } from "history"; import ErrorNotification from "../../components/ErrorNotification"; type Props = { submitForm: Permission => void, modifyPermission: (Permission, string, string) => void, permission: Permission, t: string => string, namespace: string, name: string, match: any, history: History, loading: boolean, error: Error, permissionReset: (string, string, string) => void }; type State = { permission: Permission }; class SinglePermission extends React.Component { constructor(props: Props) { super(props); this.state = { permission: { name: "", type: "READ", groupPermission: false, _links: {} } }; } componentDidMount() { const { permission } = this.props; this.props.permissionReset( this.props.namespace, this.props.name, permission.name ); if (permission) { this.setState({ permission: { name: permission.name, type: permission.type, groupPermission: permission.groupPermission, _links: permission._links } }); } } render() { const { permission } = this.state; const { t, loading, error } = this.props; const types = ["READ", "OWNER", "GROUP"]; const deleteButton = this.props.permission._links.delete ? ( ) : null; const typeSelector = this.props.permission._links.update ? (