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,28 +60,32 @@ export function namespaceSelectFilterModelFor(dependencies: Dependencies): Names
|
|||||||
equals: comparer.structural,
|
equals: comparer.structural,
|
||||||
});
|
});
|
||||||
const optionsSortingSelected = observable.set(selectedNames.get());
|
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 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 [
|
return [
|
||||||
{
|
{
|
||||||
value: selectAllNamespaces,
|
value: selectAllNamespaces,
|
||||||
label: "All Namespaces",
|
label: "All Namespaces",
|
||||||
id: "all-namespaces",
|
|
||||||
// isSelected: false,
|
|
||||||
},
|
},
|
||||||
...baseOptions.map(namespace => ({
|
...namespaceStore
|
||||||
|
.items
|
||||||
|
.map(ns => ns.getName())
|
||||||
|
.sort(sortNamespacesByIfTheyAreSelected)
|
||||||
|
.map(namespace => ({
|
||||||
value: namespace,
|
value: namespace,
|
||||||
label: namespace,
|
label: namespace,
|
||||||
id: namespace,
|
|
||||||
// isSelected: namespaces.has(namespace),
|
|
||||||
})),
|
})),
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user