mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Switch CatalogEntity and CatalogCategory abstract classes (#2612)
This commit is contained in:
parent
4d10e07087
commit
339502cf4f
@ -1,12 +1,10 @@
|
|||||||
import { observable, reaction } from "mobx";
|
import { observable, reaction } from "mobx";
|
||||||
import { WebLink } from "../catalog-entities";
|
import { WebLink } from "../catalog-entities";
|
||||||
import { CatalogEntityRegistry } from "../catalog-entity-registry";
|
import { CatalogEntityRegistry } from "../catalog";
|
||||||
|
|
||||||
describe("CatalogEntityRegistry", () => {
|
describe("CatalogEntityRegistry", () => {
|
||||||
let registry: CatalogEntityRegistry;
|
let registry: CatalogEntityRegistry;
|
||||||
const entity = new WebLink({
|
const entity = new WebLink({
|
||||||
apiVersion: "entity.k8slens.dev/v1alpha1",
|
|
||||||
kind: "WebLink",
|
|
||||||
metadata: {
|
metadata: {
|
||||||
uid: "test",
|
uid: "test",
|
||||||
name: "test-link",
|
name: "test-link",
|
||||||
@ -17,7 +15,7 @@ describe("CatalogEntityRegistry", () => {
|
|||||||
url: "https://k8slens.dev"
|
url: "https://k8slens.dev"
|
||||||
},
|
},
|
||||||
status: {
|
status: {
|
||||||
phase: "ok"
|
phase: "valid"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
import { EventEmitter } from "events";
|
import { catalogCategoryRegistry } from "../catalog/catalog-category-registry";
|
||||||
import { observable } from "mobx";
|
import { CatalogEntity, CatalogEntityActionContext, CatalogEntityAddMenuContext, CatalogEntityContextMenuContext, CatalogEntityMetadata, CatalogEntityStatus } from "../catalog";
|
||||||
import { catalogCategoryRegistry } from "../catalog-category-registry";
|
|
||||||
import { CatalogCategory, CatalogEntity, CatalogEntityActionContext, CatalogEntityAddMenuContext, CatalogEntityContextMenuContext, CatalogEntityData, CatalogEntityMetadata, CatalogEntityStatus } from "../catalog-entity";
|
|
||||||
import { clusterDisconnectHandler } from "../cluster-ipc";
|
import { clusterDisconnectHandler } from "../cluster-ipc";
|
||||||
import { ClusterStore } from "../cluster-store";
|
import { ClusterStore } from "../cluster-store";
|
||||||
import { requestMain } from "../ipc";
|
import { requestMain } from "../ipc";
|
||||||
import { productName } from "../vars";
|
import { productName } from "../vars";
|
||||||
|
import { CatalogCategory, CatalogCategorySpec } from "../catalog";
|
||||||
|
|
||||||
export type KubernetesClusterSpec = {
|
export type KubernetesClusterSpec = {
|
||||||
kubeconfigPath: string;
|
kubeconfigPath: string;
|
||||||
@ -16,32 +15,19 @@ export interface KubernetesClusterStatus extends CatalogEntityStatus {
|
|||||||
phase: "connected" | "disconnected";
|
phase: "connected" | "disconnected";
|
||||||
}
|
}
|
||||||
|
|
||||||
export class KubernetesCluster implements CatalogEntity {
|
export class KubernetesCluster extends CatalogEntity<CatalogEntityMetadata, KubernetesClusterStatus, KubernetesClusterSpec> {
|
||||||
public readonly apiVersion = "entity.k8slens.dev/v1alpha1";
|
public readonly apiVersion = "entity.k8slens.dev/v1alpha1";
|
||||||
public readonly kind = "KubernetesCluster";
|
public readonly kind = "KubernetesCluster";
|
||||||
@observable public metadata: CatalogEntityMetadata;
|
|
||||||
@observable public status: KubernetesClusterStatus;
|
|
||||||
@observable public spec: KubernetesClusterSpec;
|
|
||||||
|
|
||||||
constructor(data: CatalogEntityData) {
|
|
||||||
this.metadata = data.metadata;
|
|
||||||
this.status = data.status as KubernetesClusterStatus;
|
|
||||||
this.spec = data.spec as KubernetesClusterSpec;
|
|
||||||
}
|
|
||||||
|
|
||||||
getId() {
|
|
||||||
return this.metadata.uid;
|
|
||||||
}
|
|
||||||
|
|
||||||
getName() {
|
|
||||||
return this.metadata.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
async onRun(context: CatalogEntityActionContext) {
|
async onRun(context: CatalogEntityActionContext) {
|
||||||
context.navigate(`/cluster/${this.metadata.uid}`);
|
context.navigate(`/cluster/${this.metadata.uid}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onDetailsOpen() {
|
onDetailsOpen(): void {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
onSettingsOpen(): void {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,14 +67,14 @@ export class KubernetesCluster implements CatalogEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class KubernetesClusterCategory extends EventEmitter implements CatalogCategory {
|
export class KubernetesClusterCategory extends CatalogCategory {
|
||||||
public readonly apiVersion = "catalog.k8slens.dev/v1alpha1";
|
public readonly apiVersion = "catalog.k8slens.dev/v1alpha1";
|
||||||
public readonly kind = "CatalogCategory";
|
public readonly kind = "CatalogCategory";
|
||||||
public metadata = {
|
public metadata = {
|
||||||
name: "Kubernetes Clusters",
|
name: "Kubernetes Clusters",
|
||||||
icon: require(`!!raw-loader!./icons/kubernetes.svg`).default // eslint-disable-line
|
icon: require(`!!raw-loader!./icons/kubernetes.svg`).default // eslint-disable-line
|
||||||
};
|
};
|
||||||
public spec = {
|
public spec: CatalogCategorySpec = {
|
||||||
group: "entity.k8slens.dev",
|
group: "entity.k8slens.dev",
|
||||||
versions: [
|
versions: [
|
||||||
{
|
{
|
||||||
@ -114,10 +100,6 @@ export class KubernetesClusterCategory extends EventEmitter implements CatalogCa
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getId() {
|
|
||||||
return `${this.spec.group}/${this.spec.names.kind}`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
catalogCategoryRegistry.add(new KubernetesClusterCategory());
|
catalogCategoryRegistry.add(new KubernetesClusterCategory());
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import { observable } from "mobx";
|
import { CatalogCategory, CatalogEntity, CatalogEntityMetadata, CatalogEntityStatus } from "../catalog";
|
||||||
import { CatalogCategory, CatalogEntity, CatalogEntityData, CatalogEntityMetadata, CatalogEntityStatus } from "../catalog-entity";
|
import { catalogCategoryRegistry } from "../catalog/catalog-category-registry";
|
||||||
import { catalogCategoryRegistry } from "../catalog-category-registry";
|
|
||||||
|
|
||||||
export interface WebLinkStatus extends CatalogEntityStatus {
|
export interface WebLinkStatus extends CatalogEntityStatus {
|
||||||
phase: "valid" | "invalid";
|
phase: "valid" | "invalid";
|
||||||
@ -10,41 +9,28 @@ export type WebLinkSpec = {
|
|||||||
url: string;
|
url: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export class WebLink implements CatalogEntity {
|
export class WebLink extends CatalogEntity<CatalogEntityMetadata, WebLinkStatus, WebLinkSpec> {
|
||||||
public readonly apiVersion = "entity.k8slens.dev/v1alpha1";
|
public readonly apiVersion = "entity.k8slens.dev/v1alpha1";
|
||||||
public readonly kind = "KubernetesCluster";
|
public readonly kind = "KubernetesCluster";
|
||||||
@observable public metadata: CatalogEntityMetadata;
|
|
||||||
@observable public status: WebLinkStatus;
|
|
||||||
@observable public spec: WebLinkSpec;
|
|
||||||
|
|
||||||
constructor(data: CatalogEntityData) {
|
|
||||||
this.metadata = data.metadata;
|
|
||||||
this.status = data.status as WebLinkStatus;
|
|
||||||
this.spec = data.spec as WebLinkSpec;
|
|
||||||
}
|
|
||||||
|
|
||||||
getId() {
|
|
||||||
return this.metadata.uid;
|
|
||||||
}
|
|
||||||
|
|
||||||
getName() {
|
|
||||||
return this.metadata.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
async onRun() {
|
async onRun() {
|
||||||
window.open(this.spec.url, "_blank");
|
window.open(this.spec.url, "_blank");
|
||||||
}
|
}
|
||||||
|
|
||||||
async onDetailsOpen() {
|
public onSettingsOpen(): void {
|
||||||
//
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
async onContextMenuOpen() {
|
public onDetailsOpen(): void {
|
||||||
//
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public onContextMenuOpen(): void {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class WebLinkCategory implements CatalogCategory {
|
export class WebLinkCategory extends CatalogCategory {
|
||||||
public readonly apiVersion = "catalog.k8slens.dev/v1alpha1";
|
public readonly apiVersion = "catalog.k8slens.dev/v1alpha1";
|
||||||
public readonly kind = "CatalogCategory";
|
public readonly kind = "CatalogCategory";
|
||||||
public metadata = {
|
public metadata = {
|
||||||
@ -63,10 +49,6 @@ export class WebLinkCategory implements CatalogCategory {
|
|||||||
kind: "WebLink"
|
kind: "WebLink"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
getId() {
|
|
||||||
return `${this.spec.group}/${this.spec.names.kind}`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
catalogCategoryRegistry.add(new WebLinkCategory());
|
catalogCategoryRegistry.add(new WebLinkCategory());
|
||||||
|
|||||||
@ -1,95 +0,0 @@
|
|||||||
export interface CatalogCategoryVersion {
|
|
||||||
name: string;
|
|
||||||
entityClass: { new(data: CatalogEntityData): CatalogEntity };
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CatalogCategory {
|
|
||||||
apiVersion: string;
|
|
||||||
kind: string;
|
|
||||||
metadata: {
|
|
||||||
name: string;
|
|
||||||
icon: string;
|
|
||||||
}
|
|
||||||
spec: {
|
|
||||||
group: string;
|
|
||||||
versions: CatalogCategoryVersion[];
|
|
||||||
names: {
|
|
||||||
kind: string;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getId: () => string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type CatalogEntityMetadata = {
|
|
||||||
uid: string;
|
|
||||||
name: string;
|
|
||||||
description?: string;
|
|
||||||
source?: string;
|
|
||||||
labels: {
|
|
||||||
[key: string]: string;
|
|
||||||
}
|
|
||||||
[key: string]: string | object;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type CatalogEntityStatus = {
|
|
||||||
phase: string;
|
|
||||||
reason?: string;
|
|
||||||
message?: string;
|
|
||||||
active?: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface CatalogEntityActionContext {
|
|
||||||
navigate: (url: string) => void;
|
|
||||||
setCommandPaletteContext: (context?: CatalogEntity) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type CatalogEntityContextMenu = {
|
|
||||||
icon: string;
|
|
||||||
title: string;
|
|
||||||
onlyVisibleForSource?: string; // show only if empty or if matches with entity source
|
|
||||||
onClick: () => Promise<void>;
|
|
||||||
confirm?: {
|
|
||||||
message: string;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export type CatalogEntitySettingsMenu = {
|
|
||||||
group?: string;
|
|
||||||
title: string;
|
|
||||||
components: {
|
|
||||||
View: React.ComponentType<any>
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface CatalogEntityContextMenuContext {
|
|
||||||
navigate: (url: string) => void;
|
|
||||||
menuItems: CatalogEntityContextMenu[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CatalogEntitySettingsContext {
|
|
||||||
menuItems: CatalogEntityContextMenu[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CatalogEntityAddMenuContext {
|
|
||||||
navigate: (url: string) => void;
|
|
||||||
menuItems: CatalogEntityContextMenu[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export type CatalogEntityData = {
|
|
||||||
apiVersion: string;
|
|
||||||
kind: string;
|
|
||||||
metadata: CatalogEntityMetadata;
|
|
||||||
status: CatalogEntityStatus;
|
|
||||||
spec: {
|
|
||||||
[key: string]: any;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface CatalogEntity extends CatalogEntityData {
|
|
||||||
getId: () => string;
|
|
||||||
getName: () => string;
|
|
||||||
onRun: (context: CatalogEntityActionContext) => Promise<void>;
|
|
||||||
onDetailsOpen: (context: CatalogEntityActionContext) => Promise<void>;
|
|
||||||
onContextMenuOpen: (context: CatalogEntityContextMenuContext) => Promise<void>;
|
|
||||||
onSettingsOpen?: (context: CatalogEntitySettingsContext) => Promise<void>;
|
|
||||||
}
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import { action, computed, observable, toJS } from "mobx";
|
import { action, computed, observable, toJS } from "mobx";
|
||||||
import { CatalogCategory, CatalogEntityData } from "./catalog-entity";
|
import { CatalogCategory, CatalogEntityData, CatalogEntityKindData } from "./catalog-entity";
|
||||||
|
|
||||||
export class CatalogCategoryRegistry {
|
export class CatalogCategoryRegistry {
|
||||||
@observable protected categories: CatalogCategory[] = [];
|
@observable protected categories: CatalogCategory[] = [];
|
||||||
@ -20,7 +20,7 @@ export class CatalogCategoryRegistry {
|
|||||||
return this.categories.find((c) => c.spec.group === group && c.spec.names.kind === kind) as T;
|
return this.categories.find((c) => c.spec.group === group && c.spec.names.kind === kind) as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
getEntityForData(data: CatalogEntityData) {
|
getEntityForData(data: CatalogEntityData & CatalogEntityKindData) {
|
||||||
const category = this.getCategoryForEntity(data);
|
const category = this.getCategoryForEntity(data);
|
||||||
|
|
||||||
if (!category) {
|
if (!category) {
|
||||||
@ -39,7 +39,7 @@ export class CatalogCategoryRegistry {
|
|||||||
return new specVersion.entityClass(data);
|
return new specVersion.entityClass(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
getCategoryForEntity<T extends CatalogCategory>(data: CatalogEntityData) {
|
getCategoryForEntity<T extends CatalogCategory>(data: CatalogEntityData & CatalogEntityKindData) {
|
||||||
const splitApiVersion = data.apiVersion.split("/");
|
const splitApiVersion = data.apiVersion.split("/");
|
||||||
const group = splitApiVersion[0];
|
const group = splitApiVersion[0];
|
||||||
|
|
||||||
143
src/common/catalog/catalog-entity.ts
Normal file
143
src/common/catalog/catalog-entity.ts
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
import { EventEmitter } from "events";
|
||||||
|
import { observable } from "mobx";
|
||||||
|
|
||||||
|
type ExtractEntityMetadataType<Entity> = Entity extends CatalogEntity<infer Metadata> ? Metadata : never;
|
||||||
|
type ExtractEntityStatusType<Entity> = Entity extends CatalogEntity<any, infer Status> ? Status : never;
|
||||||
|
type ExtractEntitySpecType<Entity> = Entity extends CatalogEntity<any, any, infer Spec> ? Spec : never;
|
||||||
|
|
||||||
|
export type CatalogEntityConstructor<Entity extends CatalogEntity> = (
|
||||||
|
(new (data: CatalogEntityData<
|
||||||
|
ExtractEntityMetadataType<Entity>,
|
||||||
|
ExtractEntityStatusType<Entity>,
|
||||||
|
ExtractEntitySpecType<Entity>
|
||||||
|
>) => Entity)
|
||||||
|
);
|
||||||
|
|
||||||
|
export interface CatalogCategoryVersion<Entity extends CatalogEntity> {
|
||||||
|
name: string;
|
||||||
|
entityClass: CatalogEntityConstructor<Entity>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CatalogCategorySpec {
|
||||||
|
group: string;
|
||||||
|
versions: CatalogCategoryVersion<CatalogEntity>[];
|
||||||
|
names: {
|
||||||
|
kind: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export abstract class CatalogCategory extends EventEmitter {
|
||||||
|
abstract readonly apiVersion: string;
|
||||||
|
abstract readonly kind: string;
|
||||||
|
abstract metadata: {
|
||||||
|
name: string;
|
||||||
|
icon: string;
|
||||||
|
};
|
||||||
|
abstract spec: CatalogCategorySpec;
|
||||||
|
|
||||||
|
public getId(): string {
|
||||||
|
return `${this.spec.group}/${this.spec.names.kind}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CatalogEntityMetadata {
|
||||||
|
uid: string;
|
||||||
|
name: string;
|
||||||
|
description?: string;
|
||||||
|
source?: string;
|
||||||
|
labels: Record<string, string>;
|
||||||
|
[key: string]: string | object;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CatalogEntityStatus {
|
||||||
|
phase: string;
|
||||||
|
reason?: string;
|
||||||
|
message?: string;
|
||||||
|
active?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CatalogEntityActionContext {
|
||||||
|
navigate: (url: string) => void;
|
||||||
|
setCommandPaletteContext: (context?: CatalogEntity) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CatalogEntityContextMenu {
|
||||||
|
icon: string;
|
||||||
|
title: string;
|
||||||
|
onlyVisibleForSource?: string; // show only if empty or if matches with entity source
|
||||||
|
onClick: () => Promise<void>;
|
||||||
|
confirm?: {
|
||||||
|
message: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CatalogEntitySettingsMenu {
|
||||||
|
group?: string;
|
||||||
|
title: string;
|
||||||
|
components: {
|
||||||
|
View: React.ComponentType<any>
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CatalogEntityContextMenuContext {
|
||||||
|
navigate: (url: string) => void;
|
||||||
|
menuItems: CatalogEntityContextMenu[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CatalogEntitySettingsContext {
|
||||||
|
menuItems: CatalogEntityContextMenu[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CatalogEntityAddMenuContext {
|
||||||
|
navigate: (url: string) => void;
|
||||||
|
menuItems: CatalogEntityContextMenu[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export type CatalogEntitySpec = Record<string, any>;
|
||||||
|
|
||||||
|
export interface CatalogEntityData<
|
||||||
|
Metadata extends CatalogEntityMetadata = CatalogEntityMetadata,
|
||||||
|
Status extends CatalogEntityStatus = CatalogEntityStatus,
|
||||||
|
Spec extends CatalogEntitySpec = CatalogEntitySpec,
|
||||||
|
> {
|
||||||
|
metadata: Metadata;
|
||||||
|
status: Status;
|
||||||
|
spec: Spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CatalogEntityKindData {
|
||||||
|
readonly apiVersion: string;
|
||||||
|
readonly kind: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export abstract class CatalogEntity<
|
||||||
|
Metadata extends CatalogEntityMetadata = CatalogEntityMetadata,
|
||||||
|
Status extends CatalogEntityStatus = CatalogEntityStatus,
|
||||||
|
Spec extends CatalogEntitySpec = CatalogEntitySpec,
|
||||||
|
> implements CatalogEntityKindData {
|
||||||
|
public abstract readonly apiVersion: string;
|
||||||
|
public abstract readonly kind: string;
|
||||||
|
|
||||||
|
@observable metadata: Metadata;
|
||||||
|
@observable status: Status;
|
||||||
|
@observable spec: Spec;
|
||||||
|
|
||||||
|
constructor(data: CatalogEntityData<Metadata, Status, Spec>) {
|
||||||
|
this.metadata = data.metadata;
|
||||||
|
this.status = data.status;
|
||||||
|
this.spec = data.spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getId(): string {
|
||||||
|
return this.metadata.uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getName(): string {
|
||||||
|
return this.metadata.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract onRun?(context: CatalogEntityActionContext): void | Promise<void>;
|
||||||
|
public abstract onDetailsOpen(context: CatalogEntityActionContext): void | Promise<void>;
|
||||||
|
public abstract onContextMenuOpen(context: CatalogEntityContextMenuContext): void | Promise<void>;
|
||||||
|
public abstract onSettingsOpen(context: CatalogEntitySettingsContext): void | Promise<void>;
|
||||||
|
}
|
||||||
3
src/common/catalog/index.ts
Normal file
3
src/common/catalog/index.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export * from "./catalog-category-registry";
|
||||||
|
export * from "./catalog-entity";
|
||||||
|
export * from "./catalog-entity-registry";
|
||||||
@ -1,8 +1,7 @@
|
|||||||
|
|
||||||
import { CatalogEntity } from "../../common/catalog-entity";
|
import { CatalogEntity, catalogEntityRegistry as registry } from "../../common/catalog";
|
||||||
import { catalogEntityRegistry as registry } from "../../common/catalog-entity-registry";
|
|
||||||
|
|
||||||
export { catalogCategoryRegistry as catalogCategories } from "../../common/catalog-category-registry";
|
export { catalogCategoryRegistry as catalogCategories } from "../../common/catalog/catalog-category-registry";
|
||||||
export * from "../../common/catalog-entities";
|
export * from "../../common/catalog-entities";
|
||||||
|
|
||||||
export class CatalogEntityRegistry {
|
export class CatalogEntityRegistry {
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
export * from "../../common/catalog-entity";
|
export * from "../../common/catalog/catalog-entity";
|
||||||
|
|||||||
@ -2,8 +2,7 @@ import type { MenuRegistration } from "./registries/menu-registry";
|
|||||||
import { LensExtension } from "./lens-extension";
|
import { LensExtension } from "./lens-extension";
|
||||||
import { WindowManager } from "../main/window-manager";
|
import { WindowManager } from "../main/window-manager";
|
||||||
import { getExtensionPageUrl } from "./registries/page-registry";
|
import { getExtensionPageUrl } from "./registries/page-registry";
|
||||||
import { catalogEntityRegistry } from "../common/catalog-entity-registry";
|
import { CatalogEntity, catalogEntityRegistry } from "../common/catalog";
|
||||||
import { CatalogEntity } from "../common/catalog-entity";
|
|
||||||
import { IObservableArray } from "mobx";
|
import { IObservableArray } from "mobx";
|
||||||
|
|
||||||
export class LensMainExtension extends LensExtension {
|
export class LensMainExtension extends LensExtension {
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
import { BaseRegistry } from "./base-registry";
|
import { BaseRegistry } from "./base-registry";
|
||||||
import { action, observable } from "mobx";
|
import { action, observable } from "mobx";
|
||||||
import { LensExtension } from "../lens-extension";
|
import { LensExtension } from "../lens-extension";
|
||||||
import { CatalogEntity } from "../../common/catalog-entity";
|
import { CatalogEntity } from "../../common/catalog";
|
||||||
|
|
||||||
export type CommandContext = {
|
export type CommandContext = {
|
||||||
entity?: CatalogEntity;
|
entity?: CatalogEntity;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import type React from "react";
|
import type React from "react";
|
||||||
import { CatalogEntity } from "../../common/catalog-entity";
|
import { CatalogEntity } from "../../common/catalog";
|
||||||
import { BaseRegistry } from "./base-registry";
|
import { BaseRegistry } from "./base-registry";
|
||||||
|
|
||||||
export interface EntitySettingViewProps {
|
export interface EntitySettingViewProps {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { autorun, toJS } from "mobx";
|
import { autorun, toJS } from "mobx";
|
||||||
import { broadcastMessage, subscribeToBroadcast, unsubscribeFromBroadcast } from "../common/ipc";
|
import { broadcastMessage, subscribeToBroadcast, unsubscribeFromBroadcast } from "../common/ipc";
|
||||||
import { CatalogEntityRegistry} from "../common/catalog-entity-registry";
|
import { CatalogEntityRegistry} from "../common/catalog";
|
||||||
import "../common/catalog-entities/kubernetes-cluster";
|
import "../common/catalog-entities/kubernetes-cluster";
|
||||||
|
|
||||||
export class CatalogPusher {
|
export class CatalogPusher {
|
||||||
|
|||||||
@ -7,9 +7,8 @@ import { Cluster } from "./cluster";
|
|||||||
import logger from "./logger";
|
import logger from "./logger";
|
||||||
import { apiKubePrefix } from "../common/vars";
|
import { apiKubePrefix } from "../common/vars";
|
||||||
import { Singleton } from "../common/utils";
|
import { Singleton } from "../common/utils";
|
||||||
import { CatalogEntity } from "../common/catalog-entity";
|
import { CatalogEntity, catalogEntityRegistry } from "../common/catalog";
|
||||||
import { KubernetesCluster } from "../common/catalog-entities/kubernetes-cluster";
|
import { KubernetesCluster } from "../common/catalog-entities/kubernetes-cluster";
|
||||||
import { catalogEntityRegistry } from "../common/catalog-entity-registry";
|
|
||||||
|
|
||||||
const clusterOwnerRef = "ClusterManager";
|
const clusterOwnerRef = "ClusterManager";
|
||||||
|
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import { bindBroadcastHandlers } from "../common/ipc";
|
|||||||
import { startUpdateChecking } from "./app-updater";
|
import { startUpdateChecking } from "./app-updater";
|
||||||
import { IpcRendererNavigationEvents } from "../renderer/navigation/events";
|
import { IpcRendererNavigationEvents } from "../renderer/navigation/events";
|
||||||
import { CatalogPusher } from "./catalog-pusher";
|
import { CatalogPusher } from "./catalog-pusher";
|
||||||
import { catalogEntityRegistry } from "../common/catalog-entity-registry";
|
import { catalogEntityRegistry } from "../common/catalog";
|
||||||
import { HotbarStore } from "../common/hotbar-store";
|
import { HotbarStore } from "../common/hotbar-store";
|
||||||
import { HelmRepoManager } from "./helm/helm-repo-manager";
|
import { HelmRepoManager } from "./helm/helm-repo-manager";
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { CatalogEntityRegistry } from "../catalog-entity-registry";
|
import { CatalogEntityRegistry } from "../catalog-entity-registry";
|
||||||
import "../../../common/catalog-entities";
|
import "../../../common/catalog-entities";
|
||||||
import { catalogCategoryRegistry } from "../../../common/catalog-category-registry";
|
import { catalogCategoryRegistry } from "../../../common/catalog/catalog-category-registry";
|
||||||
|
|
||||||
describe("CatalogEntityRegistry", () => {
|
describe("CatalogEntityRegistry", () => {
|
||||||
describe("updateItems", () => {
|
describe("updateItems", () => {
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
export { catalogCategoryRegistry } from "../../common/catalog-category-registry";
|
export { catalogCategoryRegistry } from "../../common/catalog";
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import { action, observable } from "mobx";
|
import { action, observable } from "mobx";
|
||||||
import { broadcastMessage, subscribeToBroadcast } from "../../common/ipc";
|
import { broadcastMessage, subscribeToBroadcast } from "../../common/ipc";
|
||||||
import { CatalogCategory, CatalogEntity, CatalogEntityData } from "../../common/catalog-entity";
|
import { CatalogCategory, CatalogEntity, CatalogEntityData, catalogCategoryRegistry, CatalogCategoryRegistry, CatalogEntityKindData } from "../../common/catalog";
|
||||||
import { catalogCategoryRegistry, CatalogCategoryRegistry } from "../../common/catalog-category-registry";
|
|
||||||
import "../../common/catalog-entities";
|
import "../../common/catalog-entities";
|
||||||
|
|
||||||
export class CatalogEntityRegistry {
|
export class CatalogEntityRegistry {
|
||||||
@ -10,13 +9,13 @@ export class CatalogEntityRegistry {
|
|||||||
constructor(private categoryRegistry: CatalogCategoryRegistry) {}
|
constructor(private categoryRegistry: CatalogCategoryRegistry) {}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
subscribeToBroadcast("catalog:items", (ev, items: CatalogEntityData[]) => {
|
subscribeToBroadcast("catalog:items", (ev, items: (CatalogEntityData & CatalogEntityKindData)[]) => {
|
||||||
this.updateItems(items);
|
this.updateItems(items);
|
||||||
});
|
});
|
||||||
broadcastMessage("catalog:broadcast");
|
broadcastMessage("catalog:broadcast");
|
||||||
}
|
}
|
||||||
|
|
||||||
@action updateItems(items: CatalogEntityData[]) {
|
@action updateItems(items: (CatalogEntityData & CatalogEntityKindData)[]) {
|
||||||
this._items.forEach((item, index) => {
|
this._items.forEach((item, index) => {
|
||||||
const foundIndex = items.findIndex((i) => i.apiVersion === item.apiVersion && i.kind === item.kind && i.metadata.uid === item.metadata.uid);
|
const foundIndex = items.findIndex((i) => i.apiVersion === item.apiVersion && i.kind === item.kind && i.metadata.uid === item.metadata.uid);
|
||||||
|
|
||||||
|
|||||||
@ -1,16 +1,17 @@
|
|||||||
import { navigate } from "../navigation";
|
import { navigate } from "../navigation";
|
||||||
import { commandRegistry } from "../../extensions/registries";
|
import { commandRegistry } from "../../extensions/registries";
|
||||||
import { CatalogEntity } from "../../common/catalog-entity";
|
import { CatalogEntity } from "../../common/catalog";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
CatalogCategory,
|
CatalogCategory,
|
||||||
CatalogEntity,
|
CatalogEntity,
|
||||||
CatalogEntityData,
|
CatalogEntityData,
|
||||||
|
CatalogEntityKindData,
|
||||||
CatalogEntityActionContext,
|
CatalogEntityActionContext,
|
||||||
CatalogEntityAddMenuContext,
|
CatalogEntityAddMenuContext,
|
||||||
CatalogEntityContextMenu,
|
CatalogEntityContextMenu,
|
||||||
CatalogEntityContextMenuContext
|
CatalogEntityContextMenuContext
|
||||||
} from "../../common/catalog-entity";
|
} from "../../common/catalog";
|
||||||
|
|
||||||
export const catalogEntityRunContext = {
|
export const catalogEntityRunContext = {
|
||||||
navigate: (url: string) => navigate(url),
|
navigate: (url: string) => navigate(url),
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
|||||||
import { CatalogEntity, CatalogEntityActionContext } from "../../api/catalog-entity";
|
import { CatalogEntity, CatalogEntityActionContext } from "../../api/catalog-entity";
|
||||||
import { ItemObject, ItemStore } from "../../item.store";
|
import { ItemObject, ItemStore } from "../../item.store";
|
||||||
import { autobind } from "../../utils";
|
import { autobind } from "../../utils";
|
||||||
import { CatalogCategory } from "../../../common/catalog-entity";
|
import { CatalogCategory } from "../../../common/catalog";
|
||||||
|
|
||||||
export class CatalogEntityItem implements ItemObject {
|
export class CatalogEntityItem implements ItemObject {
|
||||||
constructor(public entity: CatalogEntity) {}
|
constructor(public entity: CatalogEntity) {}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import { autobind } from "../../utils";
|
|||||||
import { Notifications } from "../notifications";
|
import { Notifications } from "../notifications";
|
||||||
import { ConfirmDialog } from "../confirm-dialog";
|
import { ConfirmDialog } from "../confirm-dialog";
|
||||||
import { Tab, Tabs } from "../tabs";
|
import { Tab, Tabs } from "../tabs";
|
||||||
import { catalogCategoryRegistry } from "../../../common/catalog-category-registry";
|
import { catalogCategoryRegistry } from "../../../common/catalog";
|
||||||
import { CatalogAddButton } from "./catalog-add-button";
|
import { CatalogAddButton } from "./catalog-add-button";
|
||||||
|
|
||||||
enum sortBy {
|
enum sortBy {
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { observer } from "mobx-react";
|
|||||||
import { cssNames, IClassName } from "../../utils";
|
import { cssNames, IClassName } from "../../utils";
|
||||||
import { Tooltip } from "../tooltip";
|
import { Tooltip } from "../tooltip";
|
||||||
import { Avatar } from "@material-ui/core";
|
import { Avatar } from "@material-ui/core";
|
||||||
import { CatalogEntity, CatalogEntityContextMenu, CatalogEntityContextMenuContext } from "../../../common/catalog-entity";
|
import { CatalogEntity, CatalogEntityContextMenu, CatalogEntityContextMenuContext } from "../../../common/catalog";
|
||||||
import { Menu, MenuItem } from "../menu";
|
import { Menu, MenuItem } from "../menu";
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { observable } from "mobx";
|
import { observable } from "mobx";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user