diff --git a/config-ui/src/config/cron.ts b/config-ui/src/config/cron.ts index db01160cc61..9879815178a 100644 --- a/config-ui/src/config/cron.ts +++ b/config-ui/src/config/cron.ts @@ -59,9 +59,8 @@ export const getCron = (isManual: boolean, config: string) => { if (isManual) { return { label: 'Manual', - value: 'manual', - description: '', config: '', + description: '', nextTime: '', nextTimes: [], }; @@ -72,15 +71,13 @@ export const getCron = (isManual: boolean, config: string) => { return preset ? { ...preset, - value: preset.config, nextTime: getNextTime(preset.config), nextTimes: getNextTimes(preset.config), } : { label: 'Custom', - value: '', - description: '', config, + description: '', nextTime: getNextTime(config), nextTimes: getNextTimes(config), }; @@ -89,22 +86,22 @@ export const getCron = (isManual: boolean, config: string) => { export const getCronOptions = () => { return [ { - value: 'manual', label: 'Manual', + value: 'manual', subLabel: '', }, ] .concat( cronPresets.map((cp) => ({ - value: cp.config, label: cp.label, + value: cp.config, subLabel: cp.description, })), ) .concat([ { - value: '', label: 'Custom', + value: 'custom', subLabel: '', }, ]); diff --git a/config-ui/src/pages/blueprint/detail/components/sync-policy/index.tsx b/config-ui/src/pages/blueprint/detail/components/sync-policy/index.tsx index f743ad38bec..b4678aff84d 100644 --- a/config-ui/src/pages/blueprint/detail/components/sync-policy/index.tsx +++ b/config-ui/src/pages/blueprint/detail/components/sync-policy/index.tsx @@ -16,7 +16,7 @@ * */ -import { useMemo } from 'react'; +import { useState, useMemo } from 'react'; import dayjs from 'dayjs'; import { Tag, Checkbox, FormGroup, InputGroup, Radio, RadioGroup } from '@blueprintjs/core'; import { TimePrecision } from '@blueprintjs/datetime'; @@ -51,6 +51,8 @@ export const SyncPolicy = ({ onChangeSkipOnFail, onChangeTimeAfter, }: Props) => { + const [selectedValue, setSelectedValue] = useState('Daily'); + const [timezone, quickTimeOpts, cronOpts] = useMemo(() => { const timezone = dayjs().format('ZZ').replace('00', ''); const quickTimeOpts = [ @@ -71,14 +73,16 @@ export const SyncPolicy = ({ const handleChangeFrequency = (e: React.FormEvent) => { const value = (e.target as HTMLInputElement).value; - if (value === 'manual') { + setSelectedValue(value); + if (value === 'Manual') { onChangeIsManual(true); - } else if (!value) { + } else if (value === 'Custom') { onChangeIsManual(false); onChangeCronConfig('* * * * *'); } else { + const opt = cronOpts.find((it) => it.label === value) as any; onChangeIsManual(false); - onChangeCronConfig(value); + onChangeCronConfig(opt.value); } }; @@ -127,12 +131,12 @@ export const SyncPolicy = ({ label="Sync Frequency" subLabel="Blueprints will run on creation and recurringly based on the schedule." > - - {cronOpts.map(({ value, label, subLabel }) => ( - + + {cronOpts.map(({ label, subLabel }) => ( + ))} - {!cron.value && ( + {selectedValue === 'Custom' && ( <> diff --git a/config-ui/src/pages/blueprint/detail/status-panel.tsx b/config-ui/src/pages/blueprint/detail/status-panel.tsx index c30e1f9a80d..3f0763b95c1 100644 --- a/config-ui/src/pages/blueprint/detail/status-panel.tsx +++ b/config-ui/src/pages/blueprint/detail/status-panel.tsx @@ -125,7 +125,7 @@ export const StatusPanel = ({ from, blueprint, pipelineId, onRefresh }: Props) = {from === FromEnum.project && ( - {cron.value === 'manual' ? 'Manual' : `Next Run: ${formatTime(cron.nextTime, 'YYYY-MM-DD HH:mm')}`} + {cron.label === 'Manual' ? 'Manual' : `Next Run: ${formatTime(cron.nextTime, 'YYYY-MM-DD HH:mm')}`}