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

Fixup uses of AsyncResult and autoBind

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2023-03-02 11:13:46 -05:00
parent 0775b6a42f
commit ff49246c60
37 changed files with 72 additions and 70 deletions

View File

@ -72,7 +72,7 @@ export class ResourceStack {
return "";
}
protected async applyResources(resources: string[], extraArgs: string[] = []): Promise<AsyncResult<string, string>> {
protected async applyResources(resources: string[], extraArgs: string[] = []): AsyncResult<string, string> {
const kubectlArgs = [...extraArgs, ...this.getAdditionalArgs(extraArgs)];
return this.dependencies.kubectlApplyAll({
@ -82,7 +82,7 @@ export class ResourceStack {
});
}
protected async deleteResources(resources: string[], extraArgs: string[] = []): Promise<AsyncResult<string, string>> {
protected async deleteResources(resources: string[], extraArgs: string[] = []): AsyncResult<string, string> {
const kubectlArgs = [...extraArgs, ...this.getAdditionalArgs(extraArgs)];
return this.dependencies.kubectlDeleteAll({

View File

@ -5,7 +5,7 @@
import { getInjectable } from "@ogre-tools/injectable";
import execFileInjectable from "../../../common/fs/exec-file.injectable";
import loggerInjectable from "../../../common/logger.injectable";
import type { AsyncResult } from "../../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
import { requestSystemCAsInjectionToken } from "../common/request-system-cas-token";
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Cheatsheet#other_assertions
@ -17,7 +17,7 @@ const requestSystemCAsInjectable = getInjectable({
const execFile = di.inject(execFileInjectable);
const logger = di.inject(loggerInjectable);
const execSecurity = async (...args: string[]): Promise<AsyncResult<string[]>> => {
const execSecurity = async (...args: string[]): AsyncResult<string[]> => {
const result = await execFile("/usr/bin/security", args);
if (!result.callWasSuccessful) {

View File

@ -17,7 +17,7 @@ import requestPublicHelmRepositoriesInjectable from "./child-features/preference
import isPathInjectable from "../../renderer/components/input/validators/is-path.injectable";
import showSuccessNotificationInjectable from "../../renderer/components/notifications/show-success-notification.injectable";
import showErrorNotificationInjectable from "../../renderer/components/notifications/show-error-notification.injectable";
import type { AsyncResult } from "../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
import { testUsingFakeTime } from "@k8slens/test-utils";
describe("add custom helm repository in preferences", () => {
@ -26,7 +26,7 @@ describe("add custom helm repository in preferences", () => {
let showErrorNotificationMock: jest.Mock;
let rendered: RenderResult;
let execFileMock: AsyncFnMock<ExecFile>;
let getActiveHelmRepositoriesMock: AsyncFnMock<() => Promise<AsyncResult<HelmRepo[]>>>;
let getActiveHelmRepositoriesMock: AsyncFnMock<() => AsyncResult<HelmRepo[]>>;
beforeEach(async () => {
jest.useFakeTimers();

View File

@ -15,7 +15,7 @@ import type { HelmRepo } from "../../common/helm/helm-repo";
import requestPublicHelmRepositoriesInjectable from "./child-features/preferences/renderer/adding-of-public-helm-repository/public-helm-repositories/request-public-helm-repositories.injectable";
import showSuccessNotificationInjectable from "../../renderer/components/notifications/show-success-notification.injectable";
import showErrorNotificationInjectable from "../../renderer/components/notifications/show-error-notification.injectable";
import type { AsyncResult } from "../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
describe("add helm repository from list in preferences", () => {
let builder: ApplicationBuilder;
@ -23,7 +23,7 @@ describe("add helm repository from list in preferences", () => {
let showErrorNotificationMock: jest.Mock;
let rendered: RenderResult;
let execFileMock: AsyncFnMock<ExecFile>;
let getActiveHelmRepositoriesMock: AsyncFnMock<() => Promise<AsyncResult<HelmRepo[]>>>;
let getActiveHelmRepositoriesMock: AsyncFnMock<() => AsyncResult<HelmRepo[]>>;
let callForPublicHelmRepositoriesMock: AsyncFnMock<() => Promise<HelmRepo[]>>;
beforeEach(async () => {

View File

@ -14,12 +14,12 @@ import helmBinaryPathInjectable from "../../main/helm/helm-binary-path.injectabl
import getActiveHelmRepositoriesInjectable from "../../main/helm/repositories/get-active-helm-repositories/get-active-helm-repositories.injectable";
import type { HelmRepo } from "../../common/helm/helm-repo";
import requestPublicHelmRepositoriesInjectable from "./child-features/preferences/renderer/adding-of-public-helm-repository/public-helm-repositories/request-public-helm-repositories.injectable";
import type { AsyncResult } from "../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
describe("remove helm repository from list of active repositories in preferences", () => {
let builder: ApplicationBuilder;
let rendered: RenderResult;
let getActiveHelmRepositoriesMock: AsyncFnMock<() => Promise<AsyncResult<HelmRepo[]>>>;
let getActiveHelmRepositoriesMock: AsyncFnMock<() => AsyncResult<HelmRepo[]>>;
let execFileMock: AsyncFnMock<ExecFile>;
beforeEach(async () => {

View File

@ -3,13 +3,13 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { AsyncResult } from "../../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
import { getInjectable } from "@ogre-tools/injectable";
import isWindowsInjectable from "../../../common/vars/is-windows.injectable";
import computeUnixShellEnvironmentInjectable from "./compute-unix-shell-environment.injectable";
export type EnvironmentVariables = Partial<Record<string, string>>;
export type ComputeShellEnvironment = (shell: string) => Promise<AsyncResult<EnvironmentVariables | undefined, string>>;
export type ComputeShellEnvironment = (shell: string) => AsyncResult<EnvironmentVariables | undefined, string>;
const computeShellEnvironmentInjectable = getInjectable({
id: "compute-shell-environment",

View File

@ -10,10 +10,10 @@ import type { Cluster } from "../../common/cluster/cluster";
import { requestApiVersionsInjectionToken } from "./request-api-versions";
import { withConcurrencyLimit } from "@k8slens/utilities";
import requestKubeApiResourcesForInjectable from "./request-kube-api-resources-for.injectable";
import type { AsyncResult } from "../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
import { backoffCaller } from "../../common/utils/backoff-caller";
export type RequestApiResources = (cluster: Cluster) => Promise<AsyncResult<KubeApiResource[], Error>>;
export type RequestApiResources = (cluster: Cluster) => AsyncResult<KubeApiResource[], Error>;
export interface KubeResourceListGroup {
group: string;

View File

@ -5,14 +5,14 @@
import { getInjectionToken } from "@ogre-tools/injectable";
import type { Cluster } from "../../common/cluster/cluster";
import type { AsyncResult } from "../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
export interface KubeResourceListGroup {
group: string;
path: string;
}
export type RequestApiVersions = (cluster: Cluster) => Promise<AsyncResult<KubeResourceListGroup[], Error>>;
export type RequestApiVersions = (cluster: Cluster) => AsyncResult<KubeResourceListGroup[], Error>;
export const requestApiVersionsInjectionToken = getInjectionToken<RequestApiVersions>({
id: "request-api-versions-token",

View File

@ -6,11 +6,11 @@ import type { V1APIResourceList } from "@kubernetes/client-node";
import { getInjectable } from "@ogre-tools/injectable";
import type { Cluster } from "../../common/cluster/cluster";
import type { KubeApiResource } from "../../common/rbac";
import type { AsyncResult } from "../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
import k8sRequestInjectable from "../k8s-request.injectable";
import type { KubeResourceListGroup } from "./request-api-versions";
export type RequestKubeApiResources = (grouping: KubeResourceListGroup) => Promise<AsyncResult<KubeApiResource[], Error>>;
export type RequestKubeApiResources = (grouping: KubeResourceListGroup) => AsyncResult<KubeApiResource[], Error>;
export type RequestKubeApiResourcesFor = (cluster: Cluster) => RequestKubeApiResources;

View File

@ -5,11 +5,11 @@
import { getInjectable } from "@ogre-tools/injectable";
import type { ExecFileException } from "child_process";
import execFileInjectable from "../../../common/fs/exec-file.injectable";
import type { AsyncResult } from "../../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
import helmBinaryPathInjectable from "../helm-binary-path.injectable";
import execHelmEnvInjectable from "./exec-env.injectable";
export type ExecHelm = (args: string[]) => Promise<AsyncResult<string, ExecFileException & { stderr: string }>>;
export type ExecHelm = (args: string[]) => AsyncResult<string, ExecFileException & { stderr: string }>;
const execHelmInjectable = getInjectable({
id: "exec-helm",

View File

@ -4,7 +4,7 @@
*/
import { getInjectable } from "@ogre-tools/injectable";
import execHelmInjectable from "../exec-helm/exec-helm.injectable";
import type { AsyncResult } from "../../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
export type HelmEnv = Record<string, string> & {
HELM_REPOSITORY_CACHE?: string;
@ -17,7 +17,7 @@ const getHelmEnvInjectable = getInjectable({
instantiate: (di) => {
const execHelm = di.inject(execHelmInjectable);
return async (): Promise<AsyncResult<HelmEnv>> => {
return async (): AsyncResult<HelmEnv> => {
const result = await execHelm(["env"]);
if (!result.callWasSuccessful) {

View File

@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import type { AsyncResult } from "../../../../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
import execHelmInjectable from "../../../exec-helm/exec-helm.injectable";
import yaml from "js-yaml";
import type { KubeJsonApiData, KubeJsonApiDataList } from "../../../../../common/k8s-api/kube-json-api";
@ -18,7 +18,7 @@ const callForHelmManifestInjectable = getInjectable({
name: string,
namespace: string,
kubeconfigPath: string,
): Promise<AsyncResult<(KubeJsonApiData | KubeJsonApiDataList)[]>> => {
): AsyncResult<(KubeJsonApiData | KubeJsonApiDataList)[]> => {
const result = await execHelm([
"get",
"manifest",

View File

@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import type { AsyncResult } from "../../../../../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
import nonPromiseExecFileInjectable from "./non-promise-exec-file.injectable";
import { isNumber } from "@k8slens/utilities";
import assert from "assert";
@ -13,7 +13,7 @@ export type ExecFileWithInput = (options: {
filePath: string;
commandArguments: string[];
input: string;
}) => Promise<AsyncResult<string, unknown>>;
}) => AsyncResult<string, unknown>;
const execFileWithInputInjectable = getInjectable({
id: "exec-file-with-input",

View File

@ -5,7 +5,7 @@
import { getDiForUnitTesting } from "../../../../../getDiForUnitTesting";
import type { ExecFileWithInput } from "./exec-file-with-input.injectable";
import execFileWithInputInjectable from "./exec-file-with-input.injectable";
import type { AsyncResult } from "../../../../../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
import nonPromiseExecFileInjectable from "./non-promise-exec-file.injectable";
import { getPromiseStatus } from "@k8slens/test-utils";
import EventEmitter from "events";
@ -56,7 +56,7 @@ describe("exec-file-with-input", () => {
});
describe("when called", () => {
let actualPromise: Promise<AsyncResult<string, unknown>>;
let actualPromise: AsyncResult<string, unknown>;
beforeEach(() => {
actualPromise = execFileWithInput({

View File

@ -5,13 +5,13 @@
import { getInjectable } from "@ogre-tools/injectable";
import callForHelmManifestInjectable from "./call-for-helm-manifest/call-for-helm-manifest.injectable";
import type { KubeJsonApiData, KubeJsonApiDataList } from "../../../../common/k8s-api/kube-json-api";
import type { AsyncResult } from "../../../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
export type GetHelmReleaseResources = (
name: string,
namespace: string,
kubeconfigPath: string,
) => Promise<AsyncResult<KubeJsonApiData[], string>>;
) => AsyncResult<KubeJsonApiData[], string>;
const getHelmReleaseResourcesInjectable = getInjectable({
id: "get-helm-release-resources",

View File

@ -12,7 +12,7 @@ import type { AsyncFnMock } from "@async-fn/jest";
import asyncFn from "@async-fn/jest";
import type { ExecFileWithInput } from "./call-for-kube-resources-by-manifest/exec-file-with-input/exec-file-with-input.injectable";
import execFileWithInputInjectable from "./call-for-kube-resources-by-manifest/exec-file-with-input/exec-file-with-input.injectable";
import type { AsyncResult } from "../../../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
import type { KubeJsonApiData } from "../../../../common/k8s-api/kube-json-api";
describe("get helm release resources", () => {
@ -37,7 +37,7 @@ describe("get helm release resources", () => {
});
describe("when called", () => {
let actualPromise: Promise<AsyncResult<KubeJsonApiData[], string>>;
let actualPromise: AsyncResult<KubeJsonApiData[], string>;
beforeEach(() => {
actualPromise = getHelmReleaseResources(

View File

@ -6,7 +6,7 @@ import { getInjectable } from "@ogre-tools/injectable";
import execHelmInjectable from "../../exec-helm/exec-helm.injectable";
import type { HelmRepo } from "../../../../common/helm/helm-repo";
import loggerInjectable from "../../../../common/logger.injectable";
import type { AsyncResult } from "../../../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
const removeHelmRepositoryInjectable = getInjectable({
id: "remove-helm-repository",
@ -15,7 +15,7 @@ const removeHelmRepositoryInjectable = getInjectable({
const execHelm = di.inject(execHelmInjectable);
const logger = di.inject(loggerInjectable);
return async (repo: HelmRepo): Promise<AsyncResult<void, string>> => {
return async (repo: HelmRepo): AsyncResult<void, string> => {
logger.info(`[HELM]: removing repo ${repo.name} (${repo.url})`);
const result = await execHelm([

View File

@ -14,7 +14,7 @@ import type { WriteFile } from "../../common/fs/write-file.injectable";
import type { RemovePath } from "../../common/fs/remove.injectable";
import type { ExecFile } from "../../common/fs/exec-file.injectable";
import type { JoinPaths } from "../../common/path/join-paths.injectable";
import type { AsyncResult } from "../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
export interface ResourceApplierDependencies {
emitAppEvent: EmitAppEvent;
@ -67,13 +67,13 @@ export class ResourceApplier {
throw result.error.stderr || result.error.message;
}
async create(resource: string): Promise<AsyncResult<string, string>> {
async create(resource: string): AsyncResult<string, string> {
this.dependencies.emitAppEvent({ name: "resource", action: "apply" });
return this.kubectlApply(this.sanitizeObject(resource));
}
protected async kubectlApply(content: string): Promise<AsyncResult<string, string>> {
protected async kubectlApply(content: string): AsyncResult<string, string> {
const kubectl = await this.cluster.ensureKubectl();
const kubectlPath = await kubectl.getPath();
const proxyKubeconfigPath = await this.cluster.getProxyKubeconfigPath();
@ -112,15 +112,15 @@ export class ResourceApplier {
}
}
public async kubectlApplyAll(resources: string[], extraArgs = ["-o", "json"]): Promise<AsyncResult<string, string>> {
public async kubectlApplyAll(resources: string[], extraArgs = ["-o", "json"]): AsyncResult<string, string> {
return this.kubectlCmdAll("apply", resources, extraArgs);
}
public async kubectlDeleteAll(resources: string[], extraArgs?: string[]): Promise<AsyncResult<string, string>> {
public async kubectlDeleteAll(resources: string[], extraArgs?: string[]): AsyncResult<string, string> {
return this.kubectlCmdAll("delete", resources, extraArgs);
}
protected async kubectlCmdAll(subCmd: string, resources: string[], parentArgs: string[] = []): Promise<AsyncResult<string, string>> {
protected async kubectlCmdAll(subCmd: string, resources: string[], parentArgs: string[] = []): AsyncResult<string, string> {
const kubectl = await this.cluster.ensureKubectl();
const kubectlPath = await kubectl.getPath();
const proxyKubeconfigPath = await this.cluster.getProxyKubeconfigPath();

View File

@ -17,7 +17,6 @@ import type { CatalogCategory, CatalogCategoryRegistry, CatalogEntity } from "..
import { CatalogAddButton } from "./catalog-add-button";
import type { ShowNotification } from "../notifications";
import { MainLayout } from "../layout/main-layout";
import type { StorageLayer } from "@k8slens/utilities";
import { prevDefault } from "@k8slens/utilities";
import { CatalogEntityDetails } from "./entity-details/view";
import { CatalogMenu } from "./catalog-menu";
@ -51,6 +50,7 @@ import emitAppEventInjectable from "../../../common/app-event-bus/emit-event.inj
import type { Logger } from "../../../common/logger";
import loggerInjectable from "../../../common/logger.injectable";
import showErrorNotificationInjectable from "../notifications/show-error-notification.injectable";
import type { StorageLayer } from "../../utils/storage-helper";
interface Dependencies {
catalogPreviousActiveTabStorage: StorageLayer<string | null>;

View File

@ -7,7 +7,7 @@ import type { HelmReleaseDto } from "../../../../../common/k8s-api/endpoints/hel
import requestHelmReleasesInjectable from "../../../../../common/k8s-api/endpoints/helm-releases.api/request-releases.injectable";
import type { HelmReleaseDetails } from "../../../../../common/k8s-api/endpoints/helm-releases.api/request-details.injectable";
import requestHelmReleaseDetailsInjectable from "../../../../../common/k8s-api/endpoints/helm-releases.api/request-details.injectable";
import type { AsyncResult } from "../../../../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
export interface DetailedHelmRelease {
release: HelmReleaseDto;
@ -17,7 +17,7 @@ export interface DetailedHelmRelease {
export type RequestDetailedHelmRelease = (
name: string,
namespace: string
) => Promise<AsyncResult<DetailedHelmRelease>>;
) => AsyncResult<DetailedHelmRelease>;
const requestDetailedHelmReleaseInjectable = getInjectable({
id: "request-detailed-helm-release",

View File

@ -2,13 +2,13 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import autoBind from "auto-bind";
import { sum } from "lodash";
import { computed, makeObservable } from "mobx";
import type { Node, NodeApi } from "../../../common/k8s-api/endpoints";
import type { KubeObjectStoreDependencies, KubeObjectStoreOptions } from "../../../common/k8s-api/kube-object.store";
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
import { autoBind } from "@k8slens/utilities";
export class NodeStore extends KubeObjectStore<Node, NodeApi> {
constructor(dependencies: KubeObjectStoreDependencies, api: NodeApi, opts?: KubeObjectStoreOptions) {

View File

@ -18,10 +18,10 @@ import type { IComputedValue } from "mobx";
import currentRouteComponentInjectable from "../../routes/current-route-component.injectable";
import welcomeRouteInjectable from "../../../common/front-end-routing/routes/welcome/welcome-route.injectable";
import { buildURL } from "@k8slens/utilities";
import type { StorageLayer } from "@k8slens/utilities";
import type { WatchForGeneralEntityNavigation } from "../../api/helpers/watch-for-general-entity-navigation.injectable";
import watchForGeneralEntityNavigationInjectable from "../../api/helpers/watch-for-general-entity-navigation.injectable";
import currentPathInjectable from "../../routes/current-path.injectable";
import type { StorageLayer } from "../../utils/storage-helper";
interface Dependencies {
catalogPreviousActiveTabStorage: StorageLayer<string | null>;

View File

@ -5,9 +5,9 @@
import * as uuid from "uuid";
import { action, comparer, computed, makeObservable, observable, reaction, runInAction } from "mobx";
import type { StorageLayer } from "@k8slens/utilities";
import { autoBind } from "@k8slens/utilities";
import throttle from "lodash/throttle";
import type { StorageLayer } from "../../../utils/storage-helper";
import autoBind from "auto-bind";
export type TabId = string;

View File

@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import type { AsyncResult } from "../../../../../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
import apiManagerInjectable from "../../../../../../common/k8s-api/api-manager/manager.injectable";
import type { JsonPatch } from "../../../../../../common/k8s-api/kube-object.store";
import type { KubeObject } from "../../../../../../common/k8s-api/kube-object";
@ -13,7 +13,7 @@ import { getErrorMessage } from "../../../../../../common/utils/get-error-messag
export type CallForPatchResource = (
item: KubeObject,
patch: JsonPatch
) => Promise<AsyncResult<{ name: string; kind: string }>>;
) => AsyncResult<{ name: string; kind: string }>;
const callForPatchResourceInjectable = getInjectable({
id: "call-for-patch-resource",

View File

@ -5,14 +5,14 @@
import { getInjectable } from "@ogre-tools/injectable";
import type { KubeObject } from "../../../../../../common/k8s-api/kube-object";
import { parseKubeApi } from "../../../../../../common/k8s-api/kube-api-parse";
import type { AsyncResult } from "../../../../../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
import { getErrorMessage } from "../../../../../../common/utils/get-error-message";
import apiManagerInjectable from "../../../../../../common/k8s-api/api-manager/manager.injectable";
import { waitUntilDefined } from "@k8slens/utilities";
export type CallForResource = (
selfLink: string
) => Promise<AsyncResult<KubeObject | undefined>>;
) => AsyncResult<KubeObject | undefined>;
const callForResourceInjectable = getInjectable({
id: "call-for-resource",

View File

@ -13,7 +13,7 @@ import releasesInjectable from "../../+helm-releases/releases.injectable";
import updateReleaseInjectable from "../../+helm-releases/update-release/update-release.injectable";
import type { HelmRelease } from "../../../../common/k8s-api/endpoints/helm-releases.api";
import requestHelmReleaseConfigurationInjectable from "../../../../common/k8s-api/endpoints/helm-releases.api/request-configuration.injectable";
import type { AsyncResult } from "../../../../common/utils/async-result";
import type { AsyncResult } from "@k8slens/utilities";
import { waitUntilDefined } from "@k8slens/utilities";
import type { SelectOption } from "../../select";
import type { DockTab } from "../dock/store";
@ -22,7 +22,7 @@ import upgradeChartTabDataInjectable from "./tab-data.injectable";
export interface UpgradeChartModel {
readonly release: HelmRelease;
readonly versionOptions: IComputedValue<SelectOption<HelmChartVersion>[]>;
readonly configration: {
readonly configuration: {
readonly value: IComputedValue<string>;
set: (value: string) => void;
readonly error: IComputedValue<string | undefined>;
@ -32,7 +32,7 @@ export interface UpgradeChartModel {
readonly value: IComputedValue<HelmChartVersion | undefined>;
set: (value: SingleValue<SelectOption<HelmChartVersion>>) => void;
};
submit: () => Promise<AsyncResult<void, string>>;
submit: () => AsyncResult<void, string>;
}
const upgradeChartModelInjectable = getInjectable({
@ -69,7 +69,7 @@ const upgradeChartModelInjectable = getInjectable({
const configrationValue = observable.box<string>();
const configrationEditError = observable.box<string>();
const configration: UpgradeChartModel["configration"] = {
const configration: UpgradeChartModel["configuration"] = {
value: computed(() => configrationValue.get() ?? storedConfiguration.value.get()),
set: action((value) => {
configrationValue.set(value);
@ -97,7 +97,7 @@ const upgradeChartModelInjectable = getInjectable({
return {
release,
versionOptions,
configration,
configuration: configration,
version,
submit: async () => {
const selectedVersion = version.value.get();

View File

@ -61,7 +61,7 @@ export class NonInjectedUpgradeChart extends React.Component<UpgradeChartProps &
>
<InfoPanel
tabId={tabId}
error={model.configration.error.get()}
error={model.configuration.error.get()}
submit={this.upgrade}
submitLabel="Upgrade"
submittingMessage="Updating.."
@ -90,9 +90,9 @@ export class NonInjectedUpgradeChart extends React.Component<UpgradeChartProps &
/>
<EditorPanel
tabId={tabId}
value={model.configration.value.get()}
onChange={model.configration.set}
onError={model.configration.setError}
value={model.configuration.value.get()}
onChange={model.configuration.set}
onError={model.configuration.setError}
/>
</div>
);

View File

@ -8,7 +8,7 @@ import "./drawer.scss";
import React from "react";
import { clipboard } from "electron";
import { createPortal } from "react-dom";
import type { SingleOrMany, StorageLayer } from "@k8slens/utilities";
import type { SingleOrMany } from "@k8slens/utilities";
import { cssNames, noop } from "@k8slens/utilities";
import { Icon } from "../icon";
import type { AnimateName } from "../animate";
@ -18,6 +18,7 @@ import drawerStorageInjectable, { defaultDrawerWidth } from "./drawer-storage/dr
import { withInjectables } from "@ogre-tools/injectable-react";
import historyInjectable from "../../navigation/history.injectable";
import type { History } from "history";
import type { StorageLayer } from "../../utils/storage-helper";
export type DrawerPosition = "top" | "left" | "right" | "bottom";

View File

@ -3,9 +3,9 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import autoBind from "auto-bind";
import { computed, observable, reaction, makeObservable, action } from "mobx";
import type { PageParam } from "../../../navigation/page-param";
import { autoBind } from "@k8slens/utilities";
export enum FilterType {
SEARCH = "search",

View File

@ -7,7 +7,7 @@ import { getInjectable } from "@ogre-tools/injectable";
import { computed } from "mobx";
import { computedInjectManyInjectable } from "@ogre-tools/injectable-extension-for-mobx";
import { kubeObjectDetailItemInjectionToken } from "./kube-object-detail-item-injection-token";
import { byValue } from "../../../../common/utils/sort-function";
import { byValue } from "@k8slens/utilities";
const kubeObjectDetailItemsInjectable = getInjectable({
id: "kube-object-detail-items",

View File

@ -7,7 +7,7 @@ import styles from "./kubeconfig-dialog.module.scss";
import React from "react";
import type { IObservableValue } from "mobx";
import { observer } from "mobx-react";
import { cssNames, saveFileDialog } from "@k8slens/utilities";
import { cssNames } from "@k8slens/utilities";
import { Button } from "../button";
import type { DialogProps } from "../dialog";
import { Dialog } from "../dialog";
@ -19,6 +19,7 @@ import { clipboard } from "electron";
import { withInjectables } from "@ogre-tools/injectable-react";
import showSuccessNotificationInjectable from "../notifications/show-success-notification.injectable";
import kubeconfigDialogStateInjectable from "./state.injectable";
import { saveFileDialog } from "../../utils/saveFile";
export interface KubeconfigDialogData {
title?: React.ReactNode;

View File

@ -7,13 +7,13 @@ import styles from "./main-layout.module.scss";
import React from "react";
import { observer } from "mobx-react";
import type { StorageLayer } from "@k8slens/utilities";
import { cssNames } from "@k8slens/utilities";
import { ErrorBoundary } from "../error-boundary";
import { ResizeDirection, ResizeGrowthDirection, ResizeSide, ResizingAnchor } from "../resizing-anchor";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { SidebarStorageState } from "./sidebar-storage/sidebar-storage.injectable";
import sidebarStorageInjectable, { defaultSidebarWidth } from "./sidebar-storage/sidebar-storage.injectable";
import type { StorageLayer } from "../../utils/storage-helper";
export interface MainLayoutProps {
sidebar: React.ReactNode;

View File

@ -7,7 +7,6 @@ import styles from "./sidebar-items.module.scss";
import React from "react";
import { computed, makeObservable } from "mobx";
import type { StorageLayer } from "@k8slens/utilities";
import { cssNames } from "@k8slens/utilities";
import { observer } from "mobx-react";
import { NavLink } from "react-router-dom";
@ -16,6 +15,7 @@ import { withInjectables } from "@ogre-tools/injectable-react";
import type { SidebarStorageState } from "./sidebar-storage/sidebar-storage.injectable";
import sidebarStorageInjectable from "./sidebar-storage/sidebar-storage.injectable";
import type { HierarchicalSidebarItem } from "./sidebar-items.injectable";
import type { StorageLayer } from "../../utils/storage-helper";
interface Dependencies {
sidebarStorage: StorageLayer<SidebarStorageState>;

View File

@ -2,7 +2,7 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { StorageLayer } from "@k8slens/utilities";
import type { StorageLayer } from "../../../utils/storage-helper";
import type { TableSortParams } from "../table";
export interface TableStorageModel {

View File

@ -9,7 +9,7 @@ import type { ReactNode } from "react";
import React, { useState } from "react";
import type { TooltipProps } from "./tooltip";
import { Tooltip } from "./tooltip";
import { isReactNode } from "../../utils/isReactNode";
import { isReactNode } from "@k8slens/utilities";
import uniqueId from "lodash/uniqueId";
import type { SingleOrMany } from "@k8slens/utilities";

View File

@ -9,10 +9,10 @@ import { windowActionHandleChannel, windowLocationChangedChannel, windowOpenAppM
import { extensionDiscoveryStateChannel, extensionLoaderFromMainChannel } from "../../common/ipc/extension-handling";
import type { InstalledExtension } from "../../extensions/extension-discovery/extension-discovery";
import type { LensExtensionId } from "../../extensions/lens-extension";
import { toJS } from "@k8slens/utilities";
import type { Location } from "history";
import { getLegacyGlobalDiForExtensionApi } from "../../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
import ipcRendererInjectable from "../utils/channel/ipc-renderer.injectable";
import { toJS } from "../../common/utils";
function requestMain(channel: string, ...args: any[]) {
const di = getLegacyGlobalDiForExtensionApi();

View File

@ -4,8 +4,8 @@
*/
import autoBind from "auto-bind";
import type { ItemObject } from "../../common/item.store";
import { autoBind } from "@k8slens/utilities";
export type ForwardedPortStatus = "Active" | "Disabled";
export interface ForwardedPort {