mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
added another example
Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
parent
5a24b2c5b5
commit
e654af383b
@ -92,10 +92,6 @@ export interface SimpleParamsPageParams {
|
||||
|
||||
@observer
|
||||
export class SimpleParamsPage extends React.Component<SimpleParamsPageProps> {
|
||||
async componentDidMount() {
|
||||
await namespaceStore.loadAll();
|
||||
}
|
||||
|
||||
deactivate = () => {
|
||||
const { extension } = this.props;
|
||||
|
||||
@ -137,3 +133,25 @@ export class SimpleParamsPage extends React.Component<SimpleParamsPageProps> {
|
||||
}
|
||||
}
|
||||
|
||||
export interface NonStringParamsPageProps extends Interface.PageComponentProps<NonStringParamsPageParams> {
|
||||
extension: LensRendererExtension; // provided in "./renderer.tsx"
|
||||
}
|
||||
|
||||
export interface NonStringParamsPageParams {
|
||||
exampleId: string;
|
||||
namespaceId: Number;
|
||||
}
|
||||
|
||||
@observer
|
||||
export class NonStringParamsPage extends React.Component<NonStringParamsPageProps> {
|
||||
render() {
|
||||
const { exampleId, namespaceId } = this.props.params;
|
||||
|
||||
return (
|
||||
<div className="flex gaps inline">
|
||||
<p>exampleId is {exampleId.get()}</p>
|
||||
<p>namespaceId is {namespaceId.get()}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { Component, Interface, K8sApi, LensRendererExtension } from "@k8slens/extensions";
|
||||
import {
|
||||
ExamplePage, ExamplePageParams, namespaceStore,
|
||||
SimplePage, SimpleParamsPage, SimpleParamsPageParams
|
||||
SimplePage, SimpleParamsPage, SimpleParamsPageParams,
|
||||
NonStringParamsPage, NonStringParamsPageParams
|
||||
} from "./page";
|
||||
import React from "react";
|
||||
import path from "path";
|
||||
@ -29,6 +30,20 @@ export default class ExampleExtension extends LensRendererExtension {
|
||||
namespace: "default"
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "page-with-non-string-params",
|
||||
components: {
|
||||
Page: (props: Interface.PageComponentProps<NonStringParamsPageParams>) => {
|
||||
return <NonStringParamsPage {...props} extension={this}/>;
|
||||
},
|
||||
},
|
||||
params: {
|
||||
exampleId: "demo",
|
||||
namespaceId: {
|
||||
defaultValue: 7
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "page-with-complicated-params",
|
||||
components: {
|
||||
@ -57,14 +72,14 @@ export default class ExampleExtension extends LensRendererExtension {
|
||||
|
||||
clusterPageMenus: Interface.ClusterPageMenuRegistration[] = [
|
||||
{
|
||||
id: "top-example-menu",
|
||||
// id: "top-example-menu",
|
||||
title: "Example extension",
|
||||
components: {
|
||||
Icon: ExampleIcon,
|
||||
},
|
||||
},
|
||||
{
|
||||
parentId: "top-example-menu",
|
||||
// parentId: "top-example-menu",
|
||||
title: "Simple Page",
|
||||
target: {
|
||||
pageId: "simple-page"
|
||||
@ -74,10 +89,10 @@ export default class ExampleExtension extends LensRendererExtension {
|
||||
},
|
||||
},
|
||||
{
|
||||
parentId: "top-example-menu",
|
||||
// parentId: "top-example-menu",
|
||||
title: "Simple Params",
|
||||
target: {
|
||||
pageId: "page-with-simple-parms",
|
||||
pageId: "page-with-simple-params",
|
||||
params: {
|
||||
exampleId: "no-secret",
|
||||
namespace: "test"
|
||||
@ -88,7 +103,21 @@ export default class ExampleExtension extends LensRendererExtension {
|
||||
},
|
||||
},
|
||||
{
|
||||
parentId: "top-example-menu",
|
||||
// parentId: "top-example-menu",
|
||||
title: "Non-String Params",
|
||||
target: {
|
||||
pageId: "page-with-non-string-params",
|
||||
params: {
|
||||
exampleId: "A string",
|
||||
namespaceId: 42
|
||||
}
|
||||
},
|
||||
components: {
|
||||
Icon: ExampleIcon,
|
||||
},
|
||||
},
|
||||
{
|
||||
// parentId: "top-example-menu",
|
||||
title: "Complicated Params",
|
||||
target: {
|
||||
pageId: "page-with-complicated-params"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user