From 0b63af8d4db71555d5587cb67270a901dc6459a9 Mon Sep 17 00:00:00 2001 From: "Keith J. Grant" Date: Tue, 31 May 2022 15:02:14 -0700 Subject: [PATCH] add schedules timezone link warning to UI --- .../Schedule/shared/ScheduleForm.js | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/awx/ui/src/components/Schedule/shared/ScheduleForm.js b/awx/ui/src/components/Schedule/shared/ScheduleForm.js index ccccecc4b2..8bd5dc5b3c 100644 --- a/awx/ui/src/components/Schedule/shared/ScheduleForm.js +++ b/awx/ui/src/components/Schedule/shared/ScheduleForm.js @@ -100,15 +100,24 @@ function ScheduleFormFields({ hasDaysToKeepField, zoneOptions, zoneLinks }) { }); const [{ name: dateFieldName }] = useField('startDate'); const [{ name: timeFieldName }] = useField('startTime'); - const warnLinkedTZ = (event, selected_value) => { - console.log(selected_value) - console.log(event) - if(selected_value in zoneLinks) { - console.log("Warning: "+ selected_value +" is a link to "+ zoneLinks[selected_value] +" and will be saved as that.") + const [timezoneMessage, setTimezoneMessage] = useState(''); + const warnLinkedTZ = (event, selectedValue) => { + if (zoneLinks[selectedValue]) { + setTimezoneMessage( + `Warning: ${selectedValue} is a link to ${zoneLinks[selectedValue]} and will be saved as that.` + ); + } else { + setTimezoneMessage(''); } - timezone.onChange(); + timezone.onChange(event, selectedValue); }; + let timezoneValidatedStatus = 'default'; + if (timezoneMeta.touched && timezoneMeta.error) { + timezoneValidatedStatus = 'error'; + } else if (timezoneMessage) { + timezoneValidatedStatus = 'warning'; + } return ( <> {isWizardOpen && (