mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
example-extension reworks (3): wrap example-extension into main-layout
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
89bc526e4d
commit
c6cb8adbcf
@ -1,4 +1,4 @@
|
||||
import { DynamicPageType, Icon, LensExtension } from "@lens/extensions"; // fixme: map to generated types from "extension-api.d.ts"
|
||||
import { DynamicPageType, Icon, LensExtension } from "@lens/extensions"; // fixme: map to generated types from "extension-api.ts"
|
||||
import React from "react";
|
||||
import path from "path";
|
||||
|
||||
@ -7,12 +7,18 @@ export default class ExampleExtension extends LensExtension {
|
||||
|
||||
onActivate() {
|
||||
console.log('EXAMPLE EXTENSION: ACTIVATE', this.getMeta())
|
||||
this.unRegisterPage = this.runtime.dynamicPages.register({
|
||||
const { dynamicPages, components: { MainLayout } } = this.runtime;
|
||||
|
||||
this.unRegisterPage = dynamicPages.register({
|
||||
type: DynamicPageType.CLUSTER,
|
||||
path: "/extension-example",
|
||||
menuTitle: "Example Extension",
|
||||
components: {
|
||||
Page: ExtensionPage,
|
||||
Page: () => (
|
||||
<MainLayout>
|
||||
<ExtensionPage/>
|
||||
</MainLayout>
|
||||
),
|
||||
MenuIcon: ExtensionIcon,
|
||||
}
|
||||
})
|
||||
|
||||
@ -1,15 +1,23 @@
|
||||
// Lens renderer runtime params available to the extension after activation
|
||||
// Lens renderer runtime params available to extensions after activation
|
||||
|
||||
import logger from "../main/logger";
|
||||
import { dynamicPages } from "./register-page";
|
||||
import { MainLayout } from "../renderer/components/layout/main-layout";
|
||||
|
||||
export interface LensRuntimeRendererEnv {
|
||||
logger: typeof logger;
|
||||
dynamicPages: typeof dynamicPages
|
||||
components: {
|
||||
MainLayout: typeof MainLayout
|
||||
}
|
||||
}
|
||||
|
||||
export function getLensRuntime(): LensRuntimeRendererEnv {
|
||||
return {
|
||||
logger,
|
||||
dynamicPages,
|
||||
components: {
|
||||
MainLayout // fixme: refactor, import as pure component from "@lens/extensions"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ export interface TabRoute extends RouteProps {
|
||||
url: string;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
export interface MainLayoutProps {
|
||||
className?: any;
|
||||
tabs?: TabRoute[];
|
||||
footer?: React.ReactNode;
|
||||
@ -27,7 +27,7 @@ interface Props {
|
||||
}
|
||||
|
||||
@observer
|
||||
export class MainLayout extends React.Component<Props> {
|
||||
export class MainLayout extends React.Component<MainLayoutProps> {
|
||||
public storage = createStorage("main_layout", { pinnedSidebar: true });
|
||||
|
||||
@observable isPinned = this.storage.get().pinnedSidebar;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user