mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Adding search to extension page
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
31911f5cba
commit
0d7a284d2a
@ -12,5 +12,16 @@
|
|||||||
|
|
||||||
.info-col {
|
.info-col {
|
||||||
flex: 0.6;
|
flex: 0.6;
|
||||||
|
align-self: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.SearchInput {
|
||||||
|
margin-top: $margin / 2;
|
||||||
|
margin-bottom: $margin * 2;
|
||||||
|
|
||||||
|
> label {
|
||||||
|
padding: $padding $padding * 2;
|
||||||
|
border-radius: $radius;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,15 +1,26 @@
|
|||||||
import "./extensions.scss";
|
import "./extensions.scss";
|
||||||
|
|
||||||
import React, { Fragment } from "react";
|
import React, { Fragment } from "react";
|
||||||
import { Trans } from "@lingui/macro";
|
import { t, Trans } from "@lingui/macro";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { Badge } from "../badge";
|
import { Badge } from "../badge";
|
||||||
import { Button } from "../button";
|
import { Button } from "../button";
|
||||||
import { extensionLoader } from "../../../extensions/extension-loader";
|
import { extensionLoader } from "../../../extensions/extension-loader";
|
||||||
import { WizardLayout } from "../layout/wizard-layout";
|
import { WizardLayout } from "../layout/wizard-layout";
|
||||||
|
import { Input } from "../input";
|
||||||
|
import { _i18n } from "../../i18n";
|
||||||
|
import { computed, observable } from "mobx";
|
||||||
|
import { extensionManager } from "../../../extensions/extension-manager";
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class Extensions extends React.Component {
|
export class Extensions extends React.Component {
|
||||||
|
@observable search = ""
|
||||||
|
|
||||||
|
@computed get extensions() {
|
||||||
|
const extensions = extensionLoader.userExtensions
|
||||||
|
return extensions.filter(ext => ext.name.includes(this.search))
|
||||||
|
}
|
||||||
|
|
||||||
disable(name: string) {
|
disable(name: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,23 +32,35 @@ export class Extensions extends React.Component {
|
|||||||
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>.
|
<a href="https://docs.k8slens.dev/extensions/overview/" target="_blank">Check out documentation to learn more</a>
|
||||||
</p>
|
</p>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
renderExtensions() {
|
renderExtensions() {
|
||||||
const extensions = extensionLoader.userExtensions;
|
if (!this.extensions.length) {
|
||||||
if (!extensions.length) {
|
const message = this.search ? <Trans>No search results found</Trans> : (
|
||||||
return (
|
<>
|
||||||
<div className="flex align-center box grow justify-center gaps">
|
|
||||||
<span>There are no extensions found in</span>
|
<span>There are no extensions found in</span>
|
||||||
<Badge>/.k8slens/extensions</Badge>
|
<Badge>/.k8slens/extensions</Badge>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
return (
|
||||||
|
<div className="flex align-center box grow justify-center gaps">
|
||||||
|
{message}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return extensions.map(extension => {
|
if (!this.extensions.length) {
|
||||||
|
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;
|
const { id, name, description } = extension;
|
||||||
return (
|
return (
|
||||||
<Badge key={id} className="extension flex gaps align-center justify-space-between">
|
<Badge key={id} className="extension flex gaps align-center justify-space-between">
|
||||||
@ -63,6 +86,15 @@ export class Extensions extends React.Component {
|
|||||||
>
|
>
|
||||||
<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 */}
|
||||||
|
<Input
|
||||||
|
theme="round-black"
|
||||||
|
className="SearchInput"
|
||||||
|
autoFocus
|
||||||
|
placeholder={_i18n._(t`Search Extensions...`)}
|
||||||
|
value={this.search}
|
||||||
|
onChange={(value) => this.search = value}
|
||||||
|
/>
|
||||||
{this.renderExtensions()}
|
{this.renderExtensions()}
|
||||||
</div>
|
</div>
|
||||||
</WizardLayout>
|
</WizardLayout>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user