From f3d89084a89a2e82e50025e6eeb252c0e55b5dc6 Mon Sep 17 00:00:00 2001 From: vermilionAnd <61216850+zhuzilv@users.noreply.github.com> Date: Tue, 10 Oct 2023 09:56:22 +0800 Subject: [PATCH] fix(past-time-picker): Earliest in history feature (#2196) * fix(sinceRangePicker): change params * fix: bug echo title --------- Co-authored-by: vermilionAnd --- src/past-time-picker/PastTimePicker.tsx | 4 +++- src/static-past-time-picker/constant.ts | 7 ++++--- src/static-past-time-picker/locales/en-US.ts | 1 + src/static-past-time-picker/locales/zh-CN.ts | 1 + 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/past-time-picker/PastTimePicker.tsx b/src/past-time-picker/PastTimePicker.tsx index b3db7e10d5..5f661710f1 100644 --- a/src/past-time-picker/PastTimePicker.tsx +++ b/src/past-time-picker/PastTimePicker.tsx @@ -78,6 +78,7 @@ const PastTimePicker = (props: PastTimePickerProps) => { dayText, timeRangeText, earliestInHistory, + earliestInHistoryEcho, } = { ...defaultLocale, ...locale, @@ -119,12 +120,13 @@ const PastTimePicker = (props: PastTimePickerProps) => { } if (has(QUICK_MAPPING, time)) { const [startTime, endTime] = parseQuickDate(time); + const showSinceZero = time === 'since:0' ? earliestInHistoryEcho : `${get(QUICK_MAPPING, time)}`; return showAbsDate ? `${get(QUICK_MAPPING, time)} | ${parseFnsTimeZone(startTime, 'yyyy/MM/dd')}-${parseFnsTimeZone( endTime, 'yyyy/MM/dd' )}` - : `${get(QUICK_MAPPING, time)}`; + : showSinceZero; } const items = time.split(':'); const times = items[1].split(',').map((str) => parseInt(str, 10)); diff --git a/src/static-past-time-picker/constant.ts b/src/static-past-time-picker/constant.ts index 14466d95aa..c604d71508 100644 --- a/src/static-past-time-picker/constant.ts +++ b/src/static-past-time-picker/constant.ts @@ -3,9 +3,9 @@ import defaultLocaleText from './locales/zh-CN'; export const DATE_FORMAT = 'yyyy/MM/dd'; export const experimentalQuickOptions = (localeText: typeof defaultLocaleText) => [ - { value: 'hour:25,1', label: localeText.lastSomeHours?.(24) }, - { value: 'hour:73,1', label: localeText.lastSomeHours?.(72) }, - { value: 'hour:49,1', label: localeText.lastSomeHours?.(48) }, + { value: 'hour:25,1', label: localeText.lastSomeHours?.(24) }, + { value: 'hour:73,1', label: localeText.lastSomeHours?.(72) }, + { value: 'hour:49,1', label: localeText.lastSomeHours?.(48) }, ]; export const QUICK_MAPPING = { @@ -29,6 +29,7 @@ export const QUICK_MAPPING = { 'day:15,1': '过去 14 天', 'day:91,1': '过去 90 天', 'day:366,1': '过去 365 天', + 'since:0': '历史最早', }; export const END_DATE_MAPPING: { [key: string]: string } = { diff --git a/src/static-past-time-picker/locales/en-US.ts b/src/static-past-time-picker/locales/en-US.ts index 430364d146..157b33601d 100644 --- a/src/static-past-time-picker/locales/en-US.ts +++ b/src/static-past-time-picker/locales/en-US.ts @@ -35,6 +35,7 @@ export default { thisYearTextToYesterday: 'This year(to yesterday)', lastYearText: 'Last Year', earliestInHistory: 'Earliest in history', + earliestInHistoryEcho: 'Earliest in history to present', lastSomeHours: (text: Key) => `Last ${text} hour(s)`, last7DaysText: 'Previous 7 days', last14DaysText: 'Previous 14 days', diff --git a/src/static-past-time-picker/locales/zh-CN.ts b/src/static-past-time-picker/locales/zh-CN.ts index c480077388..b3b34a5f6b 100644 --- a/src/static-past-time-picker/locales/zh-CN.ts +++ b/src/static-past-time-picker/locales/zh-CN.ts @@ -35,6 +35,7 @@ export default { thisYearTextToYesterday: '今年(至昨日)', lastYearText: '去年', earliestInHistory: '历史最早', + earliestInHistoryEcho: '历史最早 至今日', lastSomeHours: (text: Key) => `过去 ${text} 小时`, last7DaysText: '过去7天', last14DaysText: '过去14天',