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