Skip to content

Commit

Permalink
Merge pull request ansible#83 from gamuniz/ui-work-redo
Browse files Browse the repository at this point in the history
enable scm branch ui work
  • Loading branch information
fosterseth committed Mar 6, 2023
2 parents 0ed9bf7 + 249c38a commit e6bce56
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
Expand Up @@ -48,6 +48,7 @@ function InventorySourceDetail({ inventorySource }) {
source,
source_path,
source_vars,
scm_branch,
update_cache_timeout,
update_on_launch,
verbosity,
Expand Down Expand Up @@ -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`}`}
Expand Down
1 change: 1 addition & 0 deletions awx/ui/src/screens/Inventory/shared/Inventory.helptext.js
Expand Up @@ -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) => {
Expand Down
2 changes: 2 additions & 0 deletions awx/ui/src/screens/Inventory/shared/InventorySourceForm.js
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Expand Up @@ -20,6 +20,7 @@ import {
EnabledVarField,
EnabledValueField,
HostFilterField,
BranchFormField,
} from './SharedFields';
import getHelpText from '../Inventory.helptext';

Expand All @@ -36,15 +37,13 @@ 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);
setSourcePath([...data, '/ (project root)']);
}, []),
[]
);

useEffect(() => {
if (projectMeta.initialValue) {
fetchSourcePath(projectMeta.initialValue.id);
Expand All @@ -68,17 +67,16 @@ const SCMSubForm = ({ autoPopulateProject }) => {
},
[fetchSourcePath, setFieldValue, setFieldTouched, sourcePathField.value]
);

const handleCredentialUpdate = useCallback(
(value) => {
setFieldValue('credential', value);
setFieldTouched('credential', true, false);
},
[setFieldValue, setFieldTouched]
);

return (
<>
<BranchFormField label={t`Source Control Branch/Tag/Commit`} />
<CredentialLookup
credentialTypeKind="cloud"
label={t`Credential`}
Expand Down
Expand Up @@ -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}
/>
);
};

0 comments on commit e6bce56

Please sign in to comment.