mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 18:09:57 -03:30
Resets playbook and scm-branch fields when project is changed
The playbook field becomes undefined and the scm-branch field becomes ''. This ensures that the user has to assign a playbook to the template that is associated with the project and suggests to the user to review their scm-branch. TODO: when the user updates project with scm-branch override allow the user to type in playbook in dropdown. Then, check if playbook is present in list of playbooks. If no, add it to the list of playbooks.
This commit is contained in:
parent
2daefcd94e
commit
fd1e574fcb
@ -100,8 +100,8 @@ class JobTemplateForm extends Component {
|
||||
const { project } = this.state;
|
||||
if (project && project.id) {
|
||||
try {
|
||||
const { data } = await ProjectsAPI.readDetail(project.id);
|
||||
this.setState({ project: data });
|
||||
const { data: projectData } = await ProjectsAPI.readDetail(project.id);
|
||||
this.setState({ project: projectData });
|
||||
} catch (err) {
|
||||
this.setState({ contentError: err });
|
||||
}
|
||||
@ -139,9 +139,8 @@ class JobTemplateForm extends Component {
|
||||
handleProjectUpdate(project) {
|
||||
const { setFieldValue } = this.props;
|
||||
setFieldValue('project', project.id);
|
||||
if (!project.allow_override) {
|
||||
setFieldValue('scm_branch', null);
|
||||
}
|
||||
setFieldValue('playbook', undefined);
|
||||
setFieldValue('scm_branch', '');
|
||||
this.setState({ project });
|
||||
}
|
||||
|
||||
@ -165,6 +164,7 @@ class JobTemplateForm extends Component {
|
||||
i18n,
|
||||
template,
|
||||
} = this.props;
|
||||
|
||||
const jobTypeOptions = [
|
||||
{
|
||||
value: '',
|
||||
|
||||
@ -15,6 +15,7 @@ function PlaybookSelect({
|
||||
i18n,
|
||||
}) {
|
||||
const [options, setOptions] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!projectId) {
|
||||
return;
|
||||
@ -28,6 +29,7 @@ function PlaybookSelect({
|
||||
label: playbook,
|
||||
isDisabled: false,
|
||||
}));
|
||||
|
||||
opts.unshift({
|
||||
value: '',
|
||||
key: '',
|
||||
@ -40,7 +42,6 @@ function PlaybookSelect({
|
||||
}
|
||||
})();
|
||||
}, [projectId, i18n, onError]);
|
||||
|
||||
return (
|
||||
<AnsibleSelect
|
||||
id="template-playbook"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user