Skip to content

Commit

Permalink
remove unusable common date ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
ashokaditya committed Nov 20, 2024
1 parent f29f379 commit 1978600
Showing 1 changed file with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,25 @@ export const UsageMetricsDateRangePicker = memo<UsageMetricsDateRangePickerProps
const kibana = useKibana<IUnifiedSearchPluginServices>();
const { uiSettings } = kibana.services;
const [commonlyUsedRanges] = useState(() => {
const _commonlyUsedRanges: Array<{ from: string; to: string; display: string }> =
uiSettings.get(UI_SETTINGS.TIMEPICKER_QUICK_RANGES);
if (!_commonlyUsedRanges) {
return [];
}
return (
uiSettings
?.get(UI_SETTINGS.TIMEPICKER_QUICK_RANGES)
?.map(({ from, to, display }: { from: string; to: string; display: string }) => {
return {
start: from,
end: to,
label: display,
};
}) ?? []
_commonlyUsedRanges.reduce<DurationRange[]>(
(acc, { from, to, display }: { from: string; to: string; display: string }) => {
if (!['now-30d/d', 'now-90d/d', 'now-1y/d'].includes(from)) {
acc.push({
start: from,
end: to,
label: display,
});
}
return acc;
},
[]
) ?? []
);
});

Expand Down

0 comments on commit 1978600

Please sign in to comment.