mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
added tracking cluster-manager's ipc events
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
f474a20904
commit
cf00debb33
@ -5,6 +5,7 @@ import { clusterStore } from "./cluster-store"
|
|||||||
export type WorkspaceId = string;
|
export type WorkspaceId = string;
|
||||||
|
|
||||||
export interface WorkspaceStoreModel {
|
export interface WorkspaceStoreModel {
|
||||||
|
currentWorkspace?: WorkspaceId; // last visited/activated
|
||||||
workspaces: Workspace[]
|
workspaces: Workspace[]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,6 +19,7 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
|
|||||||
static readonly defaultId: WorkspaceId = "default"
|
static readonly defaultId: WorkspaceId = "default"
|
||||||
|
|
||||||
protected data: WorkspaceStoreModel = {
|
protected data: WorkspaceStoreModel = {
|
||||||
|
currentWorkspace: WorkspaceStore.defaultId,
|
||||||
workspaces: [{
|
workspaces: [{
|
||||||
id: WorkspaceStore.defaultId,
|
id: WorkspaceStore.defaultId,
|
||||||
name: "default"
|
name: "default"
|
||||||
@ -42,6 +44,11 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
|
|||||||
return this.workspaces.findIndex(workspace => workspace.id === id);
|
return this.workspaces.findIndex(workspace => workspace.id === id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
setCurrent(id: WorkspaceId) {
|
||||||
|
this.data.currentWorkspace = id;
|
||||||
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
public saveWorkspace(newWorkspace: Workspace) {
|
public saveWorkspace(newWorkspace: Workspace) {
|
||||||
const workspace = this.getById(newWorkspace.id);
|
const workspace = this.getById(newWorkspace.id);
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import logger from "./logger"
|
|||||||
import { onMessages } from "../common/ipc-helpers";
|
import { onMessages } from "../common/ipc-helpers";
|
||||||
import { ClusterIpcMessage } from "../common/ipc-messages";
|
import { ClusterIpcMessage } from "../common/ipc-messages";
|
||||||
import { FeatureInstallRequest } from "./feature";
|
import { FeatureInstallRequest } from "./feature";
|
||||||
|
import { tracker } from "../common/tracker";
|
||||||
|
|
||||||
export interface ClusterIconUpload {
|
export interface ClusterIconUpload {
|
||||||
clusterId: string;
|
clusterId: string;
|
||||||
@ -107,44 +108,51 @@ export class ClusterManager {
|
|||||||
protected listenIpcEvents() {
|
protected listenIpcEvents() {
|
||||||
onMessages({
|
onMessages({
|
||||||
[ClusterIpcMessage.CLUSTER_ADD]: async (model: ClusterModel): Promise<boolean> => {
|
[ClusterIpcMessage.CLUSTER_ADD]: async (model: ClusterModel): Promise<boolean> => {
|
||||||
|
tracker.event("cluster", "add");
|
||||||
await this.addCluster(model);
|
await this.addCluster(model);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[ClusterIpcMessage.CLUSTER_STOP]: (clusterId: ClusterId) => {
|
[ClusterIpcMessage.CLUSTER_STOP]: (clusterId: ClusterId) => {
|
||||||
|
tracker.event("cluster", "stop");
|
||||||
this.getCluster(clusterId)?.stopServer();
|
this.getCluster(clusterId)?.stopServer();
|
||||||
},
|
},
|
||||||
[ClusterIpcMessage.CLUSTER_REFRESH]: (clusterId: ClusterId) => {
|
|
||||||
this.getCluster(clusterId)?.refreshCluster();
|
|
||||||
},
|
|
||||||
[ClusterIpcMessage.CLUSTER_REMOVE]: (clusterId: ClusterId) => {
|
[ClusterIpcMessage.CLUSTER_REMOVE]: (clusterId: ClusterId) => {
|
||||||
|
tracker.event("cluster", "remove");
|
||||||
this.removeCluster(clusterId);
|
this.removeCluster(clusterId);
|
||||||
},
|
},
|
||||||
[ClusterIpcMessage.CLUSTER_REMOVE_WORKSPACE]: (workspaceId: ClusterId) => {
|
[ClusterIpcMessage.CLUSTER_REMOVE_WORKSPACE]: (workspaceId: ClusterId) => {
|
||||||
this.removeAllByWorkspace(workspaceId);
|
this.removeAllByWorkspace(workspaceId);
|
||||||
},
|
},
|
||||||
|
[ClusterIpcMessage.CLUSTER_REFRESH]: (clusterId: ClusterId) => {
|
||||||
|
this.getCluster(clusterId)?.refreshCluster();
|
||||||
|
},
|
||||||
[ClusterIpcMessage.CLUSTER_EVENTS]: async (clusterId: ClusterId): Promise<number> => {
|
[ClusterIpcMessage.CLUSTER_EVENTS]: async (clusterId: ClusterId): Promise<number> => {
|
||||||
return await this.getCluster(clusterId)?.getEventCount() || 0;
|
return await this.getCluster(clusterId)?.getEventCount() || 0;
|
||||||
},
|
},
|
||||||
// todo: check feature failures
|
// todo: check feature failures
|
||||||
[ClusterIpcMessage.FEATURE_INSTALL]: ({ clusterId, name, config }: FeatureInstallRequest) => {
|
[ClusterIpcMessage.FEATURE_INSTALL]: ({ clusterId, name, config }: FeatureInstallRequest) => {
|
||||||
|
tracker.event("cluster", "install-feature")
|
||||||
return this.getCluster(clusterId)?.installFeature(name, config)
|
return this.getCluster(clusterId)?.installFeature(name, config)
|
||||||
},
|
},
|
||||||
[ClusterIpcMessage.FEATURE_UPGRADE]: ({ clusterId, name, config }: FeatureInstallRequest) => {
|
[ClusterIpcMessage.FEATURE_UPGRADE]: ({ clusterId, name, config }: FeatureInstallRequest) => {
|
||||||
|
tracker.event("cluster", "upgrade-feature")
|
||||||
return this.getCluster(clusterId)?.upgradeFeature(name, config)
|
return this.getCluster(clusterId)?.upgradeFeature(name, config)
|
||||||
},
|
},
|
||||||
[ClusterIpcMessage.FEATURE_REMOVE]: ({ clusterId, name }: FeatureInstallRequest) => {
|
[ClusterIpcMessage.FEATURE_REMOVE]: ({ clusterId, name }: FeatureInstallRequest) => {
|
||||||
|
tracker.event("cluster", "uninstall-feature")
|
||||||
return this.getCluster(clusterId)?.uninstallFeature(name);
|
return this.getCluster(clusterId)?.uninstallFeature(name);
|
||||||
},
|
},
|
||||||
[ClusterIpcMessage.ICON_SAVE]: async ({ clusterId, name, path }: ClusterIconUpload) => {
|
[ClusterIpcMessage.ICON_SAVE]: async ({ clusterId, name, path }: ClusterIconUpload) => {
|
||||||
|
tracker.event("cluster", "upload-icon");
|
||||||
const cluster = this.getCluster(clusterId);
|
const cluster = this.getCluster(clusterId);
|
||||||
if (!cluster) return false;
|
if (!cluster) return false;
|
||||||
cluster.preferences.icon = await this.uploadClusterIcon(cluster, name, path);
|
cluster.preferences.icon = await this.uploadClusterIcon(cluster, name, path);
|
||||||
},
|
},
|
||||||
// todo: remove current file icon ?
|
|
||||||
[ClusterIpcMessage.ICON_RESET]: async (clusterId: ClusterId) => {
|
[ClusterIpcMessage.ICON_RESET]: async (clusterId: ClusterId) => {
|
||||||
|
tracker.event("cluster", "reset-icon")
|
||||||
const cluster = this.getCluster(clusterId);
|
const cluster = this.getCluster(clusterId);
|
||||||
if (!cluster) return false;
|
if (!cluster) return false;
|
||||||
cluster.preferences.icon = null;
|
cluster.preferences.icon = null; // todo: remove current file-icon ?
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
timeout: 2000,
|
timeout: 2000,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user