diff --git a/awx/ui_next/src/api/models/JobTemplates.js b/awx/ui_next/src/api/models/JobTemplates.js index 4f631cec2a..23f2716dda 100644 --- a/awx/ui_next/src/api/models/JobTemplates.js +++ b/awx/ui_next/src/api/models/JobTemplates.js @@ -24,6 +24,10 @@ class JobTemplates extends SchedulesMixin( return this.http.post(`${this.baseUrl}${id}/launch/`, data); } + readTemplateOptions(id) { + return this.http.options(`${this.baseUrl}/${id}/`); + } + readLaunch(id) { return this.http.get(`${this.baseUrl}${id}/launch/`); } diff --git a/awx/ui_next/src/api/models/WorkflowJobTemplates.js b/awx/ui_next/src/api/models/WorkflowJobTemplates.js index 7c582cd57f..e52e050b1d 100644 --- a/awx/ui_next/src/api/models/WorkflowJobTemplates.js +++ b/awx/ui_next/src/api/models/WorkflowJobTemplates.js @@ -12,6 +12,10 @@ class WorkflowJobTemplates extends SchedulesMixin(NotificationsMixin(Base)) { return this.http.get(`${this.baseUrl}${id}/webhook_key/`); } + readWorkflowJobTemplateOptions(id) { + return this.http.options(`${this.baseUrl}/${id}/`); + } + updateWebhookKey(id) { return this.http.post(`${this.baseUrl}${id}/webhook_key/`); } diff --git a/awx/ui_next/src/screens/Template/Template.jsx b/awx/ui_next/src/screens/Template/Template.jsx index 2358fb109b..12629ebe51 100644 --- a/awx/ui_next/src/screens/Template/Template.jsx +++ b/awx/ui_next/src/screens/Template/Template.jsx @@ -36,18 +36,23 @@ function Template({ i18n, me, setBreadcrumb }) { request: loadTemplateAndRoles, } = useRequest( useCallback(async () => { - const [{ data }, notifAdminRes] = await Promise.all([ + const [{ data }, actions, notifAdminRes] = await Promise.all([ JobTemplatesAPI.readDetail(templateId), + JobTemplatesAPI.readTemplateOptions(templateId), OrganizationsAPI.read({ page_size: 1, role_level: 'notification_admin_role', }), ]); - if (data.webhook_service && data?.related?.webhook_key) { - const { - data: { webhook_key }, - } = await JobTemplatesAPI.readWebhookKey(templateId); - data.webhook_key = webhook_key; + + if (actions.data.actions.PUT) { + if (data.webhook_service && data?.related?.webhook_key) { + const { + data: { webhook_key }, + } = await JobTemplatesAPI.readWebhookKey(templateId); + + data.webhook_key = webhook_key; + } } setBreadcrumb(data); diff --git a/awx/ui_next/src/screens/Template/Template.test.jsx b/awx/ui_next/src/screens/Template/Template.test.jsx index 8176e4486a..a38209db75 100644 --- a/awx/ui_next/src/screens/Template/Template.test.jsx +++ b/awx/ui_next/src/screens/Template/Template.test.jsx @@ -18,11 +18,16 @@ const mockMe = { is_system_auditor: false, }; describe('