mirror of
https://github.com/ansible/awx.git
synced 2026-02-04 02:58:13 -03:30
Delete inventory source fields
This commit is contained in:
committed by
Ryan Petrello
parent
dce946e93f
commit
42e70bc852
@@ -3,10 +3,9 @@ import { Link, useHistory } from 'react-router-dom';
|
|||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
|
|
||||||
import { Button, Chip, List, ListItem } from '@patternfly/react-core';
|
import { Button, List, ListItem } from '@patternfly/react-core';
|
||||||
import AlertModal from '../../../components/AlertModal';
|
import AlertModal from '../../../components/AlertModal';
|
||||||
import { CardBody, CardActionsRow } from '../../../components/Card';
|
import { CardBody, CardActionsRow } from '../../../components/Card';
|
||||||
import ChipGroup from '../../../components/ChipGroup';
|
|
||||||
import { VariablesDetail } from '../../../components/CodeMirrorInput';
|
import { VariablesDetail } from '../../../components/CodeMirrorInput';
|
||||||
import ContentError from '../../../components/ContentError';
|
import ContentError from '../../../components/ContentError';
|
||||||
import ContentLoading from '../../../components/ContentLoading';
|
import ContentLoading from '../../../components/ContentLoading';
|
||||||
@@ -28,16 +27,13 @@ function InventorySourceDetail({ inventorySource, i18n }) {
|
|||||||
created,
|
created,
|
||||||
custom_virtualenv,
|
custom_virtualenv,
|
||||||
description,
|
description,
|
||||||
group_by,
|
|
||||||
id,
|
id,
|
||||||
instance_filters,
|
|
||||||
modified,
|
modified,
|
||||||
name,
|
name,
|
||||||
overwrite,
|
overwrite,
|
||||||
overwrite_vars,
|
overwrite_vars,
|
||||||
source,
|
source,
|
||||||
source_path,
|
source_path,
|
||||||
source_regions,
|
|
||||||
source_vars,
|
source_vars,
|
||||||
update_cache_timeout,
|
update_cache_timeout,
|
||||||
update_on_launch,
|
update_on_launch,
|
||||||
@@ -233,57 +229,6 @@ function InventorySourceDetail({ inventorySource, i18n }) {
|
|||||||
))}
|
))}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{source_regions && (
|
|
||||||
<Detail
|
|
||||||
fullWidth
|
|
||||||
label={i18n._(t`Regions`)}
|
|
||||||
value={
|
|
||||||
<ChipGroup
|
|
||||||
numChips={5}
|
|
||||||
totalChips={source_regions.split(',').length}
|
|
||||||
>
|
|
||||||
{source_regions.split(',').map(region => (
|
|
||||||
<Chip key={region} isReadOnly>
|
|
||||||
{region}
|
|
||||||
</Chip>
|
|
||||||
))}
|
|
||||||
</ChipGroup>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{instance_filters && (
|
|
||||||
<Detail
|
|
||||||
fullWidth
|
|
||||||
label={i18n._(t`Instance filters`)}
|
|
||||||
value={
|
|
||||||
<ChipGroup
|
|
||||||
numChips={5}
|
|
||||||
totalChips={instance_filters.split(',').length}
|
|
||||||
>
|
|
||||||
{instance_filters.split(',').map(filter => (
|
|
||||||
<Chip key={filter} isReadOnly>
|
|
||||||
{filter}
|
|
||||||
</Chip>
|
|
||||||
))}
|
|
||||||
</ChipGroup>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{group_by && (
|
|
||||||
<Detail
|
|
||||||
fullWidth
|
|
||||||
label={i18n._(t`Only group by`)}
|
|
||||||
value={
|
|
||||||
<ChipGroup numChips={5} totalChips={group_by.split(',').length}>
|
|
||||||
{group_by.split(',').map(group => (
|
|
||||||
<Chip key={group} isReadOnly>
|
|
||||||
{group}
|
|
||||||
</Chip>
|
|
||||||
))}
|
|
||||||
</ChipGroup>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{optionsList && (
|
{optionsList && (
|
||||||
<Detail fullWidth label={i18n._(t`Options`)} value={optionsList} />
|
<Detail fullWidth label={i18n._(t`Options`)} value={optionsList} />
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -64,32 +64,6 @@ describe('InventorySourceDetail', () => {
|
|||||||
assertDetail(wrapper, 'Inventory file', 'foo');
|
assertDetail(wrapper, 'Inventory file', 'foo');
|
||||||
assertDetail(wrapper, 'Verbosity', '2 (Debug)');
|
assertDetail(wrapper, 'Verbosity', '2 (Debug)');
|
||||||
assertDetail(wrapper, 'Cache timeout', '2 seconds');
|
assertDetail(wrapper, 'Cache timeout', '2 seconds');
|
||||||
expect(
|
|
||||||
wrapper
|
|
||||||
.find('Detail[label="Regions"]')
|
|
||||||
.containsAllMatchingElements([
|
|
||||||
<span>us-east-1</span>,
|
|
||||||
<span>us-east-2</span>,
|
|
||||||
])
|
|
||||||
).toEqual(true);
|
|
||||||
expect(
|
|
||||||
wrapper
|
|
||||||
.find('Detail[label="Instance filters"]')
|
|
||||||
.containsAllMatchingElements([
|
|
||||||
<span>filter1</span>,
|
|
||||||
<span>filter2</span>,
|
|
||||||
<span>filter3</span>,
|
|
||||||
])
|
|
||||||
).toEqual(true);
|
|
||||||
expect(
|
|
||||||
wrapper
|
|
||||||
.find('Detail[label="Only group by"]')
|
|
||||||
.containsAllMatchingElements([
|
|
||||||
<span>group1</span>,
|
|
||||||
<span>group2</span>,
|
|
||||||
<span>group3</span>,
|
|
||||||
])
|
|
||||||
).toEqual(true);
|
|
||||||
expect(wrapper.find('CredentialChip').text()).toBe('Cloud: mock cred');
|
expect(wrapper.find('CredentialChip').text()).toBe('Cloud: mock cred');
|
||||||
expect(wrapper.find('VariablesDetail').prop('value')).toEqual(
|
expect(wrapper.find('VariablesDetail').prop('value')).toEqual(
|
||||||
'---\nfoo: bar'
|
'---\nfoo: bar'
|
||||||
|
|||||||
@@ -75,14 +75,11 @@ const InventorySourceFormFields = ({ sourceOptions, i18n }) => {
|
|||||||
} else {
|
} else {
|
||||||
const defaults = {
|
const defaults = {
|
||||||
credential: null,
|
credential: null,
|
||||||
group_by: '',
|
|
||||||
instance_filters: '',
|
|
||||||
overwrite: false,
|
overwrite: false,
|
||||||
overwrite_vars: false,
|
overwrite_vars: false,
|
||||||
source: sourceType,
|
source: sourceType,
|
||||||
source_path: '',
|
source_path: '',
|
||||||
source_project: null,
|
source_project: null,
|
||||||
source_regions: '',
|
|
||||||
source_script: null,
|
source_script: null,
|
||||||
source_vars: '---\n',
|
source_vars: '---\n',
|
||||||
update_cache_timeout: 0,
|
update_cache_timeout: 0,
|
||||||
@@ -200,15 +197,12 @@ const InventorySourceForm = ({
|
|||||||
credential: source?.summary_fields?.credential || null,
|
credential: source?.summary_fields?.credential || null,
|
||||||
custom_virtualenv: source?.custom_virtualenv || '',
|
custom_virtualenv: source?.custom_virtualenv || '',
|
||||||
description: source?.description || '',
|
description: source?.description || '',
|
||||||
group_by: source?.group_by || '',
|
|
||||||
instance_filters: source?.instance_filters || '',
|
|
||||||
name: source?.name || '',
|
name: source?.name || '',
|
||||||
overwrite: source?.overwrite || false,
|
overwrite: source?.overwrite || false,
|
||||||
overwrite_vars: source?.overwrite_vars || false,
|
overwrite_vars: source?.overwrite_vars || false,
|
||||||
source: source?.source || '',
|
source: source?.source || '',
|
||||||
source_path: source?.source_path === '' ? '/ (project root)' : '',
|
source_path: source?.source_path === '' ? '/ (project root)' : '',
|
||||||
source_project: source?.summary_fields?.source_project || null,
|
source_project: source?.summary_fields?.source_project || null,
|
||||||
source_regions: source?.source_regions || '',
|
|
||||||
source_script: source?.summary_fields?.source_script || null,
|
source_script: source?.summary_fields?.source_script || null,
|
||||||
source_vars: source?.source_vars || '---\n',
|
source_vars: source?.source_vars || '---\n',
|
||||||
update_cache_timeout: source?.update_cache_timeout || 0,
|
update_cache_timeout: source?.update_cache_timeout || 0,
|
||||||
|
|||||||
@@ -3,14 +3,9 @@ import { useField } from 'formik';
|
|||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import CredentialLookup from '../../../../components/Lookup/CredentialLookup';
|
import CredentialLookup from '../../../../components/Lookup/CredentialLookup';
|
||||||
import {
|
import { OptionsField, SourceVarsField, VerbosityField } from './SharedFields';
|
||||||
OptionsField,
|
|
||||||
RegionsField,
|
|
||||||
SourceVarsField,
|
|
||||||
VerbosityField,
|
|
||||||
} from './SharedFields';
|
|
||||||
|
|
||||||
const AzureSubForm = ({ i18n, sourceOptions }) => {
|
const AzureSubForm = ({ i18n }) => {
|
||||||
const [credentialField, credentialMeta, credentialHelpers] = useField(
|
const [credentialField, credentialMeta, credentialHelpers] = useField(
|
||||||
'credential'
|
'credential'
|
||||||
);
|
);
|
||||||
@@ -29,11 +24,6 @@ const AzureSubForm = ({ i18n, sourceOptions }) => {
|
|||||||
value={credentialField.value}
|
value={credentialField.value}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<RegionsField
|
|
||||||
regionOptions={
|
|
||||||
sourceOptions?.actions?.POST?.source_regions?.azure_rm_region_choices
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<VerbosityField />
|
<VerbosityField />
|
||||||
<OptionsField />
|
<OptionsField />
|
||||||
<SourceVarsField />
|
<SourceVarsField />
|
||||||
|
|||||||
@@ -10,13 +10,10 @@ jest.mock('../../../../api/models/Credentials');
|
|||||||
const initialValues = {
|
const initialValues = {
|
||||||
credential: null,
|
credential: null,
|
||||||
custom_virtualenv: '',
|
custom_virtualenv: '',
|
||||||
group_by: '',
|
|
||||||
instance_filters: '',
|
|
||||||
overwrite: false,
|
overwrite: false,
|
||||||
overwrite_vars: false,
|
overwrite_vars: false,
|
||||||
source_path: '',
|
source_path: '',
|
||||||
source_project: null,
|
source_project: null,
|
||||||
source_regions: '',
|
|
||||||
source_script: null,
|
source_script: null,
|
||||||
source_vars: '---\n',
|
source_vars: '---\n',
|
||||||
update_cache_timeout: 0,
|
update_cache_timeout: 0,
|
||||||
@@ -27,11 +24,7 @@ const initialValues = {
|
|||||||
|
|
||||||
const mockSourceOptions = {
|
const mockSourceOptions = {
|
||||||
actions: {
|
actions: {
|
||||||
POST: {
|
POST: {},
|
||||||
source_regions: {
|
|
||||||
azure_rm_region_choices: [],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -58,7 +51,6 @@ describe('<AzureSubForm />', () => {
|
|||||||
|
|
||||||
test('should render subform fields', () => {
|
test('should render subform fields', () => {
|
||||||
expect(wrapper.find('FormGroup[label="Credential"]')).toHaveLength(1);
|
expect(wrapper.find('FormGroup[label="Credential"]')).toHaveLength(1);
|
||||||
expect(wrapper.find('FormGroup[label="Regions"]')).toHaveLength(1);
|
|
||||||
expect(wrapper.find('FormGroup[label="Verbosity"]')).toHaveLength(1);
|
expect(wrapper.find('FormGroup[label="Verbosity"]')).toHaveLength(1);
|
||||||
expect(wrapper.find('FormGroup[label="Update options"]')).toHaveLength(1);
|
expect(wrapper.find('FormGroup[label="Update options"]')).toHaveLength(1);
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
@@ -10,13 +10,10 @@ jest.mock('../../../../api/models/Credentials');
|
|||||||
const initialValues = {
|
const initialValues = {
|
||||||
credential: null,
|
credential: null,
|
||||||
custom_virtualenv: '',
|
custom_virtualenv: '',
|
||||||
group_by: '',
|
|
||||||
instance_filters: '',
|
|
||||||
overwrite: false,
|
overwrite: false,
|
||||||
overwrite_vars: false,
|
overwrite_vars: false,
|
||||||
source_path: '',
|
source_path: '',
|
||||||
source_project: null,
|
source_project: null,
|
||||||
source_regions: '',
|
|
||||||
source_script: null,
|
source_script: null,
|
||||||
source_vars: '---\n',
|
source_vars: '---\n',
|
||||||
update_cache_timeout: 0,
|
update_cache_timeout: 0,
|
||||||
|
|||||||
@@ -3,24 +3,10 @@ import { useField } from 'formik';
|
|||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import CredentialLookup from '../../../../components/Lookup/CredentialLookup';
|
import CredentialLookup from '../../../../components/Lookup/CredentialLookup';
|
||||||
import {
|
import { OptionsField, SourceVarsField, VerbosityField } from './SharedFields';
|
||||||
GroupByField,
|
|
||||||
InstanceFiltersField,
|
|
||||||
OptionsField,
|
|
||||||
RegionsField,
|
|
||||||
SourceVarsField,
|
|
||||||
VerbosityField,
|
|
||||||
} from './SharedFields';
|
|
||||||
|
|
||||||
const EC2SubForm = ({ i18n, sourceOptions }) => {
|
const EC2SubForm = ({ i18n }) => {
|
||||||
const [credentialField, , credentialHelpers] = useField('credential');
|
const [credentialField, , credentialHelpers] = useField('credential');
|
||||||
const groupByOptionsObj = Object.assign(
|
|
||||||
{},
|
|
||||||
...sourceOptions?.actions?.POST?.group_by?.ec2_group_by_choices.map(
|
|
||||||
([key, val]) => ({ [key]: val })
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<CredentialLookup
|
<CredentialLookup
|
||||||
@@ -31,13 +17,6 @@ const EC2SubForm = ({ i18n, sourceOptions }) => {
|
|||||||
credentialHelpers.setValue(value);
|
credentialHelpers.setValue(value);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<RegionsField
|
|
||||||
regionOptions={
|
|
||||||
sourceOptions?.actions?.POST?.source_regions?.ec2_region_choices
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<InstanceFiltersField />
|
|
||||||
<GroupByField fixedOptions={groupByOptionsObj} />
|
|
||||||
<VerbosityField />
|
<VerbosityField />
|
||||||
<OptionsField />
|
<OptionsField />
|
||||||
<SourceVarsField />
|
<SourceVarsField />
|
||||||
|
|||||||
@@ -10,13 +10,10 @@ jest.mock('../../../../api/models/Credentials');
|
|||||||
const initialValues = {
|
const initialValues = {
|
||||||
credential: null,
|
credential: null,
|
||||||
custom_virtualenv: '',
|
custom_virtualenv: '',
|
||||||
group_by: '',
|
|
||||||
instance_filters: '',
|
|
||||||
overwrite: false,
|
overwrite: false,
|
||||||
overwrite_vars: false,
|
overwrite_vars: false,
|
||||||
source_path: '',
|
source_path: '',
|
||||||
source_project: null,
|
source_project: null,
|
||||||
source_regions: '',
|
|
||||||
source_script: null,
|
source_script: null,
|
||||||
source_vars: '---\n',
|
source_vars: '---\n',
|
||||||
update_cache_timeout: 0,
|
update_cache_timeout: 0,
|
||||||
@@ -27,14 +24,7 @@ const initialValues = {
|
|||||||
|
|
||||||
const mockSourceOptions = {
|
const mockSourceOptions = {
|
||||||
actions: {
|
actions: {
|
||||||
POST: {
|
POST: {},
|
||||||
source_regions: {
|
|
||||||
ec2_region_choices: [],
|
|
||||||
},
|
|
||||||
group_by: {
|
|
||||||
ec2_group_by_choices: [],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -61,9 +51,6 @@ describe('<EC2SubForm />', () => {
|
|||||||
|
|
||||||
test('should render subform fields', () => {
|
test('should render subform fields', () => {
|
||||||
expect(wrapper.find('FormGroup[label="Credential"]')).toHaveLength(1);
|
expect(wrapper.find('FormGroup[label="Credential"]')).toHaveLength(1);
|
||||||
expect(wrapper.find('FormGroup[label="Regions"]')).toHaveLength(1);
|
|
||||||
expect(wrapper.find('FormGroup[label="Instance filters"]')).toHaveLength(1);
|
|
||||||
expect(wrapper.find('FormGroup[label="Only group by"]')).toHaveLength(1);
|
|
||||||
expect(wrapper.find('FormGroup[label="Verbosity"]')).toHaveLength(1);
|
expect(wrapper.find('FormGroup[label="Verbosity"]')).toHaveLength(1);
|
||||||
expect(wrapper.find('FormGroup[label="Update options"]')).toHaveLength(1);
|
expect(wrapper.find('FormGroup[label="Update options"]')).toHaveLength(1);
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import { useField } from 'formik';
|
|||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import CredentialLookup from '../../../../components/Lookup/CredentialLookup';
|
import CredentialLookup from '../../../../components/Lookup/CredentialLookup';
|
||||||
import { OptionsField, RegionsField, VerbosityField } from './SharedFields';
|
import { OptionsField, VerbosityField } from './SharedFields';
|
||||||
|
|
||||||
const GCESubForm = ({ i18n, sourceOptions }) => {
|
const GCESubForm = ({ i18n }) => {
|
||||||
const [credentialField, credentialMeta, credentialHelpers] = useField(
|
const [credentialField, credentialMeta, credentialHelpers] = useField(
|
||||||
'credential'
|
'credential'
|
||||||
);
|
);
|
||||||
@@ -24,11 +24,6 @@ const GCESubForm = ({ i18n, sourceOptions }) => {
|
|||||||
value={credentialField.value}
|
value={credentialField.value}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<RegionsField
|
|
||||||
regionOptions={
|
|
||||||
sourceOptions?.actions?.POST?.source_regions?.gce_region_choices
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<VerbosityField />
|
<VerbosityField />
|
||||||
<OptionsField />
|
<OptionsField />
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -10,13 +10,10 @@ jest.mock('../../../../api/models/Credentials');
|
|||||||
const initialValues = {
|
const initialValues = {
|
||||||
credential: null,
|
credential: null,
|
||||||
custom_virtualenv: '',
|
custom_virtualenv: '',
|
||||||
group_by: '',
|
|
||||||
instance_filters: '',
|
|
||||||
overwrite: false,
|
overwrite: false,
|
||||||
overwrite_vars: false,
|
overwrite_vars: false,
|
||||||
source_path: '',
|
source_path: '',
|
||||||
source_project: null,
|
source_project: null,
|
||||||
source_regions: '',
|
|
||||||
source_script: null,
|
source_script: null,
|
||||||
source_vars: '---\n',
|
source_vars: '---\n',
|
||||||
update_cache_timeout: 0,
|
update_cache_timeout: 0,
|
||||||
@@ -27,11 +24,7 @@ const initialValues = {
|
|||||||
|
|
||||||
const mockSourceOptions = {
|
const mockSourceOptions = {
|
||||||
actions: {
|
actions: {
|
||||||
POST: {
|
POST: {},
|
||||||
source_regions: {
|
|
||||||
gce_region_choices: [],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -58,7 +51,6 @@ describe('<GCESubForm />', () => {
|
|||||||
|
|
||||||
test('should render subform fields', () => {
|
test('should render subform fields', () => {
|
||||||
expect(wrapper.find('FormGroup[label="Credential"]')).toHaveLength(1);
|
expect(wrapper.find('FormGroup[label="Credential"]')).toHaveLength(1);
|
||||||
expect(wrapper.find('FormGroup[label="Regions"]')).toHaveLength(1);
|
|
||||||
expect(wrapper.find('FormGroup[label="Verbosity"]')).toHaveLength(1);
|
expect(wrapper.find('FormGroup[label="Verbosity"]')).toHaveLength(1);
|
||||||
expect(wrapper.find('FormGroup[label="Update options"]')).toHaveLength(1);
|
expect(wrapper.find('FormGroup[label="Update options"]')).toHaveLength(1);
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
@@ -10,13 +10,10 @@ jest.mock('../../../../api/models/Credentials');
|
|||||||
const initialValues = {
|
const initialValues = {
|
||||||
credential: null,
|
credential: null,
|
||||||
custom_virtualenv: '',
|
custom_virtualenv: '',
|
||||||
group_by: '',
|
|
||||||
instance_filters: '',
|
|
||||||
overwrite: false,
|
overwrite: false,
|
||||||
overwrite_vars: false,
|
overwrite_vars: false,
|
||||||
source_path: '',
|
source_path: '',
|
||||||
source_project: null,
|
source_project: null,
|
||||||
source_regions: '',
|
|
||||||
source_script: null,
|
source_script: null,
|
||||||
source_vars: '---\n',
|
source_vars: '---\n',
|
||||||
update_cache_timeout: 0,
|
update_cache_timeout: 0,
|
||||||
|
|||||||
@@ -11,13 +11,10 @@ jest.mock('../../../../api/models/Credentials');
|
|||||||
const initialValues = {
|
const initialValues = {
|
||||||
credential: null,
|
credential: null,
|
||||||
custom_virtualenv: '',
|
custom_virtualenv: '',
|
||||||
group_by: '',
|
|
||||||
instance_filters: '',
|
|
||||||
overwrite: false,
|
overwrite: false,
|
||||||
overwrite_vars: false,
|
overwrite_vars: false,
|
||||||
source_path: '',
|
source_path: '',
|
||||||
source_project: null,
|
source_project: null,
|
||||||
source_regions: '',
|
|
||||||
source_script: null,
|
source_script: null,
|
||||||
source_vars: '---\n',
|
source_vars: '---\n',
|
||||||
update_cache_timeout: 0,
|
update_cache_timeout: 0,
|
||||||
|
|||||||
@@ -10,13 +10,10 @@ jest.mock('../../../../api/models/Credentials');
|
|||||||
const initialValues = {
|
const initialValues = {
|
||||||
credential: null,
|
credential: null,
|
||||||
custom_virtualenv: '',
|
custom_virtualenv: '',
|
||||||
group_by: '',
|
|
||||||
instance_filters: '',
|
|
||||||
overwrite: false,
|
overwrite: false,
|
||||||
overwrite_vars: false,
|
overwrite_vars: false,
|
||||||
source_path: '',
|
source_path: '',
|
||||||
source_project: null,
|
source_project: null,
|
||||||
source_regions: '',
|
|
||||||
source_script: null,
|
source_script: null,
|
||||||
source_vars: '---\n',
|
source_vars: '---\n',
|
||||||
update_cache_timeout: 0,
|
update_cache_timeout: 0,
|
||||||
|
|||||||
@@ -1,16 +1,9 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t, Trans } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { useField } from 'formik';
|
import { useField } from 'formik';
|
||||||
import {
|
import { FormGroup } from '@patternfly/react-core';
|
||||||
FormGroup,
|
|
||||||
Select,
|
|
||||||
SelectOption,
|
|
||||||
SelectVariant,
|
|
||||||
} from '@patternfly/react-core';
|
|
||||||
import { arrayToString, stringToArray } from '../../../../util/strings';
|
|
||||||
import { minMaxValue } from '../../../../util/validators';
|
import { minMaxValue } from '../../../../util/validators';
|
||||||
import { BrandName } from '../../../../variables';
|
|
||||||
import AnsibleSelect from '../../../../components/AnsibleSelect';
|
import AnsibleSelect from '../../../../components/AnsibleSelect';
|
||||||
import { VariablesField } from '../../../../components/CodeMirrorInput';
|
import { VariablesField } from '../../../../components/CodeMirrorInput';
|
||||||
import FormField, {
|
import FormField, {
|
||||||
@@ -32,196 +25,6 @@ export const SourceVarsField = withI18n()(({ i18n }) => (
|
|||||||
</FormFullWidthLayout>
|
</FormFullWidthLayout>
|
||||||
));
|
));
|
||||||
|
|
||||||
export const RegionsField = withI18n()(({ i18n, regionOptions }) => {
|
|
||||||
const [field, meta, helpers] = useField('source_regions');
|
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
|
||||||
const options = Object.assign(
|
|
||||||
{},
|
|
||||||
...regionOptions.map(([key, val]) => ({ [key]: val }))
|
|
||||||
);
|
|
||||||
const selected = stringToArray(field?.value)
|
|
||||||
.filter(i => options[i])
|
|
||||||
.map(val => options[val]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FormGroup
|
|
||||||
fieldId="regions"
|
|
||||||
helperTextInvalid={meta.error}
|
|
||||||
validated="default"
|
|
||||||
label={i18n._(t`Regions`)}
|
|
||||||
labelIcon={
|
|
||||||
<FieldTooltip
|
|
||||||
content={
|
|
||||||
<Trans>
|
|
||||||
Click on the regions field to see a list of regions for your cloud
|
|
||||||
provider. You can select multiple regions, or choose
|
|
||||||
<em> All</em> to include all regions. Only Hosts associated with
|
|
||||||
the selected regions will be updated.
|
|
||||||
</Trans>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Select
|
|
||||||
variant={SelectVariant.typeaheadMulti}
|
|
||||||
id="regions"
|
|
||||||
onToggle={setIsOpen}
|
|
||||||
onClear={() => helpers.setValue('')}
|
|
||||||
onSelect={(event, option) => {
|
|
||||||
let selectedValues;
|
|
||||||
if (selected.includes(option)) {
|
|
||||||
selectedValues = selected.filter(o => o !== option);
|
|
||||||
} else {
|
|
||||||
selectedValues = selected.concat(option);
|
|
||||||
}
|
|
||||||
const selectedKeys = selectedValues.map(val =>
|
|
||||||
Object.keys(options).find(key => options[key] === val)
|
|
||||||
);
|
|
||||||
helpers.setValue(arrayToString(selectedKeys));
|
|
||||||
}}
|
|
||||||
isExpanded={isOpen}
|
|
||||||
placeholderText={i18n._(t`Select a region`)}
|
|
||||||
selections={selected}
|
|
||||||
>
|
|
||||||
{regionOptions.map(([key, val]) => (
|
|
||||||
<SelectOption key={key} value={val} />
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</FormGroup>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
export const GroupByField = withI18n()(
|
|
||||||
({ i18n, fixedOptions, isCreatable = false }) => {
|
|
||||||
const [field, meta, helpers] = useField('group_by');
|
|
||||||
const fixedOptionLabels = fixedOptions && Object.values(fixedOptions);
|
|
||||||
const selections = fixedOptions
|
|
||||||
? stringToArray(field.value).map(o => fixedOptions[o])
|
|
||||||
: stringToArray(field.value);
|
|
||||||
const [options, setOptions] = useState(selections);
|
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
|
||||||
|
|
||||||
const renderOptions = opts => {
|
|
||||||
return opts.map(option => (
|
|
||||||
<SelectOption key={option} value={option}>
|
|
||||||
{option}
|
|
||||||
</SelectOption>
|
|
||||||
));
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleFilter = event => {
|
|
||||||
const str = event.target.value.toLowerCase();
|
|
||||||
let matches;
|
|
||||||
if (fixedOptions) {
|
|
||||||
matches = fixedOptionLabels.filter(o => o.toLowerCase().includes(str));
|
|
||||||
} else {
|
|
||||||
matches = options.filter(o => o.toLowerCase().includes(str));
|
|
||||||
}
|
|
||||||
return renderOptions(matches);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSelect = (e, option) => {
|
|
||||||
let selectedValues;
|
|
||||||
if (selections.includes(option)) {
|
|
||||||
selectedValues = selections.filter(o => o !== option);
|
|
||||||
} else {
|
|
||||||
selectedValues = selections.concat(option);
|
|
||||||
}
|
|
||||||
if (fixedOptions) {
|
|
||||||
selectedValues = selectedValues.map(val =>
|
|
||||||
Object.keys(fixedOptions).find(key => fixedOptions[key] === val)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
helpers.setValue(arrayToString(selectedValues));
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FormGroup
|
|
||||||
fieldId="group-by"
|
|
||||||
helperTextInvalid={meta.error}
|
|
||||||
validated="default"
|
|
||||||
label={i18n._(t`Only group by`)}
|
|
||||||
labelIcon={
|
|
||||||
<FieldTooltip
|
|
||||||
content={
|
|
||||||
<Trans>
|
|
||||||
Select which groups to create automatically. AWX will create
|
|
||||||
group names similar to the following examples based on the
|
|
||||||
options selected:
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
Availability Zone: <strong>zones » us-east-1b</strong>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
Image ID: <strong>images » ami-b007ab1e</strong>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
Instance ID: <strong>instances » i-ca11ab1e </strong>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
Instance Type: <strong>types » type_m1_medium</strong>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
Key Name: <strong>keys » key_testing</strong>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
Region: <strong>regions » us-east-1</strong>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
Security Group:{' '}
|
|
||||||
<strong>
|
|
||||||
security_groups » security_group_default
|
|
||||||
</strong>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
Tags: <strong>tags » tag_Name_host1</strong>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
VPC ID: <strong>vpcs » vpc-5ca1ab1e</strong>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
Tag None: <strong>tags » tag_none</strong>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<br />
|
|
||||||
If blank, all groups above are created except{' '}
|
|
||||||
<em>Instance ID</em>.
|
|
||||||
</Trans>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Select
|
|
||||||
variant={SelectVariant.typeaheadMulti}
|
|
||||||
id="group-by"
|
|
||||||
onToggle={setIsOpen}
|
|
||||||
onClear={() => helpers.setValue('')}
|
|
||||||
isCreatable={isCreatable}
|
|
||||||
createText={i18n._(t`Create`)}
|
|
||||||
onCreateOption={name => {
|
|
||||||
name = name.trim();
|
|
||||||
if (!options.find(opt => opt === name)) {
|
|
||||||
setOptions(options.concat(name));
|
|
||||||
}
|
|
||||||
return name;
|
|
||||||
}}
|
|
||||||
onFilter={handleFilter}
|
|
||||||
onSelect={handleSelect}
|
|
||||||
isExpanded={isOpen}
|
|
||||||
placeholderText={i18n._(t`Select a group`)}
|
|
||||||
selections={selections}
|
|
||||||
>
|
|
||||||
{fixedOptions
|
|
||||||
? renderOptions(fixedOptionLabels)
|
|
||||||
: renderOptions(options)}
|
|
||||||
</Select>
|
|
||||||
</FormGroup>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
export const VerbosityField = withI18n()(({ i18n }) => {
|
export const VerbosityField = withI18n()(({ i18n }) => {
|
||||||
const [field, meta, helpers] = useField('verbosity');
|
const [field, meta, helpers] = useField('verbosity');
|
||||||
const isValid = !(meta.touched && meta.error);
|
const isValid = !(meta.touched && meta.error);
|
||||||
@@ -351,49 +154,3 @@ export const OptionsField = withI18n()(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export const InstanceFiltersField = withI18n()(({ i18n }) => {
|
|
||||||
// Setting BrandName to a variable here is necessary to get the jest tests
|
|
||||||
// passing. Attempting to use BrandName in the template literal results
|
|
||||||
// in failing tests.
|
|
||||||
const brandName = BrandName;
|
|
||||||
return (
|
|
||||||
<FormField
|
|
||||||
id="instance-filters"
|
|
||||||
label={i18n._(t`Instance filters`)}
|
|
||||||
name="instance_filters"
|
|
||||||
type="text"
|
|
||||||
tooltip={
|
|
||||||
<Trans>
|
|
||||||
Provide a comma-separated list of filter expressions. Hosts are
|
|
||||||
imported to {brandName} when <em>ANY</em> of the filters match.
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
Limit to hosts having a tag:
|
|
||||||
<br />
|
|
||||||
tag-key=TowerManaged
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
Limit to hosts using either key pair:
|
|
||||||
<br />
|
|
||||||
key-name=staging, key-name=production
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
Limit to hosts where the Name tag begins with <em>test</em>:<br />
|
|
||||||
tag:Name=test*
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
View the
|
|
||||||
<a
|
|
||||||
href="http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInstances.html\"
|
|
||||||
target="_blank\"
|
|
||||||
>
|
|
||||||
{' '}
|
|
||||||
Describe Instances documentation{' '}
|
|
||||||
</a>
|
|
||||||
for a complete list of supported filters.
|
|
||||||
</Trans>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -3,11 +3,7 @@ import { useField } from 'formik';
|
|||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import CredentialLookup from '../../../../components/Lookup/CredentialLookup';
|
import CredentialLookup from '../../../../components/Lookup/CredentialLookup';
|
||||||
import {
|
import { OptionsField, VerbosityField } from './SharedFields';
|
||||||
InstanceFiltersField,
|
|
||||||
OptionsField,
|
|
||||||
VerbosityField,
|
|
||||||
} from './SharedFields';
|
|
||||||
|
|
||||||
const TowerSubForm = ({ i18n }) => {
|
const TowerSubForm = ({ i18n }) => {
|
||||||
const [credentialField, credentialMeta, credentialHelpers] = useField(
|
const [credentialField, credentialMeta, credentialHelpers] = useField(
|
||||||
@@ -28,7 +24,6 @@ const TowerSubForm = ({ i18n }) => {
|
|||||||
value={credentialField.value}
|
value={credentialField.value}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<InstanceFiltersField />
|
|
||||||
<VerbosityField />
|
<VerbosityField />
|
||||||
<OptionsField />
|
<OptionsField />
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -10,13 +10,10 @@ jest.mock('../../../../api/models/Credentials');
|
|||||||
const initialValues = {
|
const initialValues = {
|
||||||
credential: null,
|
credential: null,
|
||||||
custom_virtualenv: '',
|
custom_virtualenv: '',
|
||||||
group_by: '',
|
|
||||||
instance_filters: '',
|
|
||||||
overwrite: false,
|
overwrite: false,
|
||||||
overwrite_vars: false,
|
overwrite_vars: false,
|
||||||
source_path: '',
|
source_path: '',
|
||||||
source_project: null,
|
source_project: null,
|
||||||
source_regions: '',
|
|
||||||
source_script: null,
|
source_script: null,
|
||||||
source_vars: '---\n',
|
source_vars: '---\n',
|
||||||
update_cache_timeout: 0,
|
update_cache_timeout: 0,
|
||||||
@@ -48,7 +45,6 @@ describe('<TowerSubForm />', () => {
|
|||||||
|
|
||||||
test('should render subform fields', () => {
|
test('should render subform fields', () => {
|
||||||
expect(wrapper.find('FormGroup[label="Credential"]')).toHaveLength(1);
|
expect(wrapper.find('FormGroup[label="Credential"]')).toHaveLength(1);
|
||||||
expect(wrapper.find('FormGroup[label="Instance filters"]')).toHaveLength(1);
|
|
||||||
expect(wrapper.find('FormGroup[label="Verbosity"]')).toHaveLength(1);
|
expect(wrapper.find('FormGroup[label="Verbosity"]')).toHaveLength(1);
|
||||||
expect(wrapper.find('FormGroup[label="Update options"]')).toHaveLength(1);
|
expect(wrapper.find('FormGroup[label="Update options"]')).toHaveLength(1);
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
@@ -3,13 +3,7 @@ import { useField } from 'formik';
|
|||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import CredentialLookup from '../../../../components/Lookup/CredentialLookup';
|
import CredentialLookup from '../../../../components/Lookup/CredentialLookup';
|
||||||
import {
|
import { OptionsField, SourceVarsField, VerbosityField } from './SharedFields';
|
||||||
InstanceFiltersField,
|
|
||||||
GroupByField,
|
|
||||||
OptionsField,
|
|
||||||
SourceVarsField,
|
|
||||||
VerbosityField,
|
|
||||||
} from './SharedFields';
|
|
||||||
|
|
||||||
const VMwareSubForm = ({ i18n }) => {
|
const VMwareSubForm = ({ i18n }) => {
|
||||||
const [credentialField, credentialMeta, credentialHelpers] = useField(
|
const [credentialField, credentialMeta, credentialHelpers] = useField(
|
||||||
@@ -30,8 +24,6 @@ const VMwareSubForm = ({ i18n }) => {
|
|||||||
value={credentialField.value}
|
value={credentialField.value}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<InstanceFiltersField />
|
|
||||||
<GroupByField isCreatable />
|
|
||||||
<VerbosityField />
|
<VerbosityField />
|
||||||
<OptionsField />
|
<OptionsField />
|
||||||
<SourceVarsField />
|
<SourceVarsField />
|
||||||
|
|||||||
@@ -10,13 +10,10 @@ jest.mock('../../../../api/models/Credentials');
|
|||||||
const initialValues = {
|
const initialValues = {
|
||||||
credential: null,
|
credential: null,
|
||||||
custom_virtualenv: '',
|
custom_virtualenv: '',
|
||||||
group_by: '',
|
|
||||||
instance_filters: '',
|
|
||||||
overwrite: false,
|
overwrite: false,
|
||||||
overwrite_vars: false,
|
overwrite_vars: false,
|
||||||
source_path: '',
|
source_path: '',
|
||||||
source_project: null,
|
source_project: null,
|
||||||
source_regions: '',
|
|
||||||
source_script: null,
|
source_script: null,
|
||||||
source_vars: '---\n',
|
source_vars: '---\n',
|
||||||
update_cache_timeout: 0,
|
update_cache_timeout: 0,
|
||||||
@@ -27,11 +24,7 @@ const initialValues = {
|
|||||||
|
|
||||||
const mockSourceOptions = {
|
const mockSourceOptions = {
|
||||||
actions: {
|
actions: {
|
||||||
POST: {
|
POST: {},
|
||||||
source_regions: {
|
|
||||||
gce_region_choices: [],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -58,8 +51,6 @@ describe('<VMwareSubForm />', () => {
|
|||||||
|
|
||||||
test('should render subform fields', () => {
|
test('should render subform fields', () => {
|
||||||
expect(wrapper.find('FormGroup[label="Credential"]')).toHaveLength(1);
|
expect(wrapper.find('FormGroup[label="Credential"]')).toHaveLength(1);
|
||||||
expect(wrapper.find('FormGroup[label="Instance filters"]')).toHaveLength(1);
|
|
||||||
expect(wrapper.find('FormGroup[label="Only group by"]')).toHaveLength(1);
|
|
||||||
expect(wrapper.find('FormGroup[label="Verbosity"]')).toHaveLength(1);
|
expect(wrapper.find('FormGroup[label="Verbosity"]')).toHaveLength(1);
|
||||||
expect(wrapper.find('FormGroup[label="Update options"]')).toHaveLength(1);
|
expect(wrapper.find('FormGroup[label="Update options"]')).toHaveLength(1);
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
@@ -10,13 +10,10 @@ jest.mock('../../../../api/models/Credentials');
|
|||||||
const initialValues = {
|
const initialValues = {
|
||||||
credential: null,
|
credential: null,
|
||||||
custom_virtualenv: '',
|
custom_virtualenv: '',
|
||||||
group_by: '',
|
|
||||||
instance_filters: '',
|
|
||||||
overwrite: false,
|
overwrite: false,
|
||||||
overwrite_vars: false,
|
overwrite_vars: false,
|
||||||
source_path: '',
|
source_path: '',
|
||||||
source_project: null,
|
source_project: null,
|
||||||
source_regions: '',
|
|
||||||
source_script: null,
|
source_script: null,
|
||||||
source_vars: '---\n',
|
source_vars: '---\n',
|
||||||
update_cache_timeout: 0,
|
update_cache_timeout: 0,
|
||||||
|
|||||||
@@ -96,9 +96,6 @@
|
|||||||
"source_script": "Mock Script",
|
"source_script": "Mock Script",
|
||||||
"source_vars":"---\nfoo: bar",
|
"source_vars":"---\nfoo: bar",
|
||||||
"credential": 8,
|
"credential": 8,
|
||||||
"source_regions": "us-east-1,us-east-2",
|
|
||||||
"instance_filters": "filter1,filter2,filter3",
|
|
||||||
"group_by": "group1,group2,group3",
|
|
||||||
"overwrite":true,
|
"overwrite":true,
|
||||||
"overwrite_vars":true,
|
"overwrite_vars":true,
|
||||||
"custom_virtualenv":"/venv/custom",
|
"custom_virtualenv":"/venv/custom",
|
||||||
|
|||||||
Reference in New Issue
Block a user