mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Spread preferences layout by <section> tags
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
000244a484
commit
e6a5df7a30
@ -24,15 +24,12 @@ export const KubectlBinaries = observer(({ preferences }: { preferences: UserPre
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h2>Kubectl Binary</h2>
|
<SubTitle title="Automatic kubectl binary download"/>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
label="Download kubectl binaries"
|
label="Download kubectl binaries matching the Kubernetes cluster version"
|
||||||
value={preferences.downloadKubectlBinaries}
|
value={preferences.downloadKubectlBinaries}
|
||||||
onChange={downloadKubectlBinaries => preferences.downloadKubectlBinaries = downloadKubectlBinaries}
|
onChange={downloadKubectlBinaries => preferences.downloadKubectlBinaries = downloadKubectlBinaries}
|
||||||
/>
|
/>
|
||||||
<small className="hint">
|
|
||||||
Download kubectl binaries matching to Kubernetes cluster version.
|
|
||||||
</small>
|
|
||||||
<SubTitle title="Download mirror" />
|
<SubTitle title="Download mirror" />
|
||||||
<Select
|
<Select
|
||||||
placeholder="Download mirror for kubectl"
|
placeholder="Download mirror for kubectl"
|
||||||
@ -54,7 +51,7 @@ export const KubectlBinaries = observer(({ preferences }: { preferences: UserPre
|
|||||||
<small className="hint">
|
<small className="hint">
|
||||||
The directory to download binaries into.
|
The directory to download binaries into.
|
||||||
</small>
|
</small>
|
||||||
<SubTitle title="Path to Kubectl binary" />
|
<SubTitle title="Path to kubectl binary" />
|
||||||
<Input
|
<Input
|
||||||
theme="round-black"
|
theme="round-black"
|
||||||
placeholder={bundledKubectlPath()}
|
placeholder={bundledKubectlPath()}
|
||||||
|
|||||||
@ -1,29 +1,22 @@
|
|||||||
import "./preferences.scss";
|
import "./preferences.scss";
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { computed, observable } from "mobx";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { action, computed, observable } from "mobx";
|
|
||||||
import { Icon } from "../icon";
|
|
||||||
import { Select, SelectOption } from "../select";
|
|
||||||
import { userStore } from "../../../common/user-store";
|
import { userStore } from "../../../common/user-store";
|
||||||
import { HelmRepo, repoManager } from "../../../main/helm/helm-repo-manager";
|
|
||||||
import { Input } from "../input";
|
|
||||||
import { Checkbox } from "../checkbox";
|
|
||||||
import { Notifications } from "../notifications";
|
|
||||||
import { Badge } from "../badge";
|
|
||||||
import { Button } from "../button";
|
|
||||||
import { themeStore } from "../../theme.store";
|
|
||||||
import { Tooltip } from "../tooltip";
|
|
||||||
import { KubectlBinaries } from "./kubectl-binaries";
|
|
||||||
import { appPreferenceRegistry } from "../../../extensions/registries/app-preference-registry";
|
import { appPreferenceRegistry } from "../../../extensions/registries/app-preference-registry";
|
||||||
|
import { themeStore } from "../../theme.store";
|
||||||
|
import { Checkbox } from "../checkbox";
|
||||||
|
import { Input } from "../input";
|
||||||
import { PageLayout } from "../layout/page-layout";
|
import { PageLayout } from "../layout/page-layout";
|
||||||
import { AddHelmRepoDialog } from "./add-helm-repo-dialog";
|
import { SubTitle } from "../layout/sub-title";
|
||||||
|
import { Select, SelectOption } from "../select";
|
||||||
|
import { HelmCharts } from "./helm-charts";
|
||||||
|
import { KubectlBinaries } from "./kubectl-binaries";
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class Preferences extends React.Component {
|
export class Preferences extends React.Component {
|
||||||
@observable helmLoading = false;
|
|
||||||
@observable helmRepos: HelmRepo[] = [];
|
|
||||||
@observable helmAddedRepos = observable.map<string, HelmRepo>();
|
|
||||||
@observable httpProxy = userStore.preferences.httpsProxy || "";
|
@observable httpProxy = userStore.preferences.httpsProxy || "";
|
||||||
|
|
||||||
@computed get themeOptions(): SelectOption<string>[] {
|
@computed get themeOptions(): SelectOption<string>[] {
|
||||||
@ -33,79 +26,6 @@ export class Preferences extends React.Component {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@computed get helmOptions(): SelectOption<HelmRepo>[] {
|
|
||||||
return this.helmRepos.map(repo => ({
|
|
||||||
label: repo.name,
|
|
||||||
value: repo,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
async componentDidMount() {
|
|
||||||
await this.loadHelmRepos();
|
|
||||||
}
|
|
||||||
|
|
||||||
@action
|
|
||||||
async loadHelmRepos() {
|
|
||||||
this.helmLoading = true;
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (!this.helmRepos.length) {
|
|
||||||
this.helmRepos = await repoManager.loadAvailableRepos(); // via https://helm.sh
|
|
||||||
}
|
|
||||||
const repos = await repoManager.repositories(); // via helm-cli
|
|
||||||
|
|
||||||
this.helmAddedRepos.clear();
|
|
||||||
repos.forEach(repo => this.helmAddedRepos.set(repo.name, repo));
|
|
||||||
} catch (err) {
|
|
||||||
Notifications.error(String(err));
|
|
||||||
}
|
|
||||||
this.helmLoading = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
async addRepo(repo: HelmRepo) {
|
|
||||||
try {
|
|
||||||
await repoManager.addRepo(repo);
|
|
||||||
this.helmAddedRepos.set(repo.name, repo);
|
|
||||||
} catch (err) {
|
|
||||||
Notifications.error(<>Adding helm branch <b>{repo.name}</b> has failed: {String(err)}</>);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async removeRepo(repo: HelmRepo) {
|
|
||||||
try {
|
|
||||||
await repoManager.removeRepo(repo);
|
|
||||||
this.helmAddedRepos.delete(repo.name);
|
|
||||||
} catch (err) {
|
|
||||||
Notifications.error(
|
|
||||||
<>Removing helm branch <b>{repo.name}</b> has failed: {String(err)}</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onRepoSelect = async ({ value: repo }: SelectOption<HelmRepo>) => {
|
|
||||||
const isAdded = this.helmAddedRepos.has(repo.name);
|
|
||||||
|
|
||||||
if (isAdded) {
|
|
||||||
Notifications.ok(<>Helm branch <b>{repo.name}</b> already in use</>);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.helmLoading = true;
|
|
||||||
await this.addRepo(repo);
|
|
||||||
this.helmLoading = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
formatHelmOptionLabel = ({ value: repo }: SelectOption<HelmRepo>) => {
|
|
||||||
const isAdded = this.helmAddedRepos.has(repo.name);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex gaps">
|
|
||||||
<span>{repo.name}</span>
|
|
||||||
{isAdded && <Icon small material="check" className="box right"/>}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { preferences } = userStore;
|
const { preferences } = userStore;
|
||||||
const header = <h2>Preferences</h2>;
|
const header = <h2>Preferences</h2>;
|
||||||
@ -115,100 +35,85 @@ export class Preferences extends React.Component {
|
|||||||
showOnTop
|
showOnTop
|
||||||
showNavigation
|
showNavigation
|
||||||
className="Preferences"
|
className="Preferences"
|
||||||
|
contentGaps={false}
|
||||||
header={header}
|
header={header}
|
||||||
>
|
>
|
||||||
<h2>Color Theme</h2>
|
<section>
|
||||||
<Select
|
<h1>Application</h1>
|
||||||
options={this.themeOptions}
|
<section>
|
||||||
value={preferences.colorTheme}
|
<h2>Appearance</h2>
|
||||||
onChange={({ value }: SelectOption) => preferences.colorTheme = value}
|
<SubTitle title="Theme"/>
|
||||||
/>
|
<Select
|
||||||
|
options={this.themeOptions}
|
||||||
|
value={preferences.colorTheme}
|
||||||
|
onChange={({ value }: SelectOption) => preferences.colorTheme = value}
|
||||||
|
/>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<h2>Proxy</h2>
|
||||||
|
<SubTitle title="HTTP Proxy"/>
|
||||||
|
<Input
|
||||||
|
theme="round-black"
|
||||||
|
placeholder="Type HTTP proxy url (example: http://proxy.acme.org:8080)"
|
||||||
|
value={this.httpProxy}
|
||||||
|
onChange={v => this.httpProxy = v}
|
||||||
|
onBlur={() => preferences.httpsProxy = this.httpProxy}
|
||||||
|
/>
|
||||||
|
<small className="hint">
|
||||||
|
Proxy is used only for non-cluster communication.
|
||||||
|
</small>
|
||||||
|
|
||||||
<h2>HTTP Proxy</h2>
|
<SubTitle title="Certificate Trust"/>
|
||||||
<Input
|
<Checkbox
|
||||||
theme="round-black"
|
label="Allow untrusted Certificate Authorities"
|
||||||
placeholder="Type HTTP proxy url (example: http://proxy.acme.org:8080)"
|
value={preferences.allowUntrustedCAs}
|
||||||
value={this.httpProxy}
|
onChange={v => preferences.allowUntrustedCAs = v}
|
||||||
onChange={v => this.httpProxy = v}
|
/>
|
||||||
onBlur={() => preferences.httpsProxy = this.httpProxy}
|
<small className="hint">
|
||||||
/>
|
This will make Lens to trust ANY certificate authority without any validations.{" "}
|
||||||
<small className="hint">
|
Needed with some corporate proxies that do certificate re-writing.{" "}
|
||||||
Proxy is used only for non-cluster communication.
|
Does not affect cluster communications!
|
||||||
</small>
|
</small>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<h2>Start-up</h2>
|
||||||
|
<SubTitle title="Automatic Start-up"/>
|
||||||
|
<Checkbox
|
||||||
|
label="Automatically start Lens on login"
|
||||||
|
value={preferences.openAtLogin}
|
||||||
|
onChange={v => preferences.openAtLogin = v}
|
||||||
|
/>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
|
||||||
<KubectlBinaries preferences={preferences}/>
|
<section>
|
||||||
|
<h1>Kubernetes</h1>
|
||||||
|
<section>
|
||||||
|
<h2>Kubectl binary</h2>
|
||||||
|
<KubectlBinaries preferences={preferences}/>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<h2>Helm Charts</h2>
|
||||||
|
<HelmCharts/>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
|
||||||
<h2>Helm</h2>
|
<section>
|
||||||
<div className="flex gaps">
|
<h1>Extensions</h1>
|
||||||
<Select id="HelmRepoSelect"
|
<div className="extensions flex column gaps">
|
||||||
placeholder="Repositories"
|
{appPreferenceRegistry.getItems().map(({ title, components: { Hint, Input } }, index) => {
|
||||||
isLoading={this.helmLoading}
|
return (
|
||||||
isDisabled={this.helmLoading}
|
<section key={index}>
|
||||||
options={this.helmOptions}
|
<h2>{title}</h2>
|
||||||
onChange={this.onRepoSelect}
|
<Input/>
|
||||||
formatOptionLabel={this.formatHelmOptionLabel}
|
<small className="hint">
|
||||||
controlShouldRenderValue={false}
|
<Hint/>
|
||||||
className="box grow"
|
</small>
|
||||||
/>
|
</section>
|
||||||
<Button
|
);
|
||||||
primary
|
})}
|
||||||
label="Add Custom Helm Repo"
|
</div>
|
||||||
onClick={AddHelmRepoDialog.open}
|
</section>
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<AddHelmRepoDialog onAddRepo={()=>this.loadHelmRepos()}/>
|
|
||||||
<div className="repos flex gaps column">
|
|
||||||
{Array.from(this.helmAddedRepos).map(([name, repo]) => {
|
|
||||||
const tooltipId = `message-${name}`;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Badge key={name} className="added-repo flex gaps align-center justify-space-between">
|
|
||||||
<span id={tooltipId} className="repo">{name}</span>
|
|
||||||
<Icon
|
|
||||||
material="delete"
|
|
||||||
onClick={() => this.removeRepo(repo)}
|
|
||||||
tooltip="Remove"
|
|
||||||
/>
|
|
||||||
<Tooltip targetId={tooltipId} formatters={{ narrow: true }}>
|
|
||||||
{repo.url}
|
|
||||||
</Tooltip>
|
|
||||||
</Badge>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h2>Auto start-up</h2>
|
|
||||||
<Checkbox
|
|
||||||
label="Automatically start Lens on login"
|
|
||||||
value={preferences.openAtLogin}
|
|
||||||
onChange={v => preferences.openAtLogin = v}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<h2>Certificate Trust</h2>
|
|
||||||
<Checkbox
|
|
||||||
label="Allow untrusted Certificate Authorities"
|
|
||||||
value={preferences.allowUntrustedCAs}
|
|
||||||
onChange={v => preferences.allowUntrustedCAs = v}
|
|
||||||
/>
|
|
||||||
<small className="hint">
|
|
||||||
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!
|
|
||||||
</small>
|
|
||||||
|
|
||||||
<div className="extensions flex column gaps">
|
|
||||||
{appPreferenceRegistry.getItems().map(({ title, components: { Hint, Input } }, index) => {
|
|
||||||
return (
|
|
||||||
<div key={index} className="preference">
|
|
||||||
<h2>{title}</h2>
|
|
||||||
<Input/>
|
|
||||||
<small className="hint">
|
|
||||||
<Hint/>
|
|
||||||
</small>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</PageLayout>
|
</PageLayout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,10 +59,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
h2:not(:first-of-type) {
|
|
||||||
margin-top: var(--spacing);
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
p {
|
||||||
line-height: 140%;
|
line-height: 140%;
|
||||||
}
|
}
|
||||||
@ -81,4 +77,36 @@
|
|||||||
box-shadow: 0 0 0 1px var(--borderFaintColor);
|
box-shadow: 0 0 0 1px var(--borderFaintColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
section {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin-bottom: var(--spacing);
|
||||||
|
|
||||||
|
> :not(:last-child) {
|
||||||
|
margin-bottom: var(--spacing);
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2 {
|
||||||
|
color: var(--textColorAccent);
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: x-large;
|
||||||
|
border-bottom: 1px solid var(--borderFaintColor);
|
||||||
|
padding-bottom: var(--padding);
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
font-size: large;
|
||||||
|
}
|
||||||
|
|
||||||
|
small.hint {
|
||||||
|
margin-top: calc(var(--unit) * -1.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.SubTitle {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user