Merge remote-tracking branch 'origin/master' into mobx-6.2

This commit is contained in:
Roman committed 2021-04-23 16:25:32 +03:00
commit 671e7c26ca
22 files changed
+179 -75

No files matched your search

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 20.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 256 249" style="enable-background:new 0 0 256 249;" xml:space="preserve">
<style type="text/css">
.st0{fill:#FFFFFF;}
</style>
<path class="st0" d="M247.7,151.3L247.7,151.3L247.7,151.3C247.4,151.3,247.4,151.3,247.7,151.3h-0.2c-0.2,0-0.5,0-0.5-0.2
c-0.5,0-1-0.2-1.4-0.2c-1.7-0.2-3.1-0.5-4.5-0.5c-0.7,0-1.4,0-2.4-0.2h-0.2c-5-0.5-9-1-12.8-2.1c-1.7-0.7-2.1-1.7-2.6-2.6
c0-0.2-0.2-0.2-0.2-0.5l0,0l-3.1-1c1.4-10.9,1-22.3-1.7-33.5c-2.6-11.2-7.1-21.6-13.3-31.1l2.4-2.1v-0.5c0-1.2,0.2-2.4,1.2-3.6
c2.9-2.6,6.4-4.8,10.7-7.4l0,0c0.7-0.5,1.4-0.7,2.1-1.2c1.4-0.7,2.6-1.4,4-2.4c0.2-0.2,0.7-0.5,1.2-1c0.2-0.2,0.5-0.2,0.5-0.5l0,0
c3.3-2.9,4-7.6,1.7-10.7c-1.2-1.7-3.3-2.6-5.5-2.6c-1.9,0-3.6,0.7-5.2,1.9l0,0l0,0c-0.2,0.2-0.2,0.2-0.5,0.5c-0.5,0.2-0.7,0.7-1.2,1
c-1.2,1.2-2.1,2.1-3.1,3.3c-0.5,0.5-1,1.2-1.7,1.7l0,0c-3.3,3.6-6.4,6.4-9.5,8.6c-0.7,0.5-1.4,0.7-2.1,0.7c-0.5,0-1,0-1.4-0.2h-0.5
l0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5,0.5,0.7,0.7,1.2c0,0.2,0.2,0.5,0.2,0.5l0,0
l0,0c1.4,2.9,4.3,4.5,7.1,4.5c1,0,1.9-0.2,2.9-0.7c1.7-1,3.1-2.4,3.6-4.3s0.5-4-0.5-5.9l0,0l0,0c0-0.2-0.2-0.2-0.2-0.5
c-0.2-0.5-0.5-1-0.7-1.2c-0.7-1.4-1.7-2.6-2.6-3.8c-0.5-0.7-1-1.2-1.4-1.9V229c-2.6-4-5-7.6-6.2-11.2c-0.5-1.7,0-2.6,0.2-3.8
c0-0.2,0.2-0.2,0.2-0.5l0,0l-1.2-2.9c12.6-7.4,23.3-17.8,31.4-30.6c4.3-6.7,7.6-14,10-21.4l2.9,0.5c0.2,0,0.2-0.2,0.5-0.2
c1-0.5,1.7-1.2,3.1-1.2h0.5c3.8,0.5,7.8,1.9,12.4,3.6h0.2c0.7,0.2,1.4,0.7,2.1,1c1.4,0.7,2.6,1.2,4.3,1.7c0.5,0,1,0.2,1.4,0.2
c0.2,0,0.5,0,0.7,0.2l0,0c0.7,0.2,1.2,0.2,1.9,0.2c3.6,0,6.7-2.4,7.6-5.5C254.6,156.3,251.9,152.5,247.7,151.3L247.7,151.3z
M137.7,139.7l-10.5,5l-10.5-5l-2.6-11.2l7.1-9h11.6l7.1,9L137.7,139.7L137.7,139.7z M199.7,115c1.9,8.1,2.4,16.2,1.7,24L165,128.5
c-3.3-1-5.2-4.3-4.5-7.6c0.2-1,0.7-1.9,1.4-2.6l28.7-25.9C194.7,99.1,197.8,106.7,199.7,115L199.7,115z M179.3,78.2l-31.1,22.1
c-2.6,1.7-6.2,1.2-8.3-1.4c-0.7-0.7-1-1.7-1.2-2.6l-2.1-38.7C152.9,59.4,167.8,66.8,179.3,78.2L179.3,78.2z M110.4,58.7
c2.6-0.5,5-1,7.6-1.4l-2.1,38c-0.2,3.3-2.9,6.2-6.4,6.2c-1,0-2.1-0.2-2.9-0.7L75,78.2C84.7,68.4,96.8,61.8,110.4,58.7L110.4,58.7z
M63.6,92.4l28.3,25.2c2.6,2.1,2.9,6.2,0.7,8.8c-0.7,1-1.7,1.7-2.9,1.9L52.9,139C51.4,122.8,55,106.4,63.6,92.4L63.6,92.4z
M57.1,156.8l37.8-6.4c3.1-0.2,5.9,1.9,6.7,5c0.2,1.4,0.2,2.6-0.2,3.8l0,0l-14.5,34.9C73.5,185.6,62.8,172.5,57.1,156.8L57.1,156.8z
M143.9,204.1c-5.5,1.2-10.9,1.9-16.6,1.9c-8.3,0-16.4-1.4-24-3.8l18.8-34c1.9-2.1,5-3.1,7.6-1.7c1.2,0.7,2.1,1.7,2.9,2.6l0,0
l18.3,33C148.6,202.9,146.2,203.4,143.9,204.1L143.9,204.1z M190.2,171.1c-5.9,9.5-13.8,17.1-22.8,23l-15-35.9
c-0.7-2.9,0.5-5.9,3.3-7.4c1-0.5,2.1-0.7,3.3-0.7l38,6.4C195.6,161.8,193.3,166.5,190.2,171.1L190.2,171.1z"/>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

@@ -87,7 +87,8 @@ export class KubernetesClusterCategory extends EventEmitter implements CatalogCa
public readonly apiVersion = "catalog.k8slens.dev/v1alpha1";
public readonly kind = "CatalogCategory";
public metadata = {
name: "Kubernetes Clusters"
name: "Kubernetes Clusters",
icon: require(`!!raw-loader!./icons/kubernetes.svg`).default // eslint-disable-line
};
public spec = {
group: "entity.k8slens.dev",
+2 -1
View File
@@ -49,7 +49,8 @@ export class WebLinkCategory implements CatalogCategory {
public readonly apiVersion = "catalog.k8slens.dev/v1alpha1";
public readonly kind = "CatalogCategory";
public metadata = {
name: "Web Links"
name: "Web Links",
icon: "link"
};
public spec = {
group: "entity.k8slens.dev",
+1
View File
@@ -8,6 +8,7 @@ export interface CatalogCategory {
kind: string;
metadata: {
name: string;
icon: string;
}
spec: {
group: string;
@@ -15,8 +15,9 @@ export interface EntitySettingRegistration {
kind: string;
apiVersions: string[];
source?: string;
id?: string;
components: EntitySettingComponents;
id?: string;
priority?: number;
}
export interface RegisteredEntitySetting extends EntitySettingRegistration {
@@ -32,17 +33,21 @@ export class EntitySettingRegistry extends BaseRegistry<EntitySettingRegistratio
}
getItemsForKind(kind: string, apiVersion: string, source?: string) {
const items = this.getItems().filter((item) => {
let items = this.getItems().filter((item) => {
return item.kind === kind && item.apiVersions.includes(apiVersion);
}).map((item) => {
item.priority = item.priority ?? 50;
return item;
});
if (source) {
return items.filter((item) => {
items = items.filter((item) => {
return !item.source || item.source === source;
});
} else {
return items;
}
return items.sort((a, b) => b.priority - a.priority);
}
}
+14 -16
View File
@@ -35,7 +35,7 @@ export class HelmRepoManager extends Singleton {
protected helmEnv: HelmEnv;
protected initialized: boolean;
async loadAvailableRepos(): Promise<HelmRepo[]> {
public static async loadAvailableRepos(): Promise<HelmRepo[]> {
const res = await customRequestPromise({
uri: "https://github.com/lensapp/artifact-hub-repositories/releases/download/latest/repositories.json",
json: true,
@@ -46,18 +46,18 @@ export class HelmRepoManager extends Singleton {
return orderBy<HelmRepo>(res.body, repo => repo.name);
}
async init() {
private async init() {
helmCli.setLogger(logger);
await helmCli.ensureBinary();
if (!this.initialized) {
this.helmEnv = await this.parseHelmEnv();
await this.update();
this.helmEnv = await HelmRepoManager.parseHelmEnv();
await HelmRepoManager.update();
this.initialized = true;
}
}
protected async parseHelmEnv() {
protected static async parseHelmEnv() {
const helm = await helmCli.binaryPath();
const { stdout } = await promiseExec(`"${helm}" env`).catch((error) => {
throw(error.stderr);
@@ -78,6 +78,10 @@ export class HelmRepoManager extends Singleton {
public async repositories(): Promise<HelmRepo[]> {
try {
if (!this.initialized) {
await this.init();
}
const repoConfigFile = this.helmEnv.HELM_REPOSITORY_CONFIG;
const { repositories }: HelmRepoConfig = await readFile(repoConfigFile, "utf8")
.then((yamlContent: string) => yaml.safeLoad(yamlContent))
@@ -86,7 +90,7 @@ export class HelmRepoManager extends Singleton {
}));
if (!repositories.length) {
await this.addRepo({ name: "bitnami", url: "https://charts.bitnami.com/bitnami" });
await HelmRepoManager.addRepo({ name: "bitnami", url: "https://charts.bitnami.com/bitnami" });
return await this.repositories();
}
@@ -102,13 +106,7 @@ export class HelmRepoManager extends Singleton {
}
}
public async repository(name: string) {
const repositories = await this.repositories();
return repositories.find(repo => repo.name == name);
}
public async update() {
public static async update() {
const helm = await helmCli.binaryPath();
const { stdout } = await promiseExec(`"${helm}" repo update`).catch((error) => {
return { stdout: error.stdout };
@@ -117,7 +115,7 @@ export class HelmRepoManager extends Singleton {
return stdout;
}
public async addRepo({ name, url }: HelmRepo) {
public static async addRepo({ name, url }: HelmRepo) {
logger.info(`[HELM]: adding repo "${name}" from ${url}`);
const helm = await helmCli.binaryPath();
const { stdout } = await promiseExec(`"${helm}" repo add ${name} ${url}`).catch((error) => {
@@ -127,7 +125,7 @@ export class HelmRepoManager extends Singleton {
return stdout;
}
public async addСustomRepo(repoAttributes : HelmRepo) {
public static async addСustomRepo(repoAttributes : HelmRepo) {
logger.info(`[HELM]: adding repo "${repoAttributes.name}" from ${repoAttributes.url}`);
const helm = await helmCli.binaryPath();
@@ -146,7 +144,7 @@ export class HelmRepoManager extends Singleton {
return stdout;
}
public async removeRepo({ name, url }: HelmRepo): Promise<string> {
public static async removeRepo({ name, url }: HelmRepo): Promise<string> {
logger.info(`[HELM]: removing repo "${name}" from ${url}`);
const helm = await helmCli.binaryPath();
const { stdout } = await promiseExec(`"${helm}" repo remove ${name}`).catch((error) => {
+4 -2
View File
@@ -34,7 +34,8 @@ class HelmService {
readme: "",
versions: {}
};
const repo = await HelmRepoManager.getInstance().repository(repoName);
const repos = await HelmRepoManager.getInstance().repositories();
const repo = repos.find(repo => repo.name === repoName);
const chartManager = new HelmChartManager(repo);
const chart = await chartManager.chart(chartName);
@@ -45,7 +46,8 @@ class HelmService {
}
public async getChartValues(repoName: string, chartName: string, version = "") {
const repo = await HelmRepoManager.getInstance().repository(repoName);
const repos = await HelmRepoManager.getInstance().repositories();
const repo = repos.find(repo => repo.name === repoName);
const chartManager = new HelmChartManager(repo);
return chartManager.getValues(chartName, version);
+3
View File
@@ -33,6 +33,7 @@ import { IpcRendererNavigationEvents } from "../renderer/navigation/events";
import { CatalogPusher } from "./catalog-pusher";
import { catalogEntityRegistry } from "../common/catalog-entity-registry";
import { HotbarStore } from "../common/hotbar-store";
import { HelmRepoManager } from "./helm/helm-repo-manager";
const workingDir = path.join(app.getPath("appData"), appName);
@@ -105,6 +106,8 @@ app.on("ready", async () => {
const extensionsStore = ExtensionsStore.createInstance();
const filesystemStore = FilesystemProvisionerStore.createInstance();
HelmRepoManager.createInstance(); // create the instance
logger.info("💾 Loading stores");
// preload
await Promise.all([
@@ -0,0 +1 @@
export { catalogCategoryRegistry } from "../../common/catalog-category-registry";
+2 -2
View File
@@ -60,7 +60,8 @@ export async function bootstrap(App: AppComponent) {
const filesystemStore = FilesystemProvisionerStore.createInstance();
const themeStore = ThemeStore.createInstance();
const hotbarStore = HotbarStore.createInstance();
const helmRepoManager = HelmRepoManager.createInstance();
HelmRepoManager.createInstance(); // initialize the manager
// preload common stores
await Promise.all([
@@ -70,7 +71,6 @@ export async function bootstrap(App: AppComponent) {
extensionsStore.load(),
filesystemStore.load(),
themeStore.init(),
helmRepoManager.init(),
]);
// Register additional store listeners
@@ -45,6 +45,15 @@ export class CatalogEntityItem implements ItemObject {
return this.entity.metadata.source || "unknown";
}
get searchFields() {
return [
this.name,
this.id,
this.phase,
...this.labels.map((value, key) => `${key}=${value}`)
];
}
onRun(ctx: CatalogEntityActionContext) {
this.entity.onRun(ctx);
}
+4 -1
View File
@@ -168,9 +168,12 @@ export class Catalog extends React.Component {
[sortBy.source]: (item: CatalogEntityItem) => item.source,
[sortBy.status]: (item: CatalogEntityItem) => item.phase,
}}
searchFilters={[
(entity: CatalogEntityItem) => entity.searchFields,
]}
renderTableHeader={[
{ title: "Name", className: "name", sortBy: sortBy.name },
{ title: "Source", className: "source" },
{ title: "Source", className: "source", sortBy: sortBy.source },
{ title: "Labels", className: "labels" },
{ title: "Status", className: "status", sortBy: sortBy.status },
]}
@@ -84,7 +84,7 @@ export class AddHelmRepoDialog extends React.Component<Props> {
async addCustomRepo() {
try {
await HelmRepoManager.getInstance().addСustomRepo(this.helmRepo);
await HelmRepoManager.addСustomRepo(this.helmRepo);
Notifications.ok(<>Helm repository <b>{this.helmRepo.name}</b> has added</>);
this.props.onAddRepo();
this.close();
@@ -39,7 +39,7 @@ export class HelmCharts extends React.Component {
try {
if (!this.repos.length) {
this.repos = await HelmRepoManager.getInstance().loadAvailableRepos(); // via https://helm.sh
this.repos = await HelmRepoManager.loadAvailableRepos();
}
const repos = await HelmRepoManager.getInstance().repositories(); // via helm-cli
@@ -54,7 +54,7 @@ export class HelmCharts extends React.Component {
async addRepo(repo: HelmRepo) {
try {
await HelmRepoManager.getInstance().addRepo(repo);
await HelmRepoManager.addRepo(repo);
this.addedRepos.set(repo.name, repo);
} catch (err) {
Notifications.error(<>Adding helm branch <b>{repo.name}</b> has failed: {String(err)}</>);
@@ -63,7 +63,7 @@ export class HelmCharts extends React.Component {
async removeRepo(repo: HelmRepo) {
try {
await HelmRepoManager.getInstance().removeRepo(repo);
await HelmRepoManager.removeRepo(repo);
this.addedRepos.delete(repo.name);
} catch (err) {
Notifications.error(
@@ -38,6 +38,22 @@
}
}
.badge {
color: $textColorAccent;
position: absolute;
right: 0;
bottom: 0;
margin: -$padding;
font-size: $font-size-small;
background: $clusterMenuBackground;
color: white;
padding: 0px;
border-radius: 50%;
svg {
width: 13px;
}
}
img {
width: var(--size);
height: var(--size);
@@ -12,6 +12,7 @@ import { observable, makeObservable } from "mobx";
import { navigate } from "../../navigation";
import { HotbarStore } from "../../../common/hotbar-store";
import { ConfirmDialog } from "../confirm-dialog";
import { catalogCategoryRegistry } from "../../api/catalog-category-registry";
interface Props extends DOMAttributes<HTMLElement> {
entity: CatalogEntity;
@@ -60,6 +61,21 @@ export class HotbarIcon extends React.Component<Props> {
}
}
get badgeIcon() {
const className = "badge";
const category = catalogCategoryRegistry.getCategoryForEntity(this.props.entity);
if (!category) {
return <Icon material="bug_report" className={className} />;
}
if (category.metadata.icon.includes("<svg")) {
return <Icon svg={category.metadata.icon} className={className} />;
} else {
return <Icon material={category.metadata.icon} className={className} />;
}
}
toggleMenu() {
this.menuOpen = !this.menuOpen;
}
@@ -111,6 +127,7 @@ export class HotbarIcon extends React.Component<Props> {
<div className={className}>
<Tooltip targetId={entityIconId}>{entity.metadata.name}</Tooltip>
<Avatar {...elemProps} id={entityIconId} variant="square" className={isActive ? "active" : "default"}>{this.iconString}</Avatar>
{ this.badgeIcon }
<Menu
usePortal={false}
htmlFor={entityIconId}
+1 -1
View File
@@ -94,7 +94,7 @@ export class Icon extends React.PureComponent<IconProps> {
// render as inline svg-icon
if (svg) {
const svgIconText = require(`!!raw-loader!./${svg}.svg`).default;
const svgIconText = svg.includes("<svg") ? svg : require(`!!raw-loader!./${svg}.svg`).default;
iconContent = <span className="icon" dangerouslySetInnerHTML={{ __html: svgIconText }}/>;
}
+1 -1
View File
@@ -33,7 +33,7 @@ export function createStorage<T>(key: string, defaultValue: T, observableOptions
// remove json-file when cluster deleted
if (clusterId !== undefined) {
when(() => ClusterStore.getInstance().removedClusters.has(clusterId)).then(removeFile);
when(() => ClusterStore.getInstance(false)?.removedClusters.has(clusterId)).then(removeFile);
}
}