import React, { Component } from "react"; import { Card, Button, Popover, Select, Transfer } from "antd"; import { deleteUser, listUsers, listRoles, setRoles, } from "../../util/wslink"; import DataTable from "../../components/data-table"; import notify from "../../util/notify"; import DeleteOutlined from "@ant-design/icons/DeleteOutlined"; const { Option } = Select; export class UserView extends Component { constructor(props) { super(props); this.state = { user: {}, }; this.messagesEndRef = React.createRef(); } navigate(url) { this.props.history.push(url); } async componentDidMount() { await this.getData(); } async getData() { let name = this.props.match.params.id; let users = await listUsers(); let roles = await listRoles(); this.setState({ user: users.find(x => x.name === name), roles, }); } async handleChange(targetKeys) { this.setState({ user: { ...this.state.user, roles: targetKeys, }, }); let response = await setRoles({ name: this.state.user.name, roles: targetKeys, }); console.log("Updated user roles",response); }; render() { console.log(this.state); let { user, roles } = this.state; return

{user.name}

Assign roles

option.name.toLowerCase().indexOf(inputValue.toLowerCase()) > -1} targetKeys={user.roles} onChange={this.handleChange.bind(this)} render={item => item.name} /> { await deleteUser({ name: user.name }); notify("Deleted user " + user.name, "success"); this.navigate("/users"); }} > Delete this user from the cluster } trigger="click" >
; } }