1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Remove old implementation made redundant with competition for preferences of helm repositories

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2022-06-07 08:43:46 +03:00
parent 0fbc79a9e2
commit 6342458419
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
15 changed files with 228 additions and 4192 deletions

View File

@ -313,7 +313,7 @@ exports[`deactivate helm repository from list of active repositories in preferen
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-HelmRepoSelect-live-region"
id="react-select-selection-of-active-public-helm-repository-live-region"
/>
<span
aria-atomic="false"
@ -329,7 +329,7 @@ exports[`deactivate helm repository from list of active repositories in preferen
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-HelmRepoSelect-placeholder"
id="react-select-selection-of-active-public-helm-repository-placeholder"
>
Repositories
</div>
@ -339,7 +339,7 @@ exports[`deactivate helm repository from list of active repositories in preferen
>
<input
aria-autocomplete="list"
aria-describedby="react-select-HelmRepoSelect-placeholder"
aria-describedby="react-select-selection-of-active-public-helm-repository-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
@ -347,7 +347,7 @@ exports[`deactivate helm repository from list of active repositories in preferen
autocorrect="off"
class="Select__input"
disabled=""
id="HelmRepoSelect"
id="selection-of-active-public-helm-repository"
role="combobox"
spellcheck="false"
style="opacity: 1; width: 100%; grid-area: 1 / 2; min-width: 2px; border: 0px; margin: 0px; outline: 0; padding: 0px;"
@ -397,120 +397,6 @@ exports[`deactivate helm repository from list of active repositories in preferen
</div>
</div>
</div>
<button
class="Button primary"
type="button"
>
Add Custom Helm Repo
</button>
</div>
<div
class="repos"
>
<div
class="pt-5 relative"
>
<div
class="Spinner singleColor center"
/>
</div>
</div>
</div>
<div>
<div
class="flex gaps"
>
<div>
<div
class="Select theme-lens box grow Select--is-disabled css-3iigni-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-selection-of-active-public-helm-repository-live-region"
/>
<span
aria-atomic="false"
aria-live="polite"
aria-relevant="additions text"
class="css-1f43avz-a11yText-A11yText"
/>
<div
class="Select__control Select__control--is-disabled css-1insrsq-control"
>
<div
class="Select__value-container css-319lph-ValueContainer"
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-selection-of-active-public-helm-repository-placeholder"
>
Repositories
</div>
<div
class="Select__input-container css-jzldcf-Input"
data-value=""
>
<input
aria-autocomplete="list"
aria-describedby="react-select-selection-of-active-public-helm-repository-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
autocomplete="off"
autocorrect="off"
class="Select__input"
disabled=""
id="selection-of-active-public-helm-repository"
role="combobox"
spellcheck="false"
style="opacity: 1; width: 100%; grid-area: 1 / 2; min-width: 2px; border: 0px; margin: 0px; outline: 0; padding: 0px;"
tabindex="0"
type="text"
value=""
/>
</div>
</div>
<div
class="Select__indicators css-1hb7zxy-IndicatorsContainer"
>
<div
aria-hidden="true"
class="Select__indicator Select__loading-indicator css-at12u2-loadingIndicator"
>
<span
class="css-1xtdfmb-LoadingDot"
/>
<span
class="css-zoievk-LoadingDot"
/>
<span
class="css-x748d8-LoadingDot"
/>
</div>
<span
class="Select__indicator-separator css-109onse-indicatorSeparator"
/>
<div
aria-hidden="true"
class="Select__indicator Select__dropdown-indicator css-tlfecz-indicatorContainer"
>
<svg
aria-hidden="true"
class="css-tj5bde-Svg"
focusable="false"
height="20"
viewBox="0 0 20 20"
width="20"
>
<path
d="M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"
/>
</svg>
</div>
</div>
</div>
</div>
</div>
<button
class="Button primary"
data-testid="add-custom-helm-repo-button"
@ -880,11 +766,11 @@ exports[`deactivate helm repository from list of active repositories in preferen
class="flex gaps"
>
<div
class="Select theme-lens box grow Select--is-disabled css-3iigni-container"
class="Select theme-lens box grow css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-HelmRepoSelect-live-region"
id="react-select-selection-of-active-public-helm-repository-live-region"
/>
<span
aria-atomic="false"
@ -893,32 +779,31 @@ exports[`deactivate helm repository from list of active repositories in preferen
class="css-1f43avz-a11yText-A11yText"
/>
<div
class="Select__control Select__control--is-disabled css-1insrsq-control"
class="Select__control css-1s2u09g-control"
>
<div
class="Select__value-container css-319lph-ValueContainer"
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-HelmRepoSelect-placeholder"
id="react-select-selection-of-active-public-helm-repository-placeholder"
>
Repositories
</div>
<div
class="Select__input-container css-jzldcf-Input"
class="Select__input-container css-6j8wv5-Input"
data-value=""
>
<input
aria-autocomplete="list"
aria-describedby="react-select-HelmRepoSelect-placeholder"
aria-describedby="react-select-selection-of-active-public-helm-repository-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
autocomplete="off"
autocorrect="off"
class="Select__input"
disabled=""
id="HelmRepoSelect"
id="selection-of-active-public-helm-repository"
role="combobox"
spellcheck="false"
style="opacity: 1; width: 100%; grid-area: 1 / 2; min-width: 2px; border: 0px; margin: 0px; outline: 0; padding: 0px;"
@ -931,22 +816,8 @@ exports[`deactivate helm repository from list of active repositories in preferen
<div
class="Select__indicators css-1hb7zxy-IndicatorsContainer"
>
<div
aria-hidden="true"
class="Select__indicator Select__loading-indicator css-at12u2-loadingIndicator"
>
<span
class="css-1xtdfmb-LoadingDot"
/>
<span
class="css-zoievk-LoadingDot"
/>
<span
class="css-x748d8-LoadingDot"
/>
</div>
<span
class="Select__indicator-separator css-109onse-indicatorSeparator"
class="Select__indicator-separator css-1okebmr-indicatorSeparator"
/>
<div
aria-hidden="true"
@ -968,105 +839,6 @@ exports[`deactivate helm repository from list of active repositories in preferen
</div>
</div>
</div>
<button
class="Button primary"
type="button"
>
Add Custom Helm Repo
</button>
</div>
<div
class="repos"
>
<div
class="pt-5 relative"
>
<div
class="Spinner singleColor center"
/>
</div>
</div>
</div>
<div>
<div
class="flex gaps"
>
<div>
<div
class="Select theme-lens box grow css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-selection-of-active-public-helm-repository-live-region"
/>
<span
aria-atomic="false"
aria-live="polite"
aria-relevant="additions text"
class="css-1f43avz-a11yText-A11yText"
/>
<div
class="Select__control css-1s2u09g-control"
>
<div
class="Select__value-container css-319lph-ValueContainer"
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-selection-of-active-public-helm-repository-placeholder"
>
Repositories
</div>
<div
class="Select__input-container css-6j8wv5-Input"
data-value=""
>
<input
aria-autocomplete="list"
aria-describedby="react-select-selection-of-active-public-helm-repository-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
autocomplete="off"
autocorrect="off"
class="Select__input"
id="selection-of-active-public-helm-repository"
role="combobox"
spellcheck="false"
style="opacity: 1; width: 100%; grid-area: 1 / 2; min-width: 2px; border: 0px; margin: 0px; outline: 0; padding: 0px;"
tabindex="0"
type="text"
value=""
/>
</div>
</div>
<div
class="Select__indicators css-1hb7zxy-IndicatorsContainer"
>
<span
class="Select__indicator-separator css-1okebmr-indicatorSeparator"
/>
<div
aria-hidden="true"
class="Select__indicator Select__dropdown-indicator css-tlfecz-indicatorContainer"
>
<svg
aria-hidden="true"
class="css-tj5bde-Svg"
focusable="false"
height="20"
viewBox="0 0 20 20"
width="20"
>
<path
d="M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"
/>
</svg>
</div>
</div>
</div>
</div>
</div>
<button
class="Button primary"
data-testid="add-custom-helm-repo-button"
@ -1464,11 +1236,11 @@ exports[`deactivate helm repository from list of active repositories in preferen
class="flex gaps"
>
<div
class="Select theme-lens box grow Select--is-disabled css-3iigni-container"
class="Select theme-lens box grow css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-HelmRepoSelect-live-region"
id="react-select-selection-of-active-public-helm-repository-live-region"
/>
<span
aria-atomic="false"
@ -1477,32 +1249,31 @@ exports[`deactivate helm repository from list of active repositories in preferen
class="css-1f43avz-a11yText-A11yText"
/>
<div
class="Select__control Select__control--is-disabled css-1insrsq-control"
class="Select__control css-1s2u09g-control"
>
<div
class="Select__value-container css-319lph-ValueContainer"
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-HelmRepoSelect-placeholder"
id="react-select-selection-of-active-public-helm-repository-placeholder"
>
Repositories
</div>
<div
class="Select__input-container css-jzldcf-Input"
class="Select__input-container css-6j8wv5-Input"
data-value=""
>
<input
aria-autocomplete="list"
aria-describedby="react-select-HelmRepoSelect-placeholder"
aria-describedby="react-select-selection-of-active-public-helm-repository-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
autocomplete="off"
autocorrect="off"
class="Select__input"
disabled=""
id="HelmRepoSelect"
id="selection-of-active-public-helm-repository"
role="combobox"
spellcheck="false"
style="opacity: 1; width: 100%; grid-area: 1 / 2; min-width: 2px; border: 0px; margin: 0px; outline: 0; padding: 0px;"
@ -1515,22 +1286,8 @@ exports[`deactivate helm repository from list of active repositories in preferen
<div
class="Select__indicators css-1hb7zxy-IndicatorsContainer"
>
<div
aria-hidden="true"
class="Select__indicator Select__loading-indicator css-at12u2-loadingIndicator"
>
<span
class="css-1xtdfmb-LoadingDot"
/>
<span
class="css-zoievk-LoadingDot"
/>
<span
class="css-x748d8-LoadingDot"
/>
</div>
<span
class="Select__indicator-separator css-109onse-indicatorSeparator"
class="Select__indicator-separator css-1okebmr-indicatorSeparator"
/>
<div
aria-hidden="true"
@ -1552,105 +1309,6 @@ exports[`deactivate helm repository from list of active repositories in preferen
</div>
</div>
</div>
<button
class="Button primary"
type="button"
>
Add Custom Helm Repo
</button>
</div>
<div
class="repos"
>
<div
class="pt-5 relative"
>
<div
class="Spinner singleColor center"
/>
</div>
</div>
</div>
<div>
<div
class="flex gaps"
>
<div>
<div
class="Select theme-lens box grow css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-selection-of-active-public-helm-repository-live-region"
/>
<span
aria-atomic="false"
aria-live="polite"
aria-relevant="additions text"
class="css-1f43avz-a11yText-A11yText"
/>
<div
class="Select__control css-1s2u09g-control"
>
<div
class="Select__value-container css-319lph-ValueContainer"
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-selection-of-active-public-helm-repository-placeholder"
>
Repositories
</div>
<div
class="Select__input-container css-6j8wv5-Input"
data-value=""
>
<input
aria-autocomplete="list"
aria-describedby="react-select-selection-of-active-public-helm-repository-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
autocomplete="off"
autocorrect="off"
class="Select__input"
id="selection-of-active-public-helm-repository"
role="combobox"
spellcheck="false"
style="opacity: 1; width: 100%; grid-area: 1 / 2; min-width: 2px; border: 0px; margin: 0px; outline: 0; padding: 0px;"
tabindex="0"
type="text"
value=""
/>
</div>
</div>
<div
class="Select__indicators css-1hb7zxy-IndicatorsContainer"
>
<span
class="Select__indicator-separator css-1okebmr-indicatorSeparator"
/>
<div
aria-hidden="true"
class="Select__indicator Select__dropdown-indicator css-tlfecz-indicatorContainer"
>
<svg
aria-hidden="true"
class="css-tj5bde-Svg"
focusable="false"
height="20"
viewBox="0 0 20 20"
width="20"
>
<path
d="M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"
/>
</svg>
</div>
</div>
</div>
</div>
</div>
<button
class="Button primary"
data-testid="add-custom-helm-repo-button"
@ -2052,7 +1710,7 @@ exports[`deactivate helm repository from list of active repositories in preferen
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-HelmRepoSelect-live-region"
id="react-select-selection-of-active-public-helm-repository-live-region"
/>
<span
aria-atomic="false"
@ -2068,7 +1726,7 @@ exports[`deactivate helm repository from list of active repositories in preferen
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-HelmRepoSelect-placeholder"
id="react-select-selection-of-active-public-helm-repository-placeholder"
>
Repositories
</div>
@ -2078,7 +1736,7 @@ exports[`deactivate helm repository from list of active repositories in preferen
>
<input
aria-autocomplete="list"
aria-describedby="react-select-HelmRepoSelect-placeholder"
aria-describedby="react-select-selection-of-active-public-helm-repository-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
@ -2086,7 +1744,7 @@ exports[`deactivate helm repository from list of active repositories in preferen
autocorrect="off"
class="Select__input"
disabled=""
id="HelmRepoSelect"
id="selection-of-active-public-helm-repository"
role="combobox"
spellcheck="false"
style="opacity: 1; width: 100%; grid-area: 1 / 2; min-width: 2px; border: 0px; margin: 0px; outline: 0; padding: 0px;"
@ -2136,120 +1794,6 @@ exports[`deactivate helm repository from list of active repositories in preferen
</div>
</div>
</div>
<button
class="Button primary"
type="button"
>
Add Custom Helm Repo
</button>
</div>
<div
class="repos"
>
<div
class="pt-5 relative"
>
<div
class="Spinner singleColor center"
/>
</div>
</div>
</div>
<div>
<div
class="flex gaps"
>
<div>
<div
class="Select theme-lens box grow Select--is-disabled css-3iigni-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-selection-of-active-public-helm-repository-live-region"
/>
<span
aria-atomic="false"
aria-live="polite"
aria-relevant="additions text"
class="css-1f43avz-a11yText-A11yText"
/>
<div
class="Select__control Select__control--is-disabled css-1insrsq-control"
>
<div
class="Select__value-container css-319lph-ValueContainer"
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-selection-of-active-public-helm-repository-placeholder"
>
Repositories
</div>
<div
class="Select__input-container css-jzldcf-Input"
data-value=""
>
<input
aria-autocomplete="list"
aria-describedby="react-select-selection-of-active-public-helm-repository-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
autocomplete="off"
autocorrect="off"
class="Select__input"
disabled=""
id="selection-of-active-public-helm-repository"
role="combobox"
spellcheck="false"
style="opacity: 1; width: 100%; grid-area: 1 / 2; min-width: 2px; border: 0px; margin: 0px; outline: 0; padding: 0px;"
tabindex="0"
type="text"
value=""
/>
</div>
</div>
<div
class="Select__indicators css-1hb7zxy-IndicatorsContainer"
>
<div
aria-hidden="true"
class="Select__indicator Select__loading-indicator css-at12u2-loadingIndicator"
>
<span
class="css-1xtdfmb-LoadingDot"
/>
<span
class="css-zoievk-LoadingDot"
/>
<span
class="css-x748d8-LoadingDot"
/>
</div>
<span
class="Select__indicator-separator css-109onse-indicatorSeparator"
/>
<div
aria-hidden="true"
class="Select__indicator Select__dropdown-indicator css-tlfecz-indicatorContainer"
>
<svg
aria-hidden="true"
class="css-tj5bde-Svg"
focusable="false"
height="20"
viewBox="0 0 20 20"
width="20"
>
<path
d="M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"
/>
</svg>
</div>
</div>
</div>
</div>
</div>
<button
class="Button primary"
data-testid="add-custom-helm-repo-button"

View File

@ -15,7 +15,6 @@ import * as LensExtensionsCommonApi from "../extensions/common-api";
import * as LensExtensionsRendererApi from "../extensions/renderer-api";
import { delay } from "../common/utils";
import { isMac, isDevelopment } from "../common/vars";
import { HelmRepoManager } from "../main/helm/helm-repo-manager";
import { DefaultProps } from "./mui-base-theme";
import configurePackages from "../common/configure-packages";
import * as initializers from "./initializers";
@ -151,8 +150,6 @@ export async function bootstrap(di: DiContainer) {
extensionInstallationStateStore.bindIpcListeners();
HelmRepoManager.createInstance(); // initialize the manager
// Register additional store listeners
clusterStore.registerIpcListener();

View File

@ -1,220 +0,0 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import "./add-helm-repo-dialog.scss";
import React from "react";
import type { FileFilter } from "electron";
import { observable, makeObservable, action } from "mobx";
import { observer } from "mobx-react";
import type { DialogProps } from "../dialog";
import { Dialog } from "../dialog";
import { Wizard, WizardStep } from "../wizard";
import { Input } from "../input";
import { Checkbox } from "../checkbox";
import { Button } from "../button";
import { systemName, isUrl, isPath } from "../input/input_validators";
import { SubTitle } from "../layout/sub-title";
import { Icon } from "../icon";
import { Notifications } from "../notifications";
import { type HelmRepo, HelmRepoManager } from "../../../main/helm/helm-repo-manager";
import { requestOpenFilePickingDialog } from "../../ipc";
export interface AddHelmRepoDialogProps extends Partial<DialogProps> {
onAddRepo: () => void;
}
enum FileType {
CaFile = "caFile",
KeyFile = "keyFile",
CertFile = "certFile",
}
const dialogState = observable.object({
isOpen: false,
});
function getEmptyRepo(): HelmRepo {
return { name: "", url: "", username: "", password: "", insecureSkipTlsVerify: false, caFile: "", keyFile: "", certFile: "" };
}
@observer
export class AddHelmRepoDialog extends React.Component<AddHelmRepoDialogProps> {
private static keyExtensions = ["key", "keystore", "jks", "p12", "pfx", "pem"];
private static certExtensions = ["crt", "cer", "ca-bundle", "p7b", "p7c", "p7s", "p12", "pfx", "pem"];
constructor(props: AddHelmRepoDialogProps) {
super(props);
makeObservable(this);
}
static open() {
dialogState.isOpen = true;
}
static close() {
dialogState.isOpen = false;
}
@observable helmRepo = getEmptyRepo();
@observable showOptions = false;
@action
close = () => {
AddHelmRepoDialog.close();
this.helmRepo = getEmptyRepo();
this.showOptions = false;
};
setFilepath(type: FileType, value: string) {
this.helmRepo[type] = value;
}
getFilePath(type: FileType) {
return this.helmRepo[type];
}
async selectFileDialog(type: FileType, fileFilter: FileFilter) {
const { canceled, filePaths } = await requestOpenFilePickingDialog({
defaultPath: this.getFilePath(type),
properties: ["openFile", "showHiddenFiles"],
message: `Select file`,
buttonLabel: `Use file`,
filters: [
fileFilter,
{ name: "Any", extensions: ["*"] },
],
});
if (!canceled && filePaths.length) {
this.setFilepath(type, filePaths[0]);
}
}
async addCustomRepo() {
try {
await HelmRepoManager.getInstance().addRepo(this.helmRepo);
Notifications.ok((
<>
{"Helm repository "}
<b>{this.helmRepo.name}</b>
{" has been added."}
</>
));
this.props.onAddRepo();
this.close();
} catch (err) {
Notifications.error((
<>
{"Adding helm branch "}
<b>{this.helmRepo.name}</b>
{" has failed: "}
{String(err)}
</>
));
}
}
renderFileInput(placeholder:string, fileType:FileType, fileExtensions:string[]){
return (
<div className="flex gaps align-center">
<Input
placeholder={placeholder}
validators={isPath}
className="box grow"
value={this.getFilePath(fileType)}
onChange={v => this.setFilepath(fileType, v)}
/>
<Icon
material="folder"
onClick={() => this.selectFileDialog(fileType, { name: placeholder, extensions: fileExtensions })}
tooltip="Browse"
/>
</div>
);
}
renderOptions() {
return (
<>
<SubTitle title="Security settings" />
<Checkbox
label="Skip TLS certificate checks for the repository"
value={this.helmRepo.insecureSkipTlsVerify}
onChange={v => this.helmRepo.insecureSkipTlsVerify = v}
/>
{this.renderFileInput("Key file", FileType.KeyFile, AddHelmRepoDialog.keyExtensions)}
{this.renderFileInput("Ca file", FileType.CaFile, AddHelmRepoDialog.certExtensions)}
{this.renderFileInput("Certificate file", FileType.CertFile, AddHelmRepoDialog.certExtensions)}
<SubTitle title="Chart Repository Credentials" />
<Input
placeholder="Username"
value={this.helmRepo.username}
onChange= {v => this.helmRepo.username = v}
/>
<Input
type="password"
placeholder="Password"
value={this.helmRepo.password}
onChange={v => this.helmRepo.password = v}
/>
</>
);
}
render() {
const { ...dialogProps } = this.props;
const header = <h5>Add custom Helm Repo</h5>;
return (
<Dialog
{...dialogProps}
className="AddHelmRepoDialog"
isOpen={dialogState.isOpen}
close={this.close}
>
<Wizard header={header} done={this.close}>
<WizardStep
contentClass="flow column"
nextLabel="Add"
next={() => this.addCustomRepo()}
>
<div className="flex column gaps">
<Input
autoFocus
required
placeholder="Helm repo name"
trim
validators={systemName}
value={this.helmRepo.name}
onChange={v => this.helmRepo.name = v}
/>
<Input
required
placeholder="URL"
validators={isUrl}
value={this.helmRepo.url}
onChange={v => this.helmRepo.url = v}
/>
<Button
plain
className="accordion"
onClick={() => this.showOptions = !this.showOptions}
>
More
<Icon
small
tooltip="More"
material={this.showOptions ? "remove" : "add"}
/>
</Button>
{this.showOptions && this.renderOptions()}
</div>
</WizardStep>
</Wizard>
</Dialog>
);
}
}

View File

@ -1,202 +0,0 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import styles from "./helm-charts.module.scss";
import React from "react";
import { observable, makeObservable, computed } from "mobx";
import type { HelmRepo } from "../../../main/helm/helm-repo-manager";
import { HelmRepoManager } from "../../../main/helm/helm-repo-manager";
import { Button } from "../button";
import { Icon } from "../icon";
import { Notifications } from "../notifications";
import type { SelectOption } from "../select";
import { Select } from "../select";
import { AddHelmRepoDialog } from "./add-helm-repo-dialog";
import { observer } from "mobx-react";
import { RemovableItem } from "./removable-item";
import { Notice } from "../+extensions/notice";
import { Spinner } from "../spinner";
import { noop } from "../../utils";
import type { SingleValue } from "react-select";
@observer
export class HelmCharts extends React.Component {
@observable loadingRepos = false;
@observable loadingAvailableRepos = false;
@observable repos: HelmRepo[] = [];
@observable addedRepos = observable.map<string, HelmRepo>();
constructor(props: {}) {
super(props);
makeObservable(this);
}
@computed get repoOptions() {
return this.repos.map(repo => ({
value: repo,
label: repo.name,
isSelected: this.addedRepos.has(repo.name),
}));
}
componentDidMount() {
this.loadAvailableRepos().catch(noop);
this.loadRepos().catch(noop);
}
async loadAvailableRepos() {
this.loadingAvailableRepos = true;
try {
if (!this.repos.length) {
this.repos = await HelmRepoManager.getInstance().loadAvailableRepos();
}
} catch (err) {
Notifications.error(String(err));
}
this.loadingAvailableRepos = false;
}
async loadRepos() {
this.loadingRepos = true;
try {
const repos = await HelmRepoManager.getInstance().repositories(); // via helm-cli
this.addedRepos.replace(repos.map(repo => [repo.name, repo]));
} catch (err) {
Notifications.error(String(err));
}
this.loadingRepos = false;
}
async addRepo(repo: HelmRepo) {
try {
await HelmRepoManager.getInstance().addRepo(repo);
this.addedRepos.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 HelmRepoManager.getInstance().removeRepo(repo);
this.addedRepos.delete(repo.name);
} catch (err) {
Notifications.error(
<>
{"Removing helm branch "}
<b>{repo.name}</b>
{" has failed: "}
{String(err)}
</>,
);
}
}
onRepoSelect = async (option: SingleValue<{ value: HelmRepo }>): Promise<void> => {
if (!option) {
return;
}
if (this.addedRepos.has(option.value.name)) {
return void Notifications.ok((
<>
{"Helm repo "}
<b>{option.value.name}</b>
{" already in use."}
</>
));
}
await this.addRepo(option.value);
};
formatOptionLabel = ({ value, isSelected }: SelectOption<HelmRepo>) => (
<div className="flex gaps">
<span>{value.name}</span>
{isSelected && (
<Icon
small
material="check"
className="box right" />
)}
</div>
);
renderRepositories() {
const repos = Array.from(this.addedRepos);
if (this.loadingRepos) {
return <div className="pt-5 relative"><Spinner center/></div>;
}
if (!repos.length) {
return (
<Notice>
<div className="flex-grow text-center">The repositories have not been added yet</div>
</Notice>
);
}
return repos.map(([name, repo]) => {
return (
<RemovableItem
key={name}
onRemove={() => this.removeRepo(repo)}
className="mt-3"
>
<div>
<div data-testid="repository-name" className={styles.repoName}>{name}</div>
<div className={styles.repoUrl}>{repo.url}</div>
</div>
</RemovableItem>
);
});
}
render() {
return (
<div>
<div className="flex gaps">
<Select
id="HelmRepoSelect"
placeholder="Repositories"
isLoading={this.loadingAvailableRepos}
isDisabled={this.loadingAvailableRepos}
options={this.repoOptions}
onChange={this.onRepoSelect}
value={this.repos}
formatOptionLabel={this.formatOptionLabel}
controlShouldRenderValue={false}
className="box grow"
themeName="lens"
/>
<Button
primary
label="Add Custom Helm Repo"
onClick={AddHelmRepoDialog.open}
/>
</div>
<AddHelmRepoDialog onAddRepo={() => this.loadRepos()}/>
<div className={styles.repos}>
{this.renderRepositories()}
</div>
</div>
);
}
}

View File

@ -4,9 +4,7 @@
*/
import { observer } from "mobx-react";
import React from "react";
import { HelmCharts } from "./helm-charts";
import { HelmCharts as HelmCharts2 } from "./kubernetes/helm-charts/helm-charts-2";
import { HelmCharts } from "./kubernetes/helm-charts/helm-charts";
import { KubeconfigSyncs } from "./kubeconfig-syncs";
import { KubectlBinaries } from "./kubectl-binaries";
import { Preferences } from "./preferences";
@ -27,7 +25,6 @@ export const Kubernetes = observer(() => (
<section id="helm">
<h2>Helm Charts</h2>
<HelmCharts />
<HelmCharts2 />
</section>
</section>
</Preferences>

View File

@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import "../../../add-helm-repo-dialog.scss";
import "./add-helm-repo-dialog.scss";
import React from "react";
import { Wizard, WizardStep } from "../../../../wizard";

View File

@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import "../../../add-helm-repo-dialog.scss";
import "./add-helm-repo-dialog.scss";
import React from "react";
import { Dialog } from "../../../../dialog";

View File

@ -39,21 +39,19 @@ const NonInjectedActivationOfPublicHelmRepository = observer(({
}));
return (
<div>
<Select
id="selection-of-active-public-helm-repository"
placeholder="Repositories"
isLoading={valuesAreLoading}
isDisabled={valuesAreLoading}
options={repositoryOptions}
onChange={selectRepository}
value={dereferencesPublicRepositories}
formatOptionLabel={formatOptionLabel}
controlShouldRenderValue={false}
className="box grow"
themeName="lens"
/>
</div>
<Select
id="selection-of-active-public-helm-repository"
placeholder="Repositories"
isLoading={valuesAreLoading}
isDisabled={valuesAreLoading}
options={repositoryOptions}
onChange={selectRepository}
value={dereferencesPublicRepositories}
formatOptionLabel={formatOptionLabel}
controlShouldRenderValue={false}
className="box grow"
themeName="lens"
/>
);
});

View File

@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import styles from "../../helm-charts.module.scss";
import styles from "./helm-charts.module.scss";
import React from "react";