mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Turn on noUnusedLocals, noImplicitReturns, importsNotUsedAsValues: error, and isolatedModules (#2777)
This commit is contained in:
1 parent
489cef9595
commit
5ed4537979
287 files changed
+704
-628
No files matched your search
@@ -26,6 +26,12 @@ import "@testing-library/jest-dom/extend-expect";
|
||||
import { DockTabs } from "../dock-tabs";
|
||||
import { dockStore, IDockTab, TabKind } from "../dock.store";
|
||||
|
||||
jest.mock("electron", () => ({
|
||||
app: {
|
||||
getPath: () => "/foo",
|
||||
},
|
||||
}));
|
||||
|
||||
const onChangeTab = jest.fn();
|
||||
|
||||
const getComponent = () => (
|
||||
|
||||
@@ -26,11 +26,17 @@ import selectEvent from "react-select-event";
|
||||
|
||||
import { Pod } from "../../../api/endpoints";
|
||||
import { LogResourceSelector } from "../log-resource-selector";
|
||||
import { LogTabData } from "../log-tab.store";
|
||||
import type { LogTabData } from "../log-tab.store";
|
||||
import { dockerPod, deploymentPod1 } from "./pod.mock";
|
||||
import { ThemeStore } from "../../../theme.store";
|
||||
import { UserStore } from "../../../../common/user-store";
|
||||
|
||||
jest.mock("electron", () => ({
|
||||
app: {
|
||||
getPath: () => "/foo",
|
||||
},
|
||||
}));
|
||||
|
||||
const getComponent = (tabData: LogTabData) => {
|
||||
return (
|
||||
<LogResourceSelector
|
||||
|
||||
@@ -25,6 +25,11 @@ import { dockStore } from "../dock.store";
|
||||
import { logTabStore } from "../log-tab.store";
|
||||
import { deploymentPod1, deploymentPod2, deploymentPod3, dockerPod } from "./pod.mock";
|
||||
|
||||
jest.mock("electron", () => ({
|
||||
app: {
|
||||
getPath: () => "/foo",
|
||||
},
|
||||
}));
|
||||
|
||||
podsStore.items.push(new Pod(dockerPod));
|
||||
podsStore.items.push(new Pod(deploymentPod1));
|
||||
|
||||
@@ -89,7 +89,3 @@ export function createResourceTab(tabParams: Partial<IDockTab> = {}) {
|
||||
...tabParams
|
||||
});
|
||||
}
|
||||
|
||||
export function isCreateResourceTab(tab: IDockTab) {
|
||||
return tab && tab.kind === TabKind.CREATE_RESOURCE;
|
||||
}
|
||||
@@ -30,11 +30,11 @@ import { observable } from "mobx";
|
||||
import { observer } from "mobx-react";
|
||||
import { cssNames } from "../../utils";
|
||||
import { createResourceStore } from "./create-resource.store";
|
||||
import { IDockTab } from "./dock.store";
|
||||
import type { IDockTab } from "./dock.store";
|
||||
import { EditorPanel } from "./editor-panel";
|
||||
import { InfoPanel } from "./info-panel";
|
||||
import { resourceApplierApi } from "../../api/endpoints/resource-applier.api";
|
||||
import { JsonApiErrorParsed } from "../../api/json-api";
|
||||
import type { JsonApiErrorParsed } from "../../api/json-api";
|
||||
import { Notifications } from "../notifications";
|
||||
|
||||
interface Props {
|
||||
@@ -87,10 +87,13 @@ export class CreateResource extends React.Component<Props> {
|
||||
};
|
||||
|
||||
create = async () => {
|
||||
if (this.error) return;
|
||||
if (!this.data.trim()) return; // do not save when field is empty
|
||||
const resources = jsYaml.safeLoadAll(this.data)
|
||||
.filter(v => !!v); // skip empty documents if "---" pasted at the beginning or end
|
||||
if (this.error || !this.data.trim()) {
|
||||
// do not save when field is empty or there is an error
|
||||
return null;
|
||||
}
|
||||
|
||||
// skip empty documents if "---" pasted at the beginning or end
|
||||
const resources = jsYaml.safeLoadAll(this.data).filter(Boolean);
|
||||
const createdResources: string[] = [];
|
||||
const errors: string[] = [];
|
||||
|
||||
|
||||
@@ -23,15 +23,10 @@ import React, { Fragment } from "react";
|
||||
|
||||
import { Icon } from "../icon";
|
||||
import { Tabs } from "../tabs/tabs";
|
||||
import { isCreateResourceTab } from "./create-resource.store";
|
||||
import { DockTab } from "./dock-tab";
|
||||
import { IDockTab } from "./dock.store";
|
||||
import { isEditResourceTab } from "./edit-resource.store";
|
||||
import { isInstallChartTab } from "./install-chart.store";
|
||||
import { isLogsTab } from "./log-tab.store";
|
||||
import type { IDockTab } from "./dock.store";
|
||||
import { TabKind } from "./dock.store";
|
||||
import { TerminalTab } from "./terminal-tab";
|
||||
import { isTerminalTab } from "./terminal.store";
|
||||
import { isUpgradeChartTab } from "./upgrade-chart.store";
|
||||
|
||||
interface Props {
|
||||
tabs: IDockTab[]
|
||||
@@ -41,21 +36,22 @@ interface Props {
|
||||
}
|
||||
|
||||
export const DockTabs = ({ tabs, autoFocus, selectedTab, onChangeTab }: Props) => {
|
||||
const renderTab = (tab: IDockTab) => {
|
||||
if (isTerminalTab(tab)) {
|
||||
return <TerminalTab value={tab} />;
|
||||
const renderTab = (tab?: IDockTab) => {
|
||||
if (!tab) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isCreateResourceTab(tab) || isEditResourceTab(tab)) {
|
||||
return <DockTab value={tab} icon="edit" />;
|
||||
}
|
||||
|
||||
if (isInstallChartTab(tab) || isUpgradeChartTab(tab)) {
|
||||
return <DockTab value={tab} icon={<Icon svg="install" />} />;
|
||||
}
|
||||
|
||||
if (isLogsTab(tab)) {
|
||||
return <DockTab value={tab} icon="subject" />;
|
||||
switch (tab.kind) {
|
||||
case TabKind.CREATE_RESOURCE:
|
||||
case TabKind.EDIT_RESOURCE:
|
||||
return <DockTab value={tab} icon="edit" />;
|
||||
case TabKind.INSTALL_CHART:
|
||||
case TabKind.UPGRADE_CHART:
|
||||
return <DockTab value={tab} icon={<Icon svg="install" />} />;
|
||||
case TabKind.POD_LOGS:
|
||||
return <DockTab value={tab} icon="subject" />;
|
||||
case TabKind.TERMINAL:
|
||||
return <TerminalTab value={tab} />;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ export class DockStore implements DockStorageState {
|
||||
if (this.tabs.length) {
|
||||
const newTab = this.tabs.slice(-1)[0]; // last
|
||||
|
||||
if (newTab.kind === TabKind.TERMINAL) {
|
||||
if (newTab?.kind === TabKind.TERMINAL) {
|
||||
// close the dock when selected sibling inactive terminal tab
|
||||
const { terminalStore } = await import("./terminal.store");
|
||||
|
||||
|
||||
@@ -30,19 +30,15 @@ import { MenuItem } from "../menu";
|
||||
import { MenuActions } from "../menu/menu-actions";
|
||||
import { ResizeDirection, ResizingAnchor } from "../resizing-anchor";
|
||||
import { CreateResource } from "./create-resource";
|
||||
import { createResourceTab, isCreateResourceTab } from "./create-resource.store";
|
||||
import { createResourceTab } from "./create-resource.store";
|
||||
import { DockTabs } from "./dock-tabs";
|
||||
import { dockStore, IDockTab } from "./dock.store";
|
||||
import { dockStore, IDockTab, TabKind } from "./dock.store";
|
||||
import { EditResource } from "./edit-resource";
|
||||
import { isEditResourceTab } from "./edit-resource.store";
|
||||
import { InstallChart } from "./install-chart";
|
||||
import { isInstallChartTab } from "./install-chart.store";
|
||||
import { Logs } from "./logs";
|
||||
import { isLogsTab } from "./log-tab.store";
|
||||
import { TerminalWindow } from "./terminal-window";
|
||||
import { createTerminalTab, isTerminalTab } from "./terminal.store";
|
||||
import { createTerminalTab } from "./terminal.store";
|
||||
import { UpgradeChart } from "./upgrade-chart";
|
||||
import { isUpgradeChartTab } from "./upgrade-chart.store";
|
||||
import { commandRegistry } from "../../../extensions/registries/command-registry";
|
||||
|
||||
interface Props {
|
||||
@@ -74,19 +70,31 @@ export class Dock extends React.Component<Props> {
|
||||
selectTab(tab.id);
|
||||
};
|
||||
|
||||
renderTabContent() {
|
||||
const { isOpen, height, selectedTab: tab } = dockStore;
|
||||
renderTab(tab: IDockTab) {
|
||||
switch (tab.kind) {
|
||||
case TabKind.CREATE_RESOURCE:
|
||||
return <CreateResource tab={tab} />;
|
||||
case TabKind.EDIT_RESOURCE:
|
||||
return <EditResource tab={tab} />;
|
||||
case TabKind.INSTALL_CHART:
|
||||
return <InstallChart tab={tab} />;
|
||||
case TabKind.UPGRADE_CHART:
|
||||
return <UpgradeChart tab={tab} />;
|
||||
case TabKind.POD_LOGS:
|
||||
return <Logs tab={tab} />;
|
||||
case TabKind.TERMINAL:
|
||||
return <TerminalWindow tab={tab} />;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isOpen || !tab) return;
|
||||
renderTabContent() {
|
||||
const { isOpen, height, selectedTab } = dockStore;
|
||||
|
||||
if (!isOpen || !selectedTab) return null;
|
||||
|
||||
return (
|
||||
<div className="tab-content" style={{ flexBasis: height }}>
|
||||
{isCreateResourceTab(tab) && <CreateResource tab={tab} />}
|
||||
{isEditResourceTab(tab) && <EditResource tab={tab} />}
|
||||
{isInstallChartTab(tab) && <InstallChart tab={tab} />}
|
||||
{isUpgradeChartTab(tab) && <UpgradeChart tab={tab} />}
|
||||
{isTerminalTab(tab) && <TerminalWindow tab={tab} />}
|
||||
{isLogsTab(tab) && <Logs tab={tab} />}
|
||||
{this.renderTab(selectedTab)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ import { autobind, noop } from "../../utils";
|
||||
import { DockTabStore } from "./dock-tab.store";
|
||||
import { autorun, IReactionDisposer } from "mobx";
|
||||
import { dockStore, IDockTab, TabId, TabKind } from "./dock.store";
|
||||
import { KubeObject } from "../../api/kube-object";
|
||||
import type { KubeObject } from "../../api/kube-object";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import type { KubeObjectStore } from "../../kube-object.store";
|
||||
|
||||
export interface EditingResource {
|
||||
resource: string; // resource path, e.g. /api/v1/namespaces/default
|
||||
@@ -138,7 +138,3 @@ export function editResourceTab(object: KubeObject, tabParams: Partial<IDockTab>
|
||||
|
||||
return tab;
|
||||
}
|
||||
|
||||
export function isEditResourceTab(tab: IDockTab) {
|
||||
return tab && tab.kind === TabKind.EDIT_RESOURCE;
|
||||
}
|
||||
@@ -25,14 +25,14 @@ import React from "react";
|
||||
import { action, computed, observable } from "mobx";
|
||||
import { observer } from "mobx-react";
|
||||
import jsYaml from "js-yaml";
|
||||
import { IDockTab } from "./dock.store";
|
||||
import type { IDockTab } from "./dock.store";
|
||||
import { cssNames } from "../../utils";
|
||||
import { editResourceStore } from "./edit-resource.store";
|
||||
import { InfoPanel } from "./info-panel";
|
||||
import { Badge } from "../badge";
|
||||
import { EditorPanel } from "./editor-panel";
|
||||
import { Spinner } from "../spinner";
|
||||
import { KubeObject } from "../../api/kube-object";
|
||||
import type { KubeObject } from "../../api/kube-object";
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
@@ -88,7 +88,7 @@ export class EditResource extends React.Component<Props> {
|
||||
|
||||
save = async () => {
|
||||
if (this.error) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
const store = editResourceStore.getStore(this.tabId);
|
||||
const updatedResource = await store.update(this.resource, jsYaml.safeLoad(this.draft));
|
||||
|
||||
@@ -27,7 +27,7 @@ import { cssNames } from "../../utils";
|
||||
import { AceEditor } from "../ace-editor";
|
||||
import { dockStore, TabId } from "./dock.store";
|
||||
import { DockTabStore } from "./dock-tab.store";
|
||||
import { Ace } from "ace-builds";
|
||||
import type { Ace } from "ace-builds";
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
|
||||
@@ -104,7 +104,7 @@ export class InfoPanel extends Component<Props> {
|
||||
|
||||
renderErrorIcon() {
|
||||
if (!this.props.showInlineInfo || !this.errorInfo) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -23,7 +23,7 @@ import { action, autorun } from "mobx";
|
||||
import { dockStore, IDockTab, TabId, TabKind } from "./dock.store";
|
||||
import { DockTabStore } from "./dock-tab.store";
|
||||
import { getChartDetails, getChartValues, HelmChart } from "../../api/endpoints/helm-charts.api";
|
||||
import { IReleaseUpdateDetails } from "../../api/endpoints/helm-releases.api";
|
||||
import type { IReleaseUpdateDetails } from "../../api/endpoints/helm-releases.api";
|
||||
import { Notifications } from "../notifications";
|
||||
|
||||
export interface IChartInstallData {
|
||||
@@ -48,15 +48,15 @@ export class InstallChartStore extends DockTabStore<IChartInstallData> {
|
||||
autorun(() => {
|
||||
const { selectedTab, isOpen } = dockStore;
|
||||
|
||||
if (isInstallChartTab(selectedTab) && isOpen) {
|
||||
this.loadData()
|
||||
if (selectedTab?.kind === TabKind.INSTALL_CHART && isOpen) {
|
||||
this.loadData(selectedTab.id)
|
||||
.catch(err => Notifications.error(String(err)));
|
||||
}
|
||||
}, { delay: 250 });
|
||||
}
|
||||
|
||||
@action
|
||||
async loadData(tabId = dockStore.selectedTabId) {
|
||||
async loadData(tabId: string) {
|
||||
const promises = [];
|
||||
|
||||
if (!this.getData(tabId).values) {
|
||||
@@ -116,7 +116,3 @@ export function createInstallChartTab(chart: HelmChart, tabParams: Partial<IDock
|
||||
|
||||
return tab;
|
||||
}
|
||||
|
||||
export function isInstallChartTab(tab: IDockTab) {
|
||||
return tab && tab.kind === TabKind.INSTALL_CHART;
|
||||
}
|
||||
@@ -29,7 +29,7 @@ import { cssNames, saveFileDialog } from "../../utils";
|
||||
import { logStore } from "./log.store";
|
||||
import { Checkbox } from "../checkbox";
|
||||
import { Icon } from "../icon";
|
||||
import { LogTabData } from "./log-tab.store";
|
||||
import type { LogTabData } from "./log-tab.store";
|
||||
|
||||
interface Props {
|
||||
tabData?: LogTabData
|
||||
|
||||
@@ -28,7 +28,7 @@ import debounce from "lodash/debounce";
|
||||
import { action, computed, observable } from "mobx";
|
||||
import { observer } from "mobx-react";
|
||||
import moment from "moment-timezone";
|
||||
import { Align, ListOnScrollProps } from "react-window";
|
||||
import type { Align, ListOnScrollProps } from "react-window";
|
||||
|
||||
import { SearchStore, searchStore } from "../../../common/search-store";
|
||||
import { UserStore } from "../../../common/user-store";
|
||||
|
||||
@@ -29,7 +29,7 @@ import { Badge } from "../badge";
|
||||
import { Select, SelectOption } from "../select";
|
||||
import { LogTabData, logTabStore } from "./log-tab.store";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
import { TabId } from "./dock.store";
|
||||
import type { TabId } from "./dock.store";
|
||||
|
||||
interface Props {
|
||||
tabId: TabId
|
||||
|
||||
@@ -24,7 +24,7 @@ import { reaction } from "mobx";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
|
||||
import { IPodContainer, Pod } from "../../api/endpoints";
|
||||
import { WorkloadKubeObject } from "../../api/workload-kube-object";
|
||||
import type { WorkloadKubeObject } from "../../api/workload-kube-object";
|
||||
import { DockTabStore } from "./dock-tab.store";
|
||||
import { dockStore, IDockTab, TabKind } from "./dock.store";
|
||||
|
||||
@@ -138,7 +138,3 @@ export class LogTabStore extends DockTabStore<LogTabData> {
|
||||
}
|
||||
|
||||
export const logTabStore = new LogTabStore();
|
||||
|
||||
export function isLogsTab(tab: IDockTab) {
|
||||
return tab && tab.kind === TabKind.POD_LOGS;
|
||||
}
|
||||
@@ -23,8 +23,8 @@ import { autorun, computed, observable } from "mobx";
|
||||
|
||||
import { IPodLogsQuery, Pod, podsApi } from "../../api/endpoints";
|
||||
import { autobind, interval } from "../../utils";
|
||||
import { dockStore, TabId } from "./dock.store";
|
||||
import { isLogsTab, logTabStore } from "./log-tab.store";
|
||||
import { dockStore, TabId, TabKind } from "./dock.store";
|
||||
import { logTabStore } from "./log-tab.store";
|
||||
|
||||
type PodLogLine = string;
|
||||
|
||||
@@ -45,7 +45,7 @@ export class LogStore {
|
||||
autorun(() => {
|
||||
const { selectedTab, isOpen } = dockStore;
|
||||
|
||||
if (isLogsTab(selectedTab) && isOpen) {
|
||||
if (selectedTab?.kind === TabKind.POD_LOGS && isOpen) {
|
||||
this.refresher.start();
|
||||
} else {
|
||||
this.refresher.stop();
|
||||
|
||||
@@ -25,7 +25,7 @@ import { disposeOnUnmount, observer } from "mobx-react";
|
||||
|
||||
import { searchStore } from "../../../common/search-store";
|
||||
import { autobind } from "../../utils";
|
||||
import { IDockTab } from "./dock.store";
|
||||
import type { IDockTab } from "./dock.store";
|
||||
import { InfoPanel } from "./info-panel";
|
||||
import { LogResourceSelector } from "./log-resource-selector";
|
||||
import { LogList } from "./log-list";
|
||||
|
||||
@@ -25,8 +25,8 @@ import React from "react";
|
||||
import { reaction } from "mobx";
|
||||
import { disposeOnUnmount, observer } from "mobx-react";
|
||||
import { cssNames } from "../../utils";
|
||||
import { IDockTab } from "./dock.store";
|
||||
import { Terminal } from "./terminal";
|
||||
import type { IDockTab } from "./dock.store";
|
||||
import type { Terminal } from "./terminal";
|
||||
import { terminalStore } from "./terminal.store";
|
||||
import { ThemeStore } from "../../theme.store";
|
||||
|
||||
|
||||
@@ -30,10 +30,6 @@ export interface ITerminalTab extends IDockTab {
|
||||
node?: string; // activate node shell mode
|
||||
}
|
||||
|
||||
export function isTerminalTab(tab: IDockTab) {
|
||||
return tab && tab.kind === TabKind.TERMINAL;
|
||||
}
|
||||
|
||||
export function createTerminalTab(tabParams: Partial<ITerminalTab> = {}) {
|
||||
return dockStore.createTab({
|
||||
kind: TabKind.TERMINAL,
|
||||
@@ -52,9 +48,7 @@ export class TerminalStore {
|
||||
autorun(() => {
|
||||
const { selectedTab, isOpen } = dockStore;
|
||||
|
||||
if (!isTerminalTab(selectedTab)) return;
|
||||
|
||||
if (isOpen) {
|
||||
if (selectedTab?.kind === TabKind.TERMINAL && isOpen) {
|
||||
this.connect(selectedTab.id);
|
||||
}
|
||||
});
|
||||
@@ -97,21 +91,15 @@ export class TerminalStore {
|
||||
}
|
||||
|
||||
reconnect(tabId: TabId) {
|
||||
const terminalApi = this.connections.get(tabId);
|
||||
|
||||
if (terminalApi) terminalApi.connect();
|
||||
this.connections.get(tabId)?.connect();
|
||||
}
|
||||
|
||||
isConnected(tabId: TabId) {
|
||||
return !!this.connections.get(tabId);
|
||||
return Boolean(this.connections.get(tabId));
|
||||
}
|
||||
|
||||
isDisconnected(tabId: TabId) {
|
||||
const terminalApi = this.connections.get(tabId);
|
||||
|
||||
if (terminalApi) {
|
||||
return terminalApi.readyState === WebSocketApiState.CLOSED;
|
||||
}
|
||||
return this.connections.get(tabId)?.readyState === WebSocketApiState.CLOSED;
|
||||
}
|
||||
|
||||
sendCommand(command: string, options: { enter?: boolean; newTab?: boolean; tabId?: TabId } = {}) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import { reaction, toJS } from "mobx";
|
||||
import { Terminal as XTerm } from "xterm";
|
||||
import { FitAddon } from "xterm-addon-fit";
|
||||
import { dockStore, TabId } from "./dock.store";
|
||||
import { TerminalApi } from "../../api/terminal-api";
|
||||
import type { TerminalApi } from "../../api/terminal-api";
|
||||
import { ThemeStore } from "../../theme.store";
|
||||
import { autobind } from "../../utils";
|
||||
import { isMac } from "../../../common/vars";
|
||||
|
||||
@@ -19,11 +19,12 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { action, autorun, IReactionDisposer, reaction } from "mobx";
|
||||
import { action, autorun, computed, IReactionDisposer, reaction } from "mobx";
|
||||
import { dockStore, IDockTab, TabId, TabKind } from "./dock.store";
|
||||
import { DockTabStore } from "./dock-tab.store";
|
||||
import { getReleaseValues, HelmRelease } from "../../api/endpoints/helm-releases.api";
|
||||
import { releaseStore } from "../+apps-releases/release.store";
|
||||
import { iter } from "../../utils";
|
||||
|
||||
export interface IChartUpgradeData {
|
||||
releaseName: string;
|
||||
@@ -35,6 +36,10 @@ export class UpgradeChartStore extends DockTabStore<IChartUpgradeData> {
|
||||
|
||||
values = new DockTabStore<string>();
|
||||
|
||||
@computed private get releaseNameReverseLookup(): Map<string, string> {
|
||||
return new Map(iter.map(this.data, ([id, { releaseName }]) => [releaseName, id]));
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
storageKey: "chart_releases"
|
||||
@@ -43,9 +48,7 @@ export class UpgradeChartStore extends DockTabStore<IChartUpgradeData> {
|
||||
autorun(() => {
|
||||
const { selectedTab, isOpen } = dockStore;
|
||||
|
||||
if (!isUpgradeChartTab(selectedTab)) return;
|
||||
|
||||
if (isOpen) {
|
||||
if (selectedTab?.kind === TabKind.UPGRADE_CHART && isOpen) {
|
||||
this.loadData(selectedTab.id);
|
||||
}
|
||||
}, { delay: 250 });
|
||||
@@ -64,7 +67,7 @@ export class UpgradeChartStore extends DockTabStore<IChartUpgradeData> {
|
||||
const dispose = reaction(() => {
|
||||
const release = releaseStore.getByName(releaseName);
|
||||
|
||||
if (release) return release.getRevision(); // watch changes only by revision
|
||||
return release?.getRevision(); // watch changes only by revision
|
||||
},
|
||||
release => {
|
||||
const releaseTab = this.getTabByRelease(releaseName);
|
||||
@@ -116,13 +119,7 @@ export class UpgradeChartStore extends DockTabStore<IChartUpgradeData> {
|
||||
}
|
||||
|
||||
getTabByRelease(releaseName: string): IDockTab {
|
||||
const item = [...this.data].find(item => item[1].releaseName === releaseName);
|
||||
|
||||
if (item) {
|
||||
const [tabId] = item;
|
||||
|
||||
return dockStore.getTabById(tabId);
|
||||
}
|
||||
return dockStore.getTabById(this.releaseNameReverseLookup.get(releaseName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +148,3 @@ export function createUpgradeChartTab(release: HelmRelease, tabParams: Partial<I
|
||||
|
||||
return tab;
|
||||
}
|
||||
|
||||
export function isUpgradeChartTab(tab: IDockTab) {
|
||||
return tab && tab.kind === TabKind.UPGRADE_CHART;
|
||||
}
|
||||
@@ -25,7 +25,7 @@ import React from "react";
|
||||
import { observable, reaction } from "mobx";
|
||||
import { disposeOnUnmount, observer } from "mobx-react";
|
||||
import { cssNames } from "../../utils";
|
||||
import { IDockTab } from "./dock.store";
|
||||
import type { IDockTab } from "./dock.store";
|
||||
import { InfoPanel } from "./info-panel";
|
||||
import { upgradeChartStore } from "./upgrade-chart.store";
|
||||
import { Spinner } from "../spinner";
|
||||
@@ -33,7 +33,7 @@ import { releaseStore } from "../+apps-releases/release.store";
|
||||
import { Badge } from "../badge";
|
||||
import { EditorPanel } from "./editor-panel";
|
||||
import { helmChartStore, IChartVersion } from "../+apps-helm-charts/helm-chart.store";
|
||||
import { HelmRelease } from "../../api/endpoints/helm-releases.api";
|
||||
import type { HelmRelease } from "../../api/endpoints/helm-releases.api";
|
||||
import { Select, SelectOption } from "../select";
|
||||
|
||||
interface Props {
|
||||
@@ -62,7 +62,7 @@ export class UpgradeChart extends React.Component<Props> {
|
||||
get release(): HelmRelease {
|
||||
const tabData = upgradeChartStore.getData(this.tabId);
|
||||
|
||||
if (!tabData) return;
|
||||
if (!tabData) return null;
|
||||
|
||||
return releaseStore.getByName(tabData.releaseName);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ export class UpgradeChart extends React.Component<Props> {
|
||||
};
|
||||
|
||||
upgrade = async () => {
|
||||
if (this.error) return;
|
||||
if (this.error) return null;
|
||||
const { version, repo } = this.version;
|
||||
const releaseName = this.release.getName();
|
||||
const releaseNs = this.release.getNs();
|
||||
|
||||
Reference in new issue
Block a user