1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

support-page extension fixes

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-11-12 14:49:17 +02:00
parent a489d9aabe
commit 1fc8ff0abc
7 changed files with 13 additions and 20 deletions

View File

@ -1,5 +1,4 @@
import { LensMainExtension } from "@k8slens/extensions"; import { LensMainExtension } from "@k8slens/extensions";
import { pageUrl } from "./src/common-vars";
export default class SupportPageMainExtension extends LensMainExtension { export default class SupportPageMainExtension extends LensMainExtension {
appMenus = [ appMenus = [
@ -7,7 +6,7 @@ export default class SupportPageMainExtension extends LensMainExtension {
parentId: "help", parentId: "help",
label: "Support", label: "Support",
click: () => { click: () => {
this.navigate(pageUrl); this.navigate();
} }
} }
] ]

View File

@ -1,14 +1,12 @@
import React from "react"; import React from "react";
import { Component, Interface, LensRendererExtension } from "@k8slens/extensions"; import { Component, Interface, LensRendererExtension } from "@k8slens/extensions";
import { Support } from "./src/support"; import { SupportPage } from "./src/support";
import { pageRoute, pageUrl } from "./src/common-vars";
export default class SupportPageRendererExtension extends LensRendererExtension { export default class SupportPageRendererExtension extends LensRendererExtension {
globalPages: Interface.PageRegistration[] = [ globalPages: Interface.PageRegistration[] = [
{ {
routePath: pageRoute,
components: { components: {
Page: Support, Page: SupportPage,
} }
} }
] ]
@ -16,7 +14,7 @@ export default class SupportPageRendererExtension extends LensRendererExtension
statusBarItems: Interface.StatusBarRegistration[] = [ statusBarItems: Interface.StatusBarRegistration[] = [
{ {
item: ( item: (
<div className="flex align-center gaps hover-highlight" onClick={() => this.navigate(pageUrl)}> <div className="flex align-center gaps hover-highlight" onClick={() => this.navigate()}>
<Component.Icon material="help" smallest/> <Component.Icon material="help" smallest/>
</div> </div>
) )

View File

@ -1,4 +0,0 @@
// Common variables for both processes (main & renderer)
export const pageRoute = "/support"
export const pageUrl = pageRoute; // same since no special :placeholder-s for react-router's route

View File

@ -1,4 +1,4 @@
.PageLayout.Support { .SupportPage {
a[target=_blank] { a[target=_blank] {
text-decoration: none; text-decoration: none;
border-bottom: 1px solid; border-bottom: 1px solid;

View File

@ -6,12 +6,12 @@ import { observer } from "mobx-react"
import { App, Component } from "@k8slens/extensions"; import { App, Component } from "@k8slens/extensions";
@observer @observer
export class Support extends React.Component { export class SupportPage extends React.Component {
render() { render() {
const { PageLayout } = Component; const { PageLayout } = Component;
const { slackUrl, issuesTrackerUrl } = App; const { slackUrl, issuesTrackerUrl } = App;
return ( return (
<PageLayout showOnTop className="Support" header={<h2>Support</h2>}> <PageLayout showOnTop className="SupportPage" header={<h2>Support</h2>}>
<h2>Community Slack Channel</h2> <h2>Community Slack Channel</h2>
<p> <p>
Ask a question, see what's being discussed, join the conversation <a href={slackUrl} target="_blank">here</a> Ask a question, see what's being discussed, join the conversation <a href={slackUrl} target="_blank">here</a>

View File

@ -6,9 +6,9 @@ import { WindowManager } from "../main/window-manager";
export class LensMainExtension extends LensExtension { export class LensMainExtension extends LensExtension {
@observable.shallow appMenus: MenuRegistration[] = [] @observable.shallow appMenus: MenuRegistration[] = []
async navigate(location: string, frameId?: number) { async navigate(location?: string, frameId?: number) {
const windowManager = WindowManager.getInstance<WindowManager>(); const windowManager = WindowManager.getInstance<WindowManager>();
const url = this.getPageUrl(location); const url = this.getPageUrl(location); // get full path to extension's page
await windowManager.navigate(url, frameId) await windowManager.navigate(url, frameId);
} }
} }

View File

@ -1,5 +1,4 @@
import type { AppPreferenceRegistration, ClusterFeatureRegistration, KubeObjectDetailRegistration, KubeObjectMenuRegistration, KubeObjectStatusRegistration, PageMenuRegistration, PageRegistration, StatusBarRegistration, } from "./registries" import type { AppPreferenceRegistration, ClusterFeatureRegistration, KubeObjectDetailRegistration, KubeObjectMenuRegistration, KubeObjectStatusRegistration, PageMenuRegistration, PageRegistration, StatusBarRegistration, } from "./registries"
import { ipcRenderer } from "electron"
import { observable } from "mobx"; import { observable } from "mobx";
import { LensExtension } from "./lens-extension" import { LensExtension } from "./lens-extension"
@ -15,7 +14,8 @@ export class LensRendererExtension extends LensExtension {
@observable.shallow kubeObjectDetailItems: KubeObjectDetailRegistration[] = [] @observable.shallow kubeObjectDetailItems: KubeObjectDetailRegistration[] = []
@observable.shallow kubeObjectMenuItems: KubeObjectMenuRegistration[] = [] @observable.shallow kubeObjectMenuItems: KubeObjectMenuRegistration[] = []
navigate(location: string) { async navigate(location?: string) {
ipcRenderer.emit("renderer:navigate", this.getPageUrl(location)) const { navigate } = await import("../renderer/navigation");
navigate(this.getPageUrl(location));
} }
} }