mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Finish up CatalogEntity.getId() replacements
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
609861091c
commit
682d3211ce
@ -67,22 +67,22 @@ export class KubernetesCluster extends CatalogEntity<KubernetesClusterMetadata,
|
||||
|
||||
async connect(): Promise<void> {
|
||||
if (app) {
|
||||
await ClusterStore.getInstance().getById(this.metadata.uid)?.activate();
|
||||
await ClusterStore.getInstance().getById(this.getId())?.activate();
|
||||
} else {
|
||||
await requestMain(clusterActivateHandler, this.metadata.uid, false);
|
||||
await requestMain(clusterActivateHandler, this.getId(), false);
|
||||
}
|
||||
}
|
||||
|
||||
async disconnect(): Promise<void> {
|
||||
if (app) {
|
||||
ClusterStore.getInstance().getById(this.metadata.uid)?.disconnect();
|
||||
ClusterStore.getInstance().getById(this.getId())?.disconnect();
|
||||
} else {
|
||||
await requestMain(clusterDisconnectHandler, this.metadata.uid, false);
|
||||
await requestMain(clusterDisconnectHandler, this.getId(), false);
|
||||
}
|
||||
}
|
||||
|
||||
async onRun(context: CatalogEntityActionContext) {
|
||||
context.navigate(`/cluster/${this.metadata.uid}`);
|
||||
context.navigate(`/cluster/${this.getId()}`);
|
||||
}
|
||||
|
||||
onDetailsOpen(): void {
|
||||
@ -100,7 +100,7 @@ export class KubernetesCluster extends CatalogEntity<KubernetesClusterMetadata,
|
||||
icon: "settings",
|
||||
onClick: () => broadcastMessage(
|
||||
IpcRendererNavigationEvents.NAVIGATE_IN_APP,
|
||||
`/entity/${this.metadata.uid}/settings`,
|
||||
`/entity/${this.getId()}/settings`,
|
||||
),
|
||||
});
|
||||
}
|
||||
@ -111,14 +111,14 @@ export class KubernetesCluster extends CatalogEntity<KubernetesClusterMetadata,
|
||||
context.menuItems.push({
|
||||
title: "Disconnect",
|
||||
icon: "link_off",
|
||||
onClick: () => requestMain(clusterDisconnectHandler, this.metadata.uid),
|
||||
onClick: () => requestMain(clusterDisconnectHandler, this.getId()),
|
||||
});
|
||||
break;
|
||||
case LensKubernetesClusterStatus.DISCONNECTED:
|
||||
context.menuItems.push({
|
||||
title: "Connect",
|
||||
icon: "link",
|
||||
onClick: () => context.navigate(`/cluster/${this.metadata.uid}`),
|
||||
onClick: () => context.navigate(`/cluster/${this.getId()}`),
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ export class ResourceStack {
|
||||
}
|
||||
|
||||
protected async applyResources(resources: string[], extraArgs?: string[]): Promise<string> {
|
||||
const clusterModel = ClusterStore.getInstance().getById(this.cluster.metadata.uid);
|
||||
const clusterModel = ClusterStore.getInstance().getById(this.cluster.getId());
|
||||
|
||||
if (!clusterModel) {
|
||||
throw new Error(`cluster not found`);
|
||||
@ -54,7 +54,7 @@ export class ResourceStack {
|
||||
if (app) {
|
||||
return await new ResourceApplier(clusterModel).kubectlApplyAll(resources, kubectlArgs);
|
||||
} else {
|
||||
const response = await requestMain(clusterKubectlApplyAllHandler, this.cluster.metadata.uid, resources, kubectlArgs);
|
||||
const response = await requestMain(clusterKubectlApplyAllHandler, this.cluster.getId(), resources, kubectlArgs);
|
||||
|
||||
if (response.stderr) {
|
||||
throw new Error(response.stderr);
|
||||
@ -65,7 +65,7 @@ export class ResourceStack {
|
||||
}
|
||||
|
||||
protected async deleteResources(resources: string[], extraArgs?: string[]): Promise<string> {
|
||||
const clusterModel = ClusterStore.getInstance().getById(this.cluster.metadata.uid);
|
||||
const clusterModel = ClusterStore.getInstance().getById(this.cluster.getId());
|
||||
|
||||
if (!clusterModel) {
|
||||
throw new Error(`cluster not found`);
|
||||
@ -78,7 +78,7 @@ export class ResourceStack {
|
||||
if (app) {
|
||||
return await new ResourceApplier(clusterModel).kubectlDeleteAll(resources, kubectlArgs);
|
||||
} else {
|
||||
const response = await requestMain(clusterKubectlDeleteAllHandler, this.cluster.metadata.uid, resources, kubectlArgs);
|
||||
const response = await requestMain(clusterKubectlDeleteAllHandler, this.cluster.getId(), resources, kubectlArgs);
|
||||
|
||||
if (response.stderr) {
|
||||
throw new Error(response.stderr);
|
||||
|
||||
@ -36,7 +36,7 @@ export class CatalogEntityRegistry {
|
||||
}
|
||||
|
||||
getById<T extends CatalogEntity>(id: string): T | undefined {
|
||||
return this.items.find((entity) => entity.metadata.uid === id) as T | undefined;
|
||||
return this.items.find(entity => entity.getId() === id) as T | undefined;
|
||||
}
|
||||
|
||||
getItemsForApiKind<T extends CatalogEntity>(apiVersion: string, kind: string): T[] {
|
||||
|
||||
@ -85,7 +85,7 @@ export class ClusterManager extends Singleton {
|
||||
}
|
||||
|
||||
protected updateEntityFromCluster(cluster: Cluster) {
|
||||
const index = catalogEntityRegistry.items.findIndex((entity) => entity.metadata.uid === cluster.id);
|
||||
const index = catalogEntityRegistry.items.findIndex((entity) => entity.getId() === cluster.id);
|
||||
|
||||
if (index === -1) {
|
||||
return;
|
||||
@ -169,11 +169,11 @@ export class ClusterManager extends Singleton {
|
||||
@action
|
||||
protected syncClustersFromCatalog(entities: KubernetesCluster[]) {
|
||||
for (const entity of entities) {
|
||||
const cluster = this.store.getById(entity.metadata.uid);
|
||||
const cluster = this.store.getById(entity.getId());
|
||||
|
||||
if (!cluster) {
|
||||
const model = {
|
||||
id: entity.metadata.uid,
|
||||
id: entity.getId(),
|
||||
kubeConfigPath: entity.spec.kubeconfigPath,
|
||||
contextName: entity.spec.kubeconfigContext,
|
||||
accessibleNamespaces: entity.spec.accessibleNamespaces ?? [],
|
||||
|
||||
@ -16,7 +16,7 @@ export default {
|
||||
for (const hotbar of hotbars) {
|
||||
for (let i = 0; i < hotbar.items.length; i += 1) {
|
||||
const item = hotbar.items[i];
|
||||
const entity = catalogEntityRegistry.items.find((entity) => entity.metadata.uid === item?.entity.uid);
|
||||
const entity = catalogEntityRegistry.items.find((entity) => entity.getId() === item?.entity.uid);
|
||||
|
||||
if (!entity) {
|
||||
// Clear disabled item
|
||||
|
||||
@ -120,7 +120,7 @@ export class CatalogEntityRegistry {
|
||||
const entity = this.categoryRegistry.getEntityForData(item);
|
||||
|
||||
if (entity) {
|
||||
this._entities.set(entity.metadata.uid, entity);
|
||||
this._entities.set(entity.getId(), entity);
|
||||
} else {
|
||||
this.rawEntities.push(item);
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ import type { CatalogEntity } from "../../api/catalog-entity";
|
||||
import * as components from "./components";
|
||||
|
||||
function getClusterForEntity(entity: CatalogEntity) {
|
||||
return ClusterStore.getInstance().getById(entity.metadata.uid);
|
||||
return ClusterStore.getInstance().getById(entity.getId());
|
||||
}
|
||||
|
||||
export function GeneralSettings({ entity }: EntitySettingViewProps) {
|
||||
|
||||
@ -50,7 +50,7 @@ export function initCatalog({ openCommandDialog }: Dependencies) {
|
||||
context.menuItems.push({
|
||||
title: "Delete",
|
||||
icon: "delete",
|
||||
onClick: () => onClusterDelete(entity.metadata.uid),
|
||||
onClick: () => onClusterDelete(entity.getId()),
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user