mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix: merge page url chunks with native URL()-api, simplified default page-params registration
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
1 parent
fcb18b6dd1
commit
0fd981866b
4 files changed
+44
-40
No files matched your search
@@ -1,10 +1,10 @@
|
||||
import { Component, LensRendererExtension, Navigation } from "@k8slens/extensions";
|
||||
import { CoffeeDoodle } from "react-open-doodles";
|
||||
import React from "react";
|
||||
import path from "path";
|
||||
import { observer } from "mobx-react";
|
||||
import { CoffeeDoodle } from "react-open-doodles";
|
||||
|
||||
export const exampleIdPageParam = Navigation.createUrlParam<string>({
|
||||
export const exampleId = Navigation.createUrlParam<string>({
|
||||
name: "exampleId",
|
||||
defaultValue: "demo",
|
||||
});
|
||||
@@ -22,7 +22,7 @@ export class ExamplePage extends React.Component<{ extension: LensRendererExtens
|
||||
};
|
||||
|
||||
render() {
|
||||
const exampleName = exampleIdPageParam.get();
|
||||
const exampleName = exampleId.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={() => exampleIdPageParam.set("secret")}>Show secret button</a>
|
||||
<a onClick={() => exampleId.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, exampleIdPageParam } from "./page";
|
||||
import { ExampleIcon, ExamplePage } from "./page";
|
||||
import React from "react";
|
||||
|
||||
export default class ExampleExtension extends LensRendererExtension {
|
||||
@@ -10,9 +10,11 @@ export default class ExampleExtension extends LensRendererExtension {
|
||||
components: {
|
||||
Page: () => <ExamplePage extension={this}/>,
|
||||
},
|
||||
params: [
|
||||
exampleIdPageParam,
|
||||
]
|
||||
params: {
|
||||
// setup param "exampleId" with default value "demo"
|
||||
// could be also {[paramName: string]: UrlParam} for advanced use-cases (custom parse/stringify)
|
||||
exampleId: "demo"
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -25,9 +27,7 @@ export default class ExampleExtension extends LensRendererExtension {
|
||||
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"
|
||||
exampleId: "demo-sample-2"
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user