foreman_acd 0.9.7 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -19
- data/app/controllers/ui_acd_controller.rb +1 -1
- data/db/migrate/20210503122809_add_git_url_to_ansible_playbooks.rb +1 -1
- data/lib/foreman_acd/engine.rb +4 -10
- data/lib/foreman_acd/plugin.rb +1 -1
- data/lib/foreman_acd/version.rb +1 -1
- data/package.json +5 -3
- data/test/controllers/ui_acd_controller_test.rb +1 -1
- 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 +16 -14
- 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,50 +1,43 @@
|
|
1
|
-
import
|
2
|
-
import React, { useState } from 'react'
|
1
|
+
import React from 'react';
|
3
2
|
import PropTypes from 'prop-types';
|
4
3
|
import {
|
5
4
|
Icon,
|
6
5
|
Button,
|
7
6
|
MessageDialog,
|
7
|
+
Table,
|
8
|
+
FormControl,
|
9
|
+
inlineEditFormatterFactory,
|
8
10
|
} from 'patternfly-react';
|
9
11
|
import * as resolve from 'table-resolver';
|
10
12
|
import ForemanModal from 'foremanReact/components/ForemanModal';
|
11
13
|
import Select from 'foremanReact/components/common/forms/Select';
|
14
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
12
15
|
import ParameterSelection from '../ParameterSelection';
|
13
16
|
import AddTableEntry from '../common/AddTableEntry';
|
14
17
|
import DeleteTableEntry from '../common/DeleteTableEntry';
|
15
18
|
import RailsData from '../common/RailsData';
|
16
19
|
import AnsiblePlaybookSelector from './components/AnsiblePlaybookSelector';
|
17
|
-
import { translate as __ } from 'foremanReact/common/I18n';
|
18
20
|
import { EasyHeaderFormatter } from '../../helper';
|
19
21
|
|
20
|
-
import {
|
21
|
-
Table,
|
22
|
-
FormControl,
|
23
|
-
inlineEditFormatterFactory,
|
24
|
-
} from 'patternfly-react';
|
25
|
-
|
26
22
|
import {
|
27
23
|
PARAMETER_SELECTION_PARAM_TYPE_FOREMAN,
|
28
24
|
PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE,
|
29
25
|
} from '../ParameterSelection/ParameterSelectionConstants';
|
30
26
|
|
31
27
|
class ApplicationDefinition extends React.Component {
|
32
|
-
|
33
|
-
|
34
|
-
super(props);
|
35
|
-
}
|
36
|
-
|
37
|
-
isEditing({rowData}) {
|
38
|
-
return (rowData.backup !== undefined);
|
28
|
+
static isEditing({ rowData }) {
|
29
|
+
return rowData.backup !== undefined;
|
39
30
|
}
|
40
31
|
|
41
|
-
createAnsibleGroupObject(ansibleGroups, withAll=false) {
|
32
|
+
static createAnsibleGroupObject(ansibleGroups, withAll = false) {
|
42
33
|
const ansibleGroupObj = {};
|
43
34
|
|
44
35
|
const ansibleGroupArray = Object.keys(ansibleGroups);
|
45
|
-
ansibleGroupArray.forEach(e =>
|
36
|
+
ansibleGroupArray.forEach(e => {
|
37
|
+
ansibleGroupObj[e] = e;
|
38
|
+
});
|
46
39
|
|
47
|
-
if (
|
40
|
+
if (withAll === false && ansibleGroupObj.hasOwnProperty('all')) {
|
48
41
|
delete ansibleGroupObj.all;
|
49
42
|
}
|
50
43
|
|
@@ -52,20 +45,24 @@ class ApplicationDefinition extends React.Component {
|
|
52
45
|
}
|
53
46
|
|
54
47
|
addTableEntryAllowed() {
|
55
|
-
return this.props.editMode || this.props.ansiblePlaybook.id
|
48
|
+
return this.props.editMode || this.props.ansiblePlaybook.id === '';
|
56
49
|
}
|
57
50
|
|
58
51
|
componentDidMount() {
|
59
52
|
const {
|
60
|
-
data: {
|
53
|
+
data: {
|
54
|
+
ansiblePlaybook,
|
55
|
+
services,
|
56
|
+
ansibleVarsAll,
|
57
|
+
hostgroups,
|
58
|
+
supportedPlugins,
|
59
|
+
},
|
61
60
|
initApplicationDefinition,
|
62
|
-
addApplicationDefinitionService,
|
63
61
|
deleteApplicationDefinitionService,
|
64
62
|
activateEditApplicationDefinitionService,
|
65
63
|
changeEditApplicationDefinitionService,
|
66
64
|
openForemanParameterSelectionModal,
|
67
65
|
openAnsibleParameterSelectionModal,
|
68
|
-
loadAnsibleData,
|
69
66
|
} = this.props;
|
70
67
|
|
71
68
|
const inlineEditButtonsFormatter = inlineEditFormatterFactory({
|
@@ -74,23 +71,25 @@ class ApplicationDefinition extends React.Component {
|
|
74
71
|
<td style={{ padding: '2px' }}>
|
75
72
|
<Button
|
76
73
|
bsStyle="default"
|
77
|
-
onClick={() =>
|
74
|
+
onClick={() =>
|
75
|
+
activateEditApplicationDefinitionService(additionalData)
|
76
|
+
}
|
78
77
|
>
|
79
|
-
<Icon type="pf" name="edit" title={__(
|
78
|
+
<Icon type="pf" name="edit" title={__('Edit entry')} />
|
80
79
|
</Button>
|
81
80
|
|
82
81
|
<Button
|
83
82
|
bsStyle="default"
|
84
83
|
onClick={() => openForemanParameterSelectionModal(additionalData)}
|
85
84
|
>
|
86
|
-
<Icon type="pf" name="settings" title={__(
|
85
|
+
<Icon type="pf" name="settings" title={__('Change parameters')} />
|
87
86
|
</Button>
|
88
87
|
|
89
88
|
<Button
|
90
89
|
bsStyle="default"
|
91
90
|
onClick={() => openAnsibleParameterSelectionModal(additionalData)}
|
92
91
|
>
|
93
|
-
<span title={__(
|
92
|
+
<span title={__('Change ansible variables')}>A</span>
|
94
93
|
</Button>
|
95
94
|
|
96
95
|
<DeleteTableEntry
|
@@ -104,26 +103,25 @@ class ApplicationDefinition extends React.Component {
|
|
104
103
|
renderEdit: (value, additionalData) => (
|
105
104
|
<td style={{ padding: '2px' }}>
|
106
105
|
<Button bsStyle="default" disabled>
|
107
|
-
<Icon type="pf" name={__(
|
106
|
+
<Icon type="pf" name={__('edit')} />
|
108
107
|
</Button>
|
109
108
|
|
110
109
|
<Button bsStyle="default" disabled>
|
111
|
-
<Icon type="pf" name={__(
|
110
|
+
<Icon type="pf" name={__('settings')} />
|
112
111
|
</Button>
|
113
112
|
|
114
|
-
<Button
|
115
|
-
bsStyle="default" disabled>
|
113
|
+
<Button bsStyle="default" disabled>
|
116
114
|
<span>A</span>
|
117
115
|
</Button>
|
118
116
|
|
119
117
|
<DeleteTableEntry
|
120
118
|
hidden={false}
|
121
|
-
disabled
|
119
|
+
disabled
|
122
120
|
onDeleteTableEntry={deleteApplicationDefinitionService}
|
123
121
|
additionalData={additionalData}
|
124
122
|
/>
|
125
123
|
</td>
|
126
|
-
)
|
124
|
+
),
|
127
125
|
});
|
128
126
|
this.inlineEditButtonsFormatter = inlineEditButtonsFormatter;
|
129
127
|
|
@@ -135,12 +133,17 @@ class ApplicationDefinition extends React.Component {
|
|
135
133
|
<span className="static">{value}</span>
|
136
134
|
</td>
|
137
135
|
),
|
138
|
-
renderEditText: (value, additionalData, subtype='text') => (
|
136
|
+
renderEditText: (value, additionalData, subtype = 'text') => (
|
139
137
|
<td className="editing">
|
140
138
|
<FormControl
|
141
139
|
type={subtype}
|
142
140
|
defaultValue={value}
|
143
|
-
onBlur={e =>
|
141
|
+
onBlur={e =>
|
142
|
+
changeEditApplicationDefinitionService(
|
143
|
+
e.target.value,
|
144
|
+
additionalData
|
145
|
+
)
|
146
|
+
}
|
144
147
|
/>
|
145
148
|
</td>
|
146
149
|
),
|
@@ -148,45 +151,63 @@ class ApplicationDefinition extends React.Component {
|
|
148
151
|
<td className="editing">
|
149
152
|
<Select
|
150
153
|
value={value.toString()}
|
151
|
-
onChange={e =>
|
154
|
+
onChange={e =>
|
155
|
+
changeEditApplicationDefinitionService(
|
156
|
+
e.target.value,
|
157
|
+
additionalData
|
158
|
+
)
|
159
|
+
}
|
152
160
|
options={options}
|
153
161
|
allowClear
|
154
162
|
key="key"
|
155
163
|
/>
|
156
164
|
</td>
|
157
|
-
)
|
165
|
+
),
|
158
166
|
};
|
159
167
|
|
160
168
|
const inlineEditFormatter = inlineEditFormatterFactory({
|
161
|
-
isEditing: additionalData => this.isEditing(additionalData),
|
169
|
+
isEditing: additionalData => this.constructor.isEditing(additionalData),
|
162
170
|
renderValue: (value, additionalData) => {
|
163
171
|
let prettyValue = value;
|
164
|
-
if (additionalData.property
|
172
|
+
if (additionalData.property === 'hostgroup') {
|
165
173
|
prettyValue = hostgroups[value];
|
166
|
-
}
|
167
|
-
|
168
|
-
|
174
|
+
} else if (additionalData.property === 'ansibleGroup') {
|
175
|
+
const ag = this.constructor.createAnsibleGroupObject(
|
176
|
+
this.props.ansiblePlaybook.groups
|
177
|
+
);
|
169
178
|
prettyValue = ag[value];
|
170
179
|
}
|
171
|
-
return inlineEditFormatterImpl.renderValue(prettyValue, additionalData)
|
180
|
+
return inlineEditFormatterImpl.renderValue(prettyValue, additionalData);
|
172
181
|
},
|
173
182
|
renderEdit: (value, additionalData) => {
|
174
|
-
if (additionalData.property
|
183
|
+
if (additionalData.property === 'hostgroup') {
|
175
184
|
if (additionalData.rowData.newEntry === true) {
|
176
|
-
return inlineEditFormatterImpl.renderEditSelect(
|
185
|
+
return inlineEditFormatterImpl.renderEditSelect(
|
186
|
+
value,
|
187
|
+
additionalData,
|
188
|
+
hostgroups
|
189
|
+
);
|
177
190
|
}
|
178
|
-
return inlineEditFormatterImpl.renderValue(
|
179
|
-
|
180
|
-
|
181
|
-
|
191
|
+
return inlineEditFormatterImpl.renderValue(
|
192
|
+
hostgroups[value],
|
193
|
+
additionalData
|
194
|
+
);
|
195
|
+
} else if (additionalData.property === 'ansibleGroup') {
|
196
|
+
const ag = this.constructor.createAnsibleGroupObject(
|
197
|
+
this.props.ansiblePlaybook.groups
|
198
|
+
);
|
182
199
|
|
183
200
|
if (additionalData.rowData.newEntry === true) {
|
184
|
-
return inlineEditFormatterImpl.renderEditSelect(
|
201
|
+
return inlineEditFormatterImpl.renderEditSelect(
|
202
|
+
value,
|
203
|
+
additionalData,
|
204
|
+
ag
|
205
|
+
);
|
185
206
|
}
|
186
207
|
return inlineEditFormatterImpl.renderValue(ag[value], additionalData);
|
187
208
|
}
|
188
209
|
return inlineEditFormatterImpl.renderEditText(value, additionalData);
|
189
|
-
}
|
210
|
+
},
|
190
211
|
});
|
191
212
|
this.inlineEditFormatter = inlineEditFormatter;
|
192
213
|
|
@@ -197,14 +218,24 @@ class ApplicationDefinition extends React.Component {
|
|
197
218
|
supportedPlugins,
|
198
219
|
this.headerFormatter,
|
199
220
|
this.inlineEditFormatter,
|
200
|
-
this.inlineEditButtonsFormatter
|
221
|
+
this.inlineEditButtonsFormatter
|
201
222
|
);
|
202
|
-
}
|
223
|
+
}
|
203
224
|
|
204
225
|
render() {
|
205
226
|
const {
|
206
|
-
data: {
|
207
|
-
|
227
|
+
data: {
|
228
|
+
organization,
|
229
|
+
location,
|
230
|
+
mode,
|
231
|
+
ansiblePlaybooks,
|
232
|
+
foremanDataUrl,
|
233
|
+
ansibleDataUrl,
|
234
|
+
},
|
235
|
+
showAlertModal,
|
236
|
+
alertModalText,
|
237
|
+
alertModalTitle,
|
238
|
+
closeAlertModal,
|
208
239
|
ansiblePlaybook,
|
209
240
|
services,
|
210
241
|
columns,
|
@@ -216,7 +247,6 @@ class ApplicationDefinition extends React.Component {
|
|
216
247
|
openAnsibleParameterSelectionModal,
|
217
248
|
closeAnsibleParameterSelectionModal,
|
218
249
|
changeParameterSelectionMode,
|
219
|
-
ParameterSelectionModal,
|
220
250
|
loadAnsibleData,
|
221
251
|
} = this.props;
|
222
252
|
|
@@ -227,7 +257,7 @@ class ApplicationDefinition extends React.Component {
|
|
227
257
|
onHide={closeAlertModal}
|
228
258
|
primaryAction={closeAlertModal}
|
229
259
|
primaryActionButtonContent={__('OK')}
|
230
|
-
primaryActionButtonBsStyle=
|
260
|
+
primaryActionButtonBsStyle="danger"
|
231
261
|
icon={<Icon type="pf" name="error-circle-o" />}
|
232
262
|
title={alertModalTitle}
|
233
263
|
primaryContent={alertModalText}
|
@@ -235,20 +265,21 @@ class ApplicationDefinition extends React.Component {
|
|
235
265
|
<div>
|
236
266
|
<AnsiblePlaybookSelector
|
237
267
|
label="Ansible Playbook"
|
238
|
-
hidden={
|
239
|
-
editable={
|
240
|
-
viewText={
|
241
|
-
options={
|
242
|
-
onChange={
|
243
|
-
selectValue={
|
244
|
-
additionalData={{url: ansibleDataUrl }}
|
268
|
+
hidden={false}
|
269
|
+
editable={mode === 'newDefinition'}
|
270
|
+
viewText={ansiblePlaybook.name}
|
271
|
+
options={ansiblePlaybooks}
|
272
|
+
onChange={loadAnsibleData}
|
273
|
+
selectValue={ansiblePlaybook.id.toString()}
|
274
|
+
additionalData={{ url: ansibleDataUrl }}
|
245
275
|
/>
|
246
|
-
{ansiblePlaybook.id
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
276
|
+
{ansiblePlaybook.id === '' ? (
|
277
|
+
<div style={{ paddingTop: 25 }}>
|
278
|
+
<pre>Ansible Playbook can't be blank</pre>
|
279
|
+
</div>
|
280
|
+
) : (
|
281
|
+
<div />
|
282
|
+
)}
|
252
283
|
</div>
|
253
284
|
<div className="form-group">
|
254
285
|
<Table.PfProvider
|
@@ -261,8 +292,8 @@ class ApplicationDefinition extends React.Component {
|
|
261
292
|
components={{
|
262
293
|
body: {
|
263
294
|
row: Table.InlineEditRow,
|
264
|
-
cell: cellProps => cellProps.children
|
265
|
-
}
|
295
|
+
cell: cellProps => cellProps.children,
|
296
|
+
},
|
266
297
|
}}
|
267
298
|
>
|
268
299
|
<Table.Header headerRows={resolve.headerRows({ columns })} />
|
@@ -271,27 +302,34 @@ class ApplicationDefinition extends React.Component {
|
|
271
302
|
rowKey="id"
|
272
303
|
onRow={(rowData, { rowIndex }) => ({
|
273
304
|
role: 'row',
|
274
|
-
isEditing: () => this.isEditing({ rowData }),
|
275
|
-
onCancel: () =>
|
276
|
-
|
277
|
-
|
305
|
+
isEditing: () => this.constructor.isEditing({ rowData }),
|
306
|
+
onCancel: () =>
|
307
|
+
cancelEditApplicationDefinitionService({ rowData, rowIndex }),
|
308
|
+
onConfirm: () =>
|
309
|
+
confirmEditApplicationDefinitionService({
|
310
|
+
rowData,
|
311
|
+
rowIndex,
|
312
|
+
}),
|
313
|
+
last: rowIndex === services.length - 1,
|
278
314
|
})}
|
279
315
|
/>
|
280
316
|
</Table.PfProvider>
|
281
317
|
<AddTableEntry
|
282
|
-
hidden={
|
283
|
-
disabled={
|
284
|
-
onAddTableEntry={
|
318
|
+
hidden={false}
|
319
|
+
disabled={this.addTableEntryAllowed()}
|
320
|
+
onAddTableEntry={addApplicationDefinitionService}
|
285
321
|
/>
|
286
322
|
<span style={{ marginLeft: 30 }}>
|
287
|
-
Ansible group vars
|
323
|
+
Ansible group vars 'all':
|
288
324
|
<Button
|
289
325
|
style={{ marginLeft: 10 }}
|
290
326
|
bsStyle="default"
|
291
|
-
disabled={
|
292
|
-
onClick={() =>
|
293
|
-
|
294
|
-
|
327
|
+
disabled={this.props.editMode}
|
328
|
+
onClick={() =>
|
329
|
+
openAnsibleParameterSelectionModal({
|
330
|
+
isAllGroup: true,
|
331
|
+
})
|
332
|
+
}
|
295
333
|
>
|
296
334
|
<span title={__("Change ansible variables for 'all'")}>A</span>
|
297
335
|
</Button>
|
@@ -301,27 +339,48 @@ class ApplicationDefinition extends React.Component {
|
|
301
339
|
<ForemanModal
|
302
340
|
id="AppDefinitionForemanParamSelection"
|
303
341
|
dialogClassName="param_selection_modal"
|
304
|
-
title={__(
|
342
|
+
title={__(
|
343
|
+
'Foreman Parameter definition for Application Definition'
|
344
|
+
)}
|
305
345
|
>
|
306
346
|
<ForemanModal.Header closeButton={false}>
|
307
347
|
Parameter definition
|
308
348
|
</ForemanModal.Header>
|
309
349
|
{this.props.parametersData ? (
|
310
350
|
<ParameterSelection
|
311
|
-
editModeCallback={
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
351
|
+
editModeCallback={hide =>
|
352
|
+
changeParameterSelectionMode({ mode: hide })
|
353
|
+
}
|
354
|
+
paramType={PARAMETER_SELECTION_PARAM_TYPE_FOREMAN}
|
355
|
+
hiddenParameterTypes={hiddenForemanParameterTypes}
|
356
|
+
location={location}
|
357
|
+
organization={organization}
|
358
|
+
paramDataUrl={foremanDataUrl}
|
359
|
+
data={this.props.parametersData}
|
318
360
|
/>
|
319
|
-
) : (
|
320
|
-
|
361
|
+
) : (
|
362
|
+
<span>Empty</span>
|
363
|
+
)}
|
321
364
|
<ForemanModal.Footer>
|
322
365
|
<div>
|
323
|
-
<Button
|
324
|
-
|
366
|
+
<Button
|
367
|
+
bsStyle="primary"
|
368
|
+
disabled={this.props.paramEditMode}
|
369
|
+
onClick={() =>
|
370
|
+
closeForemanParameterSelectionModal({ mode: 'save' })
|
371
|
+
}
|
372
|
+
>
|
373
|
+
{__('Save')}
|
374
|
+
</Button>
|
375
|
+
<Button
|
376
|
+
bsStyle="default"
|
377
|
+
disabled={this.props.paramEditMode}
|
378
|
+
onClick={() =>
|
379
|
+
closeForemanParameterSelectionModal({ mode: 'cancel' })
|
380
|
+
}
|
381
|
+
>
|
382
|
+
{__('Cancel')}
|
383
|
+
</Button>
|
325
384
|
</div>
|
326
385
|
</ForemanModal.Footer>
|
327
386
|
</ForemanModal>
|
@@ -330,74 +389,104 @@ class ApplicationDefinition extends React.Component {
|
|
330
389
|
<ForemanModal
|
331
390
|
id="AppDefinitionAnsibleParamSelection"
|
332
391
|
dialogClassName="param_selection_modal"
|
333
|
-
title={__(
|
392
|
+
title={__('Ansible variables for Application Definition')}
|
334
393
|
>
|
335
394
|
<ForemanModal.Header closeButton={false}>
|
336
395
|
Parameter definition
|
337
396
|
</ForemanModal.Header>
|
338
397
|
{this.props.parametersData ? (
|
339
398
|
<ParameterSelection
|
340
|
-
editModeCallback={
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
399
|
+
editModeCallback={hide =>
|
400
|
+
changeParameterSelectionMode({ mode: hide })
|
401
|
+
}
|
402
|
+
paramType={PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE}
|
403
|
+
location={location}
|
404
|
+
organization={organization}
|
405
|
+
data={this.props.parametersData}
|
345
406
|
/>
|
346
|
-
) : (
|
347
|
-
|
407
|
+
) : (
|
408
|
+
<span>Empty</span>
|
409
|
+
)}
|
348
410
|
<ForemanModal.Footer>
|
349
411
|
<div>
|
350
|
-
<Button
|
351
|
-
|
412
|
+
<Button
|
413
|
+
bsStyle="primary"
|
414
|
+
disabled={this.props.paramEditMode}
|
415
|
+
onClick={() =>
|
416
|
+
closeAnsibleParameterSelectionModal({ mode: 'save' })
|
417
|
+
}
|
418
|
+
>
|
419
|
+
{__('Save')}
|
420
|
+
</Button>
|
421
|
+
<Button
|
422
|
+
bsStyle="default"
|
423
|
+
disabled={this.props.paramEditMode}
|
424
|
+
onClick={() =>
|
425
|
+
closeAnsibleParameterSelectionModal({ mode: 'cancel' })
|
426
|
+
}
|
427
|
+
>
|
428
|
+
{__('Cancel')}
|
429
|
+
</Button>
|
352
430
|
</div>
|
353
431
|
</ForemanModal.Footer>
|
354
432
|
</ForemanModal>
|
355
433
|
</div>
|
356
434
|
<RailsData
|
357
|
-
key=
|
358
|
-
view=
|
359
|
-
parameter=
|
435
|
+
key="application_definition_services_data"
|
436
|
+
view="app_definition"
|
437
|
+
parameter="services"
|
360
438
|
value={JSON.stringify(this.props.services)}
|
361
439
|
/>
|
362
440
|
<RailsData
|
363
|
-
key=
|
364
|
-
view=
|
365
|
-
parameter=
|
441
|
+
key="application_definition_ansible_data"
|
442
|
+
view="app_definition"
|
443
|
+
parameter="ansible_vars_all"
|
366
444
|
value={JSON.stringify(this.props.ansibleVarsAll)}
|
367
445
|
/>
|
368
446
|
</span>
|
369
|
-
)
|
447
|
+
);
|
448
|
+
}
|
370
449
|
}
|
371
450
|
|
372
451
|
ApplicationDefinition.defaultProps = {
|
373
|
-
error: {},
|
374
452
|
showAlertModal: false,
|
375
453
|
alertModalText: '',
|
376
454
|
alertModalTitle: '',
|
377
455
|
editMode: false,
|
378
|
-
ansiblePlaybook: {
|
456
|
+
ansiblePlaybook: { id: '', name: '' },
|
379
457
|
services: [],
|
380
458
|
ansibleVarsAll: [],
|
381
459
|
parametersData: {},
|
382
460
|
columns: [],
|
383
461
|
hiddenForemanParameterTypes: [],
|
384
|
-
editParamsOfRowId: null,
|
385
462
|
paramEditMode: false,
|
386
|
-
|
463
|
+
deleteApplicationDefinitionService: undefined,
|
464
|
+
activateEditApplicationDefinitionService: undefined,
|
465
|
+
confirmEditApplicationDefinitionService: undefined,
|
466
|
+
cancelEditApplicationDefinitionService: undefined,
|
467
|
+
changeEditApplicationDefinitionService: undefined,
|
468
|
+
openForemanParameterSelectionModal: undefined,
|
469
|
+
closeForemanParameterSelectionModal: undefined,
|
470
|
+
openAnsibleParameterSelectionModal: undefined,
|
471
|
+
closeAnsibleParameterSelectionModal: undefined,
|
472
|
+
changeParameterSelectionMode: undefined,
|
473
|
+
};
|
387
474
|
|
388
475
|
ApplicationDefinition.propTypes = {
|
389
|
-
|
476
|
+
data: PropTypes.object.isRequired,
|
477
|
+
loadAnsibleData: PropTypes.func.isRequired,
|
478
|
+
initApplicationDefinition: PropTypes.func.isRequired,
|
390
479
|
showAlertModal: PropTypes.bool,
|
391
480
|
alertModalText: PropTypes.string,
|
392
481
|
alertModalTitle: PropTypes.string,
|
393
|
-
editMode: PropTypes.bool
|
482
|
+
editMode: PropTypes.bool,
|
394
483
|
ansiblePlaybook: PropTypes.object,
|
395
484
|
services: PropTypes.array,
|
396
485
|
ansibleVarsAll: PropTypes.array,
|
397
486
|
columns: PropTypes.array,
|
398
487
|
hiddenForemanParameterTypes: PropTypes.array,
|
399
|
-
closeAlertModal: PropTypes.func,
|
400
|
-
addApplicationDefinitionService: PropTypes.func,
|
488
|
+
closeAlertModal: PropTypes.func.isRequired,
|
489
|
+
addApplicationDefinitionService: PropTypes.func.isRequired,
|
401
490
|
deleteApplicationDefinitionService: PropTypes.func,
|
402
491
|
activateEditApplicationDefinitionService: PropTypes.func,
|
403
492
|
confirmEditApplicationDefinitionService: PropTypes.func,
|