1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

removed isSystem page-param's init field exposed to extensions-api

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-12-18 16:38:52 +02:00
parent 8ce222ecec
commit 936bdb051b
3 changed files with 18 additions and 7 deletions

View File

@ -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<V = string>(init: PageParamInit<V>) {
return new PageParam<V>(init, navigation);
}

View File

@ -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<V = string>(init: PageParamInit<V>) {
export function createPageParam<V = string>(init: PageSystemParamInit<V>) {
return new PageParam<V>(init, navigation);
}

View File

@ -3,7 +3,6 @@ import { IObservableHistory } from "mobx-observable-history";
export interface PageParamInit<V = any> {
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<V = any> {
stringify?(value: V): string | string[]; // serialize params to URL
}
export interface PageSystemParamInit<V = any> extends PageParamInit<V> {
isSystem?: boolean;
}
export class PageParam<V = any> {
static SYSTEM_PREFIX = "lens-";
readonly name: string;
protected urlName: string;
constructor(readonly init: PageParamInit<V>, protected history: IObservableHistory) {
const { isSystem, name } = init;
constructor(readonly init: PageParamInit<V> | PageSystemParamInit<V>, protected history: IObservableHistory) {
const { isSystem, name } = init as PageSystemParamInit;
this.name = name;
this.init.skipEmpty ??= true;