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

Rename log tab when pod changes

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-01-26 11:21:52 +03:00
parent fc58fc868d
commit f2fabc2321
2 changed files with 7 additions and 10 deletions

View File

@ -6,7 +6,7 @@ import { observer } from "mobx-react";
import { Pod } from "../../api/endpoints";
import { Badge } from "../badge";
import { Select, SelectOption } from "../select";
import { LogTabData } from "./log-tab.store";
import { LogTabData, logTabStore } from "./log-tab.store";
import { podsStore } from "../+workloads-pods/pods.store";
import { TabId } from "./dock.store";
@ -18,7 +18,7 @@ interface Props {
}
export const LogResourceSelector = observer((props: Props) => {
const { tabData, save, reload } = props;
const { tabData, save, reload, tabId } = props;
const { selectedPod, selectedContainer, pods } = tabData;
const pod = new Pod(selectedPod);
const containers = pod.getContainers();
@ -37,6 +37,7 @@ export const LogResourceSelector = observer((props: Props) => {
const selectedPod = podsStore.getByName(option.value, pod.getNs());
save({ selectedPod });
logTabStore.renameTab(tabId);
};
const getSelectOptions = (items: string[]) => {

View File

@ -63,8 +63,10 @@ export class LogTabStore extends DockTabStore<LogTabData> {
});
}
private get tabId() {
return dockStore.selectedTabId;
renameTab(tabId: string) {
const { selectedPod } = this.getData(tabId);
dockStore.renameTab(tabId, `Pod ${selectedPod.metadata.name}`);
}
private createDockTab(tabParams: Partial<IDockTab>) {
@ -108,12 +110,6 @@ export class LogTabStore extends DockTabStore<LogTabData> {
});
}
private renameTab(tabId: string) {
const { selectedPod } = this.getData(tabId);
dockStore.renameTab(tabId, `Pod ${selectedPod.metadata.name}`);
}
private closeTab(tabId: string) {
this.clearData(tabId);
dockStore.closeTab(tabId);