mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix: infinite spinner with no-clusters view
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
be52b4ad93
commit
4087cf025e
@ -4,7 +4,7 @@ import filenamify from "filenamify";
|
||||
import { app, ipcRenderer } from "electron";
|
||||
import { copyFile, ensureDir, unlink } from "fs-extra";
|
||||
import { action, computed, observable, toJS } from "mobx";
|
||||
import { appProto } from "./vars";
|
||||
import { appProto, noClustersHost } from "./vars";
|
||||
import { BaseStore } from "./base-store";
|
||||
import { Cluster, ClusterState } from "../main/cluster";
|
||||
import migrations from "../migrations/cluster-store"
|
||||
@ -200,6 +200,10 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
||||
|
||||
export const clusterStore = ClusterStore.getInstance<ClusterStore>();
|
||||
|
||||
export function isNoClustersView() {
|
||||
return location.hostname === noClustersHost
|
||||
}
|
||||
|
||||
export function getHostedClusterId() {
|
||||
return location.hostname.split(".")[0];
|
||||
}
|
||||
|
||||
@ -22,6 +22,9 @@ export const rendererDir = path.join(contextDir, "src/renderer");
|
||||
export const htmlTemplate = path.resolve(rendererDir, "template.html");
|
||||
export const sassCommonVars = path.resolve(rendererDir, "components/vars.scss");
|
||||
|
||||
// System pages
|
||||
export const noClustersHost = "no-clusters.localhost"
|
||||
|
||||
// Apis
|
||||
export const apiPrefix = "/api" // local router apis
|
||||
export const apiKubePrefix = "/api-kube" // k8s cluster apis
|
||||
|
||||
@ -7,7 +7,7 @@ import { openShell } from "./node-shell-session";
|
||||
import { Router } from "./router"
|
||||
import { ClusterManager } from "./cluster-manager"
|
||||
import { ContextHandler } from "./context-handler";
|
||||
import { apiKubePrefix } from "../common/vars";
|
||||
import { apiKubePrefix, noClustersHost } from "../common/vars";
|
||||
import logger from "./logger"
|
||||
|
||||
export class LensProxy {
|
||||
@ -117,7 +117,7 @@ export class LensProxy {
|
||||
}
|
||||
|
||||
protected async handleRequest(proxy: httpProxy, req: http.IncomingMessage, res: http.ServerResponse) {
|
||||
if (req.headers.host.split(":")[0] === "no-clusters.localhost") {
|
||||
if (req.headers.host.split(":")[0] === noClustersHost) {
|
||||
this.router.handleStaticFile(req.url, res);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ import { BrowserWindow, shell } from "electron"
|
||||
import windowStateKeeper from "electron-window-state"
|
||||
import type { ClusterId } from "../common/cluster-store";
|
||||
import { clusterStore } from "../common/cluster-store";
|
||||
import { noClustersHost } from "../common/vars";
|
||||
import logger from "./logger";
|
||||
|
||||
export class WindowManager {
|
||||
@ -53,7 +54,7 @@ export class WindowManager {
|
||||
protected handleNoClustersView = async ({ activate = false } = {}) => {
|
||||
if (!this.noClustersWindow) {
|
||||
this.noClustersWindow = this.initClusterView(null);
|
||||
await this.noClustersWindow.loadURL(`http://no-clusters.localhost:${this.proxyPort}`);
|
||||
await this.noClustersWindow.loadURL(`http://${noClustersHost}:${this.proxyPort}`);
|
||||
}
|
||||
if (activate) {
|
||||
this.activeView = this.noClustersWindow;
|
||||
|
||||
@ -9,7 +9,7 @@ import { cssNames, IClassName } from "../../utils";
|
||||
import { Terminal } from "../dock/terminal";
|
||||
import { i18nStore } from "../../i18n";
|
||||
import { themeStore } from "../../theme.store";
|
||||
import { clusterStore, getHostedClusterId } from "../../../common/cluster-store";
|
||||
import { clusterStore, getHostedClusterId, isNoClustersView } from "../../../common/cluster-store";
|
||||
import { CubeSpinner } from "../spinner";
|
||||
|
||||
interface Props {
|
||||
@ -30,7 +30,8 @@ export class ClusterManager extends React.Component<Props> {
|
||||
@computed get isInactive() {
|
||||
const { activeCluster, activeClusterId } = clusterStore;
|
||||
const isActivatedBefore = activeCluster?.initialized;
|
||||
return !isActivatedBefore && activeClusterId !== getHostedClusterId();
|
||||
if (isNoClustersView() || isActivatedBefore) return;
|
||||
return activeClusterId !== getHostedClusterId();
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user