-
Notifications
You must be signed in to change notification settings - Fork 92
/
index.js
66 lines (63 loc) · 1.92 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import React, { useState } from 'react';
import { Button, Form, FormGroup } from '@patternfly/react-core';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
import { translate as __ } from 'foremanReact/common/I18n';
import { selectTemplateInputs } from '../../JobWizardSelectors';
import { SelectField } from '../form/SelectField';
import { SelectedChips } from './SelectedChips';
import { TemplateInputs } from './TemplateInputs';
import { WIZARD_TITLES } from '../../JobWizardConstants';
import { WizardTitle } from '../form/WizardTitle';
const HostsAndInputs = ({
templateValues,
setTemplateValues,
selectedHosts,
setSelectedHosts,
}) => {
const templateInputs = useSelector(selectTemplateInputs);
const hostMethods = [
__('Hosts'),
__('Host collection'),
__('Host group'),
__('Search query'),
];
const [hostMethod, setHostMethod] = useState(hostMethods[0]);
return (
<>
<WizardTitle title={WIZARD_TITLES.hostsAndInputs} />
<Form>
<FormGroup fieldId="host_selection">
<SelectField
fieldId="host_methods"
options={hostMethods}
setValue={setHostMethod}
value={hostMethod}
/>
<SelectedChips
selected={selectedHosts}
setSelected={setSelectedHosts}
/>
</FormGroup>
<span>
{__('Apply to')}{' '}
<Button variant="link" isInline>
{selectedHosts.length} {__('hosts')}
</Button>
</span>
<TemplateInputs
inputs={templateInputs}
value={templateValues}
setValue={setTemplateValues}
/>
</Form>
</>
);
};
HostsAndInputs.propTypes = {
templateValues: PropTypes.object.isRequired,
setTemplateValues: PropTypes.func.isRequired,
selectedHosts: PropTypes.array.isRequired,
setSelectedHosts: PropTypes.func.isRequired,
};
export default HostsAndInputs;