diff --git a/src/renderer/components/+namespaces/namespace-select-filter-model/namespace-select-filter-model.tsx b/src/renderer/components/+namespaces/namespace-select-filter-model/namespace-select-filter-model.tsx
index 76445a46df..311128ca2d 100644
--- a/src/renderer/components/+namespaces/namespace-select-filter-model/namespace-select-filter-model.tsx
+++ b/src/renderer/components/+namespaces/namespace-select-filter-model/namespace-select-filter-model.tsx
@@ -17,6 +17,10 @@ export const selectAllNamespaces = Symbol("all-namespaces-selected");
export type SelectAllNamespaces = typeof selectAllNamespaces;
+export interface NamespaceSelectFilterOption {
+ namespace: string | SelectAllNamespaces;
+}
+
export class NamespaceSelectFilterModel {
constructor(private readonly dependencies: Dependencies) {
makeObservable(this, {
@@ -27,7 +31,7 @@ export class NamespaceSelectFilterModel {
});
}
- readonly options = computed(() => {
+ readonly options = computed((): readonly NamespaceSelectFilterOption[] => {
const baseOptions = this.dependencies.namespaceStore.items.map(ns => ns.getName());
baseOptions.sort((
@@ -36,20 +40,22 @@ export class NamespaceSelectFilterModel {
- +this.selectedNames.has(left)
));
- return [selectAllNamespaces, ...baseOptions] as const;
+ const res = [selectAllNamespaces, ...baseOptions] as const;
+
+ return res.map(namespace => ({ namespace }));
});
- formatOptionLabel = (option: string | SelectAllNamespaces) => {
- if (option === selectAllNamespaces) {
+ formatOptionLabel = ({ namespace }: NamespaceSelectFilterOption) => {
+ if (namespace === selectAllNamespaces) {
return "All Namespaces";
}
- const isSelected = this.isSelected(option);
+ const isSelected = this.isSelected(namespace);
return (
- {option}
+ {namespace}
{isSelected && (
{
- if (option === selectAllNamespaces) {
+ getOptionLabel = ({ namespace }: NamespaceSelectFilterOption) => {
+ if (namespace === selectAllNamespaces) {
return "All Namespaces";
}
- return option;
+ return namespace;
};
menuIsOpen = false;
@@ -94,7 +100,7 @@ export class NamespaceSelectFilterModel {
this.dependencies.namespaceStore.selectAll();
};
- onChange = (namespace: unknown, action: ActionMeta) => {
+ onChange = (namespace: unknown, action: ActionMeta) => {
switch (action.action) {
case "clear":
this.dependencies.namespaceStore.selectAll();
@@ -105,13 +111,13 @@ export class NamespaceSelectFilterModel {
}
break;
case "select-option":
- if (action.option === selectAllNamespaces) {
+ if (action.option?.namespace === selectAllNamespaces) {
this.dependencies.namespaceStore.selectAll();
} else if (action.option) {
if (this.isMultiSelection) {
- this.dependencies.namespaceStore.toggleSingle(action.option);
+ this.dependencies.namespaceStore.toggleSingle(action.option.namespace);
} else {
- this.dependencies.namespaceStore.selectSingle(action.option);
+ this.dependencies.namespaceStore.selectSingle(action.option.namespace);
}
}
break;
diff --git a/src/renderer/components/+namespaces/namespace-select-filter.tsx b/src/renderer/components/+namespaces/namespace-select-filter.tsx
index b641b222ce..938660f056 100644
--- a/src/renderer/components/+namespaces/namespace-select-filter.tsx
+++ b/src/renderer/components/+namespaces/namespace-select-filter.tsx
@@ -12,7 +12,7 @@ import { components } from "react-select";
import type { NamespaceStore } from "./namespace-store/namespace.store";
import { Select } from "../select";
import { withInjectables } from "@ogre-tools/injectable-react";
-import type { NamespaceSelectFilterModel, SelectAllNamespaces } from "./namespace-select-filter-model/namespace-select-filter-model";
+import type { NamespaceSelectFilterModel, NamespaceSelectFilterOption, SelectAllNamespaces } from "./namespace-select-filter-model/namespace-select-filter-model";
import namespaceSelectFilterModelInjectable from "./namespace-select-filter-model/namespace-select-filter-model.injectable";
import namespaceStoreInjectable from "./namespace-store/namespace-store.injectable";
@@ -31,7 +31,7 @@ const NonInjectedNamespaceSelectFilter = observer(({ model, id }: Dependencies &
onKeyDown={model.onKeyDown}
onClick={model.onClick}
>
-