diff --git a/src/common/workspace-store.ts b/src/common/workspace-store.ts index fd8f302235..dd84e17487 100644 --- a/src/common/workspace-store.ts +++ b/src/common/workspace-store.ts @@ -5,6 +5,7 @@ import { clusterStore } from "./cluster-store" export type WorkspaceId = string; export interface WorkspaceStoreModel { + currentWorkspace?: WorkspaceId; // last visited/activated workspaces: Workspace[] } @@ -18,6 +19,7 @@ export class WorkspaceStore extends BaseStore { static readonly defaultId: WorkspaceId = "default" protected data: WorkspaceStoreModel = { + currentWorkspace: WorkspaceStore.defaultId, workspaces: [{ id: WorkspaceStore.defaultId, name: "default" @@ -42,6 +44,11 @@ export class WorkspaceStore extends BaseStore { return this.workspaces.findIndex(workspace => workspace.id === id); } + @action + setCurrent(id: WorkspaceId) { + this.data.currentWorkspace = id; + } + @action public saveWorkspace(newWorkspace: Workspace) { const workspace = this.getById(newWorkspace.id); diff --git a/src/main/cluster-manager.ts b/src/main/cluster-manager.ts index 3c5a1d5650..a092ef4d24 100644 --- a/src/main/cluster-manager.ts +++ b/src/main/cluster-manager.ts @@ -12,6 +12,7 @@ import logger from "./logger" import { onMessages } from "../common/ipc-helpers"; import { ClusterIpcMessage } from "../common/ipc-messages"; import { FeatureInstallRequest } from "./feature"; +import { tracker } from "../common/tracker"; export interface ClusterIconUpload { clusterId: string; @@ -107,44 +108,51 @@ export class ClusterManager { protected listenIpcEvents() { onMessages({ [ClusterIpcMessage.CLUSTER_ADD]: async (model: ClusterModel): Promise => { + tracker.event("cluster", "add"); await this.addCluster(model); return true; }, [ClusterIpcMessage.CLUSTER_STOP]: (clusterId: ClusterId) => { + tracker.event("cluster", "stop"); this.getCluster(clusterId)?.stopServer(); }, - [ClusterIpcMessage.CLUSTER_REFRESH]: (clusterId: ClusterId) => { - this.getCluster(clusterId)?.refreshCluster(); - }, [ClusterIpcMessage.CLUSTER_REMOVE]: (clusterId: ClusterId) => { + tracker.event("cluster", "remove"); this.removeCluster(clusterId); }, [ClusterIpcMessage.CLUSTER_REMOVE_WORKSPACE]: (workspaceId: ClusterId) => { this.removeAllByWorkspace(workspaceId); }, + [ClusterIpcMessage.CLUSTER_REFRESH]: (clusterId: ClusterId) => { + this.getCluster(clusterId)?.refreshCluster(); + }, [ClusterIpcMessage.CLUSTER_EVENTS]: async (clusterId: ClusterId): Promise => { return await this.getCluster(clusterId)?.getEventCount() || 0; }, // todo: check feature failures [ClusterIpcMessage.FEATURE_INSTALL]: ({ clusterId, name, config }: FeatureInstallRequest) => { + tracker.event("cluster", "install-feature") return this.getCluster(clusterId)?.installFeature(name, config) }, [ClusterIpcMessage.FEATURE_UPGRADE]: ({ clusterId, name, config }: FeatureInstallRequest) => { + tracker.event("cluster", "upgrade-feature") return this.getCluster(clusterId)?.upgradeFeature(name, config) }, [ClusterIpcMessage.FEATURE_REMOVE]: ({ clusterId, name }: FeatureInstallRequest) => { + tracker.event("cluster", "uninstall-feature") return this.getCluster(clusterId)?.uninstallFeature(name); }, [ClusterIpcMessage.ICON_SAVE]: async ({ clusterId, name, path }: ClusterIconUpload) => { + tracker.event("cluster", "upload-icon"); const cluster = this.getCluster(clusterId); if (!cluster) return false; cluster.preferences.icon = await this.uploadClusterIcon(cluster, name, path); }, - // todo: remove current file icon ? [ClusterIpcMessage.ICON_RESET]: async (clusterId: ClusterId) => { + tracker.event("cluster", "reset-icon") const cluster = this.getCluster(clusterId); if (!cluster) return false; - cluster.preferences.icon = null; + cluster.preferences.icon = null; // todo: remove current file-icon ? }, }, { timeout: 2000,