From b05ebe96233bb87f1b4f1bd2cb60cf956b729d11 Mon Sep 17 00:00:00 2001 From: John Westcott IV Date: Tue, 31 May 2022 17:09:41 -0400 Subject: [PATCH] Starting UI change to warn if linked TZ is selected --- .../Schedule/shared/ScheduleForm.js | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/awx/ui/src/components/Schedule/shared/ScheduleForm.js b/awx/ui/src/components/Schedule/shared/ScheduleForm.js index 48da8e7664..ccccecc4b2 100644 --- a/awx/ui/src/components/Schedule/shared/ScheduleForm.js +++ b/awx/ui/src/components/Schedule/shared/ScheduleForm.js @@ -89,7 +89,7 @@ const generateRunOnTheDay = (days = []) => { return null; }; -function ScheduleFormFields({ hasDaysToKeepField, zoneOptions }) { +function ScheduleFormFields({ hasDaysToKeepField, zoneOptions, zoneLinks }) { const [timezone, timezoneMeta] = useField({ name: 'timezone', validate: required(t`Select a value for this field`), @@ -100,6 +100,15 @@ function ScheduleFormFields({ hasDaysToKeepField, zoneOptions }) { }); 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.") + } + timezone.onChange(); + }; + return ( <> { const { data } = await SchedulesAPI.readZoneInfo(); @@ -225,19 +235,21 @@ function ScheduleForm({ creds = results; } - const zones = data.map((zone) => ({ - value: zone.name, - key: zone.name, - label: zone.name, + const zones = data.zones.map((zone) => ({ + value: zone, + key: zone, + label: zone, })); return { zoneOptions: zones, + zoneLinks: data.zones.links, credentials: creds || [], }; }, [schedule]), { zonesOptions: [], + zoneLinks: {}, credentials: [], isLoading: true, }