mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Refresh containers on pod change
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
99f70f3401
commit
fd63045874
@ -208,6 +208,12 @@ export class DockStore {
|
|||||||
this.closeTabs(tabs);
|
this.closeTabs(tabs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renameTab(tabId: TabId, title: string) {
|
||||||
|
const tab = this.getTabById(tabId);
|
||||||
|
|
||||||
|
tab.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
selectTab(tabId: TabId) {
|
selectTab(tabId: TabId) {
|
||||||
this.selectedTabId = this.getTabById(tabId)?.id ?? null;
|
this.selectedTabId = this.getTabById(tabId)?.id ?? null;
|
||||||
|
|||||||
@ -8,17 +8,19 @@ import { Badge } from "../badge";
|
|||||||
import { Select, SelectOption } from "../select";
|
import { Select, SelectOption } from "../select";
|
||||||
import { LogTabData } from "./log-tab.store";
|
import { LogTabData } from "./log-tab.store";
|
||||||
import { podsStore } from "../+workloads-pods/pods.store";
|
import { podsStore } from "../+workloads-pods/pods.store";
|
||||||
|
import { dockStore, TabId } from "./dock.store";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
tabId: TabId
|
||||||
tabData: LogTabData
|
tabData: LogTabData
|
||||||
save: (data: Partial<LogTabData>) => void
|
save: (data: Partial<LogTabData>) => void
|
||||||
reload: () => void
|
reload: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
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, containers, initContainers, pods } = tabData;
|
const { selectedPod, selectedContainer, containers, initContainers, pods } = tabData;
|
||||||
const pod = new Pod(tabData.selectedPod);
|
const pod = new Pod(selectedPod);
|
||||||
|
|
||||||
const onContainerChange = (option: SelectOption) => {
|
const onContainerChange = (option: SelectOption) => {
|
||||||
save({
|
save({
|
||||||
@ -30,9 +32,18 @@ export const LogResourceSelector = observer((props: Props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onPodChange = (option: SelectOption) => {
|
const onPodChange = (option: SelectOption) => {
|
||||||
save({ selectedPod: podsStore.getByName(option.value, selectedPod.getNs()) });
|
const selectedPod = podsStore.getByName(option.value, pod.getNs());
|
||||||
// Change tab title
|
const { getContainers, getInitContainers, getAllContainers } = selectedPod;
|
||||||
// Refresh container list
|
|
||||||
|
save({
|
||||||
|
selectedPod,
|
||||||
|
containers: getContainers(),
|
||||||
|
initContainers: getInitContainers(),
|
||||||
|
selectedContainer: getAllContainers()[0]
|
||||||
|
});
|
||||||
|
|
||||||
|
dockStore.renameTab(tabId, `Pod ${option.value}`);
|
||||||
|
|
||||||
reload();
|
reload();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -60,7 +71,7 @@ export const LogResourceSelector = observer((props: Props) => {
|
|||||||
const podSelectOptions = [
|
const podSelectOptions = [
|
||||||
{
|
{
|
||||||
label: pod.getOwnerRefs()[0]?.name,
|
label: pod.getOwnerRefs()[0]?.name,
|
||||||
options: getSelectOptions(pods.map(pod => pod.getName()))
|
options: getSelectOptions(pods.map(pod => pod.metadata.name))
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,7 @@ export class LogTabStore extends DockTabStore<LogTabData> {
|
|||||||
const title = `${workload.kind} ${selectedPod.getName()}`;
|
const title = `${workload.kind} ${selectedPod.getName()}`;
|
||||||
|
|
||||||
this.createLogsTab(title, {
|
this.createLogsTab(title, {
|
||||||
pods: pods.length ? pods : [selectedPod],
|
pods,
|
||||||
selectedPod,
|
selectedPod,
|
||||||
selectedContainer
|
selectedContainer
|
||||||
});
|
});
|
||||||
|
|||||||
@ -88,6 +88,7 @@ export class Logs extends React.Component<Props> {
|
|||||||
const controls = (
|
const controls = (
|
||||||
<div className="flex gaps">
|
<div className="flex gaps">
|
||||||
<LogResourceSelector
|
<LogResourceSelector
|
||||||
|
tabId={this.tabId}
|
||||||
tabData={this.tabData}
|
tabData={this.tabData}
|
||||||
save={this.save}
|
save={this.save}
|
||||||
reload={this.reload}
|
reload={this.reload}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user