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

Provide better typing for dock tabs

- Change name from IDockTab to DockTabDescriptor

- Make all fields required

- Add new types for the createTab() and the create(Type)Tab() functions

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2021-07-09 17:21:34 -04:00
parent ad8dc8a7c9
commit 5a878ccffb
17 changed files with 96 additions and 72 deletions

View File

@ -24,7 +24,7 @@ import { fireEvent, render } from "@testing-library/react";
import "@testing-library/jest-dom/extend-expect"; import "@testing-library/jest-dom/extend-expect";
import { DockTabs } from "../dock-tabs"; import { DockTabs } from "../dock-tabs";
import { dockStore, IDockTab, TabKind } from "../dock.store"; import { dockStore, DockTabDescriptor, TabKind } from "../dock.store";
import { noop } from "../../../utils"; import { noop } from "../../../utils";
jest.mock("electron", () => ({ jest.mock("electron", () => ({
@ -33,12 +33,12 @@ jest.mock("electron", () => ({
}, },
})); }));
const initialTabs: IDockTab[] = [ const initialTabs: DockTabDescriptor[] = [
{ id: "terminal", kind: TabKind.TERMINAL, title: "Terminal" }, { id: "terminal", kind: TabKind.TERMINAL, title: "Terminal", pinned: false, },
{ id: "create", kind: TabKind.CREATE_RESOURCE, title: "Create resource" }, { id: "create", kind: TabKind.CREATE_RESOURCE, title: "Create resource", pinned: false, },
{ id: "edit", kind: TabKind.EDIT_RESOURCE, title: "Edit resource" }, { id: "edit", kind: TabKind.EDIT_RESOURCE, title: "Edit resource", pinned: false, },
{ id: "install", kind: TabKind.INSTALL_CHART, title: "Install chart" }, { id: "install", kind: TabKind.INSTALL_CHART, title: "Install chart", pinned: false, },
{ id: "logs", kind: TabKind.POD_LOGS, title: "Logs" }, { id: "logs", kind: TabKind.POD_LOGS, title: "Logs", pinned: false, },
]; ];
const getComponent = () => ( const getComponent = () => (
@ -142,7 +142,7 @@ describe("<DockTabs />", () => {
it("disables 'Close All' & 'Close Other' items if only 1 tab available", () => { it("disables 'Close All' & 'Close Other' items if only 1 tab available", () => {
dockStore.tabs = [{ dockStore.tabs = [{
id: "terminal", kind: TabKind.TERMINAL, title: "Terminal" id: "terminal", kind: TabKind.TERMINAL, title: "Terminal", pinned: false,
}]; }];
const { container, getByText } = renderTabs(); const { container, getByText } = renderTabs();
const tab = container.querySelector(".Tab"); const tab = container.querySelector(".Tab");
@ -157,8 +157,8 @@ describe("<DockTabs />", () => {
it("disables 'Close To The Right' item if last tab clicked", () => { it("disables 'Close To The Right' item if last tab clicked", () => {
dockStore.tabs = [ dockStore.tabs = [
{ id: "terminal", kind: TabKind.TERMINAL, title: "Terminal" }, { id: "terminal", kind: TabKind.TERMINAL, title: "Terminal", pinned: false, },
{ id: "logs", kind: TabKind.POD_LOGS, title: "Pod Logs" }, { id: "logs", kind: TabKind.POD_LOGS, title: "Pod Logs", pinned: false, },
]; ];
const { container, getByText } = renderTabs(); const { container, getByText } = renderTabs();
const tab = container.querySelectorAll(".Tab")[1]; const tab = container.querySelectorAll(".Tab")[1];

View File

@ -27,7 +27,7 @@ import filehound from "filehound";
import { watch } from "chokidar"; import { watch } from "chokidar";
import { autoBind } from "../../utils"; import { autoBind } from "../../utils";
import { DockTabStore } from "./dock-tab.store"; import { DockTabStore } from "./dock-tab.store";
import { dockStore, IDockTab, TabKind } from "./dock.store"; import { dockStore, SpecializedCreateDockTabDescriptor, TabKind } from "./dock.store";
export class CreateResourceStore extends DockTabStore<string> { export class CreateResourceStore extends DockTabStore<string> {
constructor() { constructor() {
@ -81,10 +81,10 @@ export class CreateResourceStore extends DockTabStore<string> {
export const createResourceStore = new CreateResourceStore(); export const createResourceStore = new CreateResourceStore();
export function createResourceTab(tabParams: Partial<IDockTab> = {}) { export function createResourceTab(tabParams: SpecializedCreateDockTabDescriptor = {}) {
return dockStore.createTab({ return dockStore.createTab({
kind: TabKind.CREATE_RESOURCE,
title: "Create resource", title: "Create resource",
...tabParams ...tabParams,
kind: TabKind.CREATE_RESOURCE,
}); });
} }

View File

@ -30,7 +30,7 @@ import { observable, makeObservable } from "mobx";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import { cssNames } from "../../utils"; import { cssNames } from "../../utils";
import { createResourceStore } from "./create-resource.store"; import { createResourceStore } from "./create-resource.store";
import type { IDockTab } from "./dock.store"; import type { DockTabDescriptor } from "./dock.store";
import { EditorPanel } from "./editor-panel"; import { EditorPanel } from "./editor-panel";
import { InfoPanel } from "./info-panel"; import { InfoPanel } from "./info-panel";
import { resourceApplierApi } from "../../api/endpoints/resource-applier.api"; import { resourceApplierApi } from "../../api/endpoints/resource-applier.api";
@ -39,7 +39,7 @@ import { Notifications } from "../notifications";
interface Props { interface Props {
className?: string; className?: string;
tab: IDockTab; tab: DockTabDescriptor;
} }
@observer @observer

View File

@ -24,13 +24,13 @@ import "./dock-tab.scss";
import React from "react"; import React from "react";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import { boundMethod, cssNames, prevDefault, isMiddleClick } from "../../utils"; import { boundMethod, cssNames, prevDefault, isMiddleClick } from "../../utils";
import { dockStore, IDockTab } from "./dock.store"; import { dockStore, DockTabDescriptor } from "./dock.store";
import { Tab, TabProps } from "../tabs"; import { Tab, TabProps } from "../tabs";
import { Icon } from "../icon"; import { Icon } from "../icon";
import { Menu, MenuItem } from "../menu"; import { Menu, MenuItem } from "../menu";
import { observable, makeObservable } from "mobx"; import { observable, makeObservable } from "mobx";
export interface DockTabProps extends TabProps<IDockTab> { export interface DockTabProps extends TabProps<DockTabDescriptor> {
moreActions?: React.ReactNode; moreActions?: React.ReactNode;
} }

View File

@ -24,19 +24,19 @@ import React, { Fragment } from "react";
import { Icon } from "../icon"; import { Icon } from "../icon";
import { Tabs } from "../tabs/tabs"; import { Tabs } from "../tabs/tabs";
import { DockTab } from "./dock-tab"; import { DockTab } from "./dock-tab";
import type { IDockTab } from "./dock.store"; import type { DockTabDescriptor } from "./dock.store";
import { TabKind } from "./dock.store"; import { TabKind } from "./dock.store";
import { TerminalTab } from "./terminal-tab"; import { TerminalTab } from "./terminal-tab";
interface Props { interface Props {
tabs: IDockTab[] tabs: DockTabDescriptor[]
autoFocus: boolean autoFocus: boolean
selectedTab: IDockTab selectedTab: DockTabDescriptor
onChangeTab: (tab: IDockTab) => void onChangeTab: (tab: DockTabDescriptor) => void
} }
export const DockTabs = ({ tabs, autoFocus, selectedTab, onChangeTab }: Props) => { export const DockTabs = ({ tabs, autoFocus, selectedTab, onChangeTab }: Props) => {
const renderTab = (tab?: IDockTab) => { const renderTab = (tab?: DockTabDescriptor) => {
if (!tab) { if (!tab) {
return null; return null;
} }

View File

@ -19,7 +19,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
import MD5 from "crypto-js/md5"; import * as uuid from "uuid";
import { action, computed, IReactionOptions, makeObservable, observable, reaction } from "mobx"; import { action, computed, IReactionOptions, makeObservable, observable, reaction } from "mobx";
import { autoBind, createStorage } from "../../utils"; import { autoBind, createStorage } from "../../utils";
import throttle from "lodash/throttle"; import throttle from "lodash/throttle";
@ -35,16 +35,24 @@ export enum TabKind {
POD_LOGS = "pod-logs", POD_LOGS = "pod-logs",
} }
export interface IDockTab { export interface DockTabDescriptor {
id?: TabId; id: TabId;
kind: TabKind; kind: TabKind;
title?: string; title: string;
pinned?: boolean; // not closable pinned: boolean; // not closable
/**
* DockTabData may contain extra data
*/
[key: string]: any;
} }
export type CreateDockTabDescriptor = Partial<Omit<DockTabDescriptor, "kind">> & Pick<DockTabDescriptor, "kind">;
export type SpecializedCreateDockTabDescriptor = Omit<CreateDockTabDescriptor, "kind">;
export interface DockStorageState { export interface DockStorageState {
height: number; height: number;
tabs: IDockTab[]; tabs: DockTabDescriptor[];
selectedTabId?: TabId; selectedTabId?: TabId;
isOpen?: boolean; isOpen?: boolean;
} }
@ -62,7 +70,7 @@ export class DockStore implements DockStorageState {
private storage = createStorage<DockStorageState>("dock", { private storage = createStorage<DockStorageState>("dock", {
height: 300, height: 300,
tabs: [ tabs: [
{ id: "terminal", kind: TabKind.TERMINAL, title: "Terminal" }, { id: "terminal", kind: TabKind.TERMINAL, title: "Terminal", pinned: false },
], ],
}); });
@ -88,11 +96,11 @@ export class DockStore implements DockStorageState {
}); });
} }
get tabs(): IDockTab[] { get tabs(): DockTabDescriptor[] {
return this.storage.get().tabs; return this.storage.get().tabs;
} }
set tabs(tabs: IDockTab[]) { set tabs(tabs: DockTabDescriptor[]) {
this.storage.merge({ tabs }); this.storage.merge({ tabs });
} }
@ -191,15 +199,31 @@ export class DockStore implements DockStorageState {
} }
@action @action
createTab(anonTab: IDockTab, addNumber = true): IDockTab { createTab(rawTabDesc: CreateDockTabDescriptor, addNumber = true): DockTabDescriptor {
const tabId = MD5(Math.random().toString() + Date.now()).toString(); const {
const tab: IDockTab = { id: tabId, ...anonTab }; id = uuid.v4(),
kind,
pinned = false,
...restOfTabFields
} = rawTabDesc;
let { title = kind } = rawTabDesc;
if (addNumber) { if (addNumber) {
const tabNumber = this.getNewTabNumber(tab.kind); const tabNumber = this.getNewTabNumber(kind);
if (tabNumber > 1) tab.title += ` (${tabNumber})`; if (tabNumber > 1) {
title += ` (${tabNumber})`;
}
} }
const tab: DockTabDescriptor = {
...restOfTabFields,
id,
kind,
pinned,
title
};
this.tabs.push(tab); this.tabs.push(tab);
this.selectTab(tab.id); this.selectTab(tab.id);
this.open(); this.open();
@ -234,7 +258,7 @@ export class DockStore implements DockStorageState {
} }
} }
closeTabs(tabs: IDockTab[]) { closeTabs(tabs: DockTabDescriptor[]) {
tabs.forEach(tab => this.closeTab(tab.id)); tabs.forEach(tab => this.closeTab(tab.id));
} }

View File

@ -32,7 +32,7 @@ import { ResizeDirection, ResizingAnchor } from "../resizing-anchor";
import { CreateResource } from "./create-resource"; import { CreateResource } from "./create-resource";
import { createResourceTab } from "./create-resource.store"; import { createResourceTab } from "./create-resource.store";
import { DockTabs } from "./dock-tabs"; import { DockTabs } from "./dock-tabs";
import { dockStore, IDockTab, TabKind } from "./dock.store"; import { dockStore, DockTabDescriptor, TabKind } from "./dock.store";
import { EditResource } from "./edit-resource"; import { EditResource } from "./edit-resource";
import { InstallChart } from "./install-chart"; import { InstallChart } from "./install-chart";
import { Logs } from "./logs"; import { Logs } from "./logs";
@ -62,14 +62,14 @@ export class Dock extends React.Component<Props> {
} }
}; };
onChangeTab = (tab: IDockTab) => { onChangeTab = (tab: DockTabDescriptor) => {
const { open, selectTab } = dockStore; const { open, selectTab } = dockStore;
open(); open();
selectTab(tab.id); selectTab(tab.id);
}; };
renderTab(tab: IDockTab) { renderTab(tab: DockTabDescriptor) {
switch (tab.kind) { switch (tab.kind) {
case TabKind.CREATE_RESOURCE: case TabKind.CREATE_RESOURCE:
return <CreateResource tab={tab} />; return <CreateResource tab={tab} />;

View File

@ -22,7 +22,7 @@
import { autoBind, noop } from "../../utils"; import { autoBind, noop } from "../../utils";
import { DockTabStore } from "./dock-tab.store"; import { DockTabStore } from "./dock-tab.store";
import { autorun, IReactionDisposer } from "mobx"; import { autorun, IReactionDisposer } from "mobx";
import { dockStore, IDockTab, TabId, TabKind } from "./dock.store"; import { dockStore, DockTabDescriptor, SpecializedCreateDockTabDescriptor, TabId, TabKind } from "./dock.store";
import type { KubeObject } from "../../api/kube-object"; import type { KubeObject } from "../../api/kube-object";
import { apiManager } from "../../api/api-manager"; import { apiManager } from "../../api/api-manager";
import type { KubeObjectStore } from "../../kube-object.store"; import type { KubeObjectStore } from "../../kube-object.store";
@ -96,7 +96,7 @@ export class EditResourceStore extends DockTabStore<EditingResource> {
return this.getData(tabId)?.resource; return this.getData(tabId)?.resource;
} }
getTabByResource(object: KubeObject): IDockTab { getTabByResource(object: KubeObject): DockTabDescriptor {
const [tabId] = Array.from(this.data).find(([, { resource }]) => { const [tabId] = Array.from(this.data).find(([, { resource }]) => {
return object.selfLink === resource; return object.selfLink === resource;
}) || []; }) || [];
@ -115,7 +115,7 @@ export class EditResourceStore extends DockTabStore<EditingResource> {
export const editResourceStore = new EditResourceStore(); export const editResourceStore = new EditResourceStore();
export function editResourceTab(object: KubeObject, tabParams: Partial<IDockTab> = {}) { export function editResourceTab(object: KubeObject, tabParams: SpecializedCreateDockTabDescriptor = {}) {
// use existing tab if already opened // use existing tab if already opened
let tab = editResourceStore.getTabByResource(object); let tab = editResourceStore.getTabByResource(object);
@ -128,8 +128,8 @@ export function editResourceTab(object: KubeObject, tabParams: Partial<IDockTab>
if (!tab) { if (!tab) {
tab = dockStore.createTab({ tab = dockStore.createTab({
title: `${object.kind}: ${object.getName()}`, title: `${object.kind}: ${object.getName()}`,
...tabParams,
kind: TabKind.EDIT_RESOURCE, kind: TabKind.EDIT_RESOURCE,
...tabParams
}, false); }, false);
editResourceStore.setData(tab.id, { editResourceStore.setData(tab.id, {
resource: object.selfLink, resource: object.selfLink,

View File

@ -25,7 +25,7 @@ import React from "react";
import { action, computed, makeObservable, observable } from "mobx"; import { action, computed, makeObservable, observable } from "mobx";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import jsYaml from "js-yaml"; import jsYaml from "js-yaml";
import type { IDockTab } from "./dock.store"; import type { DockTabDescriptor } from "./dock.store";
import { cssNames } from "../../utils"; import { cssNames } from "../../utils";
import { editResourceStore } from "./edit-resource.store"; import { editResourceStore } from "./edit-resource.store";
import { InfoPanel } from "./info-panel"; import { InfoPanel } from "./info-panel";
@ -36,7 +36,7 @@ import type { KubeObject } from "../../api/kube-object";
interface Props { interface Props {
className?: string; className?: string;
tab: IDockTab; tab: DockTabDescriptor;
} }
@observer @observer

View File

@ -20,7 +20,7 @@
*/ */
import { action, autorun, makeObservable } from "mobx"; import { action, autorun, makeObservable } from "mobx";
import { dockStore, IDockTab, TabId, TabKind } from "./dock.store"; import { dockStore, SpecializedCreateDockTabDescriptor, TabId, TabKind } from "./dock.store";
import { DockTabStore } from "./dock-tab.store"; import { DockTabStore } from "./dock-tab.store";
import { getChartDetails, getChartValues, HelmChart } from "../../api/endpoints/helm-charts.api"; import { getChartDetails, getChartValues, HelmChart } from "../../api/endpoints/helm-charts.api";
import type { IReleaseUpdateDetails } from "../../api/endpoints/helm-releases.api"; import type { IReleaseUpdateDetails } from "../../api/endpoints/helm-releases.api";
@ -98,12 +98,12 @@ export class InstallChartStore extends DockTabStore<IChartInstallData> {
export const installChartStore = new InstallChartStore(); export const installChartStore = new InstallChartStore();
export function createInstallChartTab(chart: HelmChart, tabParams: Partial<IDockTab> = {}) { export function createInstallChartTab(chart: HelmChart, tabParams: SpecializedCreateDockTabDescriptor = {}) {
const { name, repo, version } = chart; const { name, repo, version } = chart;
const tab = dockStore.createTab({ const tab = dockStore.createTab({
kind: TabKind.INSTALL_CHART,
title: `Helm Install: ${repo}/${name}`, title: `Helm Install: ${repo}/${name}`,
...tabParams ...tabParams,
kind: TabKind.INSTALL_CHART,
}, false); }, false);
installChartStore.setData(tab.id, { installChartStore.setData(tab.id, {

View File

@ -24,7 +24,7 @@ import "./install-chart.scss";
import React, { Component } from "react"; import React, { Component } from "react";
import { observable, makeObservable } from "mobx"; import { observable, makeObservable } from "mobx";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import { dockStore, IDockTab } from "./dock.store"; import { dockStore, DockTabDescriptor } from "./dock.store";
import { InfoPanel } from "./info-panel"; import { InfoPanel } from "./info-panel";
import { Badge } from "../badge"; import { Badge } from "../badge";
import { NamespaceSelect } from "../+namespaces/namespace-select"; import { NamespaceSelect } from "../+namespaces/namespace-select";
@ -42,7 +42,7 @@ import { navigate } from "../../navigation";
import { releaseURL } from "../../../common/routes"; import { releaseURL } from "../../../common/routes";
interface Props { interface Props {
tab: IDockTab; tab: DockTabDescriptor;
} }
@observer @observer

View File

@ -26,7 +26,7 @@ import { podsStore } from "../+workloads-pods/pods.store";
import { IPodContainer, Pod } from "../../api/endpoints"; import { IPodContainer, Pod } from "../../api/endpoints";
import type { WorkloadKubeObject } from "../../api/workload-kube-object"; import type { WorkloadKubeObject } from "../../api/workload-kube-object";
import { DockTabStore } from "./dock-tab.store"; import { DockTabStore } from "./dock-tab.store";
import { dockStore, IDockTab, TabKind } from "./dock.store"; import { dockStore, SpecializedCreateDockTabDescriptor, TabKind } from "./dock.store";
export interface LogTabData { export interface LogTabData {
pods: Pod[]; pods: Pod[];
@ -90,10 +90,10 @@ export class LogTabStore extends DockTabStore<LogTabData> {
dockStore.renameTab(tabId, `Pod ${selectedPod.metadata.name}`); dockStore.renameTab(tabId, `Pod ${selectedPod.metadata.name}`);
} }
private createDockTab(tabParams: Partial<IDockTab>) { private createDockTab(tabParams: SpecializedCreateDockTabDescriptor) {
dockStore.createTab({ dockStore.createTab({
...tabParams,
kind: TabKind.POD_LOGS, kind: TabKind.POD_LOGS,
...tabParams
}, false); }, false);
} }

View File

@ -25,7 +25,7 @@ import { disposeOnUnmount, observer } from "mobx-react";
import { searchStore } from "../../../common/search-store"; import { searchStore } from "../../../common/search-store";
import { boundMethod } from "../../utils"; import { boundMethod } from "../../utils";
import type { IDockTab } from "./dock.store"; import type { DockTabDescriptor } from "./dock.store";
import { InfoPanel } from "./info-panel"; import { InfoPanel } from "./info-panel";
import { LogResourceSelector } from "./log-resource-selector"; import { LogResourceSelector } from "./log-resource-selector";
import { LogList } from "./log-list"; import { LogList } from "./log-list";
@ -36,7 +36,7 @@ import { LogTabData, logTabStore } from "./log-tab.store";
interface Props { interface Props {
className?: string className?: string
tab: IDockTab tab: DockTabDescriptor
} }
@observer @observer

View File

@ -25,14 +25,14 @@ import React from "react";
import { reaction } from "mobx"; import { reaction } from "mobx";
import { disposeOnUnmount, observer } from "mobx-react"; import { disposeOnUnmount, observer } from "mobx-react";
import { cssNames } from "../../utils"; import { cssNames } from "../../utils";
import type { IDockTab } from "./dock.store"; import type { DockTabDescriptor } from "./dock.store";
import type { Terminal } from "./terminal"; import type { Terminal } from "./terminal";
import { terminalStore } from "./terminal.store"; import { terminalStore } from "./terminal.store";
import { ThemeStore } from "../../theme.store"; import { ThemeStore } from "../../theme.store";
interface Props { interface Props {
className?: string; className?: string;
tab: IDockTab; tab: DockTabDescriptor;
} }
@observer @observer

View File

@ -23,18 +23,18 @@ import { autorun, observable } from "mobx";
import { autoBind } from "../../utils"; import { autoBind } from "../../utils";
import { Terminal } from "./terminal"; import { Terminal } from "./terminal";
import { TerminalApi } from "../../api/terminal-api"; import { TerminalApi } from "../../api/terminal-api";
import { dockStore, IDockTab, TabId, TabKind } from "./dock.store"; import { dockStore, DockTabDescriptor, SpecializedCreateDockTabDescriptor, TabId, TabKind } from "./dock.store";
import { WebSocketApiState } from "../../api/websocket-api"; import { WebSocketApiState } from "../../api/websocket-api";
export interface ITerminalTab extends IDockTab { export interface ITerminalTab extends DockTabDescriptor {
node?: string; // activate node shell mode node?: string; // activate node shell mode
} }
export function createTerminalTab(tabParams: Partial<ITerminalTab> = {}) { export function createTerminalTab(tabParams: SpecializedCreateDockTabDescriptor = {}) {
return dockStore.createTab({ return dockStore.createTab({
kind: TabKind.TERMINAL,
title: `Terminal`, title: `Terminal`,
...tabParams ...tabParams,
kind: TabKind.TERMINAL,
}); });
} }

View File

@ -20,7 +20,7 @@
*/ */
import { action, autorun, computed, IReactionDisposer, reaction, makeObservable } from "mobx"; import { action, autorun, computed, IReactionDisposer, reaction, makeObservable } from "mobx";
import { dockStore, IDockTab, TabId, TabKind } from "./dock.store"; import { dockStore, DockTabDescriptor, SpecializedCreateDockTabDescriptor, TabId, TabKind } from "./dock.store";
import { DockTabStore } from "./dock-tab.store"; import { DockTabStore } from "./dock-tab.store";
import { getReleaseValues, HelmRelease } from "../../api/endpoints/helm-releases.api"; import { getReleaseValues, HelmRelease } from "../../api/endpoints/helm-releases.api";
import { releaseStore } from "../+apps-releases/release.store"; import { releaseStore } from "../+apps-releases/release.store";
@ -120,14 +120,14 @@ export class UpgradeChartStore extends DockTabStore<IChartUpgradeData> {
this.values.setData(tabId, values); this.values.setData(tabId, values);
} }
getTabByRelease(releaseName: string): IDockTab { getTabByRelease(releaseName: string): DockTabDescriptor {
return dockStore.getTabById(this.releaseNameReverseLookup.get(releaseName)); return dockStore.getTabById(this.releaseNameReverseLookup.get(releaseName));
} }
} }
export const upgradeChartStore = new UpgradeChartStore(); export const upgradeChartStore = new UpgradeChartStore();
export function createUpgradeChartTab(release: HelmRelease, tabParams: Partial<IDockTab> = {}) { export function createUpgradeChartTab(release: HelmRelease, tabParams: SpecializedCreateDockTabDescriptor = {}) {
let tab = upgradeChartStore.getTabByRelease(release.getName()); let tab = upgradeChartStore.getTabByRelease(release.getName());
if (tab) { if (tab) {
@ -137,9 +137,9 @@ export function createUpgradeChartTab(release: HelmRelease, tabParams: Partial<I
if (!tab) { if (!tab) {
tab = dockStore.createTab({ tab = dockStore.createTab({
kind: TabKind.UPGRADE_CHART,
title: `Helm Upgrade: ${release.getName()}`, title: `Helm Upgrade: ${release.getName()}`,
...tabParams ...tabParams,
kind: TabKind.UPGRADE_CHART,
}, false); }, false);
upgradeChartStore.setData(tab.id, { upgradeChartStore.setData(tab.id, {

View File

@ -25,7 +25,7 @@ import React from "react";
import { observable, reaction, makeObservable } from "mobx"; import { observable, reaction, makeObservable } from "mobx";
import { disposeOnUnmount, observer } from "mobx-react"; import { disposeOnUnmount, observer } from "mobx-react";
import { cssNames } from "../../utils"; import { cssNames } from "../../utils";
import type { IDockTab } from "./dock.store"; import type { DockTabDescriptor } from "./dock.store";
import { InfoPanel } from "./info-panel"; import { InfoPanel } from "./info-panel";
import { upgradeChartStore } from "./upgrade-chart.store"; import { upgradeChartStore } from "./upgrade-chart.store";
import { Spinner } from "../spinner"; import { Spinner } from "../spinner";
@ -38,7 +38,7 @@ import { Select, SelectOption } from "../select";
interface Props { interface Props {
className?: string; className?: string;
tab: IDockTab; tab: DockTabDescriptor;
} }
@observer @observer