1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-07-15 18:58:30 +03:00
parent 693385a0a0
commit ae9afc2894
5 changed files with 24 additions and 32 deletions

View File

@ -11,6 +11,8 @@ import { getFeatures, installFeature, uninstallFeature, upgradeFeature } from ".
import request, { RequestPromiseOptions } from "request-promise-native"
import logger from "./logger"
// fixme: push cluster-state/status info to views on change
enum ClusterStatus {
AccessGranted = 2,
AccessDenied = 1,

View File

@ -11,6 +11,8 @@ import { helmCli } from "./helm/helm-cli"
import { isWindows } from "../common/vars";
import { tracker } from "../common/tracker";
// fixme: terminal doesn't work in ui
export class ShellSession extends EventEmitter {
static shellEnvs: Map<string, any> = new Map()

View File

@ -1,9 +1,11 @@
import path from "path";
import { reaction } from "mobx";
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 logger from "./logger";
import { appName } from "../common/vars";
// fixme: remove switching view delay on first load
@ -33,6 +35,20 @@ export class WindowManager {
// init events and show active cluster view
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() {
@ -65,7 +81,9 @@ export class WindowManager {
async activateView(clusterId: ClusterId) {
const cluster = clusterStore.getById(clusterId);
if (!cluster) return;
if (!cluster) {
return;
}
try {
const activeView = this.activeView;
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);
if (!view) {
const { width, height, x, y } = this.windowState;

View File

@ -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>
)
}
}