import "./preferences.scss"; import React from "react"; import moment from "moment-timezone"; import { computed, observable, reaction } from "mobx"; import { disposeOnUnmount, observer } from "mobx-react"; import { userStore } from "../../../common/user-store"; import { isWindows } from "../../../common/vars"; import { appPreferenceRegistry, RegisteredAppPreference } from "../../../extensions/registries/app-preference-registry"; import { themeStore } from "../../theme.store"; import { Input } from "../input"; import { PageLayout } from "../layout/page-layout"; import { SubTitle } from "../layout/sub-title"; import { Select, SelectOption } from "../select"; import { HelmCharts } from "./helm-charts"; import { KubectlBinaries } from "./kubectl-binaries"; import { navigation } from "../../navigation"; import { Tab, Tabs } from "../tabs"; import { FormSwitch, Switcher } from "../switch"; enum Pages { Application = "application", Proxy = "proxy", Kubernetes = "kubernetes", Telemetry = "telemetry", Extensions = "extensions", Other = "other" } @observer export class Preferences extends React.Component { @observable httpProxy = userStore.preferences.httpsProxy || ""; @observable shell = userStore.preferences.shell || ""; @observable activeTab = Pages.Application; @computed get themeOptions(): SelectOption[] { return themeStore.themes.map(theme => ({ label: theme.name, value: theme.id, })); } timezoneOptions: SelectOption[] = moment.tz.names().map(zone => ({ label: zone, value: zone, })); componentDidMount() { disposeOnUnmount(this, [ reaction(() => navigation.location.hash, hash => { const fragment = hash.slice(1); // hash is /^(#\w.)?$/ if (fragment) { // ignore empty framents document.getElementById(fragment)?.scrollIntoView(); } }, { fireImmediately: true }) ]); } onTabChange = (tabId: Pages) => { this.activeTab = tabId; }; renderNavigation() { const extensions = appPreferenceRegistry.getItems().filter(e => !e.showInPreferencesTab); return (
Preferences
{extensions.length > 0 && }
); } renderExtension({ title, id, components: { Hint, Input } }: RegisteredAppPreference) { return (

); } render() { const { preferences } = userStore; const extensions = appPreferenceRegistry.getItems(); const telemetryExtensions = extensions.filter(e => e.showInPreferencesTab == Pages.Telemetry); let defaultShell = process.env.SHELL || process.env.PTYSHELL; if (!defaultShell) { if (isWindows) { defaultShell = "powershell.exe"; } else { defaultShell = "System default shell"; } } return ( {this.activeTab == Pages.Application && (

Application

this.shell = v} onBlur={() => preferences.shell = this.shell} />

preferences.openAtLogin = v.target.checked} name="startup" /> } label="Automatically start Lens on login" />

this.httpProxy = v} onBlur={() => preferences.httpsProxy = this.httpProxy} /> Proxy is used only for non-cluster communication.

preferences.allowUntrustedCAs = v.target.checked} name="startup" /> } label="Allow untrusted Certificate Authorities" /> This will make Lens to trust ANY certificate authority without any validations.{" "} Needed with some corporate proxies that do certificate re-writing.{" "} Does not affect cluster communications!
)} {this.activeTab == Pages.Kubernetes && (

Kubernetes


Helm Charts

)} {this.activeTab == Pages.Telemetry && (

Telemetry

{telemetryExtensions.map(this.renderExtension)}
)} {this.activeTab == Pages.Extensions && (

Extensions

{extensions.filter(e => !e.showInPreferencesTab).map(this.renderExtension)}
)}
); } }