mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Get rid of this.disposers while registering stuff in extensions (#1148)
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
1 parent
b765ee11bb
commit
67754ffbb9
15 files changed
+141
-197
No files matched your search
@@ -1,26 +1,16 @@
|
||||
import { LensRendererExtension, Registry } from "@k8slens/extensions";
|
||||
import { ExamplePage, ExampleIcon } from "./page"
|
||||
import { LensRendererExtension } from "@k8slens/extensions";
|
||||
import { ExampleIcon, ExamplePage } from "./page"
|
||||
import React from "react"
|
||||
|
||||
export default class ExampleExtension extends LensRendererExtension {
|
||||
onActivate() {
|
||||
console.log('EXAMPLE EXTENSION RENDERER: ACTIVATED', this.getMeta());
|
||||
}
|
||||
|
||||
registerClusterPage(registry: Registry.ClusterPageRegistry) {
|
||||
this.disposers.push(
|
||||
registry.add({
|
||||
path: "/extension-example",
|
||||
title: "Example Extension",
|
||||
components: {
|
||||
Page: () => <ExamplePage extension={this} />,
|
||||
MenuIcon: ExampleIcon,
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
onDeactivate() {
|
||||
console.log('EXAMPLE EXTENSION RENDERER: DEACTIVATED', this.getMeta());
|
||||
}
|
||||
clusterPages = [
|
||||
{
|
||||
path: "/extension-example",
|
||||
title: "Example Extension",
|
||||
components: {
|
||||
Page: () => <ExamplePage extension={this}/>,
|
||||
MenuIcon: ExampleIcon,
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,25 +1,23 @@
|
||||
import { Registry, LensRendererExtension } from "@k8slens/extensions"
|
||||
import { LensRendererExtension } from "@k8slens/extensions"
|
||||
import { MetricsFeature } from "./src/metrics-feature"
|
||||
import React from "react"
|
||||
|
||||
export default class ClusterMetricsFeatureExtension extends LensRendererExtension {
|
||||
registerClusterFeatures(registry: Registry.ClusterFeatureRegistry) {
|
||||
this.disposers.push(
|
||||
registry.add({
|
||||
title: "Metrics Stack",
|
||||
components: {
|
||||
Description: () => {
|
||||
return (
|
||||
<span>
|
||||
clusterFeatures = [
|
||||
{
|
||||
title: "Metrics Stack",
|
||||
components: {
|
||||
Description: () => {
|
||||
return (
|
||||
<span>
|
||||
Enable timeseries data visualization (Prometheus stack) for your cluster.
|
||||
Install this only if you don't have existing Prometheus stack installed.
|
||||
You can see preview of manifests <a href="https://github.com/lensapp/lens/tree/master/extensions/lens-metrics/resources" target="_blank">here</a>.
|
||||
</span>
|
||||
)
|
||||
}
|
||||
},
|
||||
feature: new MetricsFeature()
|
||||
})
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
feature: new MetricsFeature()
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,21 +1,15 @@
|
||||
import { Registry, LensRendererExtension } from "@k8slens/extensions";
|
||||
import { LensRendererExtension } from "@k8slens/extensions";
|
||||
import React from "react"
|
||||
import { NodeMenu } from "./src/node-menu"
|
||||
import { NodeMenu, NodeMenuProps } from "./src/node-menu"
|
||||
|
||||
export default class NodeMenuRendererExtension extends LensRendererExtension {
|
||||
async onActivate() {
|
||||
console.log("node-menu extension activated")
|
||||
}
|
||||
|
||||
registerKubeObjectMenus(registry: Registry.KubeObjectMenuRegistry) {
|
||||
this.disposers.push(
|
||||
registry.add({
|
||||
kind: "Node",
|
||||
apiVersions: ["v1"],
|
||||
components: {
|
||||
MenuItem: (props) => <NodeMenu {...props} />
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
kubeObjectMenuItems = [
|
||||
{
|
||||
kind: "Node",
|
||||
apiVersions: ["v1"],
|
||||
components: {
|
||||
MenuItem: (props: NodeMenuProps) => <NodeMenu {...props} />
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
import React from "react";
|
||||
import { Component, K8sApi, Navigation} from "@k8slens/extensions"
|
||||
|
||||
export function NodeMenu(props: Component.KubeObjectMenuProps<K8sApi.Node>) {
|
||||
export interface NodeMenuProps extends Component.KubeObjectMenuProps<K8sApi.Node> {
|
||||
}
|
||||
|
||||
export function NodeMenu(props: NodeMenuProps) {
|
||||
const { object: node, toolbar } = props;
|
||||
if (!node) return null;
|
||||
const nodeName = node.getName();
|
||||
|
||||
@@ -1,31 +1,23 @@
|
||||
import { Registry, LensRendererExtension } from "@k8slens/extensions";
|
||||
import { PodShellMenu } from "./src/shell-menu"
|
||||
import { PodLogsMenu } from "./src/logs-menu"
|
||||
import { LensRendererExtension } from "@k8slens/extensions";
|
||||
import { PodShellMenu, PodShellMenuProps } from "./src/shell-menu"
|
||||
import { PodLogsMenu, PodLogsMenuProps } from "./src/logs-menu"
|
||||
import React from "react"
|
||||
|
||||
export default class PodMenuRendererExtension extends LensRendererExtension {
|
||||
async onActivate() {
|
||||
console.log("pod-menu extension activated")
|
||||
}
|
||||
|
||||
registerKubeObjectMenus(registry: Registry.KubeObjectMenuRegistry) {
|
||||
this.disposers.push(
|
||||
registry.add({
|
||||
kind: "Pod",
|
||||
apiVersions: ["v1"],
|
||||
components: {
|
||||
MenuItem: (props) => <PodShellMenu {...props} />
|
||||
}
|
||||
})
|
||||
)
|
||||
this.disposers.push(
|
||||
registry.add({
|
||||
kind: "Pod",
|
||||
apiVersions: ["v1"],
|
||||
components: {
|
||||
MenuItem: (props) => <PodLogsMenu {...props} />
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
kubeObjectMenuItems = [
|
||||
{
|
||||
kind: "Pod",
|
||||
apiVersions: ["v1"],
|
||||
components: {
|
||||
MenuItem: (props: PodShellMenuProps) => <PodShellMenu {...props} />
|
||||
}
|
||||
},
|
||||
{
|
||||
kind: "Pod",
|
||||
apiVersions: ["v1"],
|
||||
components: {
|
||||
MenuItem: (props: PodLogsMenuProps) => <PodLogsMenu {...props} />
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import React from "react";
|
||||
import { Component, K8sApi, Util, Navigation } from "@k8slens/extensions";
|
||||
|
||||
interface Props extends Component.KubeObjectMenuProps<K8sApi.Pod> {
|
||||
export interface PodLogsMenuProps extends Component.KubeObjectMenuProps<K8sApi.Pod> {
|
||||
}
|
||||
|
||||
export class PodLogsMenu extends React.Component<Props> {
|
||||
export class PodLogsMenu extends React.Component<PodLogsMenuProps> {
|
||||
showLogs(container: K8sApi.IPodContainer) {
|
||||
Navigation.hideDetails();
|
||||
const pod = this.props.object;
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
import React from "react";
|
||||
import { Component, K8sApi, Util, Navigation } from "@k8slens/extensions";
|
||||
|
||||
interface Props extends Component.KubeObjectMenuProps<K8sApi.Pod> {
|
||||
export interface PodShellMenuProps extends Component.KubeObjectMenuProps<K8sApi.Pod> {
|
||||
}
|
||||
|
||||
export class PodShellMenu extends React.Component<Props> {
|
||||
export class PodShellMenu extends React.Component<PodShellMenuProps> {
|
||||
async execShell(container?: string) {
|
||||
Navigation.hideDetails();
|
||||
const { object: pod } = this.props
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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>
|
||||
)
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,29 +1,23 @@
|
||||
import { LensRendererExtension, Registry } from "@k8slens/extensions";
|
||||
import { LensRendererExtension } from "@k8slens/extensions";
|
||||
import { telemetryPreferencesStore } from "./src/telemetry-preferences-store"
|
||||
import { TelemetryPreferenceHint, TelemetryPreferenceInput } from "./src/telemetry-preference"
|
||||
import { tracker } from "./src/tracker"
|
||||
import React from "react"
|
||||
|
||||
export default class TelemetryRendererExtension extends LensRendererExtension {
|
||||
appPreferences = [
|
||||
{
|
||||
title: "Telemetry & Usage Tracking",
|
||||
components: {
|
||||
Hint: () => <TelemetryPreferenceHint/>,
|
||||
Input: () => <TelemetryPreferenceInput telemetry={telemetryPreferencesStore}/>
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
async onActivate() {
|
||||
console.log("telemetry extension activated")
|
||||
tracker.start()
|
||||
await telemetryPreferencesStore.loadExtension(this)
|
||||
}
|
||||
|
||||
registerAppPreferences(registry: Registry.AppPreferenceRegistry) {
|
||||
this.disposers.push(
|
||||
registry.add({
|
||||
title: "Telemetry & Usage Tracking",
|
||||
components: {
|
||||
Hint: () => <TelemetryPreferenceHint />,
|
||||
Input: () => <TelemetryPreferenceInput telemetry={telemetryPreferencesStore} />
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
onDeactivate() {
|
||||
console.log("telemetry extension deactivated")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user