From 649ec3e1fe355a51aa3288d586232de75220f8cb Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 3 Feb 2021 17:51:50 +0200 Subject: [PATCH] fixes & refactoring Signed-off-by: Roman --- .../+namespaces/namespace-select.tsx | 31 +++++---- .../components/+namespaces/namespace.store.ts | 64 +++++++++---------- 2 files changed, 46 insertions(+), 49 deletions(-) diff --git a/src/renderer/components/+namespaces/namespace-select.tsx b/src/renderer/components/+namespaces/namespace-select.tsx index 7c47337591..5bcf07e1cf 100644 --- a/src/renderer/components/+namespaces/namespace-select.tsx +++ b/src/renderer/components/+namespaces/namespace-select.tsx @@ -13,6 +13,8 @@ import { kubeWatchApi } from "../../api/kube-watch-api"; interface Props extends SelectProps { showIcons?: boolean; + showClusterOption?: boolean; // show "Cluster" option on the top (default: false) + showAllNamespacesOption?: boolean; // show "All namespaces" option on the top (default: false) customizeOptions?(options: SelectOption[]): SelectOption[]; } @@ -34,9 +36,15 @@ export class NamespaceSelect extends React.Component { } @computed get options(): SelectOption[] { - const { customizeOptions } = this.props; + const { customizeOptions, showClusterOption, showAllNamespacesOption } = this.props; let options: SelectOption[] = namespaceStore.items.map(ns => ({ value: ns.getName() })); + if (showAllNamespacesOption) { + options.unshift({ label: "All Namespaces", value: "" }); + } else if (showClusterOption) { + options.unshift({ label: "Cluster", value: "" }); + } + if (customizeOptions) { options = customizeOptions(options); } @@ -57,7 +65,7 @@ export class NamespaceSelect extends React.Component { }; render() { - const { className, showIcons, showClusterOption, clusterOptionLabel, customizeOptions, ...selectProps } = this.props; + const { className, showIcons, customizeOptions, ...selectProps } = this.props; return (