mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
cluster-view battling -- part 3
Signed-off-by: Roman <ixrock@gmail.com> Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
parent
09c765cab0
commit
2287332f8b
@ -3,14 +3,6 @@ import { ClusterId, clusterStore } from "./cluster-store";
|
||||
import { tracker } from "./tracker";
|
||||
|
||||
export const clusterIpc = {
|
||||
// todo: remove
|
||||
init: createIpcChannel({
|
||||
channel: "cluster:init",
|
||||
handle: async (clusterId: ClusterId) => {
|
||||
return clusterStore.getById(clusterId)?.pushState();
|
||||
},
|
||||
}),
|
||||
|
||||
activate: createIpcChannel({
|
||||
channel: "cluster:activate",
|
||||
handle: async (clusterId: ClusterId = clusterStore.activeClusterId) => {
|
||||
|
||||
@ -64,7 +64,7 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
||||
if (ipcRenderer) {
|
||||
ipcRenderer.on("cluster:state", (event, clusterState: ClusterState) => {
|
||||
this.applyWithoutSync(() => {
|
||||
logger.debug(`[CLUSTER-STORE]: received state update for cluster=${clusterState.id}`, clusterState);
|
||||
logger.info(`[CLUSTER-STORE]: received state update for cluster=${clusterState.id}`, clusterState);
|
||||
const cluster = this.getById(clusterState.id);
|
||||
if (cluster) cluster.updateModel(clusterState)
|
||||
})
|
||||
|
||||
@ -33,7 +33,7 @@ export interface IpcChannelInit {
|
||||
once?: boolean; // todo: add support
|
||||
}
|
||||
|
||||
export function createIpcChannel({ autoBind = false, mode = IpcMode.ASYNC, timeout = 0, handle, channel }: IpcChannelInit) {
|
||||
export function createIpcChannel({ autoBind = true, mode = IpcMode.ASYNC, timeout = 0, handle, channel }: IpcChannelInit) {
|
||||
channel = `${mode}:${channel}`
|
||||
|
||||
const ipcChannel = {
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import "../common/cluster-ipc";
|
||||
import type http from "http"
|
||||
import { autorun } from "mobx";
|
||||
import { ClusterId, clusterStore } from "../common/cluster-store"
|
||||
import { Cluster } from "./cluster"
|
||||
import { clusterIpc } from "../common/cluster-ipc";
|
||||
import logger from "./logger";
|
||||
|
||||
export class ClusterManager {
|
||||
@ -29,13 +29,6 @@ export class ClusterManager {
|
||||
}, {
|
||||
delay: 250
|
||||
});
|
||||
|
||||
// listen for ipc-events that must/can be handled *only* in main-process (nodeIntegration=true)
|
||||
clusterIpc.activate.handleInMain();
|
||||
clusterIpc.disconnect.handleInMain();
|
||||
clusterIpc.installFeature.handleInMain();
|
||||
clusterIpc.uninstallFeature.handleInMain();
|
||||
clusterIpc.upgradeFeature.handleInMain();
|
||||
}
|
||||
|
||||
stop() {
|
||||
|
||||
@ -31,14 +31,13 @@ import { isAllowedResource } from "../../common/rbac";
|
||||
import { ClusterSettings, clusterSettingsRoute } from "./+cluster-settings";
|
||||
import { ErrorBoundary } from "./error-boundary";
|
||||
import { Terminal } from "./dock/terminal";
|
||||
import { getHostedClusterId } from "../../common/cluster-store";
|
||||
import { clusterIpc } from "../../common/cluster-ipc";
|
||||
import { getHostedCluster } from "../../common/cluster-store";
|
||||
|
||||
@observer
|
||||
export class App extends React.Component {
|
||||
static async init() {
|
||||
await clusterIpc.init.invokeFromRenderer(getHostedClusterId())
|
||||
await Terminal.preloadFonts()
|
||||
await getHostedCluster().whenInitialized;
|
||||
}
|
||||
|
||||
get startURL() {
|
||||
|
||||
@ -44,7 +44,7 @@ export class ClusterStatus extends React.Component<Props> {
|
||||
error: res.error,
|
||||
});
|
||||
})
|
||||
await this.refreshClusterState();
|
||||
// await this.refreshClusterState();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
@ -39,8 +39,10 @@ export class ClusterView extends React.Component {
|
||||
webview.setAttribute("src", `//${clusterId}.${location.host}`)
|
||||
webview.setAttribute("nodeintegration", "true")
|
||||
webview.setAttribute("enableremotemodule", "true")
|
||||
// webview.addEventListener("did-start-loading", () => {
|
||||
// webview.openDevTools();
|
||||
// });
|
||||
webview.addEventListener("did-finish-load", () => {
|
||||
webview.openDevTools();
|
||||
webview.classList.add("loaded");
|
||||
ClusterView.isLoaded.set(clusterId, true)
|
||||
});
|
||||
@ -52,9 +54,11 @@ export class ClusterView extends React.Component {
|
||||
}
|
||||
|
||||
activateView = async (clusterId: ClusterId) => {
|
||||
const cluster = clusterStore.getById(clusterId);
|
||||
const view = ClusterView.views.get(clusterId);
|
||||
const isLoaded = ClusterView.isLoaded.has(clusterId);
|
||||
if (view && isLoaded && this.placeholder) {
|
||||
cluster.pushState(); // fixme
|
||||
this.placeholder.replaceWith(view);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user