Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Port to main] Setup date time filter props in correlations page #555

Merged
Merged
Show file tree
Hide file tree
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
21 changes: 12 additions & 9 deletions public/pages/Correlations/containers/CorrelationsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ interface CorrelationsState {

export class Correlations extends React.Component<CorrelationsProps, CorrelationsState> {
static contextType = CoreServicesContext;
private dateTimeFilter: DateTimeFilter;
constructor(props: CorrelationsProps) {
super(props);
this.state = {
Expand All @@ -82,10 +81,14 @@ export class Correlations extends React.Component<CorrelationsProps, Correlation
severityFilterOptions: [...defaultSeverityFilterItemOptions],
specificFindingInfo: undefined,
};
this.dateTimeFilter = this.props.dateTimeFilter || {
startTime: DEFAULT_DATE_RANGE.start,
endTime: DEFAULT_DATE_RANGE.end,
};
}

private get startTime() {
return this.props.dateTimeFilter?.startTime || DEFAULT_DATE_RANGE.start;
}

private get endTime() {
return this.props.dateTimeFilter?.endTime || DEFAULT_DATE_RANGE.end;
}

private shouldShowFinding(finding: CorrelationFinding) {
Expand Down Expand Up @@ -146,8 +149,8 @@ export class Correlations extends React.Component<CorrelationsProps, Correlation
this.updateGraphDataState(specificFindingInfo);
} else {
// get all correlations and display them in the graph
const start = datemath.parse(this.dateTimeFilter.startTime);
const end = datemath.parse(this.dateTimeFilter.endTime);
const start = datemath.parse(this.startTime);
const end = datemath.parse(this.endTime);
const startTime = start?.valueOf() || Date.now();
const endTime = end?.valueOf() || Date.now();
let allCorrelations = await DataStore.correlationsStore.getAllCorrelationsInWindow(
Expand Down Expand Up @@ -435,8 +438,8 @@ export class Correlations extends React.Component<CorrelationsProps, Correlation
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiSuperDatePicker
start={this.dateTimeFilter.startTime}
end={this.dateTimeFilter.endTime}
start={this.startTime}
end={this.endTime}
recentlyUsedRanges={this.state.recentlyUsedRanges}
onTimeChange={this.onTimeChange}
onRefresh={this.onRefresh}
Expand Down
2 changes: 2 additions & 0 deletions public/pages/Main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,8 @@ export default class Main extends Component<MainProps, MainState> {
{...props}
history={props.history}
onMount={() => this.setState({ selectedNavItemIndex: 6 })}
dateTimeFilter={this.state.dateTimeFilter}
setDateTimeFilter={this.setDateTimeFilter}
/>
);
}}
Expand Down