mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Move activating cluster into injectable IPC (#7355)
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
121a50ecf3
commit
497f63fde6
12 files changed
+122
-38
No files matched your search
@@ -17,11 +17,12 @@ import { Icon } from "../icon";
|
||||
import { Spinner } from "../spinner";
|
||||
import type { KubeAuthUpdate } from "../../../common/cluster-types";
|
||||
import type { CatalogEntityRegistry } from "../../api/catalog/entity/registry";
|
||||
import { requestClusterActivation } from "../../ipc";
|
||||
import type { NavigateToEntitySettings } from "../../../common/front-end-routing/routes/entity-settings/navigate-to-entity-settings.injectable";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import navigateToEntitySettingsInjectable from "../../../common/front-end-routing/routes/entity-settings/navigate-to-entity-settings.injectable";
|
||||
import catalogEntityRegistryInjectable from "../../api/catalog/entity/registry.injectable";
|
||||
import type { RequestClusterActivation } from "../../../features/cluster/activation/common/request-token";
|
||||
import requestClusterActivationInjectable from "../../../features/cluster/activation/renderer/request-activation.injectable";
|
||||
|
||||
export interface ClusterStatusProps {
|
||||
className?: IClassName;
|
||||
@@ -31,6 +32,7 @@ export interface ClusterStatusProps {
|
||||
interface Dependencies {
|
||||
navigateToEntitySettings: NavigateToEntitySettings;
|
||||
entityRegistry: CatalogEntityRegistry;
|
||||
requestClusterActivation: RequestClusterActivation;
|
||||
}
|
||||
|
||||
@observer
|
||||
@@ -83,7 +85,10 @@ class NonInjectedClusterStatus extends React.Component<ClusterStatusProps & Depe
|
||||
this.isReconnecting = true;
|
||||
|
||||
try {
|
||||
await requestClusterActivation(this.cluster.id, true);
|
||||
await this.props.requestClusterActivation({
|
||||
clusterId: this.cluster.id,
|
||||
force: true,
|
||||
});
|
||||
} catch (error) {
|
||||
this.authOutput.push({
|
||||
message: String(error),
|
||||
@@ -173,5 +178,6 @@ export const ClusterStatus = withInjectables<Dependencies, ClusterStatusProps>(N
|
||||
...props,
|
||||
navigateToEntitySettings: di.inject(navigateToEntitySettingsInjectable),
|
||||
entityRegistry: di.inject(catalogEntityRegistryInjectable),
|
||||
requestClusterActivation: di.inject(requestClusterActivationInjectable),
|
||||
}),
|
||||
});
|
||||
@@ -11,7 +11,6 @@ import { disposeOnUnmount, observer } from "mobx-react";
|
||||
import { ClusterStatus } from "./cluster-status";
|
||||
import type { ClusterFrameHandler } from "./cluster-frame-handler";
|
||||
import type { Cluster } from "../../../common/cluster/cluster";
|
||||
import { requestClusterActivation } from "../../ipc";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import type { NavigateToCatalog } from "../../../common/front-end-routing/routes/catalog/navigate-to-catalog.injectable";
|
||||
import navigateToCatalogInjectable from "../../../common/front-end-routing/routes/catalog/navigate-to-catalog.injectable";
|
||||
@@ -21,6 +20,8 @@ import type { CatalogEntityRegistry } from "../../api/catalog/entity/registry";
|
||||
import catalogEntityRegistryInjectable from "../../api/catalog/entity/registry.injectable";
|
||||
import type { GetClusterById } from "../../../common/cluster-store/get-by-id.injectable";
|
||||
import getClusterByIdInjectable from "../../../common/cluster-store/get-by-id.injectable";
|
||||
import type { RequestClusterActivation } from "../../../features/cluster/activation/common/request-token";
|
||||
import requestClusterActivationInjectable from "../../../features/cluster/activation/renderer/request-activation.injectable";
|
||||
|
||||
interface Dependencies {
|
||||
clusterId: IComputedValue<string>;
|
||||
@@ -28,6 +29,7 @@ interface Dependencies {
|
||||
navigateToCatalog: NavigateToCatalog;
|
||||
entityRegistry: CatalogEntityRegistry;
|
||||
getClusterById: GetClusterById;
|
||||
requestClusterActivation: RequestClusterActivation;
|
||||
}
|
||||
|
||||
@observer
|
||||
@@ -83,7 +85,7 @@ class NonInjectedClusterView extends React.Component<Dependencies> {
|
||||
|
||||
this.props.clusterFrames.setVisibleCluster(clusterId);
|
||||
this.props.clusterFrames.initView(clusterId);
|
||||
requestClusterActivation(clusterId, false); // activate and fetch cluster's state from main
|
||||
this.props.requestClusterActivation({ clusterId });
|
||||
this.props.entityRegistry.activeEntity = clusterId;
|
||||
}, {
|
||||
fireImmediately: true,
|
||||
@@ -117,6 +119,7 @@ export const ClusterView = withInjectables<Dependencies>(NonInjectedClusterView,
|
||||
clusterFrames: di.inject(clusterFrameHandlerInjectable),
|
||||
entityRegistry: di.inject(catalogEntityRegistryInjectable),
|
||||
getClusterById: di.inject(getClusterByIdInjectable),
|
||||
requestClusterActivation: di.inject(requestClusterActivationInjectable),
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { clusterActivateHandler, clusterDisconnectHandler, clusterSetFrameIdHandler, clusterStates } from "../../common/ipc/cluster";
|
||||
import { clusterDisconnectHandler, clusterSetFrameIdHandler, clusterStates } from "../../common/ipc/cluster";
|
||||
import type { ClusterId, ClusterState } from "../../common/cluster-types";
|
||||
import { windowActionHandleChannel, windowLocationChangedChannel, windowOpenAppMenuAsContextMenuChannel, type WindowAction } from "../../common/ipc/window";
|
||||
import { extensionDiscoveryStateChannel, extensionLoaderFromMainChannel } from "../../common/ipc/extension-handling";
|
||||
@@ -46,10 +46,6 @@ export function requestSetClusterFrameId(clusterId: ClusterId): Promise<void> {
|
||||
return requestMain(clusterSetFrameIdHandler, clusterId);
|
||||
}
|
||||
|
||||
export function requestClusterActivation(clusterId: ClusterId, force?: boolean): Promise<void> {
|
||||
return requestMain(clusterActivateHandler, clusterId, force);
|
||||
}
|
||||
|
||||
export function requestClusterDisconnection(clusterId: ClusterId, force?: boolean): Promise<void> {
|
||||
return requestMain(clusterDisconnectHandler, clusterId, force);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user