enable scm branch ui work

This commit is contained in:
Gabe Muniz 2023-03-03 01:22:12 -05:00 committed by Seth Foster
parent a952ab0a75
commit 8e6f4fae80
5 changed files with 24 additions and 4 deletions

View File

@ -48,6 +48,7 @@ function InventorySourceDetail({ inventorySource }) {
source,
source_path,
source_vars,
scm_branch,
update_cache_timeout,
update_on_launch,
verbosity,
@ -233,6 +234,11 @@ function InventorySourceDetail({ inventorySource }) {
helpText={helpText.subFormVerbosityFields}
value={VERBOSITY()[verbosity]}
/>
<Detail
label={t`Scm Branch`}
helpText={helpText.sourceControlBranch}
value={scm_branch}
/>
<Detail
label={t`Cache timeout`}
value={`${update_cache_timeout} ${t`seconds`}`}

View File

@ -152,6 +152,7 @@ const getInventoryHelpTextStrings = () => ({
},
enabledVariableField: t`Retrieve the enabled state from the given dict of host variables.
The enabled variable may be specified using dot notation, e.g: 'foo.bar'`,
sourceControlBranch: t`Branch to use on inventory sync. Project default used if blank. Only allowed if project allow_override field is set to true.`,
enabledValue: t`This field is ignored unless an Enabled Variable is set. If the enabled variable matches this value, the host will be enabled on import.`,
hostFilter: t`Regular expression where only matching host names will be imported. The filter is applied as a post-processing step after any inventory plugin filters are applied.`,
sourceVars: (docsBaseUrl, source) => {

View File

@ -71,6 +71,7 @@ const InventorySourceFormFields = ({
source_project: null,
source_script: null,
source_vars: '---\n',
scm_branch: null,
update_cache_timeout: 0,
update_on_launch: false,
verbosity: 1,
@ -248,6 +249,7 @@ const InventorySourceForm = ({
source_project: source?.summary_fields?.source_project || null,
source_script: source?.summary_fields?.source_script || null,
source_vars: source?.source_vars || '---\n',
scm_branch: source?.scm_branch || '',
update_cache_timeout: source?.update_cache_timeout || 0,
update_on_launch: source?.update_on_launch || false,
verbosity: source?.verbosity || 1,

View File

@ -20,6 +20,7 @@ import {
EnabledVarField,
EnabledValueField,
HostFilterField,
BranchFormField,
} from './SharedFields';
import getHelpText from '../Inventory.helptext';
@ -36,7 +37,6 @@ const SCMSubForm = ({ autoPopulateProject }) => {
name: 'source_path',
validate: required(t`Select a value for this field`),
});
const { error: sourcePathError, request: fetchSourcePath } = useRequest(
useCallback(async (projectId) => {
const { data } = await ProjectsAPI.readInventories(projectId);
@ -44,7 +44,6 @@ const SCMSubForm = ({ autoPopulateProject }) => {
}, []),
[]
);
useEffect(() => {
if (projectMeta.initialValue) {
fetchSourcePath(projectMeta.initialValue.id);
@ -68,7 +67,6 @@ const SCMSubForm = ({ autoPopulateProject }) => {
},
[fetchSourcePath, setFieldValue, setFieldTouched, sourcePathField.value]
);
const handleCredentialUpdate = useCallback(
(value) => {
setFieldValue('credential', value);
@ -76,9 +74,9 @@ const SCMSubForm = ({ autoPopulateProject }) => {
},
[setFieldValue, setFieldTouched]
);
return (
<>
<BranchFormField label={t`Source Control Branch/Tag/Commit`} />
<CredentialLookup
credentialTypeKind="cloud"
label={t`Credential`}

View File

@ -150,3 +150,16 @@ 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}
/>
);
};