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);
|
||||
}
|
||||
|
||||
renameTab(tabId: TabId, title: string) {
|
||||
const tab = this.getTabById(tabId);
|
||||
|
||||
tab.title = title;
|
||||
}
|
||||
|
||||
@action
|
||||
selectTab(tabId: TabId) {
|
||||
this.selectedTabId = this.getTabById(tabId)?.id ?? null;
|
||||
|
||||
@ -8,17 +8,19 @@ import { Badge } from "../badge";
|
||||
import { Select, SelectOption } from "../select";
|
||||
import { LogTabData } from "./log-tab.store";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
import { dockStore, TabId } from "./dock.store";
|
||||
|
||||
interface Props {
|
||||
tabId: TabId
|
||||
tabData: LogTabData
|
||||
save: (data: Partial<LogTabData>) => void
|
||||
reload: () => void
|
||||
}
|
||||
|
||||
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 pod = new Pod(tabData.selectedPod);
|
||||
const pod = new Pod(selectedPod);
|
||||
|
||||
const onContainerChange = (option: SelectOption) => {
|
||||
save({
|
||||
@ -30,9 +32,18 @@ export const LogResourceSelector = observer((props: Props) => {
|
||||
};
|
||||
|
||||
const onPodChange = (option: SelectOption) => {
|
||||
save({ selectedPod: podsStore.getByName(option.value, selectedPod.getNs()) });
|
||||
// Change tab title
|
||||
// Refresh container list
|
||||
const selectedPod = podsStore.getByName(option.value, pod.getNs());
|
||||
const { getContainers, getInitContainers, getAllContainers } = selectedPod;
|
||||
|
||||
save({
|
||||
selectedPod,
|
||||
containers: getContainers(),
|
||||
initContainers: getInitContainers(),
|
||||
selectedContainer: getAllContainers()[0]
|
||||
});
|
||||
|
||||
dockStore.renameTab(tabId, `Pod ${option.value}`);
|
||||
|
||||
reload();
|
||||
};
|
||||
|
||||
@ -60,7 +71,7 @@ export const LogResourceSelector = observer((props: Props) => {
|
||||
const podSelectOptions = [
|
||||
{
|
||||
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()}`;
|
||||
|
||||
this.createLogsTab(title, {
|
||||
pods: pods.length ? pods : [selectedPod],
|
||||
pods,
|
||||
selectedPod,
|
||||
selectedContainer
|
||||
});
|
||||
|
||||
@ -88,6 +88,7 @@ export class Logs extends React.Component<Props> {
|
||||
const controls = (
|
||||
<div className="flex gaps">
|
||||
<LogResourceSelector
|
||||
tabId={this.tabId}
|
||||
tabData={this.tabData}
|
||||
save={this.save}
|
||||
reload={this.reload}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user