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

Open existent tab if fount

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2020-10-06 11:42:32 +03:00
parent 68fd6014b9
commit 58e81f2a9c

View File

@ -5,7 +5,7 @@ import { dockStore, IDockTab, TabKind } from "./dock.store";
export interface IPodLogsData {
pod: Pod;
container?: IPodContainer;
container: IPodContainer;
}
@autobind()
@ -15,9 +15,18 @@ export class PodLogsStore extends DockTabStore<IPodLogsData> {
export const podLogsStore = new PodLogsStore();
export function createPodLogsTab(data: IPodLogsData, tabParams: Partial<IDockTab> = {}) {
const tab = dockStore.createTab({
const podId = data.pod.getId();
let tab = dockStore.getTabById(podId);
if (tab) {
dockStore.open();
dockStore.selectTab(tab.id);
return;
}
// If no existent tab found
tab = dockStore.createTab({
id: podId,
kind: TabKind.POD_LOGS,
title: "Logs",
title: `Logs: ${data.pod.getName()}`,
...tabParams
});
podLogsStore.setData(tab.id, data);