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 { observer } from "mobx-react";
|
||||
|
||||
export const exampleNameUrlParam = Navigation.createUrlParam<string>({
|
||||
name: "name",
|
||||
export const exampleIdPageParam = Navigation.createUrlParam<string>({
|
||||
name: "exampleId",
|
||||
defaultValue: "demo",
|
||||
});
|
||||
|
||||
@ -22,7 +22,7 @@ export class ExamplePage extends React.Component<{ extension: LensRendererExtens
|
||||
};
|
||||
|
||||
render() {
|
||||
const exampleName = exampleNameUrlParam.get();
|
||||
const exampleName = exampleIdPageParam.get();
|
||||
const doodleStyle = {
|
||||
width: "200px"
|
||||
};
|
||||
@ -36,7 +36,7 @@ export class ExamplePage extends React.Component<{ extension: LensRendererExtens
|
||||
<p>Location: <i>{location.href}</i></p>
|
||||
|
||||
<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" && (
|
||||
<Component.Button accent label="Deactivate" onClick={this.deactivate}/>
|
||||
)}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { LensRendererExtension } from "@k8slens/extensions";
|
||||
import { ExampleIcon, ExamplePage, exampleNameUrlParam } from "./page";
|
||||
import { ExampleIcon, ExamplePage, exampleIdPageParam } from "./page";
|
||||
import React from "react";
|
||||
|
||||
export default class ExampleExtension extends LensRendererExtension {
|
||||
@ -11,18 +11,37 @@ export default class ExampleExtension extends LensRendererExtension {
|
||||
Page: () => <ExamplePage extension={this}/>,
|
||||
},
|
||||
params: [
|
||||
exampleNameUrlParam,
|
||||
exampleIdPageParam,
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
clusterPageMenus = [
|
||||
{
|
||||
target: { pageId: "example" },
|
||||
title: "Example Extension",
|
||||
title: "Example extension",
|
||||
components: {
|
||||
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