mirror of
https://github.com/ansible/awx.git
synced 2026-05-12 03:47:36 -02:30
resloves outstanding issues
This commit is contained in:
@@ -107,22 +107,21 @@ function LaunchPrompt({ config, resource = {}, onLaunch, onCancel, i18n }) {
|
|||||||
return (
|
return (
|
||||||
<Formik
|
<Formik
|
||||||
initialValues={{
|
initialValues={{
|
||||||
verbosity: config.ask_verbosity_on_launch && (resource.verbosity || 0),
|
verbosity: resource.verbosity || 0,
|
||||||
inventory:
|
inventory:
|
||||||
config.ask_inventoryon_launch && resource.summary_fields?.inventory,
|
resource.summary_fields?.inventory || null,
|
||||||
credentials:
|
credentials:
|
||||||
config.ask_credential_on_launch &&
|
resource.summary_fields?.credentials || [],
|
||||||
resource.summary_fields?.credentials,
|
|
||||||
diff_mode:
|
diff_mode:
|
||||||
config.ask_diff_mode_on_launch && (resource.diff_mode || false),
|
config.ask_diff_mode_on_launch && (resource.diff_mode || false),
|
||||||
extra_vars:
|
extra_vars:
|
||||||
config.ask_variables_on_launch && (resource.extra_vars || '---'),
|
resource.extra_vars || '---',
|
||||||
job_type: config.ask_job_type_on_launch && (resource.job_type || ''),
|
job_type: resource.job_type || 'run',
|
||||||
job_tags: config.ask_job_tags_on_launch && (resource.job_tags || ''),
|
job_tags: resource.job_tags || '',
|
||||||
skip_tags: config.ask_skip_tags_on_launch && (resource.skip_tags || ''),
|
skip_tags: resource.skip_tags || '',
|
||||||
scm_branch:
|
scm_branch:
|
||||||
config.ask_scm_branch_on_launch && (resource.scm_branch || ''),
|
resource.scm_branch || '',
|
||||||
limit: config.ask_limit_on_launch && (resource.limit || ''),
|
limit: resource.limit || '',
|
||||||
}}
|
}}
|
||||||
onSubmit={values => onLaunch(values)}
|
onSubmit={values => onLaunch(values)}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export default function useInventoryStep(
|
|||||||
nodeToEdit
|
nodeToEdit
|
||||||
) {
|
) {
|
||||||
const [, meta] = useField('inventory');
|
const [, meta] = useField('inventory');
|
||||||
const resource = nodeToEdit || selectedResource;
|
const resource = nodeToEdit?.originalNodeObject || nodeToEdit?.promptValues || selectedResource;
|
||||||
const formError =
|
const formError =
|
||||||
Object.keys(visitedSteps).includes(STEP_ID) && (!meta.value || meta.error);
|
Object.keys(visitedSteps).includes(STEP_ID) && (!meta.value || meta.error);
|
||||||
|
|
||||||
@@ -50,6 +50,6 @@ function getInitialValues(config, resource) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
inventory: resource?.summary_fields?.inventory,
|
inventory: resource?.summary_fields?.inventory || resource?.inventory || null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,12 @@ export default function usePreviewStep(
|
|||||||
resource,
|
resource,
|
||||||
survey,
|
survey,
|
||||||
hasErrors,
|
hasErrors,
|
||||||
needsPreviewStep
|
needsPreviewStep,
|
||||||
|
nodeToEdit
|
||||||
) {
|
) {
|
||||||
const showStep =
|
const showStep =
|
||||||
needsPreviewStep && resource && Object.keys(config).length > 0;
|
needsPreviewStep && resource && Object.keys(config).length > 0;
|
||||||
|
const promptResource = nodeToEdit || resource
|
||||||
return {
|
return {
|
||||||
step: showStep
|
step: showStep
|
||||||
? {
|
? {
|
||||||
@@ -23,7 +25,7 @@ export default function usePreviewStep(
|
|||||||
component: (
|
component: (
|
||||||
<PreviewStep
|
<PreviewStep
|
||||||
config={config}
|
config={config}
|
||||||
resource={resource}
|
resource={promptResource}
|
||||||
survey={survey}
|
survey={survey}
|
||||||
formErrors={hasErrors}
|
formErrors={hasErrors}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -67,10 +67,11 @@ function hasPromptData(launchData) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function omitOverrides(resource, overrides) {
|
function omitOverrides(resource, overrides, defaultConfig) {
|
||||||
const clonedResource = {
|
const clonedResource = {
|
||||||
...resource,
|
...resource,
|
||||||
summary_fields: { ...resource.summary_fields },
|
summary_fields: { ...resource.summary_fields },
|
||||||
|
...defaultConfig
|
||||||
};
|
};
|
||||||
Object.keys(overrides).forEach(keyToOmit => {
|
Object.keys(overrides).forEach(keyToOmit => {
|
||||||
delete clonedResource[keyToOmit];
|
delete clonedResource[keyToOmit];
|
||||||
@@ -88,7 +89,8 @@ function PromptDetail({ i18n, resource, launchConfig = {}, overrides = {} }) {
|
|||||||
4: i18n._(t`4 (Connection Debug)`),
|
4: i18n._(t`4 (Connection Debug)`),
|
||||||
};
|
};
|
||||||
|
|
||||||
const details = omitOverrides(resource, overrides);
|
const details = omitOverrides(resource, overrides, launchConfig.defaults);
|
||||||
|
details.type = overrides?.nodeType || details.type
|
||||||
const hasOverrides = Object.keys(overrides).length > 0;
|
const hasOverrides = Object.keys(overrides).length > 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -137,13 +139,13 @@ function PromptDetail({ i18n, resource, launchConfig = {}, overrides = {} }) {
|
|||||||
<Divider css="margin-top: var(--pf-global--spacer--lg)" />
|
<Divider css="margin-top: var(--pf-global--spacer--lg)" />
|
||||||
<PromptHeader>{i18n._(t`Prompted Values`)}</PromptHeader>
|
<PromptHeader>{i18n._(t`Prompted Values`)}</PromptHeader>
|
||||||
<DetailList aria-label="Prompt Overrides">
|
<DetailList aria-label="Prompt Overrides">
|
||||||
{overrides?.job_type && (
|
{launchConfig.ask_job_type_on_launch && (
|
||||||
<Detail
|
<Detail
|
||||||
label={i18n._(t`Job Type`)}
|
label={i18n._(t`Job Type`)}
|
||||||
value={toTitleCase(overrides.job_type)}
|
value={toTitleCase(overrides.job_type)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{overrides?.credentials?.length > 0 && (
|
{launchConfig.ask_credential_on_launch && (
|
||||||
<Detail
|
<Detail
|
||||||
fullWidth
|
fullWidth
|
||||||
label={i18n._(t`Credentials`)}
|
label={i18n._(t`Credentials`)}
|
||||||
@@ -164,28 +166,28 @@ function PromptDetail({ i18n, resource, launchConfig = {}, overrides = {} }) {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{overrides?.inventory && (
|
{launchConfig.ask_inventory_on_launch && (
|
||||||
<Detail
|
<Detail
|
||||||
label={i18n._(t`Inventory`)}
|
label={i18n._(t`Inventory`)}
|
||||||
value={overrides.inventory?.name}
|
value={overrides.inventory?.name}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{overrides?.scm_branch && (
|
{launchConfig.ask_scm_branch_on_launch && (
|
||||||
<Detail
|
<Detail
|
||||||
label={i18n._(t`Source Control Branch`)}
|
label={i18n._(t`Source Control Branch`)}
|
||||||
value={overrides.scm_branch}
|
value={overrides.scm_branch}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{overrides?.limit && (
|
{launchConfig.ask_limit_on_launch && (
|
||||||
<Detail label={i18n._(t`Limit`)} value={overrides.limit} />
|
<Detail label={i18n._(t`Limit`)} value={overrides.limit} />
|
||||||
)}
|
)}
|
||||||
{overrides?.verbosity && (
|
{overrides?.verbosity && launchConfig.ask_verbosity_on_launch && (
|
||||||
<Detail
|
<Detail
|
||||||
label={i18n._(t`Verbosity`)}
|
label={i18n._(t`Verbosity`)}
|
||||||
value={VERBOSITY[overrides.verbosity]}
|
value={VERBOSITY[overrides.verbosity]}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{overrides?.job_tags && (
|
{launchConfig.ask_tags_on_launch && (
|
||||||
<Detail
|
<Detail
|
||||||
fullWidth
|
fullWidth
|
||||||
label={i18n._(t`Job Tags`)}
|
label={i18n._(t`Job Tags`)}
|
||||||
@@ -203,7 +205,7 @@ function PromptDetail({ i18n, resource, launchConfig = {}, overrides = {} }) {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{overrides?.skip_tags && (
|
{launchConfig.ask_skip_tags_on_launch && (
|
||||||
<Detail
|
<Detail
|
||||||
fullWidth
|
fullWidth
|
||||||
label={i18n._(t`Skip Tags`)}
|
label={i18n._(t`Skip Tags`)}
|
||||||
@@ -221,7 +223,7 @@ function PromptDetail({ i18n, resource, launchConfig = {}, overrides = {} }) {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{overrides?.diff_mode && (
|
{launchConfig.ask_diff_mode_on_launch && (
|
||||||
<Detail
|
<Detail
|
||||||
label={i18n._(t`Show Changes`)}
|
label={i18n._(t`Show Changes`)}
|
||||||
value={
|
value={
|
||||||
@@ -229,7 +231,7 @@ function PromptDetail({ i18n, resource, launchConfig = {}, overrides = {} }) {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{overrides?.extra_vars && (
|
{launchConfig.ask_variables_on_launch && (
|
||||||
<VariablesDetail
|
<VariablesDetail
|
||||||
label={i18n._(t`Variables`)}
|
label={i18n._(t`Variables`)}
|
||||||
rows={4}
|
rows={4}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ function NodeAddModal({ i18n }) {
|
|||||||
values?.credentials
|
values?.credentials
|
||||||
);
|
);
|
||||||
|
|
||||||
values.inventory = values?.inventory?.id;
|
|
||||||
values.addedCredentials = added;
|
values.addedCredentials = added;
|
||||||
values.removedCredentials = removed;
|
values.removedCredentials = removed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ export default function useNodeTypeStep(i18n, nodeToEdit) {
|
|||||||
const [, meta] = useField('nodeType');
|
const [, meta] = useField('nodeType');
|
||||||
const [approvalNameField] = useField('approvalName');
|
const [approvalNameField] = useField('approvalName');
|
||||||
const [nodeTypeField, ,] = useField('nodeType');
|
const [nodeTypeField, ,] = useField('nodeType');
|
||||||
const [nodeResouceField] = useField('nodeResource');
|
const [nodeResourceField] = useField('nodeResource');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
step: getStep(i18n, nodeTypeField, approvalNameField, nodeResouceField),
|
step: getStep(i18n, nodeTypeField, approvalNameField, nodeResourceField),
|
||||||
initialValues: getInitialValues(nodeToEdit),
|
initialValues: getInitialValues(nodeToEdit),
|
||||||
isReady: true,
|
isReady: true,
|
||||||
contentError: null,
|
contentError: null,
|
||||||
@@ -24,10 +24,10 @@ export default function useNodeTypeStep(i18n, nodeToEdit) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function getStep(i18n, nodeTypeField, approvalNameField, nodeResouceField) {
|
function getStep(i18n, nodeTypeField, approvalNameField, nodeResourceField) {
|
||||||
const isEnabled = () => {
|
const isEnabled = () => {
|
||||||
if (
|
if (
|
||||||
(nodeTypeField.value !== 'approval' && nodeResouceField.value === null) ||
|
(nodeTypeField.value !== 'approval' && nodeResourceField.value === null) ||
|
||||||
(nodeTypeField.value === 'approval' &&
|
(nodeTypeField.value === 'approval' &&
|
||||||
approvalNameField.value === undefined)
|
approvalNameField.value === undefined)
|
||||||
) {
|
) {
|
||||||
@@ -61,7 +61,8 @@ function getInitialValues(nodeToEdit) {
|
|||||||
typeOfNode = {
|
typeOfNode = {
|
||||||
nodeType: 'job_template',
|
nodeType: 'job_template',
|
||||||
nodeResource:
|
nodeResource:
|
||||||
nodeToEdit.originalNodeObject.summary_fields.unified_job_template,
|
nodeToEdit.originalNodeObject?.summary_fields?.unified_job_template
|
||||||
|
|| nodeToEdit.unifiedJobTemplate,
|
||||||
};
|
};
|
||||||
if (unifiedType === 'project' || unifiedType === 'project_update') {
|
if (unifiedType === 'project' || unifiedType === 'project_update') {
|
||||||
typeOfNode = { nodeType: 'project_sync' };
|
typeOfNode = { nodeType: 'project_sync' };
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export default function useWorkflowNodeSteps(
|
|||||||
i18n,
|
i18n,
|
||||||
visited,
|
visited,
|
||||||
resource,
|
resource,
|
||||||
nodeToEdit?.originalNodeObject
|
nodeToEdit
|
||||||
),
|
),
|
||||||
useCredentialsStep(config, i18n, resource, nodeToEdit?.originalNodeObject),
|
useCredentialsStep(config, i18n, resource, nodeToEdit?.originalNodeObject),
|
||||||
useOtherPromptsStep(config, i18n, resource, nodeToEdit?.originalNodeObject),
|
useOtherPromptsStep(config, i18n, resource, nodeToEdit?.originalNodeObject),
|
||||||
@@ -48,7 +48,8 @@ export default function useWorkflowNodeSteps(
|
|||||||
resource,
|
resource,
|
||||||
steps[surveyStepIndex]?.survey,
|
steps[surveyStepIndex]?.survey,
|
||||||
hasErrors,
|
hasErrors,
|
||||||
needsPreviewStep
|
needsPreviewStep,
|
||||||
|
nodeToEdit?.originalNodeObject
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -65,7 +66,7 @@ export default function useWorkflowNodeSteps(
|
|||||||
resetForm({
|
resetForm({
|
||||||
values: {
|
values: {
|
||||||
...initialValues,
|
...initialValues,
|
||||||
nodeResource: formikValues.nodeResource,
|
nodeResource: formikValues.nodeResource || initialValues.nodeResource,
|
||||||
nodeType: formikValues.nodeType || initialValues.nodeType,
|
nodeType: formikValues.nodeType || initialValues.nodeType,
|
||||||
linkType: formikValues.linkType || 'success',
|
linkType: formikValues.linkType || 'success',
|
||||||
verbosity: initialValues?.verbosity?.toString(),
|
verbosity: initialValues?.verbosity?.toString(),
|
||||||
|
|||||||
@@ -308,9 +308,10 @@ function Visualizer({ template, i18n }) {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
node.promptValues.inventory = node.promptValues?.inventory?.id
|
||||||
nodeRequests.push(
|
nodeRequests.push(
|
||||||
WorkflowJobTemplatesAPI.createNode(template.id, {
|
WorkflowJobTemplatesAPI.createNode(template.id, {
|
||||||
...node.promptValues,
|
...node.promptValues,
|
||||||
unified_job_template: node.unifiedJobTemplate.id,
|
unified_job_template: node.unifiedJobTemplate.id,
|
||||||
}).then(({ data }) => {
|
}).then(({ data }) => {
|
||||||
node.originalNodeObject = data;
|
node.originalNodeObject = data;
|
||||||
|
|||||||
Reference in New Issue
Block a user