diff --git a/src/extensions/renderer-api/navigation.ts b/src/extensions/renderer-api/navigation.ts index 6e953920e1..fd1f9196cc 100644 --- a/src/extensions/renderer-api/navigation.ts +++ b/src/extensions/renderer-api/navigation.ts @@ -1,4 +1,12 @@ -export { PageParamInit, PageParam } from "../../renderer/navigation/page-param"; -export { navigate, isActiveRoute, createPageParam } from "../../renderer/navigation/helpers"; +import { PageParam, PageParamInit } from "../../renderer/navigation/page-param"; +import { navigation } from "../../renderer/navigation"; + +export type { PageParamInit, PageParam } from "../../renderer/navigation/page-param"; +export { navigate, isActiveRoute } from "../../renderer/navigation/helpers"; export { hideDetails, showDetails, getDetailsUrl } from "../../renderer/components/kube-object/kube-object-details"; export { IURLParams } from "../../common/utils/buildUrl"; + +// exporting to extensions-api version of helper without `isSystem` flag +export function createPageParam(init: PageParamInit) { + return new PageParam(init, navigation); +} diff --git a/src/renderer/navigation/helpers.ts b/src/renderer/navigation/helpers.ts index 33ff1dd416..378f6edb96 100644 --- a/src/renderer/navigation/helpers.ts +++ b/src/renderer/navigation/helpers.ts @@ -1,6 +1,6 @@ import type { LocationDescriptor } from "history"; import { matchPath, RouteProps } from "react-router"; -import { PageParam, PageParamInit } from "./page-param"; +import { PageParam, PageSystemParamInit } from "./page-param"; import { clusterViewRoute, IClusterViewRouteParams } from "../components/cluster-manager/cluster-view.route"; import { navigation } from "./history"; @@ -14,7 +14,7 @@ export function navigate(location: LocationDescriptor) { } } -export function createPageParam(init: PageParamInit) { +export function createPageParam(init: PageSystemParamInit) { return new PageParam(init, navigation); } diff --git a/src/renderer/navigation/page-param.ts b/src/renderer/navigation/page-param.ts index 5f71bbe795..e73da03c44 100644 --- a/src/renderer/navigation/page-param.ts +++ b/src/renderer/navigation/page-param.ts @@ -3,7 +3,6 @@ import { IObservableHistory } from "mobx-observable-history"; export interface PageParamInit { name: string; - isSystem?: boolean; defaultValue?: V; defaultValueStringified?: string | string[]; // serialized version of "defaultValue" multiValues?: boolean; // false == by default @@ -13,14 +12,18 @@ export interface PageParamInit { stringify?(value: V): string | string[]; // serialize params to URL } +export interface PageSystemParamInit extends PageParamInit { + isSystem?: boolean; +} + export class PageParam { static SYSTEM_PREFIX = "lens-"; readonly name: string; protected urlName: string; - constructor(readonly init: PageParamInit, protected history: IObservableHistory) { - const { isSystem, name } = init; + constructor(readonly init: PageParamInit | PageSystemParamInit, protected history: IObservableHistory) { + const { isSystem, name } = init as PageSystemParamInit; this.name = name; this.init.skipEmpty ??= true;