mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Eliminating containers and initContainers from store
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
e1c4588156
commit
355fbc9134
@ -30,8 +30,6 @@ const getOnePodTabData = (): LogTabData => {
|
||||
pods: [] as Pod[],
|
||||
selectedPod,
|
||||
selectedContainer: selectedPod.getContainers()[0],
|
||||
containers: selectedPod.getContainers(),
|
||||
initContainers: selectedPod.getInitContainers(),
|
||||
};
|
||||
};
|
||||
|
||||
@ -43,8 +41,6 @@ const getFewPodsTabData = (): LogTabData => {
|
||||
pods: [anotherPod],
|
||||
selectedPod,
|
||||
selectedContainer: selectedPod.getContainers()[0],
|
||||
containers: selectedPod.getContainers(),
|
||||
initContainers: selectedPod.getInitContainers(),
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -32,8 +32,6 @@ describe("log tab store", () => {
|
||||
pods: [selectedPod],
|
||||
selectedPod,
|
||||
selectedContainer,
|
||||
containers: selectedPod.getContainers(),
|
||||
initContainers: [],
|
||||
showTimestamps: false,
|
||||
previous: false
|
||||
});
|
||||
@ -53,8 +51,6 @@ describe("log tab store", () => {
|
||||
pods: [selectedPod, siblingPod],
|
||||
selectedPod,
|
||||
selectedContainer,
|
||||
containers: selectedPod.getContainers(),
|
||||
initContainers: selectedPod.getInitContainers(),
|
||||
showTimestamps: false,
|
||||
previous: false
|
||||
});
|
||||
|
||||
@ -19,8 +19,10 @@ interface Props {
|
||||
|
||||
export const LogResourceSelector = observer((props: Props) => {
|
||||
const { tabData, save, reload, tabId } = props;
|
||||
const { selectedPod, selectedContainer, containers, initContainers, pods } = tabData;
|
||||
const { selectedPod, selectedContainer, pods } = tabData;
|
||||
const pod = new Pod(selectedPod);
|
||||
const containers = pod.getContainers();
|
||||
const initContainers = pod.getInitContainers();
|
||||
|
||||
const onContainerChange = (option: SelectOption) => {
|
||||
save({
|
||||
@ -38,13 +40,9 @@ export const LogResourceSelector = observer((props: Props) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const { getContainers, getInitContainers, getAllContainers } = selectedPod;
|
||||
|
||||
save({
|
||||
selectedPod,
|
||||
containers: getContainers(),
|
||||
initContainers: getInitContainers(),
|
||||
selectedContainer: getAllContainers()[0]
|
||||
selectedContainer: selectedPod.getAllContainers()[0]
|
||||
});
|
||||
|
||||
dockStore.renameTab(tabId, `Pod ${option.value}`);
|
||||
|
||||
@ -4,14 +4,12 @@ import { podsStore } from "../+workloads-pods/pods.store";
|
||||
import { IPodContainer, Pod } from "../../api/endpoints";
|
||||
import { WorkloadKubeObject } from "../../api/workload-kube-object";
|
||||
import { DockTabStore } from "./dock-tab.store";
|
||||
import { dockStore, IDockTab, TabId, TabKind } from "./dock.store";
|
||||
import { dockStore, IDockTab, TabKind } from "./dock.store";
|
||||
|
||||
export interface LogTabData {
|
||||
pods: Pod[];
|
||||
selectedPod: Pod;
|
||||
selectedContainer: IPodContainer
|
||||
containers?: IPodContainer[]
|
||||
initContainers?: IPodContainer[]
|
||||
showTimestamps?: boolean
|
||||
previous?: boolean
|
||||
}
|
||||
@ -67,29 +65,15 @@ export class LogTabStore extends DockTabStore<LogTabData> {
|
||||
}, false);
|
||||
}
|
||||
|
||||
private saveControlsData(id: TabId, data: LogTabData) {
|
||||
this.setData(id, data);
|
||||
}
|
||||
|
||||
private addBasicControlsData(data: LogTabData): LogTabData {
|
||||
const containers = data.selectedPod.getContainers();
|
||||
const initContainers = data.selectedPod.getInitContainers();
|
||||
|
||||
return {
|
||||
...data,
|
||||
containers,
|
||||
initContainers,
|
||||
showTimestamps: false,
|
||||
previous: false
|
||||
};
|
||||
}
|
||||
|
||||
private createLogsTab(title: string, data: LogTabData) {
|
||||
const id = uniqueId("log-tab-");
|
||||
const fullData = this.addBasicControlsData(data);
|
||||
|
||||
this.createDockTab({ id, title });
|
||||
this.saveControlsData(id, fullData);
|
||||
this.setData(id, {
|
||||
...data,
|
||||
showTimestamps: false,
|
||||
previous: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user