1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/renderer/routes/navigate-to-route.injectable.ts
Juho Heikka 167f42330b
Initial telemetry whitelist (#6181)
* Remove emit-telemetry tag from navigate-to-route injectable

Signed-off-by: Juho Heikka <juho.heikka@gmail.com>

* Rename injectable to more describing name

Signed-off-by: Juho Heikka <juho.heikka@gmail.com>

* Add initial injectable ids to white-list

Signed-off-by: Juho Heikka <juho.heikka@gmail.com>

Signed-off-by: Juho Heikka <juho.heikka@gmail.com>
2022-09-07 08:40:37 -04:00

40 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 { navigateToUrlInjectionToken } from "../../common/front-end-routing/navigate-to-url-injection-token";
import { navigateToRouteInjectionToken } from "../../common/front-end-routing/navigate-to-route-injection-token";
import currentlyInClusterFrameInjectable from "./currently-in-cluster-frame.injectable";
import { buildURL } from "../../common/utils/buildUrl";
const navigateToRouteInjectable = getInjectable({
id: "navigate-to-route",
instantiate: (di) => {
const navigateToUrl = di.inject(navigateToUrlInjectionToken);
const currentlyInClusterFrame = di.inject(
currentlyInClusterFrameInjectable,
);
return (route, options) => {
const url = buildURL(route.path, {
// TODO: enhance typing
params: options?.parameters as any,
query: options?.query,
fragment: options?.fragment,
});
navigateToUrl(url, {
...options,
forceRootFrame: currentlyInClusterFrame && route.clusterFrame === false,
});
};
},
injectionToken: navigateToRouteInjectionToken,
});
export default navigateToRouteInjectable;