Fix test failures due to newer dep versions

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2022-12-01 09:41:44 -05:00
1 parent e76e529f4a
commit 1eaf253205
3 files changed
+37 -22

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/**
* Get an ordering function based on the function getter
*/
export function byValue<T>(getOrderValue: (src: T) => number): (left: T, right: T) => number {
return (left, right) => {
const leftValue = getOrderValue(left);
const rightValue = getOrderValue(right);
return leftValue - rightValue;
};
}
@@ -20,21 +20,23 @@ const currentKubeObjectInDetailsInjectable = getInjectable({
const urlParam = di.inject(kubeDetailsUrlParamInjectable);
const apiManager = di.inject(apiManagerInjectable);
return asyncComputed(async (): Promise<CurrentKubeObject> => {
const path = urlParam.get();
const store = apiManager.getStore(path);
return asyncComputed({
getValueFromObservedPromise: async (): Promise<CurrentKubeObject> => {
const path = urlParam.get();
const store = apiManager.getStore(path);
if (!store) {
return undefined;
}
if (!store) {
return undefined;
}
try {
const object = await store.loadFromPath(path);
try {
const object = await store.loadFromPath(path);
return { object };
} catch (error) {
return { error: String(error) };
}
return { object };
} catch (error) {
return { error: String(error) };
}
},
});
},
});
@@ -6,9 +6,8 @@ import { getInjectable } from "@ogre-tools/injectable";
import { computed } from "mobx";
import { computedInjectManyInjectable } from "@ogre-tools/injectable-extension-for-mobx";
import { filter, map, sortBy } from "lodash/fp";
import { pipeline } from "@ogre-tools/fp";
import { kubeObjectDetailItemInjectionToken } from "./kube-object-detail-item-injection-token";
import { byValue } from "../../../../common/utils/sort-function";
const kubeObjectDetailItemsInjectable = getInjectable({
id: "kube-object-detail-items",
@@ -17,14 +16,12 @@ const kubeObjectDetailItemsInjectable = getInjectable({
const computedInjectMany = di.inject(computedInjectManyInjectable);
const items = computedInjectMany(kubeObjectDetailItemInjectionToken);
return computed(() => {
return pipeline(
items.get(),
filter((item) => item.enabled.get()),
sortBy((item) => item.orderNumber),
map((item) => item.Component),
);
});
return computed(() => (
items.get()
.filter(item => item.enabled.get())
.sort(byValue(item => item.orderNumber))
.map(item => item.Component)
));
},
});