mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Cleanup of options computed
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
6c8220e140
commit
9a62b4a9ae
@ -60,29 +60,33 @@ export function namespaceSelectFilterModelFor(dependencies: Dependencies): Names
|
||||
equals: comparer.structural,
|
||||
});
|
||||
const optionsSortingSelected = observable.set(selectedNames.get());
|
||||
const sortNamespacesByIfTheyAreSelected = (left: string, right: string) => {
|
||||
const isLeftSelected = optionsSortingSelected.has(left);
|
||||
const isRightSelected = optionsSortingSelected.has(right);
|
||||
|
||||
if (isLeftSelected === isRightSelected) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return isLeftSelected
|
||||
? 1
|
||||
: -1;
|
||||
};
|
||||
|
||||
const options = computed((): readonly NamespaceSelectFilterOption[] => {
|
||||
const baseOptions = namespaceStore.items.map(ns => ns.getName());
|
||||
// const namespaces = selectedNames.get();
|
||||
|
||||
baseOptions.sort((
|
||||
(left, right) =>
|
||||
+optionsSortingSelected.has(right)
|
||||
- +optionsSortingSelected.has(left)
|
||||
));
|
||||
|
||||
return [
|
||||
{
|
||||
value: selectAllNamespaces,
|
||||
label: "All Namespaces",
|
||||
id: "all-namespaces",
|
||||
// isSelected: false,
|
||||
},
|
||||
...baseOptions.map(namespace => ({
|
||||
value: namespace,
|
||||
label: namespace,
|
||||
id: namespace,
|
||||
// isSelected: namespaces.has(namespace),
|
||||
})),
|
||||
...namespaceStore
|
||||
.items
|
||||
.map(ns => ns.getName())
|
||||
.sort(sortNamespacesByIfTheyAreSelected)
|
||||
.map(namespace => ({
|
||||
value: namespace,
|
||||
label: namespace,
|
||||
})),
|
||||
];
|
||||
});
|
||||
const menuIsOpen = computed(() => menuState.get() === SelectMenuState.Open);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user