mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Adjust list to new extension types
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
133c534469
commit
ec4b6ad8b4
@ -3,29 +3,38 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from "react";
|
import styles from "./install.module.scss";
|
||||||
|
|
||||||
|
import React, { useEffect, useState } from "react";
|
||||||
import { Button } from "../button";
|
import { Button } from "../button";
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { SearchInput } from "../input";
|
import { SearchInput } from "../input";
|
||||||
|
import { Spinner } from "../spinner";
|
||||||
interface Extension {
|
import { Extension, getExtensions } from "./extension-list";
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
description: string;
|
|
||||||
version: string;
|
|
||||||
downloads: number;
|
|
||||||
author: string;
|
|
||||||
iconUrl?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function Install() {
|
export function Install() {
|
||||||
const extension: Extension = {
|
const [extensions, setExtensions] = useState([]);
|
||||||
id: "resourcemap",
|
|
||||||
name: "Lens Resource Map",
|
useEffect(() => {
|
||||||
description: "Lens Resource Map is an extension for Lens - The Kubernetes IDE that displays Kubernetes resources and their relations as a real-time force-directed graph.",
|
async function fetchExtensions() {
|
||||||
version: "1.0.1",
|
try {
|
||||||
downloads: 12400,
|
const response = await getExtensions();
|
||||||
author: "nevalla",
|
|
||||||
|
setExtensions(response);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchExtensions();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const renderExtensionsOrSpinner = () => {
|
||||||
|
if (!extensions.length) {
|
||||||
|
return <Spinner/>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <ExtensionList extensions={extensions}/>;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -41,8 +50,7 @@ export function Install() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2><Icon material="star"/> Featured Extensions</h2>
|
<h2><Icon material="star"/> Featured Extensions</h2>
|
||||||
|
{renderExtensionsOrSpinner()}
|
||||||
<ExtensionList extensions={[extension]}/>
|
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -56,10 +64,10 @@ function ExtensionList({ extensions }: { extensions: Extension[] }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function ExtensionCard({ extension }: { extension: Extension }) {
|
function ExtensionCard({ extension }: { extension: Extension }) {
|
||||||
const { name, version, downloads, description, author } = extension;
|
const { name, version, totalNumberOfInstallations, shortDescription, publisher } = extension;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="ExtensionCard">
|
<div className={styles.ExtensionCard}>
|
||||||
<div className="head">
|
<div className="head">
|
||||||
<div className="nameAndVersion">
|
<div className="nameAndVersion">
|
||||||
<div className="name">{name}</div>
|
<div className="name">{name}</div>
|
||||||
@ -67,17 +75,17 @@ function ExtensionCard({ extension }: { extension: Extension }) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="downloads">
|
<div className="downloads">
|
||||||
<Icon material="cloud_download"/> {downloads}
|
<Icon material="cloud_download"/> {totalNumberOfInstallations}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="description">
|
<div className="description">
|
||||||
{description}
|
{shortDescription}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="footer">
|
<div className="footer">
|
||||||
<div className="author">
|
<div className="author">
|
||||||
<img src="https://avatars.githubusercontent.com/u/455844?v=4"/> {author}
|
<img src="https://avatars.githubusercontent.com/u/455844?v=4"/> {publisher.username}
|
||||||
</div>
|
</div>
|
||||||
<div className="install">
|
<div className="install">
|
||||||
<Button primary><Icon material="cloud_download"/> Install</Button>
|
<Button primary><Icon material="cloud_download"/> Install</Button>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user