mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix: logs data disapearing causing crashes (#2566)
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
3682be2f01
commit
fa2acc3594
@ -11,7 +11,7 @@ import { Icon } from "../icon";
|
||||
import { LogTabData } from "./log-tab.store";
|
||||
|
||||
interface Props {
|
||||
tabData: LogTabData
|
||||
tabData?: LogTabData
|
||||
logs: string[]
|
||||
save: (data: Partial<LogTabData>) => void
|
||||
reload: () => void
|
||||
@ -19,6 +19,11 @@ interface Props {
|
||||
|
||||
export const LogControls = observer((props: Props) => {
|
||||
const { tabData, save, reload, logs } = props;
|
||||
|
||||
if (!tabData) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { showTimestamps, previous } = tabData;
|
||||
const since = logs.length ? logStore.getTimestamps(logs[0]) : null;
|
||||
const pod = new Pod(tabData.selectedPod);
|
||||
|
||||
@ -26,23 +26,14 @@ export class Logs extends React.Component<Props> {
|
||||
|
||||
componentDidMount() {
|
||||
disposeOnUnmount(this,
|
||||
reaction(() => this.props.tab.id, this.reload, { fireImmediately: true })
|
||||
reaction(() => this.props.tab.id, this.reload, { fireImmediately: true }),
|
||||
);
|
||||
}
|
||||
|
||||
get tabData() {
|
||||
return logTabStore.getData(this.tabId);
|
||||
}
|
||||
|
||||
get tabId() {
|
||||
return this.props.tab.id;
|
||||
}
|
||||
|
||||
@autobind()
|
||||
save(data: Partial<LogTabData>) {
|
||||
logTabStore.setData(this.tabId, { ...this.tabData, ...data });
|
||||
}
|
||||
|
||||
load = async () => {
|
||||
this.isLoading = true;
|
||||
await logStore.load(this.tabId);
|
||||
@ -82,15 +73,19 @@ export class Logs extends React.Component<Props> {
|
||||
}, 100);
|
||||
}
|
||||
|
||||
renderResourceSelector() {
|
||||
renderResourceSelector(data?: LogTabData) {
|
||||
if (!data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const logs = logStore.logs;
|
||||
const searchLogs = this.tabData.showTimestamps ? logs : logStore.logsWithoutTimestamps;
|
||||
const searchLogs = data.showTimestamps ? logs : logStore.logsWithoutTimestamps;
|
||||
const controls = (
|
||||
<div className="flex gaps">
|
||||
<LogResourceSelector
|
||||
tabId={this.tabId}
|
||||
tabData={this.tabData}
|
||||
save={this.save}
|
||||
tabData={data}
|
||||
save={newData => logTabStore.setData(this.tabId, { ...data, ...newData })}
|
||||
reload={this.reload}
|
||||
/>
|
||||
<LogSearch
|
||||
@ -115,10 +110,15 @@ export class Logs extends React.Component<Props> {
|
||||
|
||||
render() {
|
||||
const logs = logStore.logs;
|
||||
const data = logTabStore.getData(this.tabId);
|
||||
|
||||
if (!data) {
|
||||
this.reload();
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="PodLogs flex column">
|
||||
{this.renderResourceSelector()}
|
||||
{this.renderResourceSelector(data)}
|
||||
<LogList
|
||||
logs={logs}
|
||||
id={this.tabId}
|
||||
@ -128,8 +128,8 @@ export class Logs extends React.Component<Props> {
|
||||
/>
|
||||
<LogControls
|
||||
logs={logs}
|
||||
tabData={this.tabData}
|
||||
save={this.save}
|
||||
tabData={data}
|
||||
save={newData => logTabStore.setData(this.tabId, { ...data, ...newData })}
|
||||
reload={this.reload}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user