From 5c6a6e14f59c0ff9a750c41fa699a8be521d1a37 Mon Sep 17 00:00:00 2001 From: Lauri Nevala Date: Thu, 11 Mar 2021 18:25:06 +0200 Subject: [PATCH 1/2] Allow to define the path of the shell in app preferences (#2194) Co-authored-by: Sebastian Malton --- src/common/user-store.ts | 1 + src/main/shell-session.ts | 7 +++--- .../components/+preferences/preferences.tsx | 23 ++++++++++++++++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/common/user-store.ts b/src/common/user-store.ts index b0294d9e5a..3df9125224 100644 --- a/src/common/user-store.ts +++ b/src/common/user-store.ts @@ -20,6 +20,7 @@ export interface UserStoreModel { export interface UserPreferences { httpsProxy?: string; + shell?: string; colorTheme?: string; allowUntrustedCAs?: boolean; allowTelemetry?: boolean; diff --git a/src/main/shell-session.ts b/src/main/shell-session.ts index 10a2f9ed47..a8c6a36e72 100644 --- a/src/main/shell-session.ts +++ b/src/main/shell-session.ts @@ -105,10 +105,11 @@ export class ShellSession extends EventEmitter { protected async getShellEnv() { const env = JSON.parse(JSON.stringify(await shellEnv())); const pathStr = [this.kubectlBinDir, this.helmBinDir, process.env.PATH].join(path.delimiter); + const shell = userStore.preferences.shell || process.env.SHELL || process.env.PTYSHELL; if(isWindows) { env["SystemRoot"] = process.env.SystemRoot; - env["PTYSHELL"] = process.env.SHELL || "powershell.exe"; + env["PTYSHELL"] = shell || "powershell.exe"; env["PATH"] = pathStr; env["LENS_SESSION"] = "true"; const lensWslEnv = "KUBECONFIG/up:LENS_SESSION/u"; @@ -118,8 +119,8 @@ export class ShellSession extends EventEmitter { } else { env["WSLENV"] = lensWslEnv; } - } else if(typeof(process.env.SHELL) != "undefined") { - env["PTYSHELL"] = process.env.SHELL; + } else if(shell !== undefined) { + env["PTYSHELL"] = shell; env["PATH"] = pathStr; } else { env["PTYSHELL"] = ""; // blank runs the system default shell diff --git a/src/renderer/components/+preferences/preferences.tsx b/src/renderer/components/+preferences/preferences.tsx index b0442f45b6..2493599b2a 100644 --- a/src/renderer/components/+preferences/preferences.tsx +++ b/src/renderer/components/+preferences/preferences.tsx @@ -6,6 +6,7 @@ import { action, computed, observable } from "mobx"; import { Icon } from "../icon"; import { Select, SelectOption } from "../select"; import { userStore } from "../../../common/user-store"; +import { isWindows } from "../../../common/vars"; import { HelmRepo, repoManager } from "../../../main/helm/helm-repo-manager"; import { Input } from "../input"; import { Checkbox } from "../checkbox"; @@ -25,6 +26,7 @@ export class Preferences extends React.Component { @observable helmRepos: HelmRepo[] = []; @observable helmAddedRepos = observable.map(); @observable httpProxy = userStore.preferences.httpsProxy || ""; + @observable shell = userStore.preferences.shell || ""; @computed get themeOptions(): SelectOption[] { return themeStore.themes.map(theme => ({ @@ -109,6 +111,15 @@ export class Preferences extends React.Component { render() { const { preferences } = userStore; const header =

Preferences

; + let defaultShell = process.env.SHELL || process.env.PTYSHELL; + + if (!defaultShell) { + if (isWindows) { + defaultShell = "powershell.exe"; + } else { + defaultShell = "System default shell"; + } + } return ( @@ -130,7 +141,17 @@ export class Preferences extends React.Component { Proxy is used only for non-cluster communication. - +

Terminal Shell

+ this.shell = v} + onBlur={() => preferences.shell = this.shell} + /> + + The path of the shell that the terminal uses. +

Helm

From 51715b6a8c87b1923584db44d3ec6453771df738 Mon Sep 17 00:00:00 2001 From: Jim Ehrismann <40840436+jim-docker@users.noreply.github.com> Date: Thu, 11 Mar 2021 16:01:50 -0500 Subject: [PATCH 2/2] properly load workspace cluster store outside of render() (#2320) also minor bulletproofing for cluster version string Signed-off-by: Jim Ehrismann --- src/main/cluster.ts | 2 +- .../+landing-page/workspace-overview.tsx | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/cluster.ts b/src/main/cluster.ts index 88ae49d123..8920568c73 100644 --- a/src/main/cluster.ts +++ b/src/main/cluster.ts @@ -252,7 +252,7 @@ export class Cluster implements ClusterModel, ClusterState { * Kubernetes version */ get version(): string { - return String(this.metadata?.version || ""); + return String(this.metadata?.version ?? ""); } constructor(model: ClusterModel) { diff --git a/src/renderer/components/+landing-page/workspace-overview.tsx b/src/renderer/components/+landing-page/workspace-overview.tsx index c095abb31b..96b8f3a791 100644 --- a/src/renderer/components/+landing-page/workspace-overview.tsx +++ b/src/renderer/components/+landing-page/workspace-overview.tsx @@ -10,7 +10,6 @@ import { clusterViewURL } from "../cluster-manager/cluster-view.route"; import { WorkspaceClusterMenu } from "./workspace-cluster-menu"; import { kebabCase } from "lodash"; import { addClusterURL } from "../+add-cluster"; - interface Props { workspace: Workspace; } @@ -24,6 +23,12 @@ enum sortBy { @observer export class WorkspaceOverview extends Component { + private workspaceClusterStore = new WorkspaceClusterStore(this.props.workspace.id); + + componentDidMount() { + this.workspaceClusterStore.loadAll(); + } + showCluster = ({ clusterId }: ClusterItem) => { navigate(clusterViewURL({ params: { clusterId } })); @@ -31,18 +36,15 @@ export class WorkspaceOverview extends Component { render() { const { workspace } = this.props; - const workspaceClusterStore = new WorkspaceClusterStore(workspace.id); - - workspaceClusterStore.loadAll(); return ( Clusters} + renderHeaderTitle="Clusters" isClusterScoped isSearchable={false} isSelectable={false} className="WorkspaceOverview" - store={workspaceClusterStore} + store={this.workspaceClusterStore} sortingCallbacks={{ [sortBy.name]: (item: ClusterItem) => item.name, [sortBy.distribution]: (item: ClusterItem) => item.distribution, @@ -67,7 +69,7 @@ export class WorkspaceOverview extends Component { onAdd: () => navigate(addClusterURL()), }} renderItemMenu={(clusterItem: ClusterItem) => ( - + )} /> );