New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #31460 - add description field to job wizard #555
Fixes #31460 - add description field to job wizard #555
Conversation
f8c9649
to
00237b7
Compare
00237b7
to
5bc93d6
Compare
2013242
to
3b471b9
Compare
3b471b9
to
dcebace
Compare
@LaViro can you take a look? test failures are broken snapshots after pf4 update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @MariaAga,
looks nice! left a few comments,
on my end, it actually doesn't remove the braces wrapper when switching to preview:
dcebace
to
171235d
Compare
@LaViro Fixed the braces wrapper issue. I didn't include the advanced template and regular templates split in this pr before. |
171235d
to
e6e88c0
Compare
({ | ||
data: { | ||
advanced_template_inputs, | ||
effective_user, | ||
job_template: { executionTimeoutInterval, description_format }, | ||
}, | ||
}) => { | ||
const advancedTemplateValues = {}; | ||
const advancedInputs = advanced_template_inputs; | ||
if (advancedInputs) { | ||
advancedInputs.forEach(input => { | ||
advancedTemplateValues[input.name] = input?.default || ''; | ||
}); | ||
} | ||
setAdvancedValues(currentAdvancedValues => ({ | ||
...currentAdvancedValues, | ||
effectiveUserValue: effective_user?.value || '', | ||
timeoutToKill: executionTimeoutInterval || '', | ||
templateValues: advancedTemplateValues, | ||
description: description_format || '', | ||
})); | ||
}, | ||
[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
({ | |
data: { | |
advanced_template_inputs, | |
effective_user, | |
job_template: { executionTimeoutInterval, description_format }, | |
}, | |
}) => { | |
const advancedTemplateValues = {}; | |
const advancedInputs = advanced_template_inputs; | |
if (advancedInputs) { | |
advancedInputs.forEach(input => { | |
advancedTemplateValues[input.name] = input?.default || ''; | |
}); | |
} | |
setAdvancedValues(currentAdvancedValues => ({ | |
...currentAdvancedValues, | |
effectiveUserValue: effective_user?.value || '', | |
timeoutToKill: executionTimeoutInterval || '', | |
templateValues: advancedTemplateValues, | |
description: description_format || '', | |
})); | |
}, | |
[] | |
({ | |
data: { | |
advanced_template_inputs = [], | |
effective_user, | |
job_template: { executionTimeoutInterval, description_format }, | |
}, | |
}) => { | |
const templateValues = {}; | |
advanced_template_inputs.forEach(input => { | |
templateValues[input.name] = input?.default || ''; | |
}); | |
setAdvancedValues(currentAdvancedValues => ({ | |
...currentAdvancedValues, | |
effectiveUserValue: effective_user?.value || '', | |
timeoutToKill: executionTimeoutInterval || '', | |
templateValues, | |
description: description_format || '', | |
})); | |
}, | |
[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
advancedTemplateValues
and templateValues
are different as there are advanced_template_inputs
and template_inputs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just removed the const declaration from line 30 and used advanced_template_inputs
directly,
and then renamed advancedTemplateValues
on line 29 to templateValues
so in line 40 you can use it directly as templateValues,
instead of:
templateValues: advancedTemplateValues,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
templateValues
is a defined const already that is used in this pr: #556
foreman_remote_execution/webpack/JobWizard/JobWizard.js
Lines 19 to 40 in dc45ae4
const [templateValues, setTemplateValues] = useState({}); // TODO use templateValues in advanced fields - description | |
const [selectedHosts, setSelectedHosts] = useState(['host1', 'host2']); | |
const dispatch = useDispatch(); | |
const setDefaults = useCallback(response => { | |
const responseJob = response.data; | |
const advancedTemplateValues = {}; | |
const defaultTemplateValues = {}; | |
const inputs = responseJob.template_inputs; | |
const advancedInputs = responseJob.advanced_template_inputs; | |
if (advancedInputs) { | |
advancedInputs.forEach(input => { | |
advancedTemplateValues[input.name] = input?.default || ''; | |
}); | |
} | |
if (inputs) { | |
inputs.forEach(input => { | |
defaultTemplateValues[input.name] = input?.default || ''; | |
}); | |
} | |
setTemplateValues(defaultTemplateValues); | |
setAdvancedValues(currentAdvancedValues => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright, then let's revisit it on one of the final PRs, so it won't cause lot of refactoring
<DescriptionField | ||
inputs={templateInputs} | ||
value={advancedValues.description} | ||
setValue={newValue => setAdvancedValues({ description: newValue })} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a cool shortcut I thought about, but just a small nit
setValue={newValue => setAdvancedValues({ description: newValue })} | |
setValue={description => setAdvancedValues({ description })} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good suggestion, but I'm worried that if we decide to have a const named description in the component it would create issues. (for example if we destruct advancedValues)
e6e88c0
to
e002b26
Compare
({ | ||
data: { | ||
advanced_template_inputs, | ||
effective_user, | ||
job_template: { executionTimeoutInterval, description_format }, | ||
}, | ||
}) => { | ||
const advancedTemplateValues = {}; | ||
const advancedInputs = advanced_template_inputs; | ||
if (advancedInputs) { | ||
advancedInputs.forEach(input => { | ||
advancedTemplateValues[input.name] = input?.default || ''; | ||
}); | ||
} | ||
setAdvancedValues(currentAdvancedValues => ({ | ||
...currentAdvancedValues, | ||
effectiveUserValue: effective_user?.value || '', | ||
timeoutToKill: executionTimeoutInterval || '', | ||
templateValues: advancedTemplateValues, | ||
description: description_format || '', | ||
})); | ||
}, | ||
[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just removed the const declaration from line 30 and used advanced_template_inputs
directly,
and then renamed advancedTemplateValues
on line 29 to templateValues
so in line 40 you can use it directly as templateValues,
instead of:
templateValues: advancedTemplateValues,
e002b26
to
1487774
Compare
1487774
to
edf2849
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @MariaAga !
@adamruzicka can you have a final look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
(cherry picked from commit c24078a)
Adds the final field to the advanced step. Depends on #554
As the step to edit the template inputs doesn't exist yet, it doesn't use the value of the input but the name of the input instead.
New:
onclick it moves to this:
old:
Original generate description is here:
foreman_remote_execution/app/assets/javascripts/foreman_remote_execution/template_invocation.js
Lines 102 to 122 in ab166f9