/** * Copyright (c) 2021 OpenLens Authors * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ import "./preferences.scss"; import React from "react"; import moment from "moment-timezone"; import { computed, observable, reaction, makeObservable } from "mobx"; import { disposeOnUnmount, observer } from "mobx-react"; import { isWindows } from "../../../common/vars"; import { AppPreferenceRegistry, RegisteredAppPreference } from "../../../extensions/registries/app-preference-registry"; import { UserStore } from "../../../common/user-store"; import { ThemeStore } from "../../theme.store"; import { Input } from "../input"; 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"; import { KubeconfigSyncs } from "./kubeconfig-syncs"; import { SettingLayout } from "../layout/setting-layout"; import { Checkbox } from "../checkbox"; import { sentryDsn } from "../../../common/vars"; enum Pages { Application = "application", Proxy = "proxy", Kubernetes = "kubernetes", Telemetry = "telemetry", Extensions = "extensions", Other = "other" } @observer export class Preferences extends React.Component { @observable httpProxy = UserStore.getInstance().httpsProxy || ""; @observable shell = UserStore.getInstance().shell || ""; @observable activeTab = Pages.Application; constructor(props: {}) { super(props); makeObservable(this); } @computed get themeOptions(): SelectOption[] { return ThemeStore.getInstance().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.getInstance().getItems().filter(e => !e.showInPreferencesTab); return (
Preferences
{extensions.length > 0 && }
); } renderExtension({ title, id, components: { Hint, Input } }: RegisteredAppPreference) { return (

); } render() { const extensions = AppPreferenceRegistry.getInstance().getItems(); const telemetryExtensions = extensions.filter(e => e.showInPreferencesTab == Pages.Telemetry); const defaultShell = process.env.SHELL || process.env.PTYSHELL || ( isWindows ? "powershell.exe" : "System default shell" ); return ( {this.activeTab == Pages.Application && (

Application

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

UserStore.getInstance().openAtLogin = v.target.checked} name="startup" /> } label="Automatically start Lens on login" />

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

UserStore.getInstance().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


Kubeconfig Syncs


Helm Charts

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

Telemetry

{telemetryExtensions.map(this.renderExtension)} {sentryDsn ? (
{ UserStore.getInstance().allowErrorReporting = value; }} />
Automatic error reports provide vital information about issues and application crashes. It is highly recommended to keep this feature enabled to ensure fast turnaround for issues you might encounter.

) : // we don't need to shows the checkbox at all if Sentry dsn is not a valid url null }
)} {this.activeTab == Pages.Extensions && (

Extensions

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