mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
small fixes
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
f92a956e33
commit
241135a8e3
@ -1,7 +1,7 @@
|
||||
import { Component, Interface, K8sApi, LensRendererExtension } from "@k8slens/extensions";
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { CoffeeDoodle } from "react-open-doodles";
|
||||
import { Component, Interface, K8sApi, LensRendererExtension } from "@k8slens/extensions";
|
||||
|
||||
export interface ExamplePageProps extends Interface.PageComponentProps<ExamplePageParams> {
|
||||
extension: LensRendererExtension; // provided in "./renderer.tsx"
|
||||
|
||||
@ -30,7 +30,7 @@ export default class ExampleExtension extends LensRendererExtension {
|
||||
}
|
||||
];
|
||||
|
||||
clusterPageMenus: Interface.PageMenuRegistration[] = [
|
||||
clusterPageMenus: Interface.ClusterPageMenuRegistration[] = [
|
||||
{
|
||||
title: "Example extension",
|
||||
components: {
|
||||
|
||||
@ -4,5 +4,5 @@ export type { KubeObjectDetailRegistration, KubeObjectDetailComponents } from ".
|
||||
export type { KubeObjectMenuRegistration, KubeObjectMenuComponents } from "../registries/kube-object-menu-registry";
|
||||
export type { KubeObjectStatusRegistration } from "../registries/kube-object-status-registry";
|
||||
export type { PageRegistration, RegisteredPage, PageParams, PageComponentProps, PageComponents, PageTarget } from "../registries/page-registry";
|
||||
export type { PageMenuRegistration, PageMenuComponents } from "../registries/page-menu-registry";
|
||||
export type { PageMenuRegistration, ClusterPageMenuRegistration, PageMenuComponents } from "../registries/page-menu-registry";
|
||||
export type { StatusBarRegistration } from "../registries/status-bar-registry";
|
||||
@ -1,14 +1,13 @@
|
||||
import type { AppPreferenceRegistration, ClusterFeatureRegistration, KubeObjectDetailRegistration, KubeObjectMenuRegistration, KubeObjectStatusRegistration, PageMenuRegistration, PageRegistration, StatusBarRegistration, } from "./registries";
|
||||
import type { AppPreferenceRegistration, ClusterFeatureRegistration, ClusterPageMenuRegistration, KubeObjectDetailRegistration, KubeObjectMenuRegistration, KubeObjectStatusRegistration, PageMenuRegistration, PageRegistration, StatusBarRegistration, } from "./registries";
|
||||
import type { Cluster } from "../main/cluster";
|
||||
import { LensExtension } from "./lens-extension";
|
||||
import { getExtensionPageUrl } from "./registries/page-registry";
|
||||
|
||||
|
||||
export class LensRendererExtension extends LensExtension {
|
||||
globalPages: PageRegistration[] = [];
|
||||
clusterPages: PageRegistration[] = [];
|
||||
globalPageMenus: PageMenuRegistration[] = [];
|
||||
clusterPageMenus: PageMenuRegistration[] = [];
|
||||
clusterPageMenus: ClusterPageMenuRegistration[] = [];
|
||||
kubeObjectStatusTexts: KubeObjectStatusRegistration[] = [];
|
||||
appPreferences: AppPreferenceRegistration[] = [];
|
||||
clusterFeatures: ClusterFeatureRegistration[] = [];
|
||||
|
||||
@ -4,7 +4,7 @@ import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { BaseRegistry } from "./base-registry";
|
||||
import { LensExtension, sanitizeExtensionName } from "../lens-extension";
|
||||
import { isPageParamInit, PageParam, PageParamInit } from "../../renderer/navigation/page-param";
|
||||
import { PageParam, PageParamInit } from "../../renderer/navigation/page-param";
|
||||
import { createPageParam } from "../../renderer/navigation/helpers";
|
||||
|
||||
export interface PageRegistration {
|
||||
@ -103,10 +103,11 @@ export class PageRegistry extends BaseRegistry<PageRegistration, RegisteredPage>
|
||||
return;
|
||||
}
|
||||
Object.entries(params).forEach(([name, value]) => {
|
||||
const paramInit: PageParamInit = isPageParamInit(value) ? value : { name, defaultValue: value };
|
||||
const paramInit: PageParamInit = typeof value === "object"
|
||||
? { name, ...value }
|
||||
: { name, defaultValue: value };
|
||||
|
||||
paramInit.name ??= name;
|
||||
params[name] = createPageParam(paramInit);
|
||||
params[paramInit.name] = createPageParam(paramInit);
|
||||
});
|
||||
|
||||
return params as PageParams<PageParam>;
|
||||
|
||||
@ -20,10 +20,11 @@ export class PageParam<V = any> {
|
||||
protected urlName: string;
|
||||
|
||||
constructor(readonly init: PageParamInit<V>, protected history: IObservableHistory) {
|
||||
const { isSystem, name, skipEmpty = true } = init;
|
||||
const { isSystem, name } = init;
|
||||
|
||||
this.name = name;
|
||||
this.init.skipEmpty = skipEmpty;
|
||||
this.init.skipEmpty ??= true;
|
||||
this.init.multiValueSep ??= ",";
|
||||
|
||||
// prefixing to avoid collisions with extensions
|
||||
this.urlName = `${isSystem ? PageParam.SYSTEM_PREFIX : ""}${name}`;
|
||||
@ -129,12 +130,3 @@ export class PageParam<V = any> {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function isPageParamInit(paramInit: PageParamInit | any = {}): paramInit is PageParamInit {
|
||||
const init: PageParamInit = paramInit;
|
||||
|
||||
return [
|
||||
init.defaultValue !== undefined || init.defaultValueStringified !== undefined,
|
||||
typeof init.parse === "function" && typeof init.stringify === "function",
|
||||
].some(Boolean);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user