import "./add-role-dialog.scss" import * as React from "react"; import { observable } from "mobx"; import { observer } from "mobx-react"; import { t, Trans } from "@lingui/macro"; import { _i18n } from "../../i18n"; import { Dialog, DialogProps } from "../dialog"; import { Wizard, WizardStep } from "../wizard"; import { Notifications } from "../notifications"; import { rolesStore } from "./roles.store"; import { Input } from "../input"; import { showDetails } from "../../navigation"; interface Props extends Partial { } @observer export class AddRoleDialog extends React.Component { @observable static isOpen = false; @observable roleName = ""; static open() { AddRoleDialog.isOpen = true; } static close() { AddRoleDialog.isOpen = false; } close = () => { AddRoleDialog.close(); } reset = () => { this.roleName = "" } createRole = async () => { try { const role = await rolesStore.create({ name: this.roleName }); showDetails(role.selfLink); this.reset(); this.close(); } catch (err) { Notifications.error(err.toString()); } } render() { const { ...dialogProps } = this.props; const header =
Create Role
; return ( Create} next={this.createRole} > this.roleName = v} /> ) } }