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

Reset details page date range dropdown #4176

Merged
merged 1 commit into from
Jan 20, 2025
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
21 changes: 19 additions & 2 deletions src/routes/details/ocpDetails/detailsHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,28 @@ const tagPathsType = TagPathsType.ocp;

class DetailsHeaderBase extends React.Component<DetailsHeaderProps, DetailsHeaderState> {
protected defaultState: DetailsHeaderState = {
currentDateRangeType:
this.props.timeScopeValue === -2 ? DateRangeType.previousMonth : DateRangeType.currentMonthToDate,
currentDateRangeType: DateRangeType.currentMonthToDate,
};
public state: DetailsHeaderState = { ...this.defaultState };

public componentDidMount() {
this.setState({ currentDateRangeType: this.getCurrentDateRangeType() });
}

public componentDidUpdate(prevProps: DetailsHeaderProps) {
const { timeScopeValue } = this.props;

if (prevProps.timeScopeValue !== timeScopeValue) {
this.setState({ currentDateRangeType: this.getCurrentDateRangeType() });
}
}

private getCurrentDateRangeType = () => {
const { timeScopeValue } = this.props;

return timeScopeValue === -2 ? DateRangeType.previousMonth : DateRangeType.currentMonthToDate;
};

private handleOnDateRangeSelect = (value: string) => {
const { onDateRangeSelect } = this.props;

Expand Down
Loading