mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix Pod Container sorting not correlating to visuals (#5175)
This commit is contained in:
1 parent
95ed0dda1b
commit
2b24a42883
4 files changed
+8
-8
No files matched your search
@@ -113,7 +113,7 @@ class NonInjectedPods extends React.Component<Dependencies> {
|
||||
sortingCallbacks={{
|
||||
[columnId.name]: pod => getConvertedParts(pod.getName()),
|
||||
[columnId.namespace]: pod => pod.getNs(),
|
||||
[columnId.containers]: pod => pod.getContainers().length,
|
||||
[columnId.containers]: pod => pod.getContainerStatuses().length,
|
||||
[columnId.restarts]: pod => pod.getRestartsCount(),
|
||||
[columnId.owners]: pod => pod.getOwnerRefs().map(ref => ref.kind),
|
||||
[columnId.qos]: pod => pod.getQosClass(),
|
||||
|
||||
@@ -26,10 +26,10 @@ describe("Table tests", () => {
|
||||
expect(i).toStrictEqual([1, 2, 4, 3]);
|
||||
});
|
||||
|
||||
it("should sort numerically asc (by defaul) and not touch the original list", () => {
|
||||
it("should sort numerically asc (by default) and not touch the original list", () => {
|
||||
const i = [1, 2, 4, 3];
|
||||
|
||||
expect(getSorted(i, v => v, "foobar")).toStrictEqual([1, 2, 3, 4]);
|
||||
expect(getSorted(i, v => v)).toStrictEqual([1, 2, 3, 4]);
|
||||
expect(i).toStrictEqual([1, 2, 4, 3]);
|
||||
});
|
||||
|
||||
|
||||
@@ -3,15 +3,14 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { TableSortCallback } from "./table";
|
||||
import type { TableOrderBy, TableSortCallback } from "./table";
|
||||
import { Ordering, rectifyOrdering, sortCompare, tuple } from "../../utils";
|
||||
|
||||
export function getSorted<T>(rawItems: T[], sortingCallback: TableSortCallback<T> | undefined, orderByRaw: string): T[] {
|
||||
export function getSorted<T>(rawItems: T[], sortingCallback: TableSortCallback<T> | undefined, orderBy: TableOrderBy = "asc"): T[] {
|
||||
if (typeof sortingCallback !== "function") {
|
||||
return rawItems;
|
||||
}
|
||||
|
||||
const orderBy = orderByRaw === "asc" || orderByRaw === "desc" ? orderByRaw : "asc";
|
||||
const sortData = rawItems.map((item, index) => ({
|
||||
index,
|
||||
sortBy: sortingCallback(item),
|
||||
|
||||
Reference in new issue
Block a user