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
|
@observer
|
||||||
export class SimpleParamsPage extends React.Component<SimpleParamsPageProps> {
|
export class SimpleParamsPage extends React.Component<SimpleParamsPageProps> {
|
||||||
async componentDidMount() {
|
|
||||||
await namespaceStore.loadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
deactivate = () => {
|
deactivate = () => {
|
||||||
const { extension } = this.props;
|
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 { Component, Interface, K8sApi, LensRendererExtension } from "@k8slens/extensions";
|
||||||
import {
|
import {
|
||||||
ExamplePage, ExamplePageParams, namespaceStore,
|
ExamplePage, ExamplePageParams, namespaceStore,
|
||||||
SimplePage, SimpleParamsPage, SimpleParamsPageParams
|
SimplePage, SimpleParamsPage, SimpleParamsPageParams,
|
||||||
|
NonStringParamsPage, NonStringParamsPageParams
|
||||||
} from "./page";
|
} from "./page";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
@ -29,6 +30,20 @@ export default class ExampleExtension extends LensRendererExtension {
|
|||||||
namespace: "default"
|
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",
|
id: "page-with-complicated-params",
|
||||||
components: {
|
components: {
|
||||||
@ -57,14 +72,14 @@ export default class ExampleExtension extends LensRendererExtension {
|
|||||||
|
|
||||||
clusterPageMenus: Interface.ClusterPageMenuRegistration[] = [
|
clusterPageMenus: Interface.ClusterPageMenuRegistration[] = [
|
||||||
{
|
{
|
||||||
id: "top-example-menu",
|
// id: "top-example-menu",
|
||||||
title: "Example extension",
|
title: "Example extension",
|
||||||
components: {
|
components: {
|
||||||
Icon: ExampleIcon,
|
Icon: ExampleIcon,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
parentId: "top-example-menu",
|
// parentId: "top-example-menu",
|
||||||
title: "Simple Page",
|
title: "Simple Page",
|
||||||
target: {
|
target: {
|
||||||
pageId: "simple-page"
|
pageId: "simple-page"
|
||||||
@ -74,10 +89,10 @@ export default class ExampleExtension extends LensRendererExtension {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
parentId: "top-example-menu",
|
// parentId: "top-example-menu",
|
||||||
title: "Simple Params",
|
title: "Simple Params",
|
||||||
target: {
|
target: {
|
||||||
pageId: "page-with-simple-parms",
|
pageId: "page-with-simple-params",
|
||||||
params: {
|
params: {
|
||||||
exampleId: "no-secret",
|
exampleId: "no-secret",
|
||||||
namespace: "test"
|
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",
|
title: "Complicated Params",
|
||||||
target: {
|
target: {
|
||||||
pageId: "page-with-complicated-params"
|
pageId: "page-with-complicated-params"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user