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

Remove usages of "bind" utility method for simplicity

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2022-01-31 10:59:09 +02:00 committed by Sebastian Malton
parent 44a060ff42
commit 3a2633c28d
33 changed files with 238 additions and 364 deletions

View File

@ -6,7 +6,6 @@ import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import type { EnsureOptions, WriteOptions } from "fs-extra"; import type { EnsureOptions, WriteOptions } from "fs-extra";
import path from "path"; import path from "path";
import type { JsonValue } from "type-fest"; import type { JsonValue } from "type-fest";
import { bind } from "../utils";
import fsInjectable from "./fs.injectable"; import fsInjectable from "./fs.injectable";
interface Dependencies { interface Dependencies {
@ -14,7 +13,7 @@ interface Dependencies {
ensureDir: (dir: string, options?: EnsureOptions | number) => Promise<void>; ensureDir: (dir: string, options?: EnsureOptions | number) => Promise<void>;
} }
async function writeJsonFile({ writeJson, ensureDir }: Dependencies, filePath: string, content: JsonValue, options?: WriteOptions | BufferEncoding) { const writeJsonFile = ({ writeJson, ensureDir }: Dependencies) => async (filePath: string, content: JsonValue, options?: WriteOptions | BufferEncoding) => {
await ensureDir(path.dirname(filePath), { mode: 0o755 }); await ensureDir(path.dirname(filePath), { mode: 0o755 });
const resolvedOptions = typeof options === "string" const resolvedOptions = typeof options === "string"
@ -28,17 +27,18 @@ async function writeJsonFile({ writeJson, ensureDir }: Dependencies, filePath: s
spaces: 2, spaces: 2,
...resolvedOptions, ...resolvedOptions,
}); });
} };
const writeJsonFileInjectable = getInjectable({ const writeJsonFileInjectable = getInjectable({
instantiate: (di) => { instantiate: (di) => {
const { writeJson, ensureDir } = di.inject(fsInjectable); const { writeJson, ensureDir } = di.inject(fsInjectable);
return bind(writeJsonFile, null, { return writeJsonFile({
writeJson, writeJson,
ensureDir, ensureDir,
}); });
}, },
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -6,7 +6,6 @@ import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { orderBy } from "lodash"; import { orderBy } from "lodash";
import type { IComputedValue } from "mobx"; import type { IComputedValue } from "mobx";
import type { CatalogCategory, CatalogEntity } from "../../../common/catalog"; import type { CatalogCategory, CatalogEntity } from "../../../common/catalog";
import { bind } from "../../utils";
import type { ItemListLayoutProps } from "../item-object-list"; import type { ItemListLayoutProps } from "../item-object-list";
import type { RegisteredAdditionalCategoryColumn } from "./custom-category-columns"; import type { RegisteredAdditionalCategoryColumn } from "./custom-category-columns";
import categoryColumnsInjectable from "./custom-category-columns.injectable"; import categoryColumnsInjectable from "./custom-category-columns.injectable";
@ -50,7 +49,7 @@ function getBrowseAllColumns(): RegisteredAdditionalCategoryColumn[] {
]; ];
} }
function getCategoryColumns({ extensionColumns }: Dependencies, { activeCategory }: GetCategoryColumnsParams): CategoryColumns { const getCategoryColumns = ({ extensionColumns }: Dependencies) => ({ activeCategory }: GetCategoryColumnsParams): CategoryColumns => {
const allRegistrations = orderBy( const allRegistrations = orderBy(
activeCategory activeCategory
? getSpecificCategoryColumns(activeCategory, extensionColumns) ? getSpecificCategoryColumns(activeCategory, extensionColumns)
@ -83,12 +82,13 @@ function getCategoryColumns({ extensionColumns }: Dependencies, { activeCategory
renderTableContents: entity => tableRowRenderers.map(fn => fn(entity)), renderTableContents: entity => tableRowRenderers.map(fn => fn(entity)),
searchFilters, searchFilters,
}; };
} };
const getCategoryColumnsInjectable = getInjectable({ const getCategoryColumnsInjectable = getInjectable({
instantiate: (di) => bind(getCategoryColumns, null, { instantiate: (di) => getCategoryColumns({
extensionColumns: di.inject(categoryColumnsInjectable), extensionColumns: di.inject(categoryColumnsInjectable),
}), }),
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -7,14 +7,13 @@ import { requestOpenFilePickingDialog } from "../../ipc";
import { supportedExtensionFormats } from "./supported-extension-formats"; import { supportedExtensionFormats } from "./supported-extension-formats";
import attemptInstallsInjectable from "./attempt-installs/attempt-installs.injectable"; import attemptInstallsInjectable from "./attempt-installs/attempt-installs.injectable";
import directoryForDownloadsInjectable from "../../../common/app-paths/directory-for-downloads/directory-for-downloads.injectable"; import directoryForDownloadsInjectable from "../../../common/app-paths/directory-for-downloads/directory-for-downloads.injectable";
import { bind } from "../../utils";
interface Dependencies { interface Dependencies {
attemptInstalls: (filePaths: string[]) => Promise<void> attemptInstalls: (filePaths: string[]) => Promise<void>
directoryForDownloads: string directoryForDownloads: string
} }
async function installFromSelectFileDialog({ attemptInstalls, directoryForDownloads }: Dependencies) { const installFromSelectFileDialog = ({ attemptInstalls, directoryForDownloads }: Dependencies) => async () => {
const { canceled, filePaths } = await requestOpenFilePickingDialog({ const { canceled, filePaths } = await requestOpenFilePickingDialog({
defaultPath: directoryForDownloads, defaultPath: directoryForDownloads,
properties: ["openFile", "multiSelections"], properties: ["openFile", "multiSelections"],
@ -26,13 +25,14 @@ async function installFromSelectFileDialog({ attemptInstalls, directoryForDownlo
if (!canceled) { if (!canceled) {
await attemptInstalls(filePaths); await attemptInstalls(filePaths);
} }
} };
const installFromSelectFileDialogInjectable = getInjectable({ const installFromSelectFileDialogInjectable = getInjectable({
instantiate: (di) => bind(installFromSelectFileDialog, null, { instantiate: (di) => installFromSelectFileDialog({
attemptInstalls: di.inject(attemptInstallsInjectable), attemptInstalls: di.inject(attemptInstallsInjectable),
directoryForDownloads: di.inject(directoryForDownloadsInjectable), directoryForDownloads: di.inject(directoryForDownloadsInjectable),
}), }),
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -3,23 +3,18 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils";
import type { TabId } from "../dock/store"; import type { TabId } from "../dock/store";
import type { CreateResourceTabStore } from "./store";
import createResourceTabStoreInjectable from "./store.injectable"; import createResourceTabStoreInjectable from "./store.injectable";
interface Dependencies {
createResourceTabStore: CreateResourceTabStore;
}
function clearCreateResourceTabData({ createResourceTabStore }: Dependencies, tabId: TabId): void {
createResourceTabStore.clearData(tabId);
}
const clearCreateResourceTabDataInjectable = getInjectable({ const clearCreateResourceTabDataInjectable = getInjectable({
instantiate: (di) => bind(clearCreateResourceTabData, null, { instantiate: (di) => {
createResourceTabStore: di.inject(createResourceTabStoreInjectable), const createResourceTabStore = di.inject(createResourceTabStoreInjectable);
}),
return (tabId: TabId): void => {
createResourceTabStore.clearData(tabId);
};
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -3,26 +3,20 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils";
import dockStoreInjectable from "../dock/store.injectable"; import dockStoreInjectable from "../dock/store.injectable";
import { DockStore, DockTabCreateSpecific, TabKind } from "../dock/store"; import { DockTabCreateSpecific, TabKind } from "../dock/store";
interface Dependencies { const createResourceTabInjectable = getInjectable({
dockStore: DockStore instantiate: (di) => {
} const dockStore = di.inject(dockStoreInjectable);
function createResourceTab({ dockStore }: Dependencies, tabParams: DockTabCreateSpecific = {}) { return (tabParams: DockTabCreateSpecific = {}) =>
return dockStore.createTab({ dockStore.createTab({
title: "Create resource", title: "Create resource",
...tabParams, ...tabParams,
kind: TabKind.CREATE_RESOURCE, kind: TabKind.CREATE_RESOURCE,
}); });
} },
const createResourceTabInjectable = getInjectable({
instantiate: (di) => bind(createResourceTab, null, {
dockStore: di.inject(dockStoreInjectable),
}),
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -3,22 +3,18 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils"; import type { TabId } from "./store";
import type { DockStore, TabId } from "./store";
import dockStoreInjectable from "./store.injectable"; import dockStoreInjectable from "./store.injectable";
interface Dependencies {
dockStore: DockStore;
}
function closeDockTab({ dockStore }: Dependencies, tabId: TabId): void {
dockStore.closeTab(tabId);
}
const closeDockTabInjectable = getInjectable({ const closeDockTabInjectable = getInjectable({
instantiate: (di) => bind(closeDockTab, null, { instantiate: (di) => {
dockStore: di.inject(dockStoreInjectable), const dockStore = di.inject(dockStoreInjectable);
}),
return (tabId: TabId): void => {
dockStore.closeTab(tabId);
};
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -3,22 +3,17 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils";
import dockStoreInjectable from "./store.injectable"; import dockStoreInjectable from "./store.injectable";
import type { DockStore, DockTab, DockTabCreate } from "./store"; import type { DockTab, DockTabCreate } from "./store";
interface Dependencies {
dockStore: DockStore;
}
function createDockTab({ dockStore }: Dependencies, rawTabDesc: DockTabCreate, addNumber?: boolean): DockTab {
return dockStore.createTab(rawTabDesc, addNumber);
}
const createDockTabInjectable = getInjectable({ const createDockTabInjectable = getInjectable({
instantiate: (di) => bind(createDockTab, null, { instantiate: (di) => {
dockStore: di.inject(dockStoreInjectable), const dockStore = di.inject(dockStoreInjectable);
}),
return (rawTabDesc: DockTabCreate, addNumber?: boolean): DockTab =>
dockStore.createTab(rawTabDesc, addNumber);
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -3,22 +3,19 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils";
import dockStoreInjectable from "./store.injectable"; import dockStoreInjectable from "./store.injectable";
import type { DockStore, TabId } from "./store"; import type { TabId } from "./store";
interface Dependencies {
dockStore: DockStore;
}
function renameTab({ dockStore }: Dependencies, tabId: TabId, title: string): void {
dockStore.renameTab(tabId, title);
}
const renameTabInjectable = getInjectable({ const renameTabInjectable = getInjectable({
instantiate: (di) => bind(renameTab, null, {
dockStore: di.inject(dockStoreInjectable), instantiate: (di) => {
}), const dockStore = di.inject(dockStoreInjectable);
return (tabId: TabId, title: string): void => {
dockStore.renameTab(tabId, title);
};
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -3,22 +3,18 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils"; import type { TabId } from "./store";
import type { DockStore, TabId } from "./store";
import dockStoreInjectable from "./store.injectable"; import dockStoreInjectable from "./store.injectable";
interface Dependencies {
dockStore: DockStore;
}
function selectDockTab({ dockStore }: Dependencies, tabId: TabId): void {
dockStore.selectTab(tabId);
}
const selectDockTabInjectable = getInjectable({ const selectDockTabInjectable = getInjectable({
instantiate: (di) => bind(selectDockTab, null, { instantiate: (di) => {
dockStore: di.inject(dockStoreInjectable), const dockStore = di.inject(dockStoreInjectable);
}),
return (tabId: TabId): void => {
dockStore.selectTab(tabId);
};
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -3,23 +3,18 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils";
import type { TabId } from "../dock/store"; import type { TabId } from "../dock/store";
import type { EditResourceTabStore } from "./store";
import editResourceTabStoreInjectable from "./store.injectable"; import editResourceTabStoreInjectable from "./store.injectable";
interface Dependencies {
editResourceTabStore: EditResourceTabStore;
}
function clearEditResourceTabData({ editResourceTabStore }: Dependencies, tabId: TabId) {
editResourceTabStore.clearData(tabId);
}
const clearEditResourceTabDataInjectable = getInjectable({ const clearEditResourceTabDataInjectable = getInjectable({
instantiate: (di) => bind(clearEditResourceTabData, null, { instantiate: (di) => {
editResourceTabStore: di.inject(editResourceTabStoreInjectable), const editResourceTabStore = di.inject(editResourceTabStoreInjectable);
}),
return (tabId: TabId) => {
editResourceTabStore.clearData(tabId);
};
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -8,7 +8,6 @@ import dockStoreInjectable from "../dock/store.injectable";
import type { KubeObject } from "../../../../common/k8s-api/kube-object"; import type { KubeObject } from "../../../../common/k8s-api/kube-object";
import { DockStore, DockTabCreateSpecific, TabId, TabKind } from "../dock/store"; import { DockStore, DockTabCreateSpecific, TabId, TabKind } from "../dock/store";
import type { EditResourceTabStore } from "./store"; import type { EditResourceTabStore } from "./store";
import { bind } from "../../../utils";
import { runInAction } from "mobx"; import { runInAction } from "mobx";
interface Dependencies { interface Dependencies {
@ -16,7 +15,7 @@ interface Dependencies {
editResourceStore: EditResourceTabStore; editResourceStore: EditResourceTabStore;
} }
function createEditResourceTab({ dockStore, editResourceStore }: Dependencies, object: KubeObject, tabParams: DockTabCreateSpecific = {}): TabId { const createEditResourceTab = ({ dockStore, editResourceStore }: Dependencies) => (object: KubeObject, tabParams: DockTabCreateSpecific = {}): TabId => {
// use existing tab if already opened // use existing tab if already opened
const tabId = editResourceStore.getTabIdByResource(object); const tabId = editResourceStore.getTabIdByResource(object);
@ -43,10 +42,10 @@ function createEditResourceTab({ dockStore, editResourceStore }: Dependencies, o
return tab.id; return tab.id;
}); });
} };
const createEditResourceTabInjectable = getInjectable({ const createEditResourceTabInjectable = getInjectable({
instantiate: (di) => bind(createEditResourceTab, null, { instantiate: (di) => createEditResourceTab({
dockStore: di.inject(dockStoreInjectable), dockStore: di.inject(dockStoreInjectable),
editResourceStore: di.inject(editResourceTabStoreInjectable), editResourceStore: di.inject(editResourceTabStoreInjectable),
}), }),

View File

@ -3,23 +3,18 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils";
import type { TabId } from "../dock/store"; import type { TabId } from "../dock/store";
import type { InstallChartTabStore } from "./store";
import installChartTabStoreInjectable from "./store.injectable"; import installChartTabStoreInjectable from "./store.injectable";
interface Dependencies {
installChartTabStore: InstallChartTabStore;
}
function clearInstallChartTabData({ installChartTabStore }: Dependencies, tabId: TabId) {
installChartTabStore.clearData(tabId);
}
const clearInstallChartTabDataInjectable = getInjectable({ const clearInstallChartTabDataInjectable = getInjectable({
instantiate: (di) => bind(clearInstallChartTabData, null, { instantiate: (di) => {
installChartTabStore: di.inject(installChartTabStoreInjectable), const installChartTabStore = di.inject(installChartTabStoreInjectable);
}),
return (tabId: TabId) => {
installChartTabStore.clearData(tabId);
};
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -5,9 +5,13 @@
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import installChartTabStoreInjectable from "./store.injectable"; import installChartTabStoreInjectable from "./store.injectable";
import type { HelmChart } from "../../../../common/k8s-api/endpoints/helm-charts.api"; import type { HelmChart } from "../../../../common/k8s-api/endpoints/helm-charts.api";
import { DockTab, DockTabCreate, DockTabCreateSpecific, TabKind } from "../dock/store"; import {
DockTab,
DockTabCreate,
DockTabCreateSpecific,
TabKind,
} from "../dock/store";
import type { InstallChartTabStore } from "./store"; import type { InstallChartTabStore } from "./store";
import { bind } from "../../../utils";
import createDockTabInjectable from "../dock/create-dock-tab.injectable"; import createDockTabInjectable from "../dock/create-dock-tab.injectable";
interface Dependencies { interface Dependencies {
@ -15,7 +19,7 @@ interface Dependencies {
installChartStore: InstallChartTabStore; installChartStore: InstallChartTabStore;
} }
function createInstallChartTab({ createDockTab, installChartStore }: Dependencies, chart: HelmChart, tabParams: DockTabCreateSpecific = {}) { const createInstallChartTab = ({ createDockTab, installChartStore }: Dependencies) => (chart: HelmChart, tabParams: DockTabCreateSpecific = {}) => {
const { name, repo, version } = chart; const { name, repo, version } = chart;
const tab = createDockTab( const tab = createDockTab(
@ -37,10 +41,10 @@ function createInstallChartTab({ createDockTab, installChartStore }: Dependencie
}); });
return tab; return tab;
} };
const createInstallChartTabInjectable = getInjectable({ const createInstallChartTabInjectable = getInjectable({
instantiate: (di) => bind(createInstallChartTab, null, { instantiate: (di) => createInstallChartTab({
installChartStore: di.inject(installChartTabStoreInjectable), installChartStore: di.inject(installChartTabStoreInjectable),
createDockTab: di.inject(createDockTabInjectable), createDockTab: di.inject(createDockTabInjectable),
}), }),

View File

@ -3,23 +3,16 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils";
import type { TabId } from "../dock/store"; import type { TabId } from "../dock/store";
import type { LogStore } from "./store";
import logStoreInjectable from "./store.injectable"; import logStoreInjectable from "./store.injectable";
interface Dependencies {
logStore: LogStore;
}
function areLogsPresent({ logStore }: Dependencies, tabId: TabId) {
return logStore.areLogsPresent(tabId);
}
const areLogsPresentInjectable = getInjectable({ const areLogsPresentInjectable = getInjectable({
instantiate: (di) => bind(areLogsPresent, null, { instantiate: (di) => {
logStore: di.inject(logStoreInjectable), const logStore = di.inject(logStoreInjectable);
}),
return (tabId: TabId) => logStore.areLogsPresent(tabId);
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -3,23 +3,18 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils";
import type { TabId } from "../dock/store"; import type { TabId } from "../dock/store";
import type { LogTabStore } from "./tab-store";
import logTabStoreInjectable from "./tab-store.injectable"; import logTabStoreInjectable from "./tab-store.injectable";
interface Dependencies {
logTabStore: LogTabStore;
}
function clearLogTabData({ logTabStore }: Dependencies, tabId: TabId): void {
logTabStore.clearData(tabId);
}
const clearLogTabDataInjectable = getInjectable({ const clearLogTabDataInjectable = getInjectable({
instantiate: (di) => bind(clearLogTabData, null, { instantiate: (di) => {
logTabStore: di.inject(logTabStoreInjectable), const logTabStore = di.inject(logTabStoreInjectable);
}),
return (tabId: TabId): void => {
logTabStore.clearData(tabId);
};
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -3,7 +3,6 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils";
import { DockTabCreate, DockTab, TabKind, TabId } from "../dock/store"; import { DockTabCreate, DockTab, TabKind, TabId } from "../dock/store";
import type { LogTabData } from "./tab-store"; import type { LogTabData } from "./tab-store";
import * as uuid from "uuid"; import * as uuid from "uuid";
@ -18,7 +17,7 @@ interface Dependencies {
setLogTabData: (tabId: string, data: LogTabData) => void; setLogTabData: (tabId: string, data: LogTabData) => void;
} }
function createLogsTab({ createDockTab, setLogTabData }: Dependencies, title: string, data: CreateLogsTabData): TabId { const createLogsTab = ({ createDockTab, setLogTabData }: Dependencies) => (title: string, data: CreateLogsTabData): TabId => {
const id = `log-tab-${uuid.v4()}`; const id = `log-tab-${uuid.v4()}`;
runInAction(() => { runInAction(() => {
@ -35,13 +34,14 @@ function createLogsTab({ createDockTab, setLogTabData }: Dependencies, title: st
}); });
return id; return id;
} };
const createLogsTabInjectable = getInjectable({ const createLogsTabInjectable = getInjectable({
instantiate: (di) => bind(createLogsTab, null, { instantiate: (di) => createLogsTab({
createDockTab: di.inject(createDockTabInjectable), createDockTab: di.inject(createDockTabInjectable),
setLogTabData: di.inject(setLogTabDataInjectable), setLogTabData: di.inject(setLogTabDataInjectable),
}), }),
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -3,33 +3,28 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import type { Pod, IPodContainer } from "../../../../common/k8s-api/endpoints"; import type { IPodContainer, Pod } from "../../../../common/k8s-api/endpoints";
import { bind } from "../../../utils";
import type { TabId } from "../dock/store"; import type { TabId } from "../dock/store";
import createLogsTabInjectable, { CreateLogsTabData } from "./create-logs-tab.injectable"; import createLogsTabInjectable from "./create-logs-tab.injectable";
export interface PodLogsTabData { export interface PodLogsTabData {
selectedPod: Pod; selectedPod: Pod;
selectedContainer: IPodContainer; selectedContainer: IPodContainer;
} }
interface Dependencies { const createPodLogsTabInjectable = getInjectable({
createLogsTab: (title: string, data: CreateLogsTabData) => TabId; instantiate: (di) => {
} let createLogsTab = di.inject(createLogsTabInjectable);
function createPodLogsTab({ createLogsTab }: Dependencies, { selectedPod, selectedContainer }: PodLogsTabData): TabId { return ({ selectedPod, selectedContainer }: PodLogsTabData): TabId =>
return createLogsTab(`Pod ${selectedPod.getName()}`, { createLogsTab(`Pod ${selectedPod.getName()}`, {
owner: selectedPod.getOwnerRefs()[0], owner: selectedPod.getOwnerRefs()[0],
namespace: selectedPod.getNs(), namespace: selectedPod.getNs(),
selectedContainer: selectedContainer.name, selectedContainer: selectedContainer.name,
selectedPodId: selectedPod.getId(), selectedPodId: selectedPod.getId(),
}); });
} },
const createPodLogsTabInjectable = getInjectable({
instantiate: (di) => bind(createPodLogsTab, null, {
createLogsTab: di.inject(createLogsTabInjectable),
}),
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -5,7 +5,6 @@
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { podsStore } from "../../+workloads-pods/pods.store"; import { podsStore } from "../../+workloads-pods/pods.store";
import type { WorkloadKubeObject } from "../../../../common/k8s-api/workload-kube-object"; import type { WorkloadKubeObject } from "../../../../common/k8s-api/workload-kube-object";
import { bind } from "../../../utils";
import type { TabId } from "../dock/store"; import type { TabId } from "../dock/store";
import createLogsTabInjectable, { CreateLogsTabData } from "./create-logs-tab.injectable"; import createLogsTabInjectable, { CreateLogsTabData } from "./create-logs-tab.injectable";
@ -17,7 +16,7 @@ interface Dependencies {
createLogsTab: (title: string, data: CreateLogsTabData) => TabId; createLogsTab: (title: string, data: CreateLogsTabData) => TabId;
} }
function createWorkloadLogsTab({ createLogsTab }: Dependencies, { workload }: WorkloadLogsTabData): TabId | undefined { const createWorkloadLogsTab = ({ createLogsTab }: Dependencies) => ({ workload }: WorkloadLogsTabData): TabId | undefined => {
const pods = podsStore.getPodsByOwnerId(workload.getId()); const pods = podsStore.getPodsByOwnerId(workload.getId());
if (pods.length === 0) { if (pods.length === 0) {
@ -36,12 +35,13 @@ function createWorkloadLogsTab({ createLogsTab }: Dependencies, { workload }: Wo
uid: workload.getId(), uid: workload.getId(),
}, },
}); });
} };
const createWorkloadLogsTabInjectable = getInjectable({ const createWorkloadLogsTabInjectable = getInjectable({
instantiate: (di) => bind(createWorkloadLogsTab, null, { instantiate: (di) => createWorkloadLogsTab({
createLogsTab: di.inject(createLogsTabInjectable), createLogsTab: di.inject(createLogsTabInjectable),
}), }),
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -3,22 +3,16 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils"; import type { LogTabData } from "./tab-store";
import type { LogTabData, LogTabStore } from "./tab-store";
import logTabStoreInjectable from "./tab-store.injectable"; import logTabStoreInjectable from "./tab-store.injectable";
interface Dependencies {
logTabStore: LogTabStore;
}
function getLogTabData({ logTabStore }: Dependencies, tabId: string): LogTabData {
return logTabStore.getData(tabId);
}
const getLogTabDataInjectable = getInjectable({ const getLogTabDataInjectable = getInjectable({
instantiate: (di) => bind(getLogTabData, null, { instantiate: (di) => {
logTabStore: di.inject(logTabStoreInjectable), const logTabStore = di.inject(logTabStoreInjectable);
}),
return (tabId: string): LogTabData => logTabStore.getData(tabId);
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -3,22 +3,16 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils";
import type { LogStore } from "./store";
import logStoreInjectable from "./store.injectable"; import logStoreInjectable from "./store.injectable";
interface Dependencies {
logStore: LogStore;
}
function getLogsWithoutTimestamps({ logStore }: Dependencies, tabId: string): string[] {
return logStore.getLogsWithoutTimestamps(tabId);
}
const getLogsWithoutTimestampsInjectable = getInjectable({ const getLogsWithoutTimestampsInjectable = getInjectable({
instantiate: (di) => bind(getLogsWithoutTimestamps, null, { instantiate: (di) => {
logStore: di.inject(logStoreInjectable), const logStore = di.inject(logStoreInjectable);
}),
return (tabId: string): string[] =>
logStore.getLogsWithoutTimestamps(tabId);
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -3,22 +3,15 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils";
import type { LogStore } from "./store";
import logStoreInjectable from "./store.injectable"; import logStoreInjectable from "./store.injectable";
interface Dependencies {
logStore: LogStore;
}
function getLogs({ logStore }: Dependencies, tabId: string): string[] {
return logStore.getLogs(tabId);
}
const getLogsInjectable = getInjectable({ const getLogsInjectable = getInjectable({
instantiate: (di) => bind(getLogs, null, { instantiate: (di) => {
logStore: di.inject(logStoreInjectable), const logStore = di.inject(logStoreInjectable);
}),
return (tabId: string): string[] => logStore.getLogs(tabId);
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -3,22 +3,16 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils";
import type { LogStore } from "./store";
import logStoreInjectable from "./store.injectable"; import logStoreInjectable from "./store.injectable";
interface Dependencies {
logStore: LogStore;
}
function getTimestampSplitLogs({ logStore }: Dependencies, tabId: string): [string, string][] {
return logStore.getTimestampSplitLogs(tabId);
}
const getTimestampSplitLogsInjectable = getInjectable({ const getTimestampSplitLogsInjectable = getInjectable({
instantiate: (di) => bind(getTimestampSplitLogs, null, { instantiate: (di) => {
logStore: di.inject(logStoreInjectable), const logStore = di.inject(logStoreInjectable);
}),
return (tabId: string): [string, string][] =>
logStore.getTimestampSplitLogs(tabId);
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -3,23 +3,16 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils";
import type { TabId } from "../dock/store"; import type { TabId } from "../dock/store";
import type { LogTabStore } from "./tab-store";
import logTabStoreInjectable from "./tab-store.injectable"; import logTabStoreInjectable from "./tab-store.injectable";
interface Dependencies {
logTabStore: LogTabStore;
}
function isLogsTabDataValid({ logTabStore }: Dependencies, tabId: TabId) {
return logTabStore.isDataValid(tabId);
}
const isLogsTabDataValidInjectable = getInjectable({ const isLogsTabDataValidInjectable = getInjectable({
instantiate: (di) => bind(isLogsTabDataValid, null, { instantiate: (di) => {
logTabStore: di.inject(logTabStoreInjectable), const logTabStore = di.inject(logTabStoreInjectable);
}),
return (tabId: TabId) => logTabStore.isDataValid(tabId);
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -5,23 +5,20 @@
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import type { IComputedValue } from "mobx"; import type { IComputedValue } from "mobx";
import type { Pod } from "../../../../common/k8s-api/endpoints"; import type { Pod } from "../../../../common/k8s-api/endpoints";
import { bind } from "../../../utils";
import type { LogStore } from "./store";
import logStoreInjectable from "./store.injectable"; import logStoreInjectable from "./store.injectable";
import type { LogTabData } from "./tab-store"; import type { LogTabData } from "./tab-store";
interface Dependencies {
logStore: LogStore;
}
function loadLogs({ logStore }: Dependencies, tabId: string, pod: IComputedValue<Pod | undefined>, logTabData: IComputedValue<LogTabData>): Promise<void> {
return logStore.load(tabId, pod, logTabData);
}
const loadLogsInjectable = getInjectable({ const loadLogsInjectable = getInjectable({
instantiate: (di) => bind(loadLogs, null, { instantiate: (di) => {
logStore: di.inject(logStoreInjectable), const logStore = di.inject(logStoreInjectable);
}),
return (
tabId: string,
pod: IComputedValue<Pod | undefined>,
logTabData: IComputedValue<LogTabData>,
): Promise<void> => logStore.load(tabId, pod, logTabData);
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -5,23 +5,20 @@
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import type { IComputedValue } from "mobx"; import type { IComputedValue } from "mobx";
import type { Pod } from "../../../../common/k8s-api/endpoints"; import type { Pod } from "../../../../common/k8s-api/endpoints";
import { bind } from "../../../utils";
import type { LogStore } from "./store";
import logStoreInjectable from "./store.injectable"; import logStoreInjectable from "./store.injectable";
import type { LogTabData } from "./tab-store"; import type { LogTabData } from "./tab-store";
interface Dependencies {
logStore: LogStore;
}
function reloadLogs({ logStore }: Dependencies, tabId: string, pod: IComputedValue<Pod | undefined>, logTabData: IComputedValue<LogTabData>): Promise<void> {
return logStore.reload(tabId, pod, logTabData);
}
const reloadLogsInjectable = getInjectable({ const reloadLogsInjectable = getInjectable({
instantiate: (di) => bind(reloadLogs, null, { instantiate: (di) => {
logStore: di.inject(logStoreInjectable), const logStore = di.inject(logStoreInjectable);
}),
return (
tabId: string,
pod: IComputedValue<Pod | undefined>,
logTabData: IComputedValue<LogTabData>,
): Promise<void> => logStore.reload(tabId, pod, logTabData);
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -3,22 +3,16 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils"; import type { LogTabData } from "./tab-store";
import type { LogTabData, LogTabStore } from "./tab-store";
import logTabStoreInjectable from "./tab-store.injectable"; import logTabStoreInjectable from "./tab-store.injectable";
interface Dependencies {
logTabStore: LogTabStore;
}
function setLogTabData({ logTabStore }: Dependencies, tabId: string, data: LogTabData): void {
return logTabStore.setData(tabId, data);
}
const setLogTabDataInjectable = getInjectable({ const setLogTabDataInjectable = getInjectable({
instantiate: (di) => bind(setLogTabData, null, { instantiate: (di) => {
logTabStore: di.inject(logTabStoreInjectable), const logTabStore = di.inject(logTabStoreInjectable);
}),
return (tabId: string, data: LogTabData): void => logTabStore.setData(tabId, data);
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -3,22 +3,15 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils";
import type { LogStore } from "./store";
import logStoreInjectable from "./store.injectable"; import logStoreInjectable from "./store.injectable";
interface Dependencies {
logStore: LogStore;
}
function stopLoadingLogs({ logStore }: Dependencies, tabId: string): void {
return logStore.stopLoadingLogs(tabId);
}
const stopLoadingLogsInjectable = getInjectable({ const stopLoadingLogsInjectable = getInjectable({
instantiate: (di) => bind(stopLoadingLogs, null, { instantiate: (di) => {
logStore: di.inject(logStoreInjectable), const logStore = di.inject(logStoreInjectable);
}),
return (tabId: string): void => logStore.stopLoadingLogs(tabId);
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -3,23 +3,18 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils";
import type { TabId } from "../dock/store"; import type { TabId } from "../dock/store";
import type { TerminalStore } from "./store";
import terminalStoreInjectable from "./store.injectable"; import terminalStoreInjectable from "./store.injectable";
interface Dependencies {
terminalStore: TerminalStore;
}
function clearTerminalTabData({ terminalStore }: Dependencies, tabId: TabId): void {
terminalStore.destroy(tabId);
}
const clearTerminalTabDataInjectable = getInjectable({ const clearTerminalTabDataInjectable = getInjectable({
instantiate: (di) => bind(clearTerminalTabData, null, { instantiate: (di) => {
terminalStore: di.inject(terminalStoreInjectable), const terminalStore = di.inject(terminalStoreInjectable);
}),
return (tabId: TabId): void => {
terminalStore.destroy(tabId);
};
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -4,25 +4,19 @@
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import dockStoreInjectable from "../dock/store.injectable"; import dockStoreInjectable from "../dock/store.injectable";
import { DockStore, DockTabCreateSpecific, TabKind } from "../dock/store"; import { DockTabCreateSpecific, TabKind } from "../dock/store";
import { bind } from "../../../utils";
interface Dependencies { const createTerminalTabInjectable = getInjectable({
dockStore: DockStore; instantiate: (di) => {
} const dockStore = di.inject(dockStoreInjectable);
export function createTerminalTab({ dockStore }: Dependencies, tabParams: DockTabCreateSpecific = {}) { return (tabParams: DockTabCreateSpecific = {}) =>
return dockStore.createTab({ dockStore.createTab({
title: `Terminal`, title: `Terminal`,
...tabParams, ...tabParams,
kind: TabKind.TERMINAL, kind: TabKind.TERMINAL,
}); });
} },
const createTerminalTabInjectable = getInjectable({
instantiate: (di) => bind(createTerminalTab, null, {
dockStore: di.inject(dockStoreInjectable),
}),
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -4,23 +4,16 @@
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import type { TerminalApi } from "../../../api/terminal-api"; import type { TerminalApi } from "../../../api/terminal-api";
import { bind } from "../../../utils";
import type { TabId } from "../dock/store"; import type { TabId } from "../dock/store";
import type { TerminalStore } from "./store";
import terminalStoreInjectable from "./store.injectable"; import terminalStoreInjectable from "./store.injectable";
interface Dependencies {
terminalStore: TerminalStore;
}
function getTerminalApi({ terminalStore }: Dependencies, tabId: TabId): TerminalApi {
return terminalStore.getTerminalApi(tabId);
}
const getTerminalApiInjectable = getInjectable({ const getTerminalApiInjectable = getInjectable({
instantiate: (di) => bind(getTerminalApi, null, { instantiate: (di) => {
terminalStore: di.inject(terminalStoreInjectable), const terminalStore = di.inject(terminalStoreInjectable);
}),
return (tabId: TabId): TerminalApi => terminalStore.getTerminalApi(tabId);
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -5,7 +5,7 @@
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { when } from "mobx"; import { when } from "mobx";
import { TerminalApi, TerminalChannels } from "../../../api/terminal-api"; import { TerminalApi, TerminalChannels } from "../../../api/terminal-api";
import { bind, noop } from "../../../utils"; import { noop } from "../../../utils";
import { Notifications } from "../../notifications"; import { Notifications } from "../../notifications";
import selectDockTabInjectable from "../dock/select-dock-tab.injectable"; import selectDockTabInjectable from "../dock/select-dock-tab.injectable";
import type { DockTab, TabId } from "../dock/store"; import type { DockTab, TabId } from "../dock/store";
@ -35,7 +35,7 @@ export interface SendCommandOptions {
tabId?: TabId; tabId?: TabId;
} }
async function sendCommand({ selectTab, createTerminalTab, getTerminalApi }: Dependencies, command: string, options: SendCommandOptions = {}): Promise<void> { const sendCommand = ({ selectTab, createTerminalTab, getTerminalApi }: Dependencies) => async (command: string, options: SendCommandOptions = {}): Promise<void> => {
let { tabId } = options; let { tabId } = options;
if (tabId) { if (tabId) {
@ -76,14 +76,15 @@ async function sendCommand({ selectTab, createTerminalTab, getTerminalApi }: Dep
{ tabId, command }, { tabId, command },
); );
} }
} };
const sendCommandInjectable = getInjectable({ const sendCommandInjectable = getInjectable({
instantiate: (di) => bind(sendCommand, null, { instantiate: (di) => sendCommand({
createTerminalTab: di.inject(createTerminalTabInjectable), createTerminalTab: di.inject(createTerminalTabInjectable),
selectTab: di.inject(selectDockTabInjectable), selectTab: di.inject(selectDockTabInjectable),
getTerminalApi: di.inject(getTerminalApiInjectable), getTerminalApi: di.inject(getTerminalApiInjectable),
}), }),
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });

View File

@ -3,25 +3,19 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { bind } from "../../../utils";
import type { TabId } from "../dock/store"; import type { TabId } from "../dock/store";
import type { UpgradeChartTabStore } from "./store";
import upgradeChartTabStoreInjectable from "./store.injectable"; import upgradeChartTabStoreInjectable from "./store.injectable";
interface Dependencies {
upgradeChartTabStore: UpgradeChartTabStore;
}
function clearUpgradeChartTabData({ upgradeChartTabStore }: Dependencies, tabId: TabId) {
upgradeChartTabStore.clearData(tabId);
}
const clearUpgradeChartTabDataInjectable = getInjectable({ const clearUpgradeChartTabDataInjectable = getInjectable({
instantiate: (di) => bind(clearUpgradeChartTabData, null, { instantiate: (di) => {
upgradeChartTabStore: di.inject(upgradeChartTabStoreInjectable), const upgradeChartTabStore = di.inject(upgradeChartTabStoreInjectable);
}),
return (tabId: TabId) => {
upgradeChartTabStore.clearData(tabId);
};
},
lifecycle: lifecycleEnum.singleton, lifecycle: lifecycleEnum.singleton,
}); });
export default clearUpgradeChartTabDataInjectable; export default clearUpgradeChartTabDataInjectable;

View File

@ -8,7 +8,6 @@ import dockStoreInjectable from "../dock/store.injectable";
import type { HelmRelease } from "../../../../common/k8s-api/endpoints/helm-releases.api"; import type { HelmRelease } from "../../../../common/k8s-api/endpoints/helm-releases.api";
import { DockStore, DockTabCreateSpecific, TabId, TabKind } from "../dock/store"; import { DockStore, DockTabCreateSpecific, TabId, TabKind } from "../dock/store";
import type { UpgradeChartTabStore } from "./store"; import type { UpgradeChartTabStore } from "./store";
import { bind } from "../../../utils";
import { runInAction } from "mobx"; import { runInAction } from "mobx";
interface Dependencies { interface Dependencies {
@ -16,7 +15,7 @@ interface Dependencies {
dockStore: DockStore dockStore: DockStore
} }
function createUpgradeChartTab({ upgradeChartStore, dockStore }: Dependencies, release: HelmRelease, tabParams: DockTabCreateSpecific = {}): TabId { const createUpgradeChartTab = ({ upgradeChartStore, dockStore }: Dependencies) => (release: HelmRelease, tabParams: DockTabCreateSpecific = {}): TabId => {
const tabId = upgradeChartStore.getTabIdByRelease(release.getName()); const tabId = upgradeChartStore.getTabIdByRelease(release.getName());
if (tabId) { if (tabId) {
@ -43,10 +42,10 @@ function createUpgradeChartTab({ upgradeChartStore, dockStore }: Dependencies, r
return tab.id; return tab.id;
}); });
} };
const createUpgradeChartTabInjectable = getInjectable({ const createUpgradeChartTabInjectable = getInjectable({
instantiate: (di) => bind(createUpgradeChartTab, null, { instantiate: (di) => createUpgradeChartTab({
upgradeChartStore: di.inject(upgradeChartTabStoreInjectable), upgradeChartStore: di.inject(upgradeChartTabStoreInjectable),
dockStore: di.inject(dockStoreInjectable), dockStore: di.inject(dockStoreInjectable),
}), }),