Get rid of this.disposers while registering stuff in extensions (#1148)

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman authored and GitHub committed 2020-10-27 17:07:21 +02:00
1 parent b765ee11bb
commit 67754ffbb9
15 files changed
+141 -197

No files matched your search

+10 -16
View File
@@ -1,20 +1,14 @@
import { LensMainExtension, Registry, windowManager } from "@k8slens/extensions";
import { LensMainExtension, windowManager } from "@k8slens/extensions";
import { supportPageURL } from "./src/support.route";
export default class SupportPageMainExtension extends LensMainExtension {
async onActivate() {
console.log("support page extension activated")
}
async registerAppMenus(registry: Registry.MenuRegistry) {
this.disposers.push(
registry.add({
parentId: "help",
label: "Support",
click() {
windowManager.navigate(supportPageURL());
}
})
)
}
appMenus = [
{
parentId: "help",
label: "Support",
click() {
windowManager.navigate(supportPageURL());
}
}
]
}
+24 -32
View File
@@ -1,39 +1,31 @@
import React from "react";
import { Component, LensRendererExtension, Navigation, Registry } from "@k8slens/extensions";
import { Component, LensRendererExtension, Navigation } from "@k8slens/extensions";
import { supportPageRoute, supportPageURL } from "./src/support.route";
import { Support } from "./src/support";
export default class SupportPageRendererExtension extends LensRendererExtension {
async onActivate() {
console.log("support page extension activated")
}
globalPages = [
{
...supportPageRoute,
url: supportPageURL(),
hideInMenu: true,
components: {
Page: Support,
}
}
]
registerGlobalPage(registry: Registry.GlobalPageRegistry) {
this.disposers.push(
registry.add({
...supportPageRoute,
url: supportPageURL(),
hideInMenu: true,
components: {
Page: Support,
}
})
)
}
registerStatusBarItem(registry: Registry.StatusBarRegistry) {
this.disposers.push(
registry.add({
item: (
<div
className="flex align-center gaps hover-highlight"
onClick={() => Navigation.navigate(supportPageURL())}
>
<Component.Icon material="help_outline" small />
<span>Support</span>
</div>
)
})
)
}
statusBarItems = [
{
item: (
<div
className="flex align-center gaps hover-highlight"
onClick={() => Navigation.navigate(supportPageURL())}
>
<Component.Icon material="help_outline" small/>
<span>Support</span>
</div>
)
}
]
}