From e45d90f92915236c1a5506147eac41926b35e403 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Mon, 19 Apr 2021 17:04:44 -0400 Subject: [PATCH] Add ability to add accessible namespaces when adding clusters Signed-off-by: Sebastian Malton --- .../components/+add-cluster/add-cluster.scss | 8 ++++ .../components/+add-cluster/add-cluster.tsx | 47 +++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/src/renderer/components/+add-cluster/add-cluster.scss b/src/renderer/components/+add-cluster/add-cluster.scss index 1185fcd761..fe4cf31874 100644 --- a/src/renderer/components/+add-cluster/add-cluster.scss +++ b/src/renderer/components/+add-cluster/add-cluster.scss @@ -17,6 +17,14 @@ } } + .content { + overflow-y: scroll; + } + + .MuiTabs-indicator { + background-color: var(--primary); + } + code { color: $pink-400; } diff --git a/src/renderer/components/+add-cluster/add-cluster.tsx b/src/renderer/components/+add-cluster/add-cluster.tsx index c5778beb0a..8833634333 100644 --- a/src/renderer/components/+add-cluster/add-cluster.tsx +++ b/src/renderer/components/+add-cluster/add-cluster.tsx @@ -19,6 +19,7 @@ import { navigate } from "../../navigation"; import { iter } from "../../utils"; import { AceEditor } from "../ace-editor"; import { Button } from "../button"; +import { EditableList } from "../editable-list"; import { Input } from "../input"; import { PageLayout } from "../layout/page-layout"; import { Notifications } from "../notifications"; @@ -47,7 +48,9 @@ export class AddCluster extends React.Component { @observable proxyServer = ""; @observable isWaiting = false; @observable showProxySettings = false; + @observable showAccessibleNamespaces = false; @observable errorText: string; + accessibleNamespaces = observable.set(); componentDidMount() { appEventBus.emit({ name: "cluster-add", action: "start" }); @@ -63,6 +66,10 @@ export class AddCluster extends React.Component { return this.selectedContexts.length > 0; } + @computed get accessibleNamespacesList(): string[] { + return Array.from(this.accessibleNamespaces); + } + @action refreshContexts = debounce(() => { const { config, error } = loadConfigFromString(this.customConfig.trim() || "{}"); @@ -147,6 +154,45 @@ export class AddCluster extends React.Component { this.showProxySettings = !this.showProxySettings; }; + toggleShowAccessibleNamespaces = () => { + this.showAccessibleNamespaces = !this.showAccessibleNamespaces; + }; + + renderAccessibleNamespaces() { + return ( + <> +

+ Accessible Namespaces + + { + this.showAccessibleNamespaces + ? + : + } + +

+ {this.showAccessibleNamespaces && ( +
+

This setting is useful for manually specifying which namespaces you have access to. This is useful when you do not have permissions to list namespaces.

+ this.accessibleNamespaces.add(newNamespace)} + remove={({ oldItem }) => this.accessibleNamespaces.delete(oldItem)} + items={this.accessibleNamespacesList} + /> + + These settings will be applied too all clusters being added. + +
+ )} + + ); + } + renderProxySettings() { return ( <> @@ -222,6 +268,7 @@ export class AddCluster extends React.Component { {Array.from(this.kubeContexts.values(), this.renderContextSelectionEntry)} {this.renderProxySettings()} + {this.renderAccessibleNamespaces()} ); }