mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Allow namespace to specified on role creation (#2020)
* Allow users to specify the namespace when creating a custom role. * Default role namespace remains the "global" namespace allowing for cluster role creatoin. Signed-off-by: Jameel Al-Aziz <me@jalaziz.io>
This commit is contained in:
parent
da1d0d162f
commit
a2f4fac720
@ -5,9 +5,11 @@ import { observable } from "mobx";
|
|||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { Dialog, DialogProps } from "../dialog";
|
import { Dialog, DialogProps } from "../dialog";
|
||||||
import { Wizard, WizardStep } from "../wizard";
|
import { Wizard, WizardStep } from "../wizard";
|
||||||
|
import { SubTitle } from "../layout/sub-title";
|
||||||
import { Notifications } from "../notifications";
|
import { Notifications } from "../notifications";
|
||||||
import { rolesStore } from "./roles.store";
|
import { rolesStore } from "./roles.store";
|
||||||
import { Input } from "../input";
|
import { Input } from "../input";
|
||||||
|
import { NamespaceSelect } from "../+namespaces/namespace-select";
|
||||||
import { showDetails } from "../kube-object";
|
import { showDetails } from "../kube-object";
|
||||||
|
|
||||||
interface Props extends Partial<DialogProps> {
|
interface Props extends Partial<DialogProps> {
|
||||||
@ -18,6 +20,7 @@ export class AddRoleDialog extends React.Component<Props> {
|
|||||||
@observable static isOpen = false;
|
@observable static isOpen = false;
|
||||||
|
|
||||||
@observable roleName = "";
|
@observable roleName = "";
|
||||||
|
@observable namespace = "";
|
||||||
|
|
||||||
static open() {
|
static open() {
|
||||||
AddRoleDialog.isOpen = true;
|
AddRoleDialog.isOpen = true;
|
||||||
@ -33,11 +36,12 @@ export class AddRoleDialog extends React.Component<Props> {
|
|||||||
|
|
||||||
reset = () => {
|
reset = () => {
|
||||||
this.roleName = "";
|
this.roleName = "";
|
||||||
|
this.namespace = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
createRole = async () => {
|
createRole = async () => {
|
||||||
try {
|
try {
|
||||||
const role = await rolesStore.create({ name: this.roleName });
|
const role = await rolesStore.create({ name: this.roleName, namespace: this.namespace });
|
||||||
|
|
||||||
showDetails(role.selfLink);
|
showDetails(role.selfLink);
|
||||||
this.reset();
|
this.reset();
|
||||||
@ -64,13 +68,20 @@ export class AddRoleDialog extends React.Component<Props> {
|
|||||||
nextLabel="Create"
|
nextLabel="Create"
|
||||||
next={this.createRole}
|
next={this.createRole}
|
||||||
>
|
>
|
||||||
|
<SubTitle title="Role Name" />
|
||||||
<Input
|
<Input
|
||||||
required autoFocus
|
required autoFocus
|
||||||
placeholder={`Role name`}
|
placeholder={`Name`}
|
||||||
iconLeft="supervisor_account"
|
iconLeft="supervisor_account"
|
||||||
value={this.roleName}
|
value={this.roleName}
|
||||||
onChange={v => this.roleName = v}
|
onChange={v => this.roleName = v}
|
||||||
/>
|
/>
|
||||||
|
<SubTitle title="Namespace" />
|
||||||
|
<NamespaceSelect
|
||||||
|
themeName="light"
|
||||||
|
value={this.namespace}
|
||||||
|
onChange={({ value }) => this.namespace = value}
|
||||||
|
/>
|
||||||
</WizardStep>
|
</WizardStep>
|
||||||
</Wizard>
|
</Wizard>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user