Cleanup 'Cluster' to remove environment specific details (#6951)

- requestNamespaceListPermissions is infallable so no need to have the extra try/catch

- Refactor isMetricHidden method away from Cluster

- Refactor shouldShowResource out of Cluster

- Refactor isInLocalKubeconfig out of Cluster

- Remove depecrated and unused workspace from Cluster

- Refactor out kubectl as a dependency of Cluster

- Remove from cluster getter used only once

- Split out ClusterConnection from Cluster

- Also split out KubeAuthProxyServer from ContextHandler

- Rename ContextHandler to PrometheusHandler

- Cleanup onNetworkOffline/Online impls within ClusterManager

- Remove annotations from ClusterConnection

- Remove mobx annotations from Cluster

- Rename loadConfigFromFileInjectable

- Remove all uses of dead createClusterInjectionToken

- Fix type errors related to broadcastConnectionUpdate

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2023-03-10 09:37:39 +02:00
1 parent e6d6d1d8f7
commit ad9bafe2a5
133 files changed
+2544 -1961

No files matched your search

@@ -11,6 +11,7 @@ import applicationMenuItemCompositeInjectable from "../../../../features/applica
import emitAppEventInjectable from "../../../../common/app-event-bus/emit-event.injectable";
import getClusterByIdInjectable from "../../../../common/cluster-store/get-by-id.injectable";
import pushCatalogToRendererInjectable from "../../../catalog-sync-to-renderer/push-catalog-to-renderer.injectable";
import clusterConnectionInjectable from "../../../cluster/cluster-connection.injectable";
const setupIpcMainHandlersInjectable = getInjectable({
id: "setup-ipc-main-handlers",
@@ -34,6 +35,7 @@ const setupIpcMainHandlersInjectable = getInjectable({
clusterStore,
emitAppEvent,
getClusterById,
getClusterConnection: (cluster) => di.inject(clusterConnectionInjectable, cluster),
});
},
};
@@ -18,12 +18,15 @@ import { getApplicationMenuTemplate } from "../../../../features/application-men
import type { MenuItemRoot } from "../../../../features/application-menu/main/application-menu-item-composite.injectable";
import type { EmitAppEvent } from "../../../../common/app-event-bus/emit-event.injectable";
import type { GetClusterById } from "../../../../common/cluster-store/get-by-id.injectable";
import type { Cluster } from "../../../../common/cluster/cluster";
import type { ClusterConnection } from "../../../cluster/cluster-connection.injectable";
interface Dependencies {
applicationMenuItemComposite: IComputedValue<Composite<ApplicationMenuItemTypes | MenuItemRoot>>;
clusterStore: ClusterStore;
emitAppEvent: EmitAppEvent;
getClusterById: GetClusterById;
pushCatalogToRenderer: () => void;
getClusterConnection: (cluster: Cluster) => ClusterConnection;
}
export const setupIpcMainHandlers = ({
@@ -32,10 +35,18 @@ export const setupIpcMainHandlers = ({
emitAppEvent,
getClusterById,
pushCatalogToRenderer,
getClusterConnection,
}: Dependencies) => {
ipcMainHandle(clusterActivateHandler, (event, clusterId: ClusterId, force = false) => {
return getClusterById(clusterId)
?.activate(force);
ipcMainHandle(clusterActivateHandler, async (event, clusterId: ClusterId, force = false) => {
const cluster = getClusterById(clusterId);
if (!cluster) {
return;
}
const clusterConnection = getClusterConnection(cluster);
await clusterConnection.activate(force);
});
ipcMainHandle(clusterSetFrameIdHandler, (event: IpcMainInvokeEvent, clusterId: ClusterId) => {
@@ -51,10 +62,14 @@ export const setupIpcMainHandlers = ({
emitAppEvent({ name: "cluster", action: "stop" });
const cluster = getClusterById(clusterId);
if (cluster) {
cluster.disconnect();
clusterFrameMap.delete(cluster.id);
if (!cluster) {
return;
}
const clusterConnection = getClusterConnection(cluster);
clusterConnection.disconnect();
clusterFrameMap.delete(cluster.id);
});
ipcMainHandle(windowActionHandleChannel, (event, action) => handleWindowAction(action));