mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
revert NamespaceSelect
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
4e986b85cc
commit
2606b8ec3d
@ -5,16 +5,17 @@ import { computed } from "mobx";
|
|||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { t, Trans } from "@lingui/macro";
|
import { t, Trans } from "@lingui/macro";
|
||||||
import { Select, SelectOption, SelectProps } from "../select";
|
import { Select, SelectOption, SelectProps } from "../select";
|
||||||
import ReactSelect, { ActionMeta, components, OptionTypeBase, ValueType } from "react-select"
|
|
||||||
import { autobind, cssNames, noop } from "../../utils";
|
import { autobind, cssNames, noop } from "../../utils";
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { namespaceStore } from "./namespace.store";
|
import { namespaceStore } from "./namespace.store";
|
||||||
import { _i18n } from "../../i18n";
|
import { _i18n } from "../../i18n";
|
||||||
|
import ReactSelect, { ActionMeta, components } from "react-select";
|
||||||
|
|
||||||
interface Props extends SelectProps {
|
interface Props extends SelectProps {
|
||||||
showIcons?: boolean;
|
showIcons?: boolean;
|
||||||
showClusterOption?: boolean; // show cluster option on the top (default: false)
|
showClusterOption?: boolean; // show cluster option on the top (default: false)
|
||||||
clusterOptionLabel?: React.ReactNode; // label for cluster option (default: "Cluster")
|
clusterOptionLabel?: React.ReactNode; // label for cluster option (default: "Cluster")
|
||||||
|
customizeOptions?(nsOptions: SelectOption[]): SelectOption[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultProps: Partial<Props> = {
|
const defaultProps: Partial<Props> = {
|
||||||
@ -42,15 +43,12 @@ export class NamespaceSelect extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@computed get options(): SelectOption[] {
|
@computed get options(): SelectOption[] {
|
||||||
const options: SelectOption[] = namespaceStore.items
|
const { customizeOptions, showClusterOption, clusterOptionLabel } = this.props;
|
||||||
.map(ns => ({ value: ns.getName() }))
|
let options: SelectOption[] = namespaceStore.items.map(ns => ({ value: ns.getName() }));
|
||||||
.map(opt => ({ ...opt, label: this.formatOptionLabel(opt) }))
|
options = customizeOptions ? customizeOptions(options) : options;
|
||||||
|
|
||||||
const { showClusterOption, clusterOptionLabel } = this.props;
|
|
||||||
if (showClusterOption) {
|
if (showClusterOption) {
|
||||||
options.unshift({ value: null, label: clusterOptionLabel });
|
options.unshift({ value: null, label: clusterOptionLabel });
|
||||||
}
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +69,7 @@ export class NamespaceSelect extends React.Component<Props> {
|
|||||||
<Select
|
<Select
|
||||||
className={cssNames("NamespaceSelect", className)}
|
className={cssNames("NamespaceSelect", className)}
|
||||||
menuClass="NamespaceSelectMenu"
|
menuClass="NamespaceSelectMenu"
|
||||||
autoConvertOptions={false}
|
formatOptionLabel={this.formatOptionLabel}
|
||||||
options={this.options}
|
options={this.options}
|
||||||
{...selectProps}
|
{...selectProps}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user