1
0
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:
Roman 2020-07-28 11:42:57 +03:00
parent be52b4ad93
commit 4087cf025e
5 changed files with 15 additions and 6 deletions

View File

@ -4,7 +4,7 @@ import filenamify from "filenamify";
import { app, ipcRenderer } from "electron"; import { app, ipcRenderer } from "electron";
import { copyFile, ensureDir, unlink } from "fs-extra"; import { copyFile, ensureDir, unlink } from "fs-extra";
import { action, computed, observable, toJS } from "mobx"; import { action, computed, observable, toJS } from "mobx";
import { appProto } from "./vars"; import { appProto, noClustersHost } from "./vars";
import { BaseStore } from "./base-store"; import { BaseStore } from "./base-store";
import { Cluster, ClusterState } from "../main/cluster"; import { Cluster, ClusterState } from "../main/cluster";
import migrations from "../migrations/cluster-store" import migrations from "../migrations/cluster-store"
@ -200,6 +200,10 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
export const clusterStore = ClusterStore.getInstance<ClusterStore>(); export const clusterStore = ClusterStore.getInstance<ClusterStore>();
export function isNoClustersView() {
return location.hostname === noClustersHost
}
export function getHostedClusterId() { export function getHostedClusterId() {
return location.hostname.split(".")[0]; return location.hostname.split(".")[0];
} }

View File

@ -22,6 +22,9 @@ export const rendererDir = path.join(contextDir, "src/renderer");
export const htmlTemplate = path.resolve(rendererDir, "template.html"); export const htmlTemplate = path.resolve(rendererDir, "template.html");
export const sassCommonVars = path.resolve(rendererDir, "components/vars.scss"); export const sassCommonVars = path.resolve(rendererDir, "components/vars.scss");
// System pages
export const noClustersHost = "no-clusters.localhost"
// Apis // Apis
export const apiPrefix = "/api" // local router apis export const apiPrefix = "/api" // local router apis
export const apiKubePrefix = "/api-kube" // k8s cluster apis export const apiKubePrefix = "/api-kube" // k8s cluster apis

View File

@ -7,7 +7,7 @@ import { openShell } from "./node-shell-session";
import { Router } from "./router" import { Router } from "./router"
import { ClusterManager } from "./cluster-manager" import { ClusterManager } from "./cluster-manager"
import { ContextHandler } from "./context-handler"; import { ContextHandler } from "./context-handler";
import { apiKubePrefix } from "../common/vars"; import { apiKubePrefix, noClustersHost } from "../common/vars";
import logger from "./logger" import logger from "./logger"
export class LensProxy { export class LensProxy {
@ -117,7 +117,7 @@ export class LensProxy {
} }
protected async handleRequest(proxy: httpProxy, req: http.IncomingMessage, res: http.ServerResponse) { 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); this.router.handleStaticFile(req.url, res);
return; return;
} }

View File

@ -3,6 +3,7 @@ import { BrowserWindow, shell } from "electron"
import windowStateKeeper from "electron-window-state" import windowStateKeeper from "electron-window-state"
import type { ClusterId } from "../common/cluster-store"; import type { ClusterId } from "../common/cluster-store";
import { clusterStore } from "../common/cluster-store"; import { clusterStore } from "../common/cluster-store";
import { noClustersHost } from "../common/vars";
import logger from "./logger"; import logger from "./logger";
export class WindowManager { export class WindowManager {
@ -53,7 +54,7 @@ export class WindowManager {
protected handleNoClustersView = async ({ activate = false } = {}) => { protected handleNoClustersView = async ({ activate = false } = {}) => {
if (!this.noClustersWindow) { if (!this.noClustersWindow) {
this.noClustersWindow = this.initClusterView(null); 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) { if (activate) {
this.activeView = this.noClustersWindow; this.activeView = this.noClustersWindow;

View File

@ -9,7 +9,7 @@ import { cssNames, IClassName } from "../../utils";
import { Terminal } from "../dock/terminal"; import { Terminal } from "../dock/terminal";
import { i18nStore } from "../../i18n"; import { i18nStore } from "../../i18n";
import { themeStore } from "../../theme.store"; import { themeStore } from "../../theme.store";
import { clusterStore, getHostedClusterId } from "../../../common/cluster-store"; import { clusterStore, getHostedClusterId, isNoClustersView } from "../../../common/cluster-store";
import { CubeSpinner } from "../spinner"; import { CubeSpinner } from "../spinner";
interface Props { interface Props {
@ -30,7 +30,8 @@ export class ClusterManager extends React.Component<Props> {
@computed get isInactive() { @computed get isInactive() {
const { activeCluster, activeClusterId } = clusterStore; const { activeCluster, activeClusterId } = clusterStore;
const isActivatedBefore = activeCluster?.initialized; const isActivatedBefore = activeCluster?.initialized;
return !isActivatedBefore && activeClusterId !== getHostedClusterId(); if (isNoClustersView() || isActivatedBefore) return;
return activeClusterId !== getHostedClusterId();
} }
render() { render() {