From 2606b8ec3d97eb1e797474243c99e05bbd146dcf Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Fri, 25 Sep 2020 14:54:23 -0400 Subject: [PATCH] revert NamespaceSelect Signed-off-by: Sebastian Malton --- .../components/+namespaces/namespace-select.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/renderer/components/+namespaces/namespace-select.tsx b/src/renderer/components/+namespaces/namespace-select.tsx index b8d1f75978..73b3d4407e 100644 --- a/src/renderer/components/+namespaces/namespace-select.tsx +++ b/src/renderer/components/+namespaces/namespace-select.tsx @@ -5,16 +5,17 @@ import { computed } from "mobx"; import { observer } from "mobx-react"; import { t, Trans } from "@lingui/macro"; import { Select, SelectOption, SelectProps } from "../select"; -import ReactSelect, { ActionMeta, components, OptionTypeBase, ValueType } from "react-select" import { autobind, cssNames, noop } from "../../utils"; import { Icon } from "../icon"; import { namespaceStore } from "./namespace.store"; import { _i18n } from "../../i18n"; +import ReactSelect, { ActionMeta, components } from "react-select"; interface Props extends SelectProps { showIcons?: boolean; 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 = { @@ -42,15 +43,12 @@ export class NamespaceSelect extends React.Component { } @computed get options(): SelectOption[] { - const options: SelectOption[] = namespaceStore.items - .map(ns => ({ value: ns.getName() })) - .map(opt => ({ ...opt, label: this.formatOptionLabel(opt) })) - - const { showClusterOption, clusterOptionLabel } = this.props; + const { customizeOptions, showClusterOption, clusterOptionLabel } = this.props; + let options: SelectOption[] = namespaceStore.items.map(ns => ({ value: ns.getName() })); + options = customizeOptions ? customizeOptions(options) : options; if (showClusterOption) { options.unshift({ value: null, label: clusterOptionLabel }); } - return options; } @@ -71,7 +69,7 @@ export class NamespaceSelect extends React.Component {