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:
parent
fc58fc868d
commit
f2fabc2321
@ -6,7 +6,7 @@ import { observer } from "mobx-react";
|
|||||||
import { Pod } from "../../api/endpoints";
|
import { Pod } from "../../api/endpoints";
|
||||||
import { Badge } from "../badge";
|
import { Badge } from "../badge";
|
||||||
import { Select, SelectOption } from "../select";
|
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 { podsStore } from "../+workloads-pods/pods.store";
|
||||||
import { TabId } from "./dock.store";
|
import { TabId } from "./dock.store";
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const LogResourceSelector = observer((props: Props) => {
|
export const LogResourceSelector = observer((props: Props) => {
|
||||||
const { tabData, save, reload } = props;
|
const { tabData, save, reload, tabId } = props;
|
||||||
const { selectedPod, selectedContainer, pods } = tabData;
|
const { selectedPod, selectedContainer, pods } = tabData;
|
||||||
const pod = new Pod(selectedPod);
|
const pod = new Pod(selectedPod);
|
||||||
const containers = pod.getContainers();
|
const containers = pod.getContainers();
|
||||||
@ -37,6 +37,7 @@ export const LogResourceSelector = observer((props: Props) => {
|
|||||||
const selectedPod = podsStore.getByName(option.value, pod.getNs());
|
const selectedPod = podsStore.getByName(option.value, pod.getNs());
|
||||||
|
|
||||||
save({ selectedPod });
|
save({ selectedPod });
|
||||||
|
logTabStore.renameTab(tabId);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSelectOptions = (items: string[]) => {
|
const getSelectOptions = (items: string[]) => {
|
||||||
|
|||||||
@ -63,8 +63,10 @@ export class LogTabStore extends DockTabStore<LogTabData> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private get tabId() {
|
renameTab(tabId: string) {
|
||||||
return dockStore.selectedTabId;
|
const { selectedPod } = this.getData(tabId);
|
||||||
|
|
||||||
|
dockStore.renameTab(tabId, `Pod ${selectedPod.metadata.name}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
private createDockTab(tabParams: Partial<IDockTab>) {
|
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) {
|
private closeTab(tabId: string) {
|
||||||
this.clearData(tabId);
|
this.clearData(tabId);
|
||||||
dockStore.closeTab(tabId);
|
dockStore.closeTab(tabId);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user