diff --git a/src/renderer/components/+namespaces/namespace-select.tsx b/src/renderer/components/+namespaces/namespace-select.tsx index 6ee7ea2d57..5bcf07e1cf 100644 --- a/src/renderer/components/+namespaces/namespace-select.tsx +++ b/src/renderer/components/+namespaces/namespace-select.tsx @@ -13,17 +13,14 @@ import { kubeWatchApi } from "../../api/kube-watch-api"; 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[]; + 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[]; } const defaultProps: Partial = { showIcons: true, showClusterOption: false, - get clusterOptionLabel() { - return `Cluster`; - }, }; @observer @@ -39,13 +36,17 @@ export class NamespaceSelect extends React.Component { } @computed get options(): SelectOption[] { - const { customizeOptions, showClusterOption, clusterOptionLabel } = this.props; + const { customizeOptions, showClusterOption, showAllNamespacesOption } = this.props; let options: SelectOption[] = namespaceStore.items.map(ns => ({ value: ns.getName() })); - options = customizeOptions ? customizeOptions(options) : options; + if (showAllNamespacesOption) { + options.unshift({ label: "All Namespaces", value: "" }); + } else if (showClusterOption) { + options.unshift({ label: "Cluster", value: "" }); + } - if (showClusterOption) { - options.unshift({ value: null, label: clusterOptionLabel }); + if (customizeOptions) { + options = customizeOptions(options); } return options; @@ -64,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 (