mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
updated example with 2 menu-items targeting same page with different params
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
99c613546e
commit
fcb18b6dd1
@ -4,8 +4,8 @@ import React from "react";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
|
|
||||||
export const exampleNameUrlParam = Navigation.createUrlParam<string>({
|
export const exampleIdPageParam = Navigation.createUrlParam<string>({
|
||||||
name: "name",
|
name: "exampleId",
|
||||||
defaultValue: "demo",
|
defaultValue: "demo",
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ export class ExamplePage extends React.Component<{ extension: LensRendererExtens
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const exampleName = exampleNameUrlParam.get();
|
const exampleName = exampleIdPageParam.get();
|
||||||
const doodleStyle = {
|
const doodleStyle = {
|
||||||
width: "200px"
|
width: "200px"
|
||||||
};
|
};
|
||||||
@ -36,7 +36,7 @@ export class ExamplePage extends React.Component<{ extension: LensRendererExtens
|
|||||||
<p>Location: <i>{location.href}</i></p>
|
<p>Location: <i>{location.href}</i></p>
|
||||||
|
|
||||||
<p className="url-params-demo flex column gaps">
|
<p className="url-params-demo flex column gaps">
|
||||||
<a onClick={() => exampleNameUrlParam.set("secret")}>Show secret button</a>
|
<a onClick={() => exampleIdPageParam.set("secret")}>Show secret button</a>
|
||||||
{exampleName === "secret" && (
|
{exampleName === "secret" && (
|
||||||
<Component.Button accent label="Deactivate" onClick={this.deactivate}/>
|
<Component.Button accent label="Deactivate" onClick={this.deactivate}/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { LensRendererExtension } from "@k8slens/extensions";
|
import { LensRendererExtension } from "@k8slens/extensions";
|
||||||
import { ExampleIcon, ExamplePage, exampleNameUrlParam } from "./page";
|
import { ExampleIcon, ExamplePage, exampleIdPageParam } from "./page";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default class ExampleExtension extends LensRendererExtension {
|
export default class ExampleExtension extends LensRendererExtension {
|
||||||
@ -11,18 +11,37 @@ export default class ExampleExtension extends LensRendererExtension {
|
|||||||
Page: () => <ExamplePage extension={this}/>,
|
Page: () => <ExamplePage extension={this}/>,
|
||||||
},
|
},
|
||||||
params: [
|
params: [
|
||||||
exampleNameUrlParam,
|
exampleIdPageParam,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
clusterPageMenus = [
|
clusterPageMenus = [
|
||||||
{
|
{
|
||||||
target: { pageId: "example" },
|
title: "Example extension",
|
||||||
title: "Example Extension",
|
|
||||||
components: {
|
components: {
|
||||||
Icon: ExampleIcon,
|
Icon: ExampleIcon,
|
||||||
}
|
},
|
||||||
}
|
target: {
|
||||||
|
pageId: "example",
|
||||||
|
params: {
|
||||||
|
// cause target page has registered a url-param with name "exampleId" == exampleNameUrlParam.name
|
||||||
|
// passing values to page to generate final link
|
||||||
|
exampleId: "demo-2"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Example secret page",
|
||||||
|
components: {
|
||||||
|
Icon: ExampleIcon,
|
||||||
|
},
|
||||||
|
target: {
|
||||||
|
pageId: "example",
|
||||||
|
params: {
|
||||||
|
exampleId: "secret"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user