mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fixes, tweak example-extension for demo
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
1 parent
b7be386e6b
commit
cd7f906afc
9 files changed
+70
-47
No files matched your search
@@ -1,12 +1,19 @@
|
||||
import { LensRendererExtension, Component } from "@k8slens/extensions";
|
||||
import { Component, LensRendererExtension, Navigation } from "@k8slens/extensions";
|
||||
import { CoffeeDoodle } from "react-open-doodles";
|
||||
import path from "path";
|
||||
import React from "react";
|
||||
import path from "path";
|
||||
import { observer } from "mobx-react";
|
||||
|
||||
export const exampleNameUrlParam = Navigation.createUrlParam<string>({
|
||||
name: "name",
|
||||
defaultValue: "demo",
|
||||
});
|
||||
|
||||
export function ExampleIcon(props: Component.IconProps) {
|
||||
return <Component.Icon {...props} material="pages" tooltip={path.basename(__filename)}/>;
|
||||
}
|
||||
|
||||
@observer
|
||||
export class ExamplePage extends React.Component<{ extension: LensRendererExtension }> {
|
||||
deactivate = () => {
|
||||
const { extension } = this.props;
|
||||
@@ -15,16 +22,24 @@ export class ExamplePage extends React.Component<{ extension: LensRendererExtens
|
||||
};
|
||||
|
||||
render() {
|
||||
const exampleName = exampleNameUrlParam.get();
|
||||
const doodleStyle = {
|
||||
width: "200px"
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex column gaps align-flex-start">
|
||||
<div style={doodleStyle}><CoffeeDoodle accent="#3d90ce" /></div>
|
||||
<div className="flex column gaps align-flex-start" style={{ padding: 24 }}>
|
||||
<div style={doodleStyle}><CoffeeDoodle accent="#3d90ce"/></div>
|
||||
|
||||
<p>Hello from Example extension!</p>
|
||||
<p>File: <i>{__filename}</i></p>
|
||||
<Component.Button accent label="Deactivate" onClick={this.deactivate}/>
|
||||
<p>Location: <i>{location.href}</i></p>
|
||||
|
||||
<p className="url-params-demo flex column gaps">
|
||||
<a onClick={() => exampleNameUrlParam.set("secret")}>Show secret button</a>
|
||||
{exampleName === "secret" && (
|
||||
<Component.Button accent label="Deactivate" onClick={this.deactivate}/>
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { LensRendererExtension } from "@k8slens/extensions";
|
||||
import { ExampleIcon, ExamplePage } from "./page";
|
||||
import { ExampleIcon, ExamplePage, exampleNameUrlParam } from "./page";
|
||||
import React from "react";
|
||||
|
||||
export default class ExampleExtension extends LensRendererExtension {
|
||||
@@ -9,13 +9,16 @@ export default class ExampleExtension extends LensRendererExtension {
|
||||
title: "Example Extension",
|
||||
components: {
|
||||
Page: () => <ExamplePage extension={this}/>,
|
||||
}
|
||||
},
|
||||
params: [
|
||||
exampleNameUrlParam,
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
clusterPageMenus = [
|
||||
{
|
||||
target: { pageId: "example", params: {} },
|
||||
target: { pageId: "example" },
|
||||
title: "Example Extension",
|
||||
components: {
|
||||
Icon: ExampleIcon,
|
||||
|
||||
Reference in new issue
Block a user