Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions x-pack/plugins/beats_management/public/pages/main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ interface MainPagesState {
enrollmentToken: string;
} | null;
beats: CMPopulatedBeat[];
unfilteredBeats: CMPopulatedBeat[];
loadedBeatsAtLeastOnce: boolean;
}

Expand All @@ -50,6 +51,7 @@ class MainPagesComponent extends React.PureComponent<MainPagesProps, MainPagesSt
this.state = {
loadedBeatsAtLeastOnce: false,
beats: [],
unfilteredBeats: [],
};
}
public onSelectedTabChanged = (id: string) => {
Expand All @@ -68,7 +70,7 @@ class MainPagesComponent extends React.PureComponent<MainPagesProps, MainPagesSt
public render() {
if (
this.state.loadedBeatsAtLeastOnce &&
this.state.beats.length === 0 &&
this.state.unfilteredBeats.length === 0 &&
!this.props.location.pathname.includes('/overview/initial')
) {
return <Redirect to="/overview/initial/help" />;
Expand Down Expand Up @@ -231,15 +233,21 @@ class MainPagesComponent extends React.PureComponent<MainPagesProps, MainPagesSt
}

let beats: CMPopulatedBeat[];
let unfilteredBeats: CMPopulatedBeat[];
try {
beats = await this.props.libs.beats.getAll(query);
[beats, unfilteredBeats] = await Promise.all([
this.props.libs.beats.getAll(query),
this.props.libs.beats.getAll(),
]);
} catch (e) {
beats = [];
unfilteredBeats = [];
}
if (this.mounted) {
this.setState({
loadedBeatsAtLeastOnce: true,
beats,
unfilteredBeats,
});
}
};
Expand Down