@@ -61,6 +79,18 @@ function ScheduleListItem({ i18n, isSelected, onSelect, schedule, rowIndex }) {
{schedule.name}
+ {Boolean(isMissingInventory || isMissingSurvey) && (
+
+ (
+ {message}
+ ))}
+ position="right"
+ >
+
+
+
+ )}
{
@@ -80,7 +110,7 @@ function ScheduleListItem({ i18n, isSelected, onSelect, schedule, rowIndex }) {
)}
|
-
+
{
describe('User has edit permissions', () => {
beforeAll(() => {
wrapper = mountWithContexts(
-
+
);
});
@@ -118,6 +116,9 @@ describe('ScheduleListItem', () => {
.simulate('change');
expect(onSelect).toHaveBeenCalledTimes(1);
});
+ test('Toggle button is enabled', () => {
+ expect(wrapper.find('ScheduleToggle').prop('isDisabled')).toBe(false);
+ });
});
describe('User has read-only permissions', () => {
@@ -186,4 +187,35 @@ describe('ScheduleListItem', () => {
).toBe(true);
});
});
+ describe('schedule has missing prompt data', () => {
+ beforeAll(() => {
+ wrapper = mountWithContexts(
+
+ );
+ });
+
+ afterAll(() => {
+ wrapper.unmount();
+ });
+
+ test('should show missing resource icon', () => {
+ expect(wrapper.find('ExclamationTriangleIcon').length).toBe(1);
+ expect(wrapper.find('ScheduleToggle').prop('isDisabled')).toBe(true);
+ });
+ });
});
diff --git a/awx/ui_next/src/components/Schedule/ScheduleToggle/ScheduleToggle.jsx b/awx/ui_next/src/components/Schedule/ScheduleToggle/ScheduleToggle.jsx
index cb15696415..cc9d333fa3 100644
--- a/awx/ui_next/src/components/Schedule/ScheduleToggle/ScheduleToggle.jsx
+++ b/awx/ui_next/src/components/Schedule/ScheduleToggle/ScheduleToggle.jsx
@@ -8,7 +8,7 @@ import ErrorDetail from '../../ErrorDetail';
import useRequest from '../../../util/useRequest';
import { SchedulesAPI } from '../../../api';
-function ScheduleToggle({ schedule, onToggle, className, i18n }) {
+function ScheduleToggle({ schedule, onToggle, className, i18n, isDisabled }) {
const [isEnabled, setIsEnabled] = useState(schedule.enabled);
const [showError, setShowError] = useState(false);
@@ -55,7 +55,9 @@ function ScheduleToggle({ schedule, onToggle, className, i18n }) {
labelOff={i18n._(t`Off`)}
isChecked={isEnabled}
isDisabled={
- isLoading || !schedule.summary_fields.user_capabilities.edit
+ isLoading ||
+ !schedule.summary_fields.user_capabilities.edit ||
+ isDisabled
}
onChange={toggleSchedule}
aria-label={i18n._(t`Toggle schedule`)}
diff --git a/awx/ui_next/src/components/Schedule/Schedules.jsx b/awx/ui_next/src/components/Schedule/Schedules.jsx
index f0daa8989b..22f429dd29 100644
--- a/awx/ui_next/src/components/Schedule/Schedules.jsx
+++ b/awx/ui_next/src/components/Schedule/Schedules.jsx
@@ -10,6 +10,8 @@ function Schedules({
loadScheduleOptions,
loadSchedules,
setBreadcrumb,
+ launchConfig,
+ surveyConfig,
resource,
}) {
const match = useRouteMatch();
@@ -17,14 +19,27 @@ function Schedules({
return (
-
+
-
+
diff --git a/awx/ui_next/src/components/Schedule/data.schedules.json b/awx/ui_next/src/components/Schedule/data.schedules.json
index 13ef941811..75b1e15ebf 100644
--- a/awx/ui_next/src/components/Schedule/data.schedules.json
+++ b/awx/ui_next/src/components/Schedule/data.schedules.json
@@ -8,6 +8,7 @@
"rrule":
"DTSTART;TZID=America/New_York:20200220T000000 RRULE:FREQ=DAILY;INTERVAL=1;COUNT=1",
"id": 1,
+ "extra_data":{},
"summary_fields": {
"unified_job_template": {
"id": 6,
@@ -27,6 +28,7 @@
"rrule":
"DTSTART;TZID=America/New_York:20200220T000000 RRULE:FREQ=DAILY;INTERVAL=1;COUNT=1",
"id": 2,
+ "extra_data":{},
"summary_fields": {
"unified_job_template": {
"id": 7,
@@ -46,6 +48,7 @@
"rrule":
"DTSTART;TZID=America/New_York:20200220T000000 RRULE:FREQ=DAILY;INTERVAL=1;COUNT=1",
"id": 3,
+ "extra_data":{},
"summary_fields": {
"unified_job_template": {
"id": 8,
@@ -65,6 +68,7 @@
"rrule":
"DTSTART;TZID=America/New_York:20200220T000000 RRULE:FREQ=DAILY;INTERVAL=1;COUNT=1",
"id": 4,
+ "extra_data":{},
"summary_fields": {
"unified_job_template": {
"id": 9,
@@ -84,6 +88,7 @@
"rrule":
"DTSTART;TZID=America/New_York:20200220T000000 RRULE:FREQ=DAILY;INTERVAL=1;COUNT=1",
"id": 5,
+ "extra_data":{"novalue":null},
"summary_fields": {
"unified_job_template": {
"id": 10,
@@ -103,4 +108,4 @@
"next_run": "2020-02-20T05:00:00Z"
}
]
-}
\ No newline at end of file
+}
diff --git a/awx/ui_next/src/components/Schedule/shared/ScheduleForm.jsx b/awx/ui_next/src/components/Schedule/shared/ScheduleForm.jsx
index 35504df3b6..3088996a3d 100644
--- a/awx/ui_next/src/components/Schedule/shared/ScheduleForm.jsx
+++ b/awx/ui_next/src/components/Schedule/shared/ScheduleForm.jsx
@@ -12,11 +12,7 @@ import {
ActionGroup,
} from '@patternfly/react-core';
import { Config } from '../../../contexts/Config';
-import {
- SchedulesAPI,
- JobTemplatesAPI,
- WorkflowJobTemplatesAPI,
-} from '../../../api';
+import { SchedulesAPI } from '../../../api';
import AnsibleSelect from '../../AnsibleSelect';
import ContentError from '../../ContentError';
import ContentLoading from '../../ContentLoading';
@@ -194,6 +190,8 @@ function ScheduleForm({
schedule,
submitError,
resource,
+ launchConfig,
+ surveyConfig,
...rest
}) {
const [isWizardOpen, setIsWizardOpen] = useState(false);
@@ -210,37 +208,15 @@ function ScheduleForm({
const isTemplate =
resource.type === 'workflow_job_template' ||
resource.type === 'job_template';
- const isWorkflowJobTemplate =
- isTemplate && resource.type === 'workflow_job_template';
-
const {
request: loadScheduleData,
error: contentError,
contentLoading,
- result: { zoneOptions, surveyConfig, launchConfig, credentials },
+ result: { zoneOptions, credentials },
} = useRequest(
useCallback(async () => {
- const readLaunch =
- isTemplate &&
- (isWorkflowJobTemplate
- ? WorkflowJobTemplatesAPI.readLaunch(resource.id)
- : JobTemplatesAPI.readLaunch(resource.id));
- const [{ data }, { data: launchConfiguration }] = await Promise.all([
- SchedulesAPI.readZoneInfo(),
- readLaunch,
- ]);
+ const { data } = await SchedulesAPI.readZoneInfo();
- const readSurvey = isWorkflowJobTemplate
- ? WorkflowJobTemplatesAPI.readSurvey(resource.id)
- : JobTemplatesAPI.readSurvey(resource.id);
-
- let surveyConfiguration = null;
-
- if (isTemplate && launchConfiguration.survey_enabled) {
- const { data: survey } = await readSurvey;
-
- surveyConfiguration = survey;
- }
let creds;
if (schedule.id) {
const {
@@ -249,37 +225,6 @@ function ScheduleForm({
creds = results;
}
- const missingRequiredInventory = Boolean(
- !resource.inventory && !schedule?.summary_fields?.inventory.id
- );
- let missingRequiredSurvey = false;
-
- if (
- schedule.id &&
- isTemplate &&
- !launchConfiguration?.can_start_without_user_input
- ) {
- missingRequiredSurvey = surveyConfiguration?.spec?.every(question => {
- let hasValue;
- if (Object.keys(schedule)?.length === 0) {
- hasValue = true;
- }
- Object.entries(schedule?.extra_data).forEach(([key, value]) => {
- if (
- question.required &&
- question.variable === key &&
- value.length > 0
- ) {
- hasValue = false;
- }
- });
- return hasValue;
- });
- }
- if (missingRequiredInventory || missingRequiredSurvey) {
- setIsSaveDisabled(true);
- }
-
const zones = data.map(zone => {
return {
value: zone.name,
@@ -290,18 +235,61 @@ function ScheduleForm({
return {
zoneOptions: zones,
- surveyConfig: surveyConfiguration || {},
- launchConfig: launchConfiguration,
credentials: creds || [],
};
- }, [isTemplate, isWorkflowJobTemplate, resource, schedule]),
+ }, [schedule]),
{
zonesOptions: [],
- surveyConfig: {},
- launchConfig: {},
credentials: [],
}
);
+ const missingRequiredInventory = useCallback(() => {
+ let missingInventory = false;
+ if (
+ launchConfig.inventory_needed_to_start &&
+ !schedule?.summary_fields?.inventory?.id
+ ) {
+ missingInventory = true;
+ }
+ return missingInventory;
+ }, [launchConfig, schedule]);
+
+ const hasMissingSurveyValue = useCallback(() => {
+ let missingValues = false;
+ if (launchConfig?.survey_enabled) {
+ surveyConfig.spec.forEach(question => {
+ const hasDefaultValue = Boolean(question.default);
+ const hasSchedule = Object.keys(schedule).length;
+ const isRequired = question.required;
+ if (isRequired && !hasDefaultValue) {
+ if (!hasSchedule) {
+ missingValues = true;
+ } else {
+ const hasMatchingKey = Object.keys(schedule?.extra_data).includes(
+ question.variable
+ );
+ Object.values(schedule?.extra_data).forEach(value => {
+ if (!value || !hasMatchingKey) {
+ missingValues = true;
+ } else {
+ missingValues = false;
+ }
+ });
+ if (!Object.values(schedule.extra_data).length) {
+ missingValues = true;
+ }
+ }
+ }
+ });
+ }
+ return missingValues;
+ }, [launchConfig, schedule, surveyConfig]);
+
+ useEffect(() => {
+ if (isTemplate && (missingRequiredInventory() || hasMissingSurveyValue())) {
+ setIsSaveDisabled(true);
+ }
+ }, [isTemplate, hasMissingSurveyValue, missingRequiredInventory]);
useEffect(() => {
loadScheduleData();
@@ -532,6 +520,7 @@ function ScheduleForm({
>
{i18n._(t`Save`)}
+
{isTemplate && showPromptButton && (
', () => {
);
@@ -158,7 +163,6 @@ describe('', () => {
const handleCancel = jest.fn();
JobTemplatesAPI.readLaunch.mockResolvedValue(launchData);
- JobTemplatesAPI.readSurvey.mockResolvedValue(survey);
SchedulesAPI.readCredentials.mockResolvedValue(credentials);
SchedulesAPI.readZoneInfo.mockResolvedValue({
data: [
@@ -172,7 +176,30 @@ describe('', () => {
);
});
@@ -186,31 +213,6 @@ describe('', () => {
describe('Prompted Schedule', () => {
let promptWrapper;
beforeEach(async () => {
- JobTemplatesAPI.readLaunch.mockResolvedValue({
- data: {
- can_start_without_user_input: false,
- passwords_needed_to_start: [],
- ask_scm_branch_on_launch: false,
- ask_variables_on_launch: false,
- ask_tags_on_launch: false,
- ask_diff_mode_on_launch: false,
- ask_skip_tags_on_launch: false,
- ask_job_type_on_launch: false,
- ask_limit_on_launch: false,
- ask_verbosity_on_launch: false,
- ask_inventory_on_launch: true,
- ask_credential_on_launch: false,
- survey_enabled: false,
- variables_needed_to_start: [],
- credential_needed_to_start: false,
- inventory_needed_to_start: true,
- job_template_data: {
- name: 'Demo Job Template',
- id: 7,
- description: '',
- },
- },
- });
SchedulesAPI.readZoneInfo.mockResolvedValue({
data: [
{
@@ -231,6 +233,30 @@ describe('', () => {
credentials: [],
},
}}
+ launchConfig={{
+ can_start_without_user_input: false,
+ passwords_needed_to_start: [],
+ ask_scm_branch_on_launch: false,
+ ask_variables_on_launch: false,
+ ask_tags_on_launch: false,
+ ask_diff_mode_on_launch: false,
+ ask_skip_tags_on_launch: false,
+ ask_job_type_on_launch: false,
+ ask_limit_on_launch: false,
+ ask_verbosity_on_launch: false,
+ ask_inventory_on_launch: true,
+ ask_credential_on_launch: false,
+ survey_enabled: false,
+ variables_needed_to_start: [],
+ credential_needed_to_start: false,
+ inventory_needed_to_start: true,
+ job_template_data: {
+ name: 'Demo Job Template',
+ id: 7,
+ description: '',
+ },
+ }}
+ surveyConfig={{ spec: [{ required: true, default: '' }] }}
/>
);
});
@@ -257,6 +283,12 @@ describe('', () => {
expect(promptWrapper.find('WizardNavItem').length).toBe(2);
});
+ test('should render disabled save button due to missing required surevy values', () => {
+ expect(
+ promptWrapper.find('Button[aria-label="Save"]').prop('isDisabled')
+ ).toBe(true);
+ });
+
test('should update prompt modal data', async () => {
InventoriesAPI.read.mockResolvedValue({
data: {
@@ -337,6 +369,29 @@ describe('', () => {
id: 23,
type: 'job_template',
}}
+ launchConfig={{
+ can_start_without_user_input: false,
+ passwords_needed_to_start: [],
+ ask_scm_branch_on_launch: false,
+ ask_variables_on_launch: false,
+ ask_tags_on_launch: false,
+ ask_diff_mode_on_launch: false,
+ ask_skip_tags_on_launch: false,
+ ask_job_type_on_launch: false,
+ ask_limit_on_launch: false,
+ ask_verbosity_on_launch: false,
+ ask_inventory_on_launch: true,
+ ask_credential_on_launch: false,
+ survey_enabled: false,
+ variables_needed_to_start: [],
+ credential_needed_to_start: false,
+ inventory_needed_to_start: true,
+ job_template_data: {
+ name: 'Demo Job Template',
+ id: 7,
+ description: '',
+ },
+ }}
/>
);
});
@@ -359,31 +414,6 @@ describe('', () => {
},
],
});
- JobTemplatesAPI.readLaunch.mockResolvedValue({
- data: {
- can_start_without_user_input: true,
- passwords_needed_to_start: [],
- ask_scm_branch_on_launch: false,
- ask_variables_on_launch: false,
- ask_tags_on_launch: false,
- ask_diff_mode_on_launch: false,
- ask_skip_tags_on_launch: false,
- ask_job_type_on_launch: false,
- ask_limit_on_launch: false,
- ask_verbosity_on_launch: false,
- ask_inventory_on_launch: false,
- ask_credential_on_launch: false,
- survey_enabled: false,
- variables_needed_to_start: [],
- credential_needed_to_start: false,
- inventory_needed_to_start: false,
- job_template_data: {
- name: 'Demo Job Template',
- id: 7,
- description: '',
- },
- },
- });
await act(async () => {
wrapper = mountWithContexts(
@@ -391,6 +421,29 @@ describe('', () => {
handleSubmit={jest.fn()}
handleCancel={jest.fn()}
resource={{ id: 23, type: 'job_template', inventory: 1 }}
+ launchConfig={{
+ can_start_without_user_input: true,
+ passwords_needed_to_start: [],
+ ask_scm_branch_on_launch: false,
+ ask_variables_on_launch: false,
+ ask_tags_on_launch: false,
+ ask_diff_mode_on_launch: false,
+ ask_skip_tags_on_launch: false,
+ ask_job_type_on_launch: false,
+ ask_limit_on_launch: false,
+ ask_verbosity_on_launch: false,
+ ask_inventory_on_launch: false,
+ ask_credential_on_launch: false,
+ survey_enabled: false,
+ variables_needed_to_start: [],
+ credential_needed_to_start: false,
+ inventory_needed_to_start: false,
+ job_template_data: {
+ name: 'Demo Job Template',
+ id: 7,
+ description: '',
+ },
+ }}
/>
);
});
@@ -687,32 +740,7 @@ describe('', () => {
},
],
});
- JobTemplatesAPI.readLaunch.mockResolvedValue({
- data: {
- can_start_without_user_input: true,
- passwords_needed_to_start: [],
- ask_scm_branch_on_launch: false,
- ask_variables_on_launch: false,
- ask_tags_on_launch: false,
- ask_diff_mode_on_launch: false,
- ask_skip_tags_on_launch: false,
- ask_job_type_on_launch: false,
- ask_limit_on_launch: false,
- ask_verbosity_on_launch: false,
- ask_inventory_on_launch: false,
- ask_credential_on_launch: false,
- survey_enabled: false,
- variables_needed_to_start: [],
- credential_needed_to_start: false,
- inventory_needed_to_start: false,
- job_template_data: {
- name: 'Demo Job Template',
- id: 7,
- description: '',
- },
- },
- });
- JobTemplatesAPI.readSurvey.mockResolvedValue({});
+
SchedulesAPI.readCredentials.mockResolvedValue(credentials);
});
afterEach(() => {
@@ -728,21 +756,65 @@ describe('', () => {
handleCancel={jest.fn()}
schedule={{ inventory: null, ...mockSchedule }}
resource={{ id: 23, type: 'job_template' }}
+ launchConfig={{
+ can_start_without_user_input: true,
+ passwords_needed_to_start: [],
+ ask_scm_branch_on_launch: false,
+ ask_variables_on_launch: false,
+ ask_tags_on_launch: false,
+ ask_diff_mode_on_launch: false,
+ ask_skip_tags_on_launch: false,
+ ask_job_type_on_launch: false,
+ ask_limit_on_launch: false,
+ ask_verbosity_on_launch: false,
+ ask_inventory_on_launch: false,
+ ask_credential_on_launch: false,
+ survey_enabled: false,
+ variables_needed_to_start: [],
+ credential_needed_to_start: false,
+ inventory_needed_to_start: false,
+ job_template_data: {
+ name: 'Demo Job Template',
+ id: 7,
+ description: '',
+ },
+ }}
/>
);
});
- expect(JobTemplatesAPI.readLaunch).toBeCalledWith(23);
- expect(JobTemplatesAPI.readSurvey).toBeCalledWith(23);
expect(SchedulesAPI.readCredentials).toBeCalledWith(27);
});
- test('should not call API to get credentials ', async () => {
+ test('should not call API to get credentials ', async () => {
await act(async () => {
wrapper = mountWithContexts(
);
});
@@ -782,6 +854,7 @@ describe('', () => {
handleSubmit={jest.fn()}
handleCancel={jest.fn()}
schedule={mockSchedule}
+ launchConfig={{ inventory_needed_to_start: false }}
resource={{ id: 23, type: 'job_template' }}
/>
);
@@ -806,6 +879,7 @@ describe('', () => {
', () => {
', () => {
', () => {
', () => {
', () => {
0 && schedule) || resource;
sourceOfValues.summary_fields = {
- credentials: [...resourceCredentials, ...scheduleCredentials],
+ credentials: [...(resourceCredentials || []), ...scheduleCredentials],
...sourceOfValues.summary_fields,
};
const { resetForm, values } = useFormikContext();
diff --git a/awx/ui_next/src/screens/Job/JobDetail/JobDetail.jsx b/awx/ui_next/src/screens/Job/JobDetail/JobDetail.jsx
index 04063ed310..b50b25ea23 100644
--- a/awx/ui_next/src/screens/Job/JobDetail/JobDetail.jsx
+++ b/awx/ui_next/src/screens/Job/JobDetail/JobDetail.jsx
@@ -326,11 +326,6 @@ function JobDetail({ job, i18n }) {
user={created_by}
/>
-
{job.extra_vars && (
', () => {
name: 'Test Source Workflow',
},
},
- job_explanation: 'It failed, bummer!',
}}
/>
);
@@ -70,7 +69,6 @@ describe('', () => {
assertDetail('Job Slice', '0/1');
assertDetail('Credentials', 'SSH: Demo Credential');
assertDetail('Machine Credential', 'SSH: Machine cred');
- assertDetail('Explanation', 'It failed, bummer!');
const credentialChip = wrapper.find(
`Detail[label="Credentials"] CredentialChip`
diff --git a/awx/ui_next/src/screens/Template/Template.jsx b/awx/ui_next/src/screens/Template/Template.jsx
index 5b8233b1af..4bc2216c22 100644
--- a/awx/ui_next/src/screens/Template/Template.jsx
+++ b/awx/ui_next/src/screens/Template/Template.jsx
@@ -32,20 +32,33 @@ function Template({ i18n, setBreadcrumb }) {
const { me = {} } = useConfig();
const {
- result: { isNotifAdmin, template },
+ result: { isNotifAdmin, template, surveyConfig, launchConfig },
isLoading,
error: contentError,
request: loadTemplateAndRoles,
} = useRequest(
useCallback(async () => {
- const [{ data }, actions, notifAdminRes] = await Promise.all([
+ const [
+ { data },
+ actions,
+ notifAdminRes,
+ { data: launchConfiguration },
+ ] = await Promise.all([
JobTemplatesAPI.readDetail(templateId),
JobTemplatesAPI.readTemplateOptions(templateId),
OrganizationsAPI.read({
page_size: 1,
role_level: 'notification_admin_role',
}),
+ JobTemplatesAPI.readLaunch(templateId),
]);
+ let surveyConfiguration = null;
+
+ if (data.survey_enabled) {
+ const { data: survey } = await JobTemplatesAPI.readSurvey(templateId);
+
+ surveyConfiguration = survey;
+ }
if (data.summary_fields.credentials) {
const params = {
page: 1,
@@ -71,6 +84,8 @@ function Template({ i18n, setBreadcrumb }) {
return {
template: data,
isNotifAdmin: notifAdminRes.data.results.length > 0,
+ surveyConfig: surveyConfiguration,
+ launchConfig: launchConfiguration,
};
}, [templateId]),
{ isNotifAdmin: false, template: null }
@@ -204,6 +219,8 @@ function Template({ i18n, setBreadcrumb }) {
resource={template}
loadSchedules={loadSchedules}
loadScheduleOptions={loadScheduleOptions}
+ surveyConfig={surveyConfig}
+ launchConfig={launchConfig}
/>
{canSeeNotificationsTab && (
diff --git a/awx/ui_next/src/screens/Template/Template.test.jsx b/awx/ui_next/src/screens/Template/Template.test.jsx
index afb7221f06..d0e370a697 100644
--- a/awx/ui_next/src/screens/Template/Template.test.jsx
+++ b/awx/ui_next/src/screens/Template/Template.test.jsx
@@ -21,7 +21,7 @@ describe('', () => {
let wrapper;
beforeEach(() => {
JobTemplatesAPI.readDetail.mockResolvedValue({
- data: mockJobTemplateData,
+ data: { ...mockJobTemplateData, survey_enabled: false },
});
JobTemplatesAPI.readTemplateOptions.mockResolvedValue({
data: {
@@ -56,6 +56,7 @@ describe('', () => {
],
},
});
+ JobTemplatesAPI.readLaunch.mockResolvedValue({ data: {} });
JobTemplatesAPI.readWebhookKey.mockResolvedValue({
data: {
webhook_key: 'key',
diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplate.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplate.jsx
index 8d50bd937c..6bfa39c6c8 100644
--- a/awx/ui_next/src/screens/Template/WorkflowJobTemplate.jsx
+++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplate.jsx
@@ -36,21 +36,37 @@ function WorkflowJobTemplate({ i18n, setBreadcrumb }) {
const { me = {} } = useConfig();
const {
- result: { isNotifAdmin, template },
+ result: { isNotifAdmin, template, surveyConfig, launchConfig },
isLoading: hasRolesandTemplateLoading,
error: rolesAndTemplateError,
request: loadTemplateAndRoles,
} = useRequest(
useCallback(async () => {
- const [{ data }, actions, notifAdminRes] = await Promise.all([
+ const [
+ { data },
+ actions,
+ notifAdminRes,
+ { data: launchConfiguration },
+ ] = await Promise.all([
WorkflowJobTemplatesAPI.readDetail(templateId),
WorkflowJobTemplatesAPI.readWorkflowJobTemplateOptions(templateId),
OrganizationsAPI.read({
page_size: 1,
role_level: 'notification_admin_role',
}),
+ WorkflowJobTemplatesAPI.readLaunch(templateId),
]);
+ let surveyConfiguration = null;
+
+ if (data.survey_enabled) {
+ const { data: survey } = await WorkflowJobTemplatesAPI.readSurvey(
+ templateId
+ );
+
+ surveyConfiguration = survey;
+ }
+
if (actions.data.actions.PUT) {
if (data.webhook_service && data?.related?.webhook_key) {
const {
@@ -65,6 +81,8 @@ function WorkflowJobTemplate({ i18n, setBreadcrumb }) {
return {
template: data,
isNotifAdmin: notifAdminRes.data.results.length > 0,
+ launchConfig: launchConfiguration,
+ surveyConfig: surveyConfiguration,
};
}, [setBreadcrumb, templateId]),
{ isNotifAdmin: false, template: null }
@@ -207,6 +225,8 @@ function WorkflowJobTemplate({ i18n, setBreadcrumb }) {
resource={template}
loadSchedules={loadSchedules}
loadScheduleOptions={loadScheduleOptions}
+ surveyConfig={surveyConfig}
+ launchConfig={launchConfig}
/>
)}
diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplate.test.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplate.test.jsx
index 5694764058..17febc6af1 100644
--- a/awx/ui_next/src/screens/Template/WorkflowJobTemplate.test.jsx
+++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplate.test.jsx
@@ -26,7 +26,7 @@ describe('', () => {
let wrapper;
beforeEach(() => {
WorkflowJobTemplatesAPI.readDetail.mockResolvedValue({
- data: mockWorkflowJobTemplateData,
+ data: { ...mockWorkflowJobTemplateData, survey_enabled: false },
});
WorkflowJobTemplatesAPI.readWorkflowJobTemplateOptions.mockResolvedValue({
data: {
@@ -45,6 +45,7 @@ describe('', () => {
],
},
});
+ WorkflowJobTemplatesAPI.readLaunch.mockResolvedValue({ data: {} });
WorkflowJobTemplatesAPI.readWebhookKey.mockResolvedValue({
data: {
webhook_key: 'key',