diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/PreviewStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/PreviewStep.jsx
index e8171debe2..f7e8ed1c36 100644
--- a/awx/ui_next/src/components/LaunchPrompt/steps/PreviewStep.jsx
+++ b/awx/ui_next/src/components/LaunchPrompt/steps/PreviewStep.jsx
@@ -8,10 +8,18 @@ import getSurveyValues from '../getSurveyValues';
function PreviewStep({ resource, config, survey, formErrors }) {
const { values } = useFormikContext();
const surveyValues = getSurveyValues(values);
- const passwordFields = survey.spec
- .filter(q => q.type === 'password')
- .map(q => q.variable);
- const masked = maskPasswords(surveyValues, passwordFields);
+ let extraVars;
+ if (survey && survey.spec) {
+ const passwordFields = survey.spec
+ .filter(q => q.type === 'password')
+ .map(q => q.variable);
+ const masked = maskPasswords(surveyValues, passwordFields);
+ extraVars = yaml.safeDump(
+ mergeExtraVars(values.extra_vars || '---', masked)
+ );
+ } else {
+ extraVars = values.extra_vars || '---';
+ }
return (
<>
{formErrors && (
diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/PreviewStep.test.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/PreviewStep.test.jsx
new file mode 100644
index 0000000000..47aba96bb1
--- /dev/null
+++ b/awx/ui_next/src/components/LaunchPrompt/steps/PreviewStep.test.jsx
@@ -0,0 +1,78 @@
+import React from 'react';
+import { act } from 'react-dom/test-utils';
+import { Formik } from 'formik';
+import { mountWithContexts } from '../../../../testUtils/enzymeHelpers';
+import PreviewStep from './PreviewStep';
+
+const resource = {
+ id: 1,
+ type: 'job_template',
+ summary_fields: {
+ inventory: { id: 12 },
+ recent_jobs: [],
+ },
+ related: {},
+};
+
+const survey = {
+ name: '',
+ spec: [
+ {
+ variable: 'foo',
+ type: 'text',
+ },
+ ],
+};
+
+describe('PreviewStep', () => {
+ test('should render PromptDetail', async () => {
+ let wrapper;
+ await act(async () => {
+ wrapper = mountWithContexts(
+
+
+
+ );
+ });
+
+ const detail = wrapper.find('PromptDetail');
+ expect(detail).toHaveLength(1);
+ expect(detail.prop('resource')).toEqual(resource);
+ expect(detail.prop('overrides')).toEqual({
+ extra_vars: 'foo: abc\n',
+ limit: '4',
+ survey_foo: 'abc',
+ });
+ });
+
+ test('should render PromptDetail without survey', async () => {
+ let wrapper;
+ await act(async () => {
+ wrapper = mountWithContexts(
+
+
+
+ );
+ });
+
+ const detail = wrapper.find('PromptDetail');
+ expect(detail).toHaveLength(1);
+ expect(detail.prop('resource')).toEqual(resource);
+ expect(detail.prop('overrides')).toEqual({
+ extra_vars: '---',
+ limit: '4',
+ });
+ });
+});
diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx
index e0d0ea009b..cd1deb76f7 100644
--- a/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx
+++ b/awx/ui_next/src/components/LaunchPrompt/steps/useInventoryStep.jsx
@@ -9,6 +9,9 @@ export default function useInventoryStep(config, resource, visitedSteps, i18n) {
const [stepErrors, setStepErrors] = useState({});
const validate = values => {
+ if (!config.ask_inventory_on_launch) {
+ return {};
+ }
const errors = {};
if (!values.inventory) {
errors.inventory = i18n._(t`An inventory must be selected`);
diff --git a/awx/ui_next/src/components/LaunchPrompt/steps/useSurveyStep.jsx b/awx/ui_next/src/components/LaunchPrompt/steps/useSurveyStep.jsx
index 7cee7f7f6d..5ee623dd14 100644
--- a/awx/ui_next/src/components/LaunchPrompt/steps/useSurveyStep.jsx
+++ b/awx/ui_next/src/components/LaunchPrompt/steps/useSurveyStep.jsx
@@ -56,7 +56,7 @@ export default function useSurveyStep(config, resource, visitedSteps, i18n) {
isReady: !isLoading && !!survey,
error,
setTouched: setFieldsTouched => {
- if (!survey) {
+ if (!survey || !survey.spec) {
return;
}
const fields = {};