Skip to content

Commit

Permalink
set default range
Browse files Browse the repository at this point in the history
Signed-off-by: Kawika Avilla <[email protected]>
  • Loading branch information
kavilla committed Apr 24, 2024
1 parent 83a5f33 commit 96b721b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@ export default function QueryBarTopRow(props: QueryBarTopRowProps) {
function getDateRange() {
const defaultTimeSetting = uiSettings!.get(UI_SETTINGS.TIMEPICKER_TIME_DEFAULTS);
return {
from: props.dateRangeFrom || defaultTimeSetting.from,
to: props.dateRangeTo || defaultTimeSetting.to,
from:
queryUiEnhancement?.dateRange?.initialFrom ||
props.dateRangeFrom ||
defaultTimeSetting.from,
to: queryUiEnhancement?.dateRange?.initialTo || props.dateRangeTo || defaultTimeSetting.to,
};
}

Expand Down Expand Up @@ -317,8 +320,8 @@ export default function QueryBarTopRow(props: QueryBarTopRowProps) {
return (
<EuiFlexItem className={wrapperClasses}>
<EuiSuperDatePicker
start={props.dateRangeFrom}
end={props.dateRangeTo}
start={queryUiEnhancement?.dateRange?.initialFrom ?? props.dateRangeFrom}
end={queryUiEnhancement?.dateRange?.initialTo ?? props.dateRangeTo}
isPaused={props.isRefreshPaused}
refreshInterval={props.refreshInterval}
onTimeChange={onTimeChange}
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/data/public/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export interface QueryEnhancement {
// will replace '<data_source>' with the data source name
initialValue?: string;
};
dateRange?: {
initialFrom?: string;
initialTo?: string;
};
};
fields?: {
filterable?: boolean;
Expand Down

0 comments on commit 96b721b

Please sign in to comment.