Show scm_branch if project allows branch override

This commit is contained in:
Vidya Nambiar
2023-03-07 14:57:07 -05:00
committed by Seth Foster
parent a5f9506f49
commit a7b4c03188
2 changed files with 11 additions and 15 deletions

View File

@@ -20,9 +20,9 @@ import {
EnabledVarField, EnabledVarField,
EnabledValueField, EnabledValueField,
HostFilterField, HostFilterField,
BranchFormField,
} from './SharedFields'; } from './SharedFields';
import getHelpText from '../Inventory.helptext'; import getHelpText from '../Inventory.helptext';
import FormField from 'components/FormField';
const SCMSubForm = ({ autoPopulateProject }) => { const SCMSubForm = ({ autoPopulateProject }) => {
const helpText = getHelpText(); const helpText = getHelpText();
@@ -57,6 +57,7 @@ const SCMSubForm = ({ autoPopulateProject }) => {
(value) => { (value) => {
setFieldValue('source_project', value); setFieldValue('source_project', value);
setFieldTouched('source_project', true, false); setFieldTouched('source_project', true, false);
setFieldValue('scm_branch', '', false);
if (sourcePathField.value) { if (sourcePathField.value) {
setFieldValue('source_path', ''); setFieldValue('source_path', '');
setFieldTouched('source_path', false); setFieldTouched('source_path', false);
@@ -76,7 +77,15 @@ const SCMSubForm = ({ autoPopulateProject }) => {
); );
return ( return (
<> <>
<BranchFormField label={t`Source Control Branch/Tag/Commit`} /> {projectField.value?.allow_override && (
<FormField
id="project-scm-branch"
name="scm_branch"
type="text"
label={t`Source Control Branch/Tag/Commit`}
tooltip={helpText.sourceControlBranch}
/>
)}
<CredentialLookup <CredentialLookup
credentialTypeKind="cloud" credentialTypeKind="cloud"
label={t`Credential`} label={t`Credential`}

View File

@@ -150,16 +150,3 @@ export const HostFilterField = () => {
/> />
); );
}; };
export const BranchFormField = ({ label }) => {
const helpText = getHelpText();
return (
<FormField
id="project-scm-branch"
name="scm_branch"
type="text"
label={label}
tooltip={helpText.sourceControlBranch}
/>
);
};