From 3afef111e87bc92d2c3814e5e736dc2e4a3137d2 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Fri, 5 Feb 2021 09:45:29 +0200 Subject: [PATCH] Revert "Allow to quick select/deselect all namespaces in `NamespaceSelect` (#2068)" This reverts commit 1b492f27addee7a5e1a146afea5a0719bd6b665d. Signed-off-by: Jari Kolehmainen --- .../+namespaces/namespace-select.tsx | 87 +++++++------------ .../components/+namespaces/namespace.store.ts | 76 +++++++--------- .../item-object-list/page-filters.store.ts | 2 +- 3 files changed, 65 insertions(+), 100 deletions(-) diff --git a/src/renderer/components/+namespaces/namespace-select.tsx b/src/renderer/components/+namespaces/namespace-select.tsx index 5bcf07e1cf..6ee7ea2d57 100644 --- a/src/renderer/components/+namespaces/namespace-select.tsx +++ b/src/renderer/components/+namespaces/namespace-select.tsx @@ -13,14 +13,17 @@ 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[]; + showClusterOption?: boolean; // show cluster option on the top (default: false) + clusterOptionLabel?: React.ReactNode; // label for cluster option (default: "Cluster") + customizeOptions?(nsOptions: SelectOption[]): SelectOption[]; } const defaultProps: Partial = { showIcons: true, showClusterOption: false, + get clusterOptionLabel() { + return `Cluster`; + }, }; @observer @@ -36,17 +39,13 @@ export class NamespaceSelect extends React.Component { } @computed get options(): SelectOption[] { - const { customizeOptions, showClusterOption, showAllNamespacesOption } = this.props; + const { customizeOptions, showClusterOption, clusterOptionLabel } = 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: "" }); - } + options = customizeOptions ? customizeOptions(options) : options; - if (customizeOptions) { - options = customizeOptions(options); + if (showClusterOption) { + options.unshift({ value: null, label: clusterOptionLabel }); } return options; @@ -65,7 +64,7 @@ export class NamespaceSelect extends React.Component { }; render() { - const { className, showIcons, customizeOptions, ...selectProps } = this.props; + const { className, showIcons, showClusterOption, clusterOptionLabel, customizeOptions, ...selectProps } = this.props; return (