foreman_acd 0.9.7 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/foreman_acd/version.rb +1 -1
- data/package.json +5 -3
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +210 -121
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +79 -91
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +30 -15
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +15 -15
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +96 -63
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +22 -11
- data/webpack/components/ApplicationDefinition/__fixtures__/{applicationDefinitionConfData_1.fixtures.js → applicationDefinitionConfData1.fixtures.js} +77 -105
- data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +49 -29
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +4 -4
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionHelper.test.js +16 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +0 -5
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +25 -25
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +9 -1
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +11 -11
- data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +30 -25
- data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +3 -3
- data/webpack/components/ApplicationDefinition/index.js +0 -1
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +91 -105
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +59 -84
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +12 -6
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +21 -27
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +14 -7
- data/webpack/components/ApplicationDefinitionImport/__fixtures__/{applicationDefinitionImportConfData_1.fixtures.js → applicationDefinitionImportConfData1.fixtures.js} +32 -40
- data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +14 -16
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +38 -8
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +0 -2
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +9 -9
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +116 -2
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +3 -3
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +344 -193
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +92 -105
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +34 -17
- data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +4 -7
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +114 -74
- data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +18 -9
- data/webpack/components/ApplicationInstance/__fixtures__/{applicationInstanceConfData_1.fixtures.js → applicationInstanceConfData1.fixtures.js} +68 -86
- data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +24 -32
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +75 -10
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +0 -8
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +27 -27
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +606 -2
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +12 -12
- data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +32 -25
- data/webpack/components/ApplicationInstance/components/Service.js +7 -18
- data/webpack/components/ApplicationInstance/components/ServiceCounter.js +25 -18
- data/webpack/components/ApplicationInstance/index.js +0 -1
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +167 -110
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +20 -25
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +10 -5
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +9 -12
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +12 -6
- data/webpack/components/ApplicationInstanceReport/__fixtures__/{applicationInstanceReportData_1.fixtures.js → applicationInstanceReportData1.fixtures.js} +154 -101
- data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +3 -10
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +28 -22
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +5 -7
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +0 -1
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +2 -2
- data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +9 -5
- data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +1 -3
- data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +35 -56
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +21 -28
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +6 -3
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +16 -19
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -4
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData1.fixtures.js +187 -0
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +13 -24
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +3 -2
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +11 -14
- data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +5 -5
- data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +31 -25
- data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +3 -9
- data/webpack/components/ParameterSelection/ParameterSelection.js +258 -174
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +110 -100
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +22 -11
- data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +13 -11
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +63 -49
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +10 -5
- data/webpack/components/ParameterSelection/__fixtures__/{parameterSelectionData_1.fixtures.js → parameterSelectionData1.fixtures.js} +67 -104
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +22 -26
- data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +50 -36
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionHelper.test.js +76 -0
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +0 -2
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +23 -25
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +100 -0
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +99 -112
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +18 -19
- data/webpack/components/ParameterSelection/index.js +1 -4
- data/webpack/components/SyncGitRepo/SyncGitRepo.js +124 -117
- data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +64 -74
- data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +17 -17
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData1.fixtures.js +7 -0
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +10 -18
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +80 -6
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +9 -11
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +192 -1
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +4 -4
- data/webpack/components/SyncGitRepo/components/FormTextInput.js +26 -21
- data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +29 -24
- data/webpack/components/SyncGitRepo/index.js +2 -5
- data/webpack/components/common/AddTableEntry.js +3 -10
- data/webpack/components/common/DeleteTableEntry.js +7 -15
- data/webpack/components/common/EditTableEntry.js +7 -7
- data/webpack/components/common/ExtSelect.js +12 -8
- data/webpack/components/common/ExtTextInput.js +12 -7
- data/webpack/components/common/LockTableEntry.js +6 -6
- data/webpack/components/common/RailsData.js +6 -16
- data/webpack/components/common/__tests__/ExtSelect.test.js +2 -2
- data/webpack/components/common/__tests__/RailsData.test.js +0 -2
- data/webpack/global_test_setup.js +11 -0
- data/webpack/helper.js +10 -21
- data/webpack/helper.test.js +17 -29
- data/webpack/index.js +25 -7
- data/webpack/js-yaml.js +1563 -1135
- data/webpack/reducer.js +52 -27
- metadata +13 -11
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +0 -191
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +0 -153
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +0 -7
@@ -1,16 +1,17 @@
|
|
1
|
-
import React
|
1
|
+
import React from 'react';
|
2
2
|
import PropTypes from 'prop-types';
|
3
3
|
import {
|
4
4
|
Icon,
|
5
5
|
Button,
|
6
6
|
MessageDialog,
|
7
|
+
Table,
|
8
|
+
FormControl,
|
9
|
+
inlineEditFormatterFactory,
|
7
10
|
} from 'patternfly-react';
|
8
11
|
import * as resolve from 'table-resolver';
|
12
|
+
import $ from 'jquery';
|
9
13
|
import ForemanModal from 'foremanReact/components/ForemanModal';
|
10
|
-
import {
|
11
|
-
sprintf,
|
12
|
-
translate as __
|
13
|
-
} from 'foremanReact/common/I18n';
|
14
|
+
import { sprintf, translate as __ } from 'foremanReact/common/I18n';
|
14
15
|
import Select from 'foremanReact/components/common/forms/Select';
|
15
16
|
import ParameterSelection from '../ParameterSelection';
|
16
17
|
import ExistingHostSelection from '../ExistingHostSelection';
|
@@ -19,14 +20,7 @@ import DeleteTableEntry from '../common/DeleteTableEntry';
|
|
19
20
|
import RailsData from '../common/RailsData';
|
20
21
|
import AppDefinitionSelector from './components/AppDefinitionSelector';
|
21
22
|
import ServiceCounter from './components/ServiceCounter';
|
22
|
-
import { arrayToObject } from '../../helper';
|
23
|
-
import { EasyHeaderFormatter } from '../../helper';
|
24
|
-
|
25
|
-
import {
|
26
|
-
Table,
|
27
|
-
FormControl,
|
28
|
-
inlineEditFormatterFactory,
|
29
|
-
} from 'patternfly-react';
|
23
|
+
import { arrayToObject, EasyHeaderFormatter } from '../../helper';
|
30
24
|
|
31
25
|
import {
|
32
26
|
PARAMETER_SELECTION_PARAM_TYPE_FOREMAN,
|
@@ -34,67 +28,84 @@ import {
|
|
34
28
|
} from '../ParameterSelection/ParameterSelectionConstants';
|
35
29
|
|
36
30
|
class ApplicationInstance extends React.Component {
|
37
|
-
|
38
|
-
|
39
|
-
super(props);
|
40
|
-
}
|
41
|
-
|
42
|
-
isEditing({rowData}) {
|
43
|
-
return (rowData.backup !== undefined);
|
31
|
+
static isEditing({ rowData }) {
|
32
|
+
return rowData.backup !== undefined;
|
44
33
|
}
|
45
34
|
|
46
35
|
changeDataAllowed() {
|
47
|
-
return this.props.editMode || this.props.appDefinition.id
|
36
|
+
return this.props.editMode || this.props.appDefinition.id === '';
|
48
37
|
}
|
49
38
|
|
50
39
|
validateParameters() {
|
51
40
|
let result = true;
|
52
|
-
let msg =
|
41
|
+
let msg = '';
|
53
42
|
|
54
43
|
this.props.hosts.forEach(h => {
|
55
|
-
if (
|
44
|
+
if (
|
45
|
+
h.foremanParameters.map(e => e.value).filter(i => i === '').length > 0
|
46
|
+
) {
|
56
47
|
result = false;
|
57
48
|
|
58
|
-
if (msg
|
59
|
-
msg += __(
|
49
|
+
if (msg === '') {
|
50
|
+
msg += __(
|
51
|
+
'For some hosts the values for some parameters are missing. Check the values for these hosts:\n'
|
52
|
+
);
|
60
53
|
}
|
61
|
-
msg +=
|
54
|
+
msg += `- ${h.hostname}\n`;
|
62
55
|
}
|
63
56
|
});
|
64
57
|
|
65
|
-
const invalidMinServices = this.props.services.filter(
|
66
|
-
|
58
|
+
const invalidMinServices = this.props.services.filter(
|
59
|
+
s => Number(s.minCount) !== 0 && s.currentCount < s.minCount
|
60
|
+
);
|
61
|
+
const invalidMaxServices = this.props.services.filter(
|
62
|
+
s => Number(s.maxCount) !== 0 && s.currentCount > s.maxCount
|
63
|
+
);
|
67
64
|
|
68
65
|
if (invalidMinServices.length > 0 || invalidMaxServices.length > 0) {
|
69
66
|
result = false;
|
70
67
|
|
71
|
-
if (msg
|
72
|
-
msg +=
|
68
|
+
if (msg !== '') {
|
69
|
+
msg += '\n';
|
73
70
|
}
|
74
71
|
|
75
|
-
msg += __(
|
76
|
-
msg +=
|
77
|
-
|
78
|
-
invalidMinServices.
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
72
|
+
msg += __('Unachieved service counts:');
|
73
|
+
msg += '\n';
|
74
|
+
|
75
|
+
invalidMinServices.forEach(s => {
|
76
|
+
msg += sprintf(
|
77
|
+
__(
|
78
|
+
`- service ${s.name} expects at ${s.minCount} least configured hosts\n`
|
79
|
+
)
|
80
|
+
);
|
81
|
+
});
|
82
|
+
|
83
|
+
invalidMaxServices.forEach(s => {
|
84
|
+
msg += sprintf(
|
85
|
+
__(
|
86
|
+
`- service ${s.name} expects no more than ${s.axCount} configured hosts\n`
|
87
|
+
)
|
88
|
+
);
|
89
|
+
});
|
85
90
|
}
|
86
91
|
|
87
92
|
return {
|
88
93
|
validateResult: result,
|
89
|
-
validateMsg: msg
|
90
|
-
}
|
94
|
+
validateMsg: msg,
|
95
|
+
};
|
91
96
|
}
|
92
97
|
|
93
98
|
componentDidMount() {
|
94
99
|
const {
|
95
|
-
data: {
|
100
|
+
data: {
|
101
|
+
mode,
|
102
|
+
appDefinition,
|
103
|
+
hosts,
|
104
|
+
ansibleVarsAll,
|
105
|
+
appDefinitionUrl,
|
106
|
+
supportedPlugins,
|
107
|
+
},
|
96
108
|
initApplicationInstance,
|
97
|
-
addApplicationInstanceHost,
|
98
109
|
deleteApplicationInstanceHost,
|
99
110
|
activateEditApplicationInstanceHost,
|
100
111
|
changeEditApplicationInstanceHost,
|
@@ -107,36 +118,47 @@ class ApplicationInstance extends React.Component {
|
|
107
118
|
loadApplicationDefinition(appDefinition.id, { url: appDefinitionUrl });
|
108
119
|
}
|
109
120
|
|
110
|
-
const
|
121
|
+
const alreadyDeployedMsg = __(
|
122
|
+
'This is an already deployed host. Changing the parameters is not possible!'
|
123
|
+
);
|
111
124
|
|
112
125
|
const inlineEditButtonsFormatter = inlineEditFormatterFactory({
|
113
126
|
isEditing: additionalData => this.props.editMode,
|
114
127
|
renderValue: (value, additionalData) => (
|
115
128
|
<td style={{ padding: '2px' }}>
|
116
|
-
{
|
117
|
-
<Icon
|
118
|
-
|
129
|
+
{additionalData.rowData.isExistingHost === true ? (
|
130
|
+
<Icon
|
131
|
+
style={{ marginRight: 8, marginLeft: 2 }}
|
132
|
+
type="pf"
|
133
|
+
name="info"
|
134
|
+
title={alreadyDeployedMsg}
|
135
|
+
/>
|
136
|
+
) : (
|
137
|
+
<span />
|
138
|
+
)}
|
119
139
|
<Button
|
120
140
|
bsStyle="default"
|
121
141
|
onClick={() => activateEditApplicationInstanceHost(additionalData)}
|
122
142
|
>
|
123
|
-
<Icon type="pf" name="edit" title={__(
|
143
|
+
<Icon type="pf" name="edit" title={__('Edit entry')} />
|
124
144
|
</Button>
|
125
145
|
|
126
|
-
{
|
146
|
+
{additionalData.rowData.isExistingHost === false ? (
|
127
147
|
<Button
|
128
148
|
bsStyle="default"
|
129
149
|
onClick={() => openForemanParameterSelectionModal(additionalData)}
|
130
150
|
>
|
131
|
-
<Icon type="pf" name="settings" title={__(
|
151
|
+
<Icon type="pf" name="settings" title={__('Change parameters')} />
|
132
152
|
</Button>
|
133
|
-
) : (
|
153
|
+
) : (
|
154
|
+
<span />
|
155
|
+
)}
|
134
156
|
|
135
157
|
<Button
|
136
158
|
bsStyle="default"
|
137
159
|
onClick={() => openAnsibleParameterSelectionModal(additionalData)}
|
138
160
|
>
|
139
|
-
<span title={__(
|
161
|
+
<span title={__('Change ansible variables')}>A</span>
|
140
162
|
</Button>
|
141
163
|
|
142
164
|
<DeleteTableEntry
|
@@ -149,18 +171,27 @@ class ApplicationInstance extends React.Component {
|
|
149
171
|
),
|
150
172
|
renderEdit: (value, additionalData) => (
|
151
173
|
<td style={{ padding: '2px' }}>
|
152
|
-
{
|
153
|
-
<Icon
|
154
|
-
|
174
|
+
{additionalData.rowData.isExistingHost === true ? (
|
175
|
+
<Icon
|
176
|
+
style={{ marginRight: 8, marginLeft: 2 }}
|
177
|
+
type="pf"
|
178
|
+
name="info"
|
179
|
+
title={alreadyDeployedMsg}
|
180
|
+
/>
|
181
|
+
) : (
|
182
|
+
<span />
|
183
|
+
)}
|
155
184
|
<Button bsStyle="default" disabled>
|
156
|
-
<Icon type="pf" name={__(
|
185
|
+
<Icon type="pf" name={__('edit')} />
|
157
186
|
</Button>
|
158
187
|
|
159
|
-
{
|
188
|
+
{additionalData.rowData.isExistingHost === false ? (
|
160
189
|
<Button bsStyle="default" disabled>
|
161
|
-
<Icon type="pf" name={__(
|
190
|
+
<Icon type="pf" name={__('settings')} />
|
162
191
|
</Button>
|
163
|
-
) : (
|
192
|
+
) : (
|
193
|
+
<span />
|
194
|
+
)}
|
164
195
|
|
165
196
|
<Button bsStyle="default" disabled>
|
166
197
|
<span>A</span>
|
@@ -168,12 +199,12 @@ class ApplicationInstance extends React.Component {
|
|
168
199
|
|
169
200
|
<DeleteTableEntry
|
170
201
|
hidden={false}
|
171
|
-
disabled
|
202
|
+
disabled
|
172
203
|
onDeleteTableEntry={deleteApplicationInstanceHost}
|
173
204
|
additionalData={additionalData}
|
174
205
|
/>
|
175
206
|
</td>
|
176
|
-
)
|
207
|
+
),
|
177
208
|
});
|
178
209
|
this.inlineEditButtonsFormatter = inlineEditButtonsFormatter;
|
179
210
|
|
@@ -185,12 +216,14 @@ class ApplicationInstance extends React.Component {
|
|
185
216
|
<span className="static">{value}</span>
|
186
217
|
</td>
|
187
218
|
),
|
188
|
-
renderEditText: (value, additionalData, subtype='text') => (
|
219
|
+
renderEditText: (value, additionalData, subtype = 'text') => (
|
189
220
|
<td className="editing">
|
190
221
|
<FormControl
|
191
222
|
type={subtype}
|
192
223
|
defaultValue={value}
|
193
|
-
onBlur={e =>
|
224
|
+
onBlur={e =>
|
225
|
+
changeEditApplicationInstanceHost(e.target.value, additionalData)
|
226
|
+
}
|
194
227
|
/>
|
195
228
|
</td>
|
196
229
|
),
|
@@ -198,45 +231,67 @@ class ApplicationInstance extends React.Component {
|
|
198
231
|
<td className="editing">
|
199
232
|
<Select
|
200
233
|
value={value.toString()}
|
201
|
-
onChange={e =>
|
234
|
+
onChange={e =>
|
235
|
+
changeEditApplicationInstanceHost(e.target.value, additionalData)
|
236
|
+
}
|
202
237
|
options={options}
|
203
238
|
allowClear
|
204
239
|
key="key"
|
205
240
|
/>
|
206
241
|
</td>
|
207
|
-
)
|
242
|
+
),
|
208
243
|
};
|
209
244
|
|
210
245
|
const inlineEditFormatter = inlineEditFormatterFactory({
|
211
|
-
isEditing: additionalData => this.isEditing(additionalData),
|
246
|
+
isEditing: additionalData => this.constructor.isEditing(additionalData),
|
212
247
|
renderValue: (value, additionalData) => {
|
213
248
|
let prettyValue = value;
|
214
|
-
if (additionalData.property
|
215
|
-
const serviceList = arrayToObject(this.props.services,
|
249
|
+
if (additionalData.property === 'service') {
|
250
|
+
const serviceList = arrayToObject(this.props.services, 'id', 'name');
|
216
251
|
prettyValue = serviceList[value];
|
217
252
|
}
|
218
|
-
return inlineEditFormatterImpl.renderValue(prettyValue, additionalData)
|
253
|
+
return inlineEditFormatterImpl.renderValue(prettyValue, additionalData);
|
219
254
|
},
|
220
255
|
renderEdit: (value, additionalData) => {
|
221
256
|
let prettyValue = value;
|
222
|
-
if (additionalData.property
|
223
|
-
const availableServices = this.props.services.filter(
|
224
|
-
|
257
|
+
if (additionalData.property === 'service') {
|
258
|
+
const availableServices = this.props.services.filter(
|
259
|
+
service =>
|
260
|
+
Number(service.maxCount) === 0 ||
|
261
|
+
service.currentCount < service.maxCount
|
262
|
+
);
|
263
|
+
const serviceList = arrayToObject(availableServices, 'id', 'name');
|
225
264
|
|
226
265
|
if (additionalData.rowData.newEntry === true) {
|
227
|
-
return inlineEditFormatterImpl.renderEditSelect(
|
266
|
+
return inlineEditFormatterImpl.renderEditSelect(
|
267
|
+
value,
|
268
|
+
additionalData,
|
269
|
+
serviceList
|
270
|
+
);
|
228
271
|
}
|
229
272
|
prettyValue = serviceList[value];
|
230
|
-
return inlineEditFormatterImpl.renderValue(
|
273
|
+
return inlineEditFormatterImpl.renderValue(
|
274
|
+
prettyValue,
|
275
|
+
additionalData
|
276
|
+
);
|
231
277
|
}
|
232
|
-
if (additionalData.property
|
278
|
+
if (additionalData.property === 'hostname') {
|
233
279
|
if (additionalData.rowData.newEntry === true) {
|
234
|
-
return inlineEditFormatterImpl.renderEditText(
|
280
|
+
return inlineEditFormatterImpl.renderEditText(
|
281
|
+
value,
|
282
|
+
additionalData
|
283
|
+
);
|
235
284
|
}
|
236
|
-
return inlineEditFormatterImpl.renderValue(
|
285
|
+
return inlineEditFormatterImpl.renderValue(
|
286
|
+
prettyValue,
|
287
|
+
additionalData
|
288
|
+
);
|
237
289
|
}
|
238
|
-
return inlineEditFormatterImpl.renderEditText(
|
239
|
-
|
290
|
+
return inlineEditFormatterImpl.renderEditText(
|
291
|
+
prettyValue,
|
292
|
+
additionalData
|
293
|
+
);
|
294
|
+
},
|
240
295
|
});
|
241
296
|
this.inlineEditFormatter = inlineEditFormatter;
|
242
297
|
|
@@ -247,14 +302,24 @@ class ApplicationInstance extends React.Component {
|
|
247
302
|
supportedPlugins,
|
248
303
|
this.headerFormatter,
|
249
304
|
this.inlineEditFormatter,
|
250
|
-
this.inlineEditButtonsFormatter
|
305
|
+
this.inlineEditButtonsFormatter
|
251
306
|
);
|
252
|
-
}
|
307
|
+
}
|
253
308
|
|
254
309
|
render() {
|
255
310
|
const {
|
256
|
-
data: {
|
257
|
-
|
311
|
+
data: {
|
312
|
+
mode,
|
313
|
+
applications,
|
314
|
+
organization,
|
315
|
+
location,
|
316
|
+
foremanDataUrl,
|
317
|
+
appDefinitionUrl,
|
318
|
+
},
|
319
|
+
showAlertModal,
|
320
|
+
alertModalText,
|
321
|
+
alertModalTitle,
|
322
|
+
closeAlertModal,
|
258
323
|
appDefinition,
|
259
324
|
services,
|
260
325
|
hosts,
|
@@ -272,13 +337,15 @@ class ApplicationInstance extends React.Component {
|
|
272
337
|
loadApplicationDefinition,
|
273
338
|
} = this.props;
|
274
339
|
|
275
|
-
|
340
|
+
const { validateResult, validateMsg } = this.validateParameters();
|
276
341
|
|
277
|
-
|
278
|
-
|
342
|
+
/* eslint-disable jquery/no-attr */
|
343
|
+
if (validateResult === false) {
|
344
|
+
$('input[type="submit"][name="commit"]').attr('disabled', true);
|
279
345
|
} else {
|
280
|
-
$('input[type="submit"][name="commit"]').attr(
|
346
|
+
$('input[type="submit"][name="commit"]').attr('disabled', false);
|
281
347
|
}
|
348
|
+
/* eslint-enable jquery/no-attr */
|
282
349
|
|
283
350
|
return (
|
284
351
|
<span>
|
@@ -287,7 +354,7 @@ class ApplicationInstance extends React.Component {
|
|
287
354
|
onHide={closeAlertModal}
|
288
355
|
primaryAction={closeAlertModal}
|
289
356
|
primaryActionButtonContent={__('OK')}
|
290
|
-
primaryActionButtonBsStyle=
|
357
|
+
primaryActionButtonBsStyle="danger"
|
291
358
|
icon={<Icon type="pf" name="error-circle-o" />}
|
292
359
|
title={alertModalTitle}
|
293
360
|
primaryContent={alertModalText}
|
@@ -295,26 +362,28 @@ class ApplicationInstance extends React.Component {
|
|
295
362
|
<div className="service-counter">
|
296
363
|
<ServiceCounter
|
297
364
|
title="Service counts"
|
298
|
-
serviceList={
|
299
|
-
hostList={
|
365
|
+
serviceList={services}
|
366
|
+
hostList={hosts}
|
300
367
|
/>
|
301
368
|
</div>
|
302
369
|
<div>
|
303
370
|
<AppDefinitionSelector
|
304
371
|
label="Application Definition"
|
305
|
-
hidden={
|
306
|
-
editable={
|
307
|
-
viewText={
|
308
|
-
options={
|
309
|
-
onChange={
|
310
|
-
selectValue={
|
311
|
-
additionalData={{url: appDefinitionUrl}}
|
372
|
+
hidden={false}
|
373
|
+
editable={mode === 'newInstance'}
|
374
|
+
viewText={appDefinition.name}
|
375
|
+
options={applications}
|
376
|
+
onChange={loadApplicationDefinition}
|
377
|
+
selectValue={appDefinition.id.toString()}
|
378
|
+
additionalData={{ url: appDefinitionUrl }}
|
312
379
|
/>
|
313
|
-
{appDefinition.id
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
380
|
+
{appDefinition.id === '' ? (
|
381
|
+
<div style={{ paddingTop: 25 }}>
|
382
|
+
<pre>App Definition can't be blank</pre>
|
383
|
+
</div>
|
384
|
+
) : (
|
385
|
+
<div />
|
386
|
+
)}
|
318
387
|
</div>
|
319
388
|
<div className="form-group">
|
320
389
|
<Table.PfProvider
|
@@ -327,8 +396,8 @@ class ApplicationInstance extends React.Component {
|
|
327
396
|
components={{
|
328
397
|
body: {
|
329
398
|
row: Table.InlineEditRow,
|
330
|
-
cell: cellProps => cellProps.children
|
331
|
-
}
|
399
|
+
cell: cellProps => cellProps.children,
|
400
|
+
},
|
332
401
|
}}
|
333
402
|
>
|
334
403
|
<Table.Header headerRows={resolve.headerRows({ columns })} />
|
@@ -337,38 +406,48 @@ class ApplicationInstance extends React.Component {
|
|
337
406
|
rowKey="id"
|
338
407
|
onRow={(rowData, { rowIndex }) => ({
|
339
408
|
role: 'row',
|
340
|
-
isEditing: () => this.isEditing({ rowData }),
|
341
|
-
onCancel: () =>
|
342
|
-
|
343
|
-
|
409
|
+
isEditing: () => this.constructor.isEditing({ rowData }),
|
410
|
+
onCancel: () =>
|
411
|
+
cancelEditApplicationInstanceHost({ rowData, rowIndex }),
|
412
|
+
onConfirm: () =>
|
413
|
+
confirmEditApplicationInstanceHost({
|
414
|
+
rowData,
|
415
|
+
rowIndex,
|
416
|
+
appDefinition,
|
417
|
+
}),
|
418
|
+
last: rowIndex === services.length - 1,
|
344
419
|
})}
|
345
420
|
/>
|
346
421
|
</Table.PfProvider>
|
347
422
|
<AddTableEntry
|
348
|
-
hidden={
|
349
|
-
disabled={
|
350
|
-
onAddTableEntry={
|
423
|
+
hidden={false}
|
424
|
+
disabled={this.changeDataAllowed()}
|
425
|
+
onAddTableEntry={addApplicationInstanceHost}
|
351
426
|
/>
|
352
427
|
<span style={{ marginLeft: 10 }}>
|
353
428
|
<Button
|
354
429
|
bsStyle="default"
|
355
|
-
disabled={
|
356
|
-
onClick={() =>
|
357
|
-
|
358
|
-
|
430
|
+
disabled={this.changeDataAllowed()}
|
431
|
+
onClick={() =>
|
432
|
+
openAddExistingHostsModal({
|
433
|
+
isAllGroup: true,
|
434
|
+
})
|
435
|
+
}
|
359
436
|
>
|
360
|
-
<Icon title={__(
|
437
|
+
<Icon title={__('Add existing hosts')} type="pf" name="server" />
|
361
438
|
</Button>
|
362
439
|
</span>
|
363
440
|
<span style={{ marginLeft: 30 }}>
|
364
|
-
Ansible group vars
|
441
|
+
Ansible group vars ‘all’:
|
365
442
|
<Button
|
366
443
|
style={{ marginLeft: 10 }}
|
367
444
|
bsStyle="default"
|
368
|
-
disabled={
|
369
|
-
onClick={() =>
|
370
|
-
|
371
|
-
|
445
|
+
disabled={this.changeDataAllowed()}
|
446
|
+
onClick={() =>
|
447
|
+
openAnsibleParameterSelectionModal({
|
448
|
+
isAllGroup: true,
|
449
|
+
})
|
450
|
+
}
|
372
451
|
>
|
373
452
|
<span title={__("Change ansible variables for 'all'")}>A</span>
|
374
453
|
</Button>
|
@@ -378,27 +457,48 @@ class ApplicationInstance extends React.Component {
|
|
378
457
|
<ForemanModal
|
379
458
|
id="AppInstanceForemanParamSelection"
|
380
459
|
dialogClassName="param_selection_modal"
|
381
|
-
title={__(
|
460
|
+
title={__(
|
461
|
+
'Foreman Parameter specification for Application Instance'
|
462
|
+
)}
|
382
463
|
>
|
383
464
|
<ForemanModal.Header closeButton={false}>
|
384
|
-
{__(
|
465
|
+
{__('Parameter specification')}
|
385
466
|
</ForemanModal.Header>
|
386
467
|
{this.props.parametersData ? (
|
387
468
|
<ParameterSelection
|
388
|
-
editModeCallback={
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
469
|
+
editModeCallback={hide =>
|
470
|
+
changeParameterSelectionMode({ mode: hide })
|
471
|
+
}
|
472
|
+
paramType={PARAMETER_SELECTION_PARAM_TYPE_FOREMAN}
|
473
|
+
hiddenParameterTypes={hiddenForemanParameterTypes}
|
474
|
+
location={location}
|
475
|
+
organization={organization}
|
476
|
+
paramDataUrl={foremanDataUrl}
|
477
|
+
data={this.props.parametersData}
|
395
478
|
/>
|
396
|
-
) : (
|
397
|
-
|
479
|
+
) : (
|
480
|
+
<span>Empty</span>
|
481
|
+
)}
|
398
482
|
<ForemanModal.Footer>
|
399
483
|
<div>
|
400
|
-
<Button
|
401
|
-
|
484
|
+
<Button
|
485
|
+
bsStyle="primary"
|
486
|
+
disabled={this.props.paramEditMode}
|
487
|
+
onClick={() =>
|
488
|
+
closeForemanParameterSelectionModal({ mode: 'save' })
|
489
|
+
}
|
490
|
+
>
|
491
|
+
{__('Save')}
|
492
|
+
</Button>
|
493
|
+
<Button
|
494
|
+
bsStyle="default"
|
495
|
+
disabled={this.props.paramEditMode}
|
496
|
+
onClick={() =>
|
497
|
+
closeForemanParameterSelectionModal({ mode: 'cancel' })
|
498
|
+
}
|
499
|
+
>
|
500
|
+
{__('Cancel')}
|
501
|
+
</Button>
|
402
502
|
</div>
|
403
503
|
</ForemanModal.Footer>
|
404
504
|
</ForemanModal>
|
@@ -407,25 +507,44 @@ class ApplicationInstance extends React.Component {
|
|
407
507
|
<ForemanModal
|
408
508
|
id="AppInstanceAnsibleParamSelection"
|
409
509
|
dialogClassName="param_selection_modal"
|
410
|
-
title={__(
|
510
|
+
title={__('Ansible group variables for Application Instance')}
|
411
511
|
>
|
412
512
|
<ForemanModal.Header closeButton={false}>
|
413
|
-
{__(
|
513
|
+
{__('Parameter specification')}
|
414
514
|
</ForemanModal.Header>
|
415
515
|
{this.props.parametersData ? (
|
416
516
|
<ParameterSelection
|
417
|
-
editModeCallback={
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
517
|
+
editModeCallback={hide =>
|
518
|
+
changeParameterSelectionMode({ mode: hide })
|
519
|
+
}
|
520
|
+
paramType={PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE}
|
521
|
+
location={location}
|
522
|
+
organization={organization}
|
523
|
+
data={this.props.parametersData}
|
422
524
|
/>
|
423
|
-
) : (
|
424
|
-
|
525
|
+
) : (
|
526
|
+
<span>Empty</span>
|
527
|
+
)}
|
425
528
|
<ForemanModal.Footer>
|
426
529
|
<div>
|
427
|
-
<Button
|
428
|
-
|
530
|
+
<Button
|
531
|
+
bsStyle="primary"
|
532
|
+
disabled={this.props.paramEditMode}
|
533
|
+
onClick={() =>
|
534
|
+
closeAnsibleParameterSelectionModal({ mode: 'save' })
|
535
|
+
}
|
536
|
+
>
|
537
|
+
{__('Save')}
|
538
|
+
</Button>
|
539
|
+
<Button
|
540
|
+
bsStyle="default"
|
541
|
+
disabled={this.props.paramEditMode}
|
542
|
+
onClick={() =>
|
543
|
+
closeAnsibleParameterSelectionModal({ mode: 'cancel' })
|
544
|
+
}
|
545
|
+
>
|
546
|
+
{__('Cancel')}
|
547
|
+
</Button>
|
429
548
|
</div>
|
430
549
|
</ForemanModal.Footer>
|
431
550
|
</ForemanModal>
|
@@ -434,92 +553,124 @@ class ApplicationInstance extends React.Component {
|
|
434
553
|
<ForemanModal
|
435
554
|
id="AppInstanceAddExistingHosts"
|
436
555
|
dialogClassName="add_existing_hosts_modal"
|
437
|
-
title={__(
|
556
|
+
title={__('Add existing hosts to an Application Instance')}
|
438
557
|
>
|
439
558
|
<ForemanModal.Header closeButton={false}>
|
440
|
-
{__(
|
559
|
+
{__('Existing hosts selection')}
|
441
560
|
</ForemanModal.Header>
|
442
561
|
<ExistingHostSelection
|
443
|
-
location={
|
444
|
-
organization={
|
445
|
-
services={
|
446
|
-
allHosts={
|
562
|
+
location={location}
|
563
|
+
organization={organization}
|
564
|
+
services={services}
|
565
|
+
allHosts={this.props.hosts}
|
447
566
|
/>
|
448
567
|
<ForemanModal.Footer>
|
449
568
|
<div>
|
450
|
-
<Button
|
451
|
-
|
569
|
+
<Button
|
570
|
+
bsStyle="primary"
|
571
|
+
disabled={this.props.paramEditMode}
|
572
|
+
onClick={() => closeAddExistingHostsModal({ mode: 'save' })}
|
573
|
+
>
|
574
|
+
{__('Save')}
|
575
|
+
</Button>
|
576
|
+
<Button
|
577
|
+
bsStyle="default"
|
578
|
+
disabled={this.props.paramEditMode}
|
579
|
+
onClick={() => closeAddExistingHostsModal({ mode: 'cancel' })}
|
580
|
+
>
|
581
|
+
{__('Cancel')}
|
582
|
+
</Button>
|
452
583
|
</div>
|
453
584
|
</ForemanModal.Footer>
|
454
585
|
</ForemanModal>
|
455
586
|
</div>
|
456
|
-
{validateResult
|
587
|
+
{validateResult === false ? (
|
457
588
|
<div style={{ paddingTop: 25 }}>
|
458
|
-
<pre>{
|
589
|
+
<pre>{validateMsg}</pre>
|
459
590
|
</div>
|
460
|
-
) : (
|
591
|
+
) : (
|
592
|
+
<div />
|
593
|
+
)}
|
461
594
|
<RailsData
|
462
|
-
key=
|
463
|
-
view=
|
464
|
-
parameter=
|
595
|
+
key="application_instance_hosts_data"
|
596
|
+
view="app_instance"
|
597
|
+
parameter="hosts"
|
465
598
|
value={JSON.stringify(this.props.hosts)}
|
466
599
|
/>
|
467
600
|
<RailsData
|
468
|
-
key=
|
469
|
-
view=
|
470
|
-
parameter=
|
601
|
+
key="application_instance_ansible_data"
|
602
|
+
view="app_instance"
|
603
|
+
parameter="ansible_vars_all"
|
471
604
|
value={JSON.stringify(this.props.ansibleVarsAll)}
|
472
605
|
/>
|
473
606
|
</span>
|
474
|
-
)
|
607
|
+
);
|
608
|
+
}
|
475
609
|
}
|
476
610
|
|
477
611
|
ApplicationInstance.defaultProps = {
|
478
|
-
error: {},
|
479
|
-
showAlertModal: false,
|
480
612
|
alertModalText: '',
|
481
613
|
alertModalTitle: '',
|
482
|
-
appDefinition: { "id": '', "name": '' },
|
483
|
-
editMode: false,
|
484
|
-
services: [],
|
485
|
-
hosts: [],
|
486
614
|
ansibleVarsAll: [],
|
487
|
-
|
615
|
+
appDefinition: { id: '', name: '' },
|
488
616
|
columns: [],
|
617
|
+
data: {
|
618
|
+
appDefinitionUrl: '',
|
619
|
+
appDefinition: undefined,
|
620
|
+
applications: undefined,
|
621
|
+
foremanDataUrl: '',
|
622
|
+
supportedPlugins: {},
|
623
|
+
},
|
624
|
+
editMode: false,
|
489
625
|
hiddenForemanParameterTypes: [],
|
490
|
-
|
626
|
+
hosts: [],
|
627
|
+
parametersData: {},
|
491
628
|
paramEditMode: false,
|
492
|
-
|
629
|
+
services: [],
|
630
|
+
showAlertModal: false,
|
631
|
+
};
|
493
632
|
|
494
633
|
ApplicationInstance.propTypes = {
|
495
|
-
initApplicationInstance: PropTypes.func,
|
496
|
-
showAlertModal: PropTypes.bool,
|
497
634
|
alertModalText: PropTypes.string,
|
498
635
|
alertModalTitle: PropTypes.string,
|
499
|
-
|
500
|
-
services: PropTypes.array,
|
636
|
+
ansibleVarsAll: PropTypes.array,
|
501
637
|
appDefinition: PropTypes.object,
|
502
638
|
columns: PropTypes.array,
|
639
|
+
data: PropTypes.shape({
|
640
|
+
appDefinitionUrl: PropTypes.string,
|
641
|
+
ansibleVarsAll: PropTypes.array.isRequired,
|
642
|
+
appDefinition: PropTypes.object,
|
643
|
+
applications: PropTypes.object,
|
644
|
+
foremanDataUrl: PropTypes.string,
|
645
|
+
hosts: PropTypes.array.isRequired,
|
646
|
+
location: PropTypes.string.isRequired,
|
647
|
+
mode: PropTypes.string.isRequired,
|
648
|
+
organization: PropTypes.string.isRequired,
|
649
|
+
supportedPlugins: PropTypes.object,
|
650
|
+
}),
|
651
|
+
editMode: PropTypes.bool,
|
503
652
|
hiddenForemanParameterTypes: PropTypes.array,
|
504
653
|
hosts: PropTypes.array,
|
505
|
-
ansibleVarsAll: PropTypes.array,
|
506
|
-
closeAlertModal: PropTypes.func,
|
507
|
-
loadApplicationDefinition: PropTypes.func,
|
508
|
-
addApplicationInstanceHost: PropTypes.func,
|
509
|
-
deleteApplicationInstanceHost: PropTypes.func,
|
510
|
-
activateEditApplicationInstanceHost: PropTypes.func,
|
511
|
-
confirmEditApplicationInstanceHost: PropTypes.func,
|
512
|
-
cancelEditApplicationInstanceHost: PropTypes.func,
|
513
|
-
changeEditApplicationInstanceHost: PropTypes.func,
|
514
|
-
openForemanParameterSelectionModal: PropTypes.func,
|
515
|
-
closeForemanParameterSelectionModal: PropTypes.func,
|
516
|
-
openAnsibleParameterSelectionModal: PropTypes.func,
|
517
|
-
closeAnsibleParameterSelectionModal: PropTypes.func,
|
518
|
-
openAddExistingHostsModal: PropTypes.func,
|
519
|
-
closeAddExistingHostsModal: PropTypes.func,
|
520
|
-
changeParameterSelectionMode: PropTypes.func,
|
521
654
|
parametersData: PropTypes.object,
|
522
655
|
paramEditMode: PropTypes.bool,
|
656
|
+
services: PropTypes.array,
|
657
|
+
showAlertModal: PropTypes.bool,
|
658
|
+
activateEditApplicationInstanceHost: PropTypes.func.isRequired,
|
659
|
+
addApplicationInstanceHost: PropTypes.func.isRequired,
|
660
|
+
cancelEditApplicationInstanceHost: PropTypes.func.isRequired,
|
661
|
+
changeEditApplicationInstanceHost: PropTypes.func.isRequired,
|
662
|
+
changeParameterSelectionMode: PropTypes.func.isRequired,
|
663
|
+
closeAddExistingHostsModal: PropTypes.func.isRequired,
|
664
|
+
closeAlertModal: PropTypes.func.isRequired,
|
665
|
+
closeAnsibleParameterSelectionModal: PropTypes.func.isRequired,
|
666
|
+
closeForemanParameterSelectionModal: PropTypes.func.isRequired,
|
667
|
+
confirmEditApplicationInstanceHost: PropTypes.func.isRequired,
|
668
|
+
deleteApplicationInstanceHost: PropTypes.func.isRequired,
|
669
|
+
initApplicationInstance: PropTypes.func.isRequired,
|
670
|
+
loadApplicationDefinition: PropTypes.func.isRequired,
|
671
|
+
openForemanParameterSelectionModal: PropTypes.func.isRequired,
|
672
|
+
openAnsibleParameterSelectionModal: PropTypes.func.isRequired,
|
673
|
+
openAddExistingHostsModal: PropTypes.func.isRequired,
|
523
674
|
};
|
524
675
|
|
525
676
|
export default ApplicationInstance;
|