Skip to content

Commit

Permalink
Fix pod logs dock tab (#4738)
Browse files Browse the repository at this point in the history
- Move all dependencies into a transient LogsViewModel

- Remove dependencies on dockStore.selectedTab

- Make all bindings as late as possible, as per mobx rules

Signed-off-by: Sebastian Malton <[email protected]>
  • Loading branch information
Nokel81 authored Jan 25, 2022
1 parent b037c3b commit b3df5b4
Show file tree
Hide file tree
Showing 42 changed files with 648 additions and 642 deletions.
11 changes: 11 additions & 0 deletions src/common/utils/collection-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,14 @@ export function getOrInsert<K, V>(map: Map<K, V>, key: K, value: V): V {
export function getOrInsertMap<K, MK, MV>(map: Map<K, Map<MK, MV>>, key: K): Map<MK, MV> {
return getOrInsert(map, key, new Map<MK, MV>());
}

/**
* Like `getOrInsert` but with delayed creation of the item
*/
export function getOrInsertWith<K, V>(map: Map<K, V>, key: K, value: () => V): V {
if (!map.has(key)) {
map.set(key, value());
}

return map.get(key);
}
2 changes: 1 addition & 1 deletion src/extensions/renderer-api/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { asLegacyGlobalFunctionForExtensionApi } from "../as-legacy-globals-for-
import createTerminalTabInjectable from "../../renderer/components/dock/create-terminal-tab/create-terminal-tab.injectable";
import terminalStoreInjectable from "../../renderer/components/dock/terminal-store/terminal-store.injectable";
import { asLegacyGlobalObjectForExtensionApi } from "../as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
import logTabStoreInjectable from "../../renderer/components/dock/log-tab-store/log-tab-store.injectable";
import logTabStoreInjectable from "../../renderer/components/dock/logs/tab-store.injectable";
import { asLegacyGlobalSingletonForExtensionApi } from "../as-legacy-globals-for-extension-api/as-legacy-global-singleton-for-extension-api";
import { TerminalStore as TerminalStoreClass } from "../../renderer/components/dock/terminal-store/terminal.store";

Expand Down
151 changes: 0 additions & 151 deletions src/renderer/components/dock/__test__/log-resource-selector.test.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/renderer/components/dock/dock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { DockTabs } from "./dock-tabs";
import { DockStore, DockTab, TabKind } from "./dock-store/dock.store";
import { EditResource } from "./edit-resource";
import { InstallChart } from "./install-chart";
import { Logs } from "./logs";
import { LogsDockTab } from "./logs/dock-tab";
import { TerminalWindow } from "./terminal-window";
import { UpgradeChart } from "./upgrade-chart";
import { withInjectables } from "@ogre-tools/injectable-react";
Expand Down Expand Up @@ -85,7 +85,7 @@ class NonInjectedDock extends React.Component<Props & Dependencies> {
case TabKind.UPGRADE_CHART:
return <UpgradeChart tab={tab} />;
case TabKind.POD_LOGS:
return <Logs />;
return <LogsDockTab tab={tab} />;
case TabKind.TERMINAL:
return <TerminalWindow tab={tab} />;
}
Expand Down

This file was deleted.

136 changes: 0 additions & 136 deletions src/renderer/components/dock/logs.tsx

This file was deleted.

Loading

0 comments on commit b3df5b4

Please sign in to comment.