mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* Fix cluster frame display issue - Add some defensive code to prevent this sort of infinite loop - Add some unit tests Signed-off-by: Sebastian Malton <sebastian@malton.name> * fix unit tests Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix build Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix lint Signed-off-by: Sebastian Malton <sebastian@malton.name> * Factor out injectable for getting of cluster config data Signed-off-by: Sebastian Malton <sebastian@malton.name>
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import { getInjectable } from "@ogre-tools/injectable";
|
|
import { computed } from "mobx";
|
|
import clusterOverviewRouteInjectable from "../../../common/front-end-routing/routes/cluster/overview/cluster-overview-route.injectable";
|
|
import workloadsOverviewRouteInjectable from "../../../common/front-end-routing/routes/cluster/workloads/overview/workloads-overview-route.injectable";
|
|
|
|
const startUrlInjectable = getInjectable({
|
|
id: "start-url",
|
|
|
|
instantiate: (di) => {
|
|
const clusterOverviewRoute = di.inject(clusterOverviewRouteInjectable);
|
|
const workloadOverviewRoute = di.inject(workloadsOverviewRouteInjectable);
|
|
|
|
return computed(() => {
|
|
if (clusterOverviewRoute.isEnabled.get()) {
|
|
return clusterOverviewRoute.path;
|
|
}
|
|
|
|
if (workloadOverviewRoute.isEnabled.get()) {
|
|
return workloadOverviewRoute.path;
|
|
}
|
|
|
|
/**
|
|
* NOTE: This will never be executed as `workloadOverviewRoute.isEnabled` always is true. It
|
|
* is here is guard against accidental changes at a distance within `workloadOverviewRoute`.
|
|
*/
|
|
throw new Error("Exhausted all possible starting locations and none are active. This is a bug.");
|
|
});
|
|
},
|
|
});
|
|
|
|
export default startUrlInjectable;
|