mirror of
https://github.com/ansible/awx.git
synced 2026-03-29 06:45:09 -02:30
add instance groups to JT form
This commit is contained in:
@@ -68,6 +68,9 @@ class JobTemplateForm extends Component {
|
|||||||
this.loadRelatedProjectPlaybooks = this.loadRelatedProjectPlaybooks.bind(
|
this.loadRelatedProjectPlaybooks = this.loadRelatedProjectPlaybooks.bind(
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
|
this.handleInstanceGroupsChange = this.handleInstanceGroupsChange.bind(
|
||||||
|
this
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@@ -116,6 +119,7 @@ class JobTemplateForm extends Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
console.log('loading...');
|
||||||
const { data } = await JobTemplatesAPI.readInstanceGroups(template.id);
|
const { data } = await JobTemplatesAPI.readInstanceGroups(template.id);
|
||||||
console.log(data.results);
|
console.log(data.results);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -217,6 +221,10 @@ class JobTemplateForm extends Component {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleInstanceGroupsChange(relatedInstanceGroups) {
|
||||||
|
this.setState({ relatedInstanceGroups });
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
loadedLabels,
|
loadedLabels,
|
||||||
@@ -225,6 +233,9 @@ class JobTemplateForm extends Component {
|
|||||||
inventory,
|
inventory,
|
||||||
project,
|
project,
|
||||||
relatedProjectPlaybooks = [],
|
relatedProjectPlaybooks = [],
|
||||||
|
newLabels,
|
||||||
|
removedLabels,
|
||||||
|
relatedInstanceGroups,
|
||||||
} = this.state;
|
} = this.state;
|
||||||
const {
|
const {
|
||||||
handleCancel,
|
handleCancel,
|
||||||
@@ -522,8 +533,7 @@ class JobTemplateForm extends Component {
|
|||||||
<div>
|
<div>
|
||||||
<Switch
|
<Switch
|
||||||
id="template-show-changes"
|
id="template-show-changes"
|
||||||
label={i18n._(t`On`)}
|
label={field.value ? i18n._(t`On`) : i18n._(t`Off`)}
|
||||||
labelOff={i18n._(t`Off`)}
|
|
||||||
isChecked={field.value}
|
isChecked={field.value}
|
||||||
onChange={checked =>
|
onChange={checked =>
|
||||||
form.setFieldValue(field.name, checked)
|
form.setFieldValue(field.name, checked)
|
||||||
@@ -534,13 +544,13 @@ class JobTemplateForm extends Component {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</FormRow>
|
</FormRow>
|
||||||
{/* <InstanceGroupsLookup
|
<InstanceGroupsLookup
|
||||||
value={instanceGroups}
|
value={relatedInstanceGroups}
|
||||||
onChange={this.handleInstanceGroupsChange}
|
onChange={this.handleInstanceGroupsChange}
|
||||||
tooltip={i18n._(
|
tooltip={i18n._(
|
||||||
t`Select the Instance Groups for this Organization to run on.`
|
t`Select the Instance Groups for this Organization to run on.`
|
||||||
)}
|
)}
|
||||||
/> */}
|
/>
|
||||||
</CollapsibleSection>
|
</CollapsibleSection>
|
||||||
<FormActionGroup onCancel={handleCancel} onSubmit={handleSubmit} />
|
<FormActionGroup onCancel={handleCancel} onSubmit={handleSubmit} />
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prevents styled-components from passing down an unsupported
|
||||||
|
* props to children, resulting in console warnings.
|
||||||
|
* https://github.com/styled-components/styled-components/issues/439
|
||||||
|
*/
|
||||||
export default function omitProps(Component, ...omit) {
|
export default function omitProps(Component, ...omit) {
|
||||||
return function Omit(props) {
|
return function Omit(props) {
|
||||||
const clean = { ...props };
|
const clean = { ...props };
|
||||||
|
|||||||
35
awx/ui_next/src/util/omitProps.test.jsx
Normal file
35
awx/ui_next/src/util/omitProps.test.jsx
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { mount } from 'enzyme';
|
||||||
|
import omitProps from './omitProps';
|
||||||
|
|
||||||
|
describe('omitProps', () => {
|
||||||
|
test('should render child component', () => {
|
||||||
|
const Omit = omitProps('div');
|
||||||
|
const wrapper = mount(<Omit foo="one" bar="two" />);
|
||||||
|
|
||||||
|
const div = wrapper.find('div');
|
||||||
|
expect(div).toHaveLength(1);
|
||||||
|
expect(div.prop('foo')).toEqual('one');
|
||||||
|
expect(div.prop('bar')).toEqual('two');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should not pass omitted props to child component', () => {
|
||||||
|
const Omit = omitProps('div', 'foo', 'bar');
|
||||||
|
const wrapper = mount(<Omit foo="one" bar="two" />);
|
||||||
|
|
||||||
|
const div = wrapper.find('div');
|
||||||
|
expect(div).toHaveLength(1);
|
||||||
|
expect(div.prop('foo')).toEqual(undefined);
|
||||||
|
expect(div.prop('bar')).toEqual(undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should support mix of omitted and non-omitted props', () => {
|
||||||
|
const Omit = omitProps('div', 'foo');
|
||||||
|
const wrapper = mount(<Omit foo="one" bar="two" />);
|
||||||
|
|
||||||
|
const div = wrapper.find('div');
|
||||||
|
expect(div).toHaveLength(1);
|
||||||
|
expect(div.prop('foo')).toEqual(undefined);
|
||||||
|
expect(div.prop('bar')).toEqual('two');
|
||||||
|
});
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user