From e160ba48b5713d256d6a2b74239aedd4585a8953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maren=20S=C3=BCwer?= Date: Thu, 23 Aug 2018 14:14:49 +0200 Subject: [PATCH] add edit view --- scm-ui/public/locales/en/permissions.json | 6 +- .../components/table/PermissionRowEditable.js | 108 ++++++++++++++++++ .../components/table/PermissionsTable.js | 35 +++--- 3 files changed, 134 insertions(+), 15 deletions(-) create mode 100644 scm-ui/src/permissions/components/table/PermissionRowEditable.js diff --git a/scm-ui/public/locales/en/permissions.json b/scm-ui/public/locales/en/permissions.json index 9e1eb0a841..686a01156d 100644 --- a/scm-ui/public/locales/en/permissions.json +++ b/scm-ui/public/locales/en/permissions.json @@ -4,8 +4,12 @@ "error-subtitle": "Unknown permissions error" }, "permission": { - "name": "Username", + "name": "Name", "type": "Type", "group-permission": "Group Permission" + }, + "edit-permission": { + "delete-button": "Delete", + "save-button": "Save Changes" } } diff --git a/scm-ui/src/permissions/components/table/PermissionRowEditable.js b/scm-ui/src/permissions/components/table/PermissionRowEditable.js new file mode 100644 index 0000000000..7666fa92b1 --- /dev/null +++ b/scm-ui/src/permissions/components/table/PermissionRowEditable.js @@ -0,0 +1,108 @@ +// @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"; + +type Props = { + permission: Permission, + t: string => string +}; + +type State = { + name: string, + type: string, + groupPermission: boolean +}; + +class PermissionRowEditable extends React.Component { + constructor(props: Props) { + super(props); + + this.state = { + name: "", + type: "READ", + groupPermission: false + }; + } + + componentDidMount() { + const { permission } = this.props; + if (permission) { + this.setState({ + name: permission.name, + type: permission.type, + groupPermission: permission.groupPermission + }); + } + } + + render() { + const { name, type, groupPermission } = this.state; + const { t } = this.props; + const types = ["READ", "OWNER", "GROUP"]; + + const deleteButton = this.props.permission._links.delete ? ( + + ) : null; + + return ( + + + + + +