Skip to content

Commit

Permalink
passing props for date time filter (#551) (#555)
Browse files Browse the repository at this point in the history
Signed-off-by: Amardeepsingh Siglani <[email protected]>
  • Loading branch information
amsiglan authored Apr 26, 2023
1 parent b90dfac commit 7db9498
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
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

0 comments on commit 7db9498

Please sign in to comment.