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 extensions: LensExtension[] = []
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 { whatsNewURL } from "../renderer/components/+whats-new/whats-new.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 { extensionsURL } from "../renderer/components/+extensions";
import logger from "./logger";
export type MenuTopId = "mac" | "file" | "edit" | "view" | "help"
@ -73,6 +73,7 @@ export function buildMenu(windowManager: WindowManager) {
},
{
label: 'Extensions',
accelerator: 'CmdOrCtrl+Shift+E',
click() {
navigate(extensionsURL())
}

View File

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

View File

@ -1,15 +1,13 @@
import "./extensions.scss";
import React, { Fragment } from "react";
import { t, Trans } from "@lingui/macro";
import { computed, observable } from "mobx";
import { observer } from "mobx-react";
import { Badge } from "../badge";
import { t, Trans } from "@lingui/macro";
import { _i18n } from "../../i18n";
import { Button } from "../button";
import { extensionLoader } from "../../../extensions/extension-loader";
import { WizardLayout } from "../layout/wizard-layout";
import { Input } from "../input";
import { _i18n } from "../../i18n";
import { computed, observable } from "mobx";
import { extensionLoader } from "../../../extensions/extension-loader";
import { extensionManager } from "../../../extensions/extension-manager";
@observer
@ -29,69 +27,53 @@ export class Extensions extends React.Component {
<Fragment>
<h2>Lens Extension API</h2>
<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>
<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>
</Fragment>
)
}
renderExtensions() {
if (!this.extensions.length) {
const message = this.search ? <Trans>No search results found</Trans> : (
<>
<span>There are no extensions found in</span>
<Badge>/.k8slens/extensions</Badge>
</>
)
const extensionsPath = extensionManager.localFolderPath;
const { extensions, search } = this;
if (!extensions.length) {
return (
<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>
)
}
if (!this.extensions.length) {
return extensions.map(({ id, name, description }) => {
return (
<div className="flex align-center box grow justify-center gaps">
<span>There are no extensions found in</span>
<Badge>{extensionManager.localFolderPath}</Badge>
</div>
)
}
return this.extensions.map(extension => {
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 className="description">
{description}
</div>
<div key={id} className="extension flex gaps align-center">
<div className="box grow flex column gaps">
<code className="name">{name}</code>
<span className="description">{description}</span>
</div>
<Button onClick={() => this.disable(name)}>Disable</Button>
</Badge>
<Button plain active onClick={() => this.disable(name)}>
Disable
</Button>
</div>
)
})
}
render() {
return (
<WizardLayout
className="Extensions"
infoPanel={this.renderInfo()}
>
<WizardLayout className="Extensions" infoPanel={this.renderInfo()}>
<h2><Trans>Extensions</Trans></h2>
<div className="extension-list">
{/* TODO: Use generic search input after https://github.com/lensapp/lens/pull/1114 will be pushed */}
<Input
autoFocus
theme="round-black"
className="SearchInput"
autoFocus
placeholder={_i18n._(t`Search Extensions...`)}
placeholder={_i18n._(t`Search extensions`)}
value={this.search}
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 { hasLoadedView, initView, lensViews, refreshViews } from "./lens-views";
import { globalPageRegistry } from "../../../extensions/registries/page-registry";
import { extensionsRoute } from "../+extensions";
import { Extensions } from "../+extensions/extensions";
import { Extensions, extensionsRoute } from "../+extensions";
import { getMatchedClusterId } from "../../navigation";
@observer