mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
fix(explore): timepicker show human readable string in pill (#12300)
* fix(explore): timepicker show human readable string in pill * fix lint
This commit is contained in:
@@ -183,15 +183,25 @@ export default function DateFilterControl(props: DateFilterLabelProps) {
|
||||
const [evalResponse, setEvalResponse] = useState<string>(value);
|
||||
|
||||
useEffect(() => {
|
||||
fetchTimeRange(value, endpoints).then(({ value, error }) => {
|
||||
if (error) {
|
||||
setEvalResponse(error || '');
|
||||
setValidTimeRange(false);
|
||||
} else {
|
||||
setActualTimeRange(value || '');
|
||||
setValidTimeRange(true);
|
||||
}
|
||||
});
|
||||
const valueToLower = value.toLowerCase();
|
||||
if (
|
||||
valueToLower.startsWith('last') ||
|
||||
valueToLower.startsWith('next') ||
|
||||
valueToLower.startsWith('previous')
|
||||
) {
|
||||
setActualTimeRange(value);
|
||||
setValidTimeRange(true);
|
||||
} else {
|
||||
fetchTimeRange(value, endpoints).then(({ value, error }) => {
|
||||
if (error) {
|
||||
setEvalResponse(error || '');
|
||||
setValidTimeRange(false);
|
||||
} else {
|
||||
setActualTimeRange(value || '');
|
||||
setValidTimeRange(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [value]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -77,12 +77,9 @@ export type CommonRangeType =
|
||||
| 'Last quarter'
|
||||
| 'Last year';
|
||||
|
||||
export const PreviousCalendarWeek =
|
||||
'DATETRUNC(DATEADD(DATETIME("TODAY"), -1, WEEK), WEEK) : LASTDAY(DATEADD(DATETIME("TODAY"), -1, WEEK), WEEK)';
|
||||
export const PreviousCalendarMonth =
|
||||
'DATETRUNC(DATEADD(DATETIME("TODAY"), -1, MONTH), MONTH) : LASTDAY(DATEADD(DATETIME("TODAY"), -1, MONTH), MONTH)';
|
||||
export const PreviousCalendarYear =
|
||||
'DATETRUNC(DATEADD(DATETIME("TODAY"), -1, YEAR), YEAR) : LASTDAY(DATEADD(DATETIME("TODAY"), -1, YEAR), YEAR)';
|
||||
export const PreviousCalendarWeek = 'previous calendar week';
|
||||
export const PreviousCalendarMonth = 'previous calendar month';
|
||||
export const PreviousCalendarYear = 'previous calendar year';
|
||||
export type CalendarRangeType =
|
||||
| typeof PreviousCalendarWeek
|
||||
| typeof PreviousCalendarMonth
|
||||
|
||||
Reference in New Issue
Block a user