mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
clean up
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
693385a0a0
commit
ae9afc2894
@ -11,6 +11,8 @@ import { getFeatures, installFeature, uninstallFeature, upgradeFeature } from ".
|
|||||||
import request, { RequestPromiseOptions } from "request-promise-native"
|
import request, { RequestPromiseOptions } from "request-promise-native"
|
||||||
import logger from "./logger"
|
import logger from "./logger"
|
||||||
|
|
||||||
|
// fixme: push cluster-state/status info to views on change
|
||||||
|
|
||||||
enum ClusterStatus {
|
enum ClusterStatus {
|
||||||
AccessGranted = 2,
|
AccessGranted = 2,
|
||||||
AccessDenied = 1,
|
AccessDenied = 1,
|
||||||
|
|||||||
@ -11,6 +11,8 @@ import { helmCli } from "./helm/helm-cli"
|
|||||||
import { isWindows } from "../common/vars";
|
import { isWindows } from "../common/vars";
|
||||||
import { tracker } from "../common/tracker";
|
import { tracker } from "../common/tracker";
|
||||||
|
|
||||||
|
// fixme: terminal doesn't work in ui
|
||||||
|
|
||||||
export class ShellSession extends EventEmitter {
|
export class ShellSession extends EventEmitter {
|
||||||
static shellEnvs: Map<string, any> = new Map()
|
static shellEnvs: Map<string, any> = new Map()
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
|
import path from "path";
|
||||||
import { reaction } from "mobx";
|
import { reaction } from "mobx";
|
||||||
import { BrowserWindow, shell } from "electron"
|
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 logger from "./logger";
|
import logger from "./logger";
|
||||||
|
import { appName } from "../common/vars";
|
||||||
|
|
||||||
// fixme: remove switching view delay on first load
|
// fixme: remove switching view delay on first load
|
||||||
|
|
||||||
@ -33,6 +35,20 @@ export class WindowManager {
|
|||||||
|
|
||||||
// init events and show active cluster view
|
// init events and show active cluster view
|
||||||
this.bindEvents();
|
this.bindEvents();
|
||||||
|
|
||||||
|
// handle initial view load without clusters
|
||||||
|
if (!clusterStore.clusters.size) {
|
||||||
|
this.initNoClustersView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// fixme: first run without clusters
|
||||||
|
protected async initNoClustersView() {
|
||||||
|
const htmlView = path.join(__dirname, `${appName}.html`);
|
||||||
|
const view = this.initView(undefined);
|
||||||
|
await view.loadFile(htmlView);
|
||||||
|
view.show();
|
||||||
|
this.hideSplash();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bindEvents() {
|
protected bindEvents() {
|
||||||
@ -65,7 +81,9 @@ export class WindowManager {
|
|||||||
|
|
||||||
async activateView(clusterId: ClusterId) {
|
async activateView(clusterId: ClusterId) {
|
||||||
const cluster = clusterStore.getById(clusterId);
|
const cluster = clusterStore.getById(clusterId);
|
||||||
if (!cluster) return;
|
if (!cluster) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const activeView = this.activeView;
|
const activeView = this.activeView;
|
||||||
const isLoadedBefore = !!this.getView(clusterId);
|
const isLoadedBefore = !!this.getView(clusterId);
|
||||||
@ -98,7 +116,7 @@ export class WindowManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected initView(clusterId: ClusterId) {
|
protected initView(clusterId: ClusterId): BrowserWindow {
|
||||||
let view = this.getView(clusterId);
|
let view = this.getView(clusterId);
|
||||||
if (!view) {
|
if (!view) {
|
||||||
const { width, height, x, y } = this.windowState;
|
const { width, height, x, y } = this.windowState;
|
||||||
|
|||||||
@ -1,30 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
import { observer } from "mobx-react";
|
|
||||||
import { ClusterId, clusterStore } from "../../../common/cluster-store";
|
|
||||||
import { WorkspaceId, workspaceStore } from "../../../common/workspace-store";
|
|
||||||
|
|
||||||
export const clusterContext = React.createContext(getClusterContext());
|
|
||||||
|
|
||||||
export interface ClusterContextValue {
|
|
||||||
workspaceId: WorkspaceId;
|
|
||||||
clusterId?: ClusterId;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getClusterContext(): ClusterContextValue {
|
|
||||||
return {
|
|
||||||
clusterId: clusterStore.activeClusterId,
|
|
||||||
workspaceId: workspaceStore.currentWorkspaceId,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@observer
|
|
||||||
export class ClusterContext extends React.Component {
|
|
||||||
render() {
|
|
||||||
const { Provider } = clusterContext;
|
|
||||||
return (
|
|
||||||
<Provider value={getClusterContext()}>
|
|
||||||
{this.props.children}
|
|
||||||
</Provider>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user