1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-10-30 13:53:05 +02:00
parent bf4e408cdb
commit 7d34bbc250
6 changed files with 36 additions and 55 deletions

View File

@ -35,7 +35,7 @@ export class ExtensionLoader {
} }
} }
@computed get userExtensions() { @computed get userExtensions(): LensExtension[] {
const builtIn = getBundledExtensions().map(ext => `lens-${ext}`) const builtIn = getBundledExtensions().map(ext => `lens-${ext}`)
const extensions: LensExtension[] = [] const extensions: LensExtension[] = []
this.instances.forEach(instance => { this.instances.forEach(instance => {

View File

@ -6,8 +6,8 @@ import { addClusterURL } from "../renderer/components/+add-cluster/add-cluster.r
import { preferencesURL } from "../renderer/components/+preferences/preferences.route"; import { preferencesURL } from "../renderer/components/+preferences/preferences.route";
import { whatsNewURL } from "../renderer/components/+whats-new/whats-new.route"; import { whatsNewURL } from "../renderer/components/+whats-new/whats-new.route";
import { clusterSettingsURL } from "../renderer/components/+cluster-settings/cluster-settings.route"; import { clusterSettingsURL } from "../renderer/components/+cluster-settings/cluster-settings.route";
import { extensionsURL } from "../renderer/components/+extensions/extensions.route";
import { menuRegistry } from "../extensions/registries/menu-registry"; import { menuRegistry } from "../extensions/registries/menu-registry";
import { extensionsURL } from "../renderer/components/+extensions";
import logger from "./logger"; import logger from "./logger";
export type MenuTopId = "mac" | "file" | "edit" | "view" | "help" export type MenuTopId = "mac" | "file" | "edit" | "view" | "help"
@ -73,6 +73,7 @@ export function buildMenu(windowManager: WindowManager) {
}, },
{ {
label: 'Extensions', label: 'Extensions',
accelerator: 'CmdOrCtrl+Shift+E',
click() { click() {
navigate(extensionsURL()) navigate(extensionsURL())
} }

View File

@ -1,12 +1,10 @@
.Extensions { .Extensions {
.Badge.extension { .extension-list {
.extension {
display: flex; display: flex;
margin-bottom: $margin; margin-bottom: $margin;
padding: $padding $padding * 2; padding: $padding $padding * 2;
background: $colorVague;
.name {
color: $textColorAccent;
padding-bottom: $padding;
} }
} }

View File

@ -1,15 +1,13 @@
import "./extensions.scss"; import "./extensions.scss";
import React, { Fragment } from "react"; import React, { Fragment } from "react";
import { t, Trans } from "@lingui/macro"; import { computed, observable } from "mobx";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import { Badge } from "../badge"; import { t, Trans } from "@lingui/macro";
import { _i18n } from "../../i18n";
import { Button } from "../button"; import { Button } from "../button";
import { extensionLoader } from "../../../extensions/extension-loader";
import { WizardLayout } from "../layout/wizard-layout"; import { WizardLayout } from "../layout/wizard-layout";
import { Input } from "../input"; import { Input } from "../input";
import { _i18n } from "../../i18n"; import { extensionLoader } from "../../../extensions/extension-loader";
import { computed, observable } from "mobx";
import { extensionManager } from "../../../extensions/extension-manager"; import { extensionManager } from "../../../extensions/extension-manager";
@observer @observer
@ -29,69 +27,53 @@ export class Extensions extends React.Component {
<Fragment> <Fragment>
<h2>Lens Extension API</h2> <h2>Lens Extension API</h2>
<p> <p>
The Extensions API in Lens allows users to customize and enhance the Lens experience by creating their own menus or page content that is extended from the existing pages. Many of the core features of Lens are built as extensions and use the same Extension API. The Extensions API in Lens allows users to customize and enhance the Lens experience by creating their own menus or page content that is extended from the existing pages. Many of the core
features of Lens are built as extensions and use the same Extension API.
</p> </p>
<p> <p>
<a href="https://docs.k8slens.dev/extensions/overview/" target="_blank">Check out documentation to learn more</a> Check out documentation to <a href="https://docs.k8slens.dev/" target="_blank">learn more</a>
</p> </p>
</Fragment> </Fragment>
) )
} }
renderExtensions() { renderExtensions() {
if (!this.extensions.length) { const extensionsPath = extensionManager.localFolderPath;
const message = this.search ? <Trans>No search results found</Trans> : ( const { extensions, search } = this;
<> if (!extensions.length) {
<span>There are no extensions found in</span>
<Badge>/.k8slens/extensions</Badge>
</>
)
return ( return (
<div className="flex align-center box grow justify-center gaps"> <div className="flex align-center box grow justify-center gaps">
{message} {search && <Trans>No search results found</Trans>}
{!search && <p>There are no extensions in <code>{extensionsPath}</code></p>}
</div> </div>
) )
} }
if (!this.extensions.length) { return extensions.map(({ id, name, description }) => {
return ( return (
<div className="flex align-center box grow justify-center gaps"> <div key={id} className="extension flex gaps align-center">
<span>There are no extensions found in</span> <div className="box grow flex column gaps">
<Badge>{extensionManager.localFolderPath}</Badge> <code className="name">{name}</code>
<span className="description">{description}</span>
</div> </div>
) <Button plain active onClick={() => this.disable(name)}>
} Disable
return this.extensions.map(extension => { </Button>
const { id, name, description } = extension;
return (
<Badge key={id} className="extension flex gaps align-center justify-space-between">
<div>
<div className="name">
{name}
</div> </div>
<div className="description">
{description}
</div>
</div>
<Button onClick={() => this.disable(name)}>Disable</Button>
</Badge>
) )
}) })
} }
render() { render() {
return ( return (
<WizardLayout <WizardLayout className="Extensions" infoPanel={this.renderInfo()}>
className="Extensions"
infoPanel={this.renderInfo()}
>
<h2><Trans>Extensions</Trans></h2> <h2><Trans>Extensions</Trans></h2>
<div className="extension-list"> <div className="extension-list">
{/* TODO: Use generic search input after https://github.com/lensapp/lens/pull/1114 will be pushed */} {/* TODO: Use generic search input after https://github.com/lensapp/lens/pull/1114 will be pushed */}
<Input <Input
autoFocus
theme="round-black" theme="round-black"
className="SearchInput" className="SearchInput"
autoFocus placeholder={_i18n._(t`Search extensions`)}
placeholder={_i18n._(t`Search Extensions...`)}
value={this.search} value={this.search}
onChange={(value) => this.search = value} onChange={(value) => this.search = value}
/> />

View File

@ -1 +1,2 @@
export * from "./extensions.route" export * from "./extensions.route"
export * from "./extensions"

View File

@ -16,8 +16,7 @@ import { clusterViewRoute, clusterViewURL } from "./cluster-view.route";
import { clusterStore } from "../../../common/cluster-store"; import { clusterStore } from "../../../common/cluster-store";
import { hasLoadedView, initView, lensViews, refreshViews } from "./lens-views"; import { hasLoadedView, initView, lensViews, refreshViews } from "./lens-views";
import { globalPageRegistry } from "../../../extensions/registries/page-registry"; import { globalPageRegistry } from "../../../extensions/registries/page-registry";
import { extensionsRoute } from "../+extensions"; import { Extensions, extensionsRoute } from "../+extensions";
import { Extensions } from "../+extensions/extensions";
import { getMatchedClusterId } from "../../navigation"; import { getMatchedClusterId } from "../../navigation";
@observer @observer