feat: only choose 15 time

pull/19758/head
Joel 8 months ago committed by Junyan Qin
parent 9ff564e3eb
commit cadf3eac00
No known key found for this signature in database
GPG Key ID: 22FE3AFADC710CEB

@ -21,6 +21,7 @@ const TimePicker = ({
onClear, onClear,
renderTrigger, renderTrigger,
title, title,
minuteFilter,
popupClassName, popupClassName,
}: TimePickerProps) => { }: TimePickerProps) => {
const { t } = useTranslation() const { t } = useTranslation()
@ -152,6 +153,7 @@ const TimePicker = ({
{/* Time Options */} {/* Time Options */}
<Options <Options
selectedTime={selectedTime} selectedTime={selectedTime}
minuteFilter={minuteFilter}
handleSelectHour={handleSelectHour} handleSelectHour={handleSelectHour}
handleSelectMinute={handleSelectMinute} handleSelectMinute={handleSelectMinute}
handleSelectPeriod={handleSelectPeriod} handleSelectPeriod={handleSelectPeriod}

@ -5,6 +5,7 @@ import OptionListItem from '../common/option-list-item'
const Options: FC<TimeOptionsProps> = ({ const Options: FC<TimeOptionsProps> = ({
selectedTime, selectedTime,
minuteFilter,
handleSelectHour, handleSelectHour,
handleSelectMinute, handleSelectMinute,
handleSelectPeriod, handleSelectPeriod,
@ -33,7 +34,7 @@ const Options: FC<TimeOptionsProps> = ({
{/* Minute */} {/* Minute */}
<ul className='no-scrollbar flex h-[208px] flex-col gap-y-0.5 overflow-y-auto pb-[184px]'> <ul className='no-scrollbar flex h-[208px] flex-col gap-y-0.5 overflow-y-auto pb-[184px]'>
{ {
minuteOptions.map((minute) => { (minuteFilter ? minuteFilter(minuteOptions) : minuteOptions).map((minute) => {
const isSelected = selectedTime?.format('mm') === minute const isSelected = selectedTime?.format('mm') === minute
return ( return (
<OptionListItem <OptionListItem

@ -28,6 +28,7 @@ export type DatePickerProps = {
onClear: () => void onClear: () => void
triggerWrapClassName?: string triggerWrapClassName?: string
renderTrigger?: (props: TriggerProps) => React.ReactNode renderTrigger?: (props: TriggerProps) => React.ReactNode
minuteFilter?: (minutes: string[]) => string[]
popupZIndexClassname?: string popupZIndexClassname?: string
} }
@ -55,6 +56,7 @@ export type TimePickerProps = {
onClear: () => void onClear: () => void
renderTrigger?: () => React.ReactNode renderTrigger?: () => React.ReactNode
title?: string title?: string
minuteFilter?: (minutes: string[]) => string[]
popupClassName?: string popupClassName?: string
} }
@ -83,6 +85,7 @@ export type CalendarItemProps = {
export type TimeOptionsProps = { export type TimeOptionsProps = {
selectedTime: Dayjs | undefined selectedTime: Dayjs | undefined
minuteFilter?: (minutes: string[]) => string[]
handleSelectHour: (hour: string) => void handleSelectHour: (hour: string) => void
handleSelectMinute: (minute: string) => void handleSelectMinute: (minute: string) => void
handleSelectPeriod: (period: Period) => void handleSelectPeriod: (period: Period) => void

@ -42,6 +42,13 @@ const AutoUpdateSetting: FC<Props> = ({
exclude_plugins, exclude_plugins,
include_plugins, include_plugins,
} = payload } = payload
const minuteFilter = useCallback((minutes: string[]) => {
return minutes.filter((m) => {
const time = Number.parseInt(m, 10)
return time % 15 === 0
})
}, [])
const strategyDescription = useMemo(() => { const strategyDescription = useMemo(() => {
switch (strategy_setting) { switch (strategy_setting) {
case AUTO_UPDATE_STRATEGY.fixOnly: case AUTO_UPDATE_STRATEGY.fixOnly:
@ -108,6 +115,7 @@ const AutoUpdateSetting: FC<Props> = ({
onClear={() => handleChange('upgrade_time_of_day')(0)} onClear={() => handleChange('upgrade_time_of_day')(0)}
popupClassName='z-[99]' popupClassName='z-[99]'
title={t(`${i18nPrefix}.updateTime`)} title={t(`${i18nPrefix}.updateTime`)}
minuteFilter={minuteFilter}
/> />
</div> </div>
<div> <div>

Loading…
Cancel
Save