foreman_acd 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +122 -0
- data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +54 -0
- data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +54 -0
- data/app/controllers/foreman_acd/api/v2/app_playbooks_controller.rb +0 -0
- data/app/controllers/foreman_acd/app_definitions_controller.rb +7 -4
- data/app/controllers/foreman_acd/app_instances_controller.rb +33 -126
- data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +23 -0
- data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
- data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
- data/app/controllers/ui_acd_controller.rb +11 -3
- data/app/models/foreman_acd/ansible_playbook.rb +50 -0
- data/app/models/foreman_acd/app_definition.rb +2 -0
- data/app/models/foreman_acd/app_instance.rb +7 -0
- data/app/services/foreman_acd/app_configurator.rb +70 -0
- data/app/services/foreman_acd/app_deployer.rb +143 -0
- data/app/services/foreman_acd/inventory_creator.rb +67 -0
- data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +21 -0
- data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +3 -0
- data/app/views/foreman_acd/ansible_playbooks/index.html.erb +30 -0
- data/app/views/foreman_acd/ansible_playbooks/new.html.erb +3 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +3 -0
- data/app/views/foreman_acd/app_definitions/_form.html.erb +24 -10
- data/app/views/foreman_acd/app_definitions/edit.html.erb +5 -0
- data/app/views/foreman_acd/app_instances/_form.html.erb +7 -5
- data/app/views/foreman_acd/app_instances/index.html.erb +5 -1
- data/app/views/templates/job/run_acd_ansible_playbook.erb +49 -0
- data/app/views/ui_acd/ansible_data.json.rabl +6 -0
- data/app/views/ui_acd/app.json.rabl +6 -2
- data/app/views/ui_acd/app_definition.json.rabl +1 -1
- data/app/views/ui_acd/{fdata.json.rabl → foreman_data.json.rabl} +1 -1
- data/config/routes.rb +24 -1
- data/db/migrate/20200916091018_create_ansible_playbooks.rb +20 -0
- data/db/migrate/20200917120220_add_ansible_playbook_id.rb +14 -0
- data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +5 -0
- data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +5 -0
- data/db/seeds.d/75-job_templates.rb +8 -0
- data/lib/foreman_acd/engine.rb +3 -0
- data/lib/foreman_acd/plugin.rb +53 -2
- data/lib/foreman_acd/version.rb +1 -1
- data/package.json +1 -1
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +137 -22
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +95 -11
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +7 -2
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +26 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +117 -21
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +2 -0
- data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +49 -0
- data/webpack/components/ApplicationDefinition/index.js +4 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +92 -22
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +37 -8
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +4 -2
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +98 -26
- data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +2 -1
- data/webpack/components/ApplicationInstance/index.js +2 -0
- data/webpack/components/ParameterSelection/ParameterSelection.js +46 -37
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +49 -52
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +5 -3
- data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +0 -32
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +32 -16
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -2
- data/webpack/components/ParameterSelection/index.js +4 -4
- data/webpack/components/common/DeleteTableEntry.js +1 -1
- data/webpack/reducer.js +14 -11
- metadata +48 -3
@@ -22,8 +22,10 @@ import {
|
|
22
22
|
APPLICATION_INSTANCE_HOST_EDIT_CONFIRM,
|
23
23
|
APPLICATION_INSTANCE_HOST_EDIT_CHANGE,
|
24
24
|
APPLICATION_INSTANCE_HOST_EDIT_CANCEL,
|
25
|
-
|
26
|
-
|
25
|
+
APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN,
|
26
|
+
APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE,
|
27
|
+
APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN,
|
28
|
+
APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE,
|
27
29
|
APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_REQUEST,
|
28
30
|
APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_SUCCESS,
|
29
31
|
APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_FAILURE,
|
@@ -32,6 +34,7 @@ import {
|
|
32
34
|
export const initApplicationInstance = (
|
33
35
|
appDefinition,
|
34
36
|
hosts,
|
37
|
+
ansibleVarsAll,
|
35
38
|
headerFormatter,
|
36
39
|
inlineEditFormatter,
|
37
40
|
inlineEditButtonsFormatter,
|
@@ -107,6 +110,7 @@ export const initApplicationInstance = (
|
|
107
110
|
|
108
111
|
initialState.appDefinition = appDefinition;
|
109
112
|
initialState.hosts = hosts;
|
113
|
+
initialState.ansibleVarsAll = ansibleVarsAll;
|
110
114
|
|
111
115
|
dispatch({
|
112
116
|
type: APPLICATION_INSTANCE_INIT,
|
@@ -184,27 +188,52 @@ export const changeEditApplicationInstanceHost = (value, additionalData) => ({
|
|
184
188
|
},
|
185
189
|
});
|
186
190
|
|
187
|
-
export const
|
191
|
+
export const openForemanParameterSelectionModal = (additionalData) => dispatch => {
|
188
192
|
dispatch({
|
189
|
-
type:
|
193
|
+
type: APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN,
|
190
194
|
payload: {
|
191
195
|
...additionalData,
|
192
196
|
}
|
193
197
|
});
|
194
198
|
dispatch(
|
195
|
-
setModalOpen({ id: '
|
199
|
+
setModalOpen({ id: 'AppInstanceForemanParamSelection' })
|
196
200
|
);
|
197
201
|
}
|
198
202
|
|
199
|
-
export const
|
203
|
+
export const closeForemanParameterSelectionModal = (additionalData) => dispatch => {
|
200
204
|
dispatch({
|
201
|
-
type:
|
205
|
+
type: APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE,
|
202
206
|
payload: {
|
203
207
|
...additionalData,
|
204
208
|
}
|
205
209
|
});
|
206
210
|
|
207
211
|
dispatch(
|
208
|
-
setModalClosed({ id: '
|
212
|
+
setModalClosed({ id: 'AppInstanceForemanParamSelection' })
|
213
|
+
);
|
214
|
+
}
|
215
|
+
|
216
|
+
export const openAnsibleParameterSelectionModal = (additionalData) => dispatch => {
|
217
|
+
dispatch({
|
218
|
+
type: APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN,
|
219
|
+
payload: {
|
220
|
+
...additionalData,
|
221
|
+
}
|
222
|
+
});
|
223
|
+
dispatch(
|
224
|
+
setModalOpen({ id: 'AppInstanceAnsibleParamSelection' })
|
225
|
+
);
|
226
|
+
}
|
227
|
+
|
228
|
+
export const closeAnsibleParameterSelectionModal = (additionalData) => dispatch => {
|
229
|
+
dispatch({
|
230
|
+
type: APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE,
|
231
|
+
payload: {
|
232
|
+
...additionalData,
|
233
|
+
}
|
234
|
+
});
|
235
|
+
|
236
|
+
dispatch(
|
237
|
+
setModalClosed({ id: 'AppInstanceAnsibleParamSelection' })
|
209
238
|
);
|
210
239
|
}
|
@@ -8,5 +8,7 @@ export const APPLICATION_INSTANCE_HOST_EDIT_ACTIVATE = 'APPLICATION_INSTANCE_HOS
|
|
8
8
|
export const APPLICATION_INSTANCE_HOST_EDIT_CONFIRM = 'APPLICATION_INSTANCE_HOST_EDIT_CONFIRM';
|
9
9
|
export const APPLICATION_INSTANCE_HOST_EDIT_CHANGE = 'APPLICATION_INSTANCE_HOST_EDIT_CHANGE';
|
10
10
|
export const APPLICATION_INSTANCE_HOST_EDIT_CANCEL = 'APPLICATION_INSTANCE_HOST_EDIT_CANCEL';
|
11
|
-
export const
|
12
|
-
export const
|
11
|
+
export const APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN = 'APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN';
|
12
|
+
export const APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE = 'APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE';
|
13
|
+
export const APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN = 'APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN';
|
14
|
+
export const APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE = 'APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE';
|
@@ -17,10 +17,17 @@ import {
|
|
17
17
|
APPLICATION_INSTANCE_HOST_EDIT_CONFIRM,
|
18
18
|
APPLICATION_INSTANCE_HOST_EDIT_CHANGE,
|
19
19
|
APPLICATION_INSTANCE_HOST_EDIT_CANCEL,
|
20
|
-
|
21
|
-
|
20
|
+
APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN,
|
21
|
+
APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE,
|
22
|
+
APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN,
|
23
|
+
APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE,
|
22
24
|
} from './ApplicationInstanceConstants';
|
23
25
|
|
26
|
+
import {
|
27
|
+
PARAMETER_SELECTION_PARAM_TYPE_FOREMAN,
|
28
|
+
PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE,
|
29
|
+
} from '../ParameterSelection/ParameterSelectionConstants';
|
30
|
+
|
24
31
|
export const initialState = Immutable({
|
25
32
|
name: false,
|
26
33
|
error: { errorMsg: '', status: '', statusText: '' },
|
@@ -40,6 +47,7 @@ const applicationInstanceConf = (state = initialState, action) => {
|
|
40
47
|
return state.set('loading', true);
|
41
48
|
}
|
42
49
|
case APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_SUCCESS: {
|
50
|
+
let newState = {};
|
43
51
|
const services = JSON.parse(payload.app_definition.services);
|
44
52
|
|
45
53
|
// initialize all services count with 0
|
@@ -56,11 +64,18 @@ const applicationInstanceConf = (state = initialState, action) => {
|
|
56
64
|
});
|
57
65
|
}
|
58
66
|
|
59
|
-
|
67
|
+
newState = {
|
60
68
|
appDefinition: payload.app_definition,
|
61
69
|
services: services,
|
62
70
|
loading: false,
|
63
|
-
}
|
71
|
+
};
|
72
|
+
|
73
|
+
// Initialize ansibleVarsAll if there is no data available in app instance
|
74
|
+
if (state.ansibleVarsAll.length <= 0) {
|
75
|
+
newState['ansibleVarsAll'] = JSON.parse(payload.app_definition.ansible_vars_all);
|
76
|
+
}
|
77
|
+
|
78
|
+
return state.merge(newState);
|
64
79
|
}
|
65
80
|
case APPLICATION_INSTANCE_HOST_ADD: {
|
66
81
|
let hosts = [];
|
@@ -71,7 +86,7 @@ const applicationInstanceConf = (state = initialState, action) => {
|
|
71
86
|
index = Math.max(...hosts.map(e => e.id)) + 1;
|
72
87
|
}
|
73
88
|
|
74
|
-
const newRow = {id: index, hostname: "", description: '', service: '',
|
89
|
+
const newRow = {id: index, hostname: "", description: '', service: '', foremanParameters: [], ansibleParameters: [], newEntry: true };
|
75
90
|
newRow.backup = cloneDeep(newRow)
|
76
91
|
hosts.push(newRow);
|
77
92
|
|
@@ -131,7 +146,8 @@ const applicationInstanceConf = (state = initialState, action) => {
|
|
131
146
|
// Initialize the new Instance with the parameters of the Application Definition.
|
132
147
|
if (thisHost.newEntry === true) {
|
133
148
|
const selectedService = state.services.filter(entry => entry.id == payload.rowData.service)[0];
|
134
|
-
hosts[index].
|
149
|
+
hosts[index].foremanParameters = selectedService.foremanParameters;
|
150
|
+
hosts[index].ansibleParameters = selectedService.ansibleParameters;
|
135
151
|
|
136
152
|
const hostServiceId = Number(thisHost.service);
|
137
153
|
const service = services.find(serv => serv['id'] == hostServiceId);
|
@@ -175,35 +191,35 @@ const applicationInstanceConf = (state = initialState, action) => {
|
|
175
191
|
hosts: hosts
|
176
192
|
});
|
177
193
|
}
|
178
|
-
case
|
194
|
+
case APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN: {
|
179
195
|
let parametersData = {};
|
180
196
|
|
181
|
-
|
182
|
-
|
197
|
+
const selectedService = state.services.filter(entry => entry.id == payload.rowData.service)[0];
|
198
|
+
|
199
|
+
parametersData.paramDefinition = {
|
200
|
+
id: selectedService.id,
|
201
|
+
name: selectedService.name,
|
202
|
+
dataId: selectedService.hostgroup,
|
203
|
+
hostId: payload.rowData.id,
|
204
|
+
// TODO: is this really correct? Guess it shoud be dataId and we should get rid of them
|
205
|
+
//hostgroup_id: selectedService.hostgroup,
|
206
|
+
};
|
207
|
+
parametersData.type = PARAMETER_SELECTION_PARAM_TYPE_FOREMAN;
|
208
|
+
parametersData.parameters = payload.rowData.foremanParameters;
|
209
|
+
parametersData.useDefaultValue = false;
|
210
|
+
parametersData.allowRowAdjustment = false;
|
211
|
+
parametersData.allowNameAdjustment = false;
|
212
|
+
parametersData.allowDescriptionAdjustment = false;
|
183
213
|
|
184
|
-
parametersData.serviceDefinition = {
|
185
|
-
id: selectedService.id,
|
186
|
-
name: selectedService.name,
|
187
|
-
hostgroup_id: selectedService.hostgroup,
|
188
|
-
hostId: payload.rowData.id,
|
189
|
-
};
|
190
|
-
parametersData.parameters = payload.rowData.parameters;
|
191
|
-
|
192
|
-
if (parametersData.parameters.length > 0) {
|
193
|
-
parametersData.mode = 'editInstance';
|
194
|
-
} else {
|
195
|
-
parametersData.mode = 'newInstance';
|
196
|
-
}
|
197
|
-
}
|
198
214
|
return state.merge({
|
199
215
|
parametersData: parametersData,
|
200
216
|
});
|
201
217
|
}
|
202
|
-
case
|
218
|
+
case APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE: {
|
203
219
|
if (payload.mode == 'save') {
|
204
220
|
const hosts = cloneDeep(state.hosts);
|
205
|
-
const index = findIndex(hosts, { id: state.parametersData.
|
206
|
-
hosts[index].
|
221
|
+
const index = findIndex(hosts, { id: state.parametersData.paramDefinition.hostId });
|
222
|
+
hosts[index].foremanParameters = cloneDeep(payload.parameterSelection);
|
207
223
|
|
208
224
|
return state.merge({
|
209
225
|
parametersData: null,
|
@@ -215,6 +231,62 @@ const applicationInstanceConf = (state = initialState, action) => {
|
|
215
231
|
});
|
216
232
|
}
|
217
233
|
}
|
234
|
+
case APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN: {
|
235
|
+
let parametersData = {};
|
236
|
+
|
237
|
+
if ((payload.hasOwnProperty('isAllGroup')) && (payload.isAllGroup == true)) {
|
238
|
+
parametersData.parameters = state.ansibleVarsAll;
|
239
|
+
parametersData.paramDefinition = {
|
240
|
+
isAllGroup: true,
|
241
|
+
}
|
242
|
+
} else {
|
243
|
+
const selectedService = state.services.filter(entry => entry.id == payload.rowData.service)[0];
|
244
|
+
|
245
|
+
parametersData.paramDefinition = {
|
246
|
+
id: selectedService.id,
|
247
|
+
name: selectedService.name,
|
248
|
+
hostId: payload.rowData.id,
|
249
|
+
// TODO: is this really correct? Guess it shoud be dataId and we should get rid of them
|
250
|
+
//hostgroup_id: selectedService.hostgroup,
|
251
|
+
};
|
252
|
+
parametersData.parameters = payload.rowData.ansibleParameters;
|
253
|
+
}
|
254
|
+
|
255
|
+
parametersData.type = PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE;
|
256
|
+
parametersData.useDefaultValue = false;
|
257
|
+
parametersData.allowRowAdjustment = false;
|
258
|
+
parametersData.allowNameAdjustment = false;
|
259
|
+
parametersData.allowDescriptionAdjustment = false;
|
260
|
+
|
261
|
+
return state.merge({
|
262
|
+
parametersData: parametersData,
|
263
|
+
});
|
264
|
+
}
|
265
|
+
case APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE: {
|
266
|
+
let newState = {};
|
267
|
+
if (payload.mode == 'save') {
|
268
|
+
if ((state.parametersData.paramDefinition.hasOwnProperty('isAllGroup')) && (state.parametersData.paramDefinition.isAllGroup == true)) {
|
269
|
+
newState = {
|
270
|
+
parametersData: null,
|
271
|
+
ansibleVarsAll: cloneDeep(payload.parameterSelection),
|
272
|
+
};
|
273
|
+
} else {
|
274
|
+
const hosts = cloneDeep(state.hosts);
|
275
|
+
const index = findIndex(hosts, { id: state.parametersData.paramDefinition.hostId });
|
276
|
+
hosts[index].ansibleParameters = cloneDeep(payload.parameterSelection);
|
277
|
+
|
278
|
+
newState = {
|
279
|
+
parametersData: null,
|
280
|
+
hosts: hosts
|
281
|
+
};
|
282
|
+
}
|
283
|
+
} else {
|
284
|
+
newState = {
|
285
|
+
parametersData: null,
|
286
|
+
};
|
287
|
+
}
|
288
|
+
return state.merge(newState);
|
289
|
+
}
|
218
290
|
default:
|
219
291
|
return state;
|
220
292
|
}
|
@@ -4,5 +4,6 @@ export const selectEditMode = state => applicationInstanceConf(state).editMode;
|
|
4
4
|
export const selectAppDefinition = state => applicationInstanceConf(state).appDefinition;
|
5
5
|
export const selectHosts = state => applicationInstanceConf(state).hosts;
|
6
6
|
export const selectColumns = state => applicationInstanceConf(state).columns;
|
7
|
-
export const selectParametersData = state => applicationInstanceConf(state).parametersData;
|
8
7
|
export const selectServices = state => applicationInstanceConf(state).services;
|
8
|
+
export const selectParametersData = state => applicationInstanceConf(state).parametersData;
|
9
|
+
export const selectAnsibleVarsAll = state => applicationInstanceConf(state).ansibleVarsAll;
|
@@ -12,6 +12,7 @@ import {
|
|
12
12
|
selectServices,
|
13
13
|
selectColumns,
|
14
14
|
selectParametersData,
|
15
|
+
selectAnsibleVarsAll,
|
15
16
|
} from './ApplicationInstanceSelectors';
|
16
17
|
|
17
18
|
const mapStateToProps = state => ({
|
@@ -21,6 +22,7 @@ const mapStateToProps = state => ({
|
|
21
22
|
services: selectServices(state),
|
22
23
|
columns: selectColumns(state),
|
23
24
|
parametersData: selectParametersData(state),
|
25
|
+
ansibleVarsAll: selectAnsibleVarsAll(state),
|
24
26
|
});
|
25
27
|
|
26
28
|
const mapDispatchToProps = dispatch =>
|
@@ -10,12 +10,6 @@ import DeleteTableEntry from '../common/DeleteTableEntry';
|
|
10
10
|
import ExtSelect from '../common/ExtSelect';
|
11
11
|
|
12
12
|
import {
|
13
|
-
isNewDefinition,
|
14
|
-
isEditDefinition,
|
15
|
-
isDefinition,
|
16
|
-
isNewInstance,
|
17
|
-
isEditInstance,
|
18
|
-
isInstance,
|
19
13
|
transformForemanData,
|
20
14
|
} from './ParameterSelectionHelper';
|
21
15
|
|
@@ -27,6 +21,8 @@ import {
|
|
27
21
|
|
28
22
|
import {
|
29
23
|
PARAMETER_SELECTION_TYPES,
|
24
|
+
PARAMETER_SELECTION_PARAM_TYPE_FOREMAN,
|
25
|
+
PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE,
|
30
26
|
} from './ParameterSelectionConstants';
|
31
27
|
|
32
28
|
import {
|
@@ -60,19 +56,28 @@ class ParameterSelection extends React.Component {
|
|
60
56
|
|
61
57
|
componentDidMount() {
|
62
58
|
const {
|
63
|
-
data: {
|
59
|
+
data: { useDefaultValue, allowRowAdjustment, allowNameAdjustment, allowDescriptionAdjustment, parameters, paramDefinition },
|
64
60
|
location,
|
65
61
|
organization,
|
66
|
-
|
62
|
+
paramType,
|
63
|
+
paramDataUrl,
|
67
64
|
initParameterSelection,
|
68
65
|
sortParameter,
|
69
66
|
deleteParameter,
|
70
67
|
activateEditParameter,
|
71
68
|
changeEditParameter,
|
72
|
-
|
69
|
+
loadParamData,
|
73
70
|
} = this.props;
|
74
71
|
|
75
|
-
|
72
|
+
if (paramDataUrl !== undefined) {
|
73
|
+
switch (paramType) {
|
74
|
+
case PARAMETER_SELECTION_PARAM_TYPE_FOREMAN: {
|
75
|
+
loadParamData({ paramDefinition: paramDefinition, url: paramDataUrl, dataType: paramType, clearParameters: false });
|
76
|
+
break;
|
77
|
+
}
|
78
|
+
default: { }
|
79
|
+
}
|
80
|
+
}
|
76
81
|
|
77
82
|
const inlineEditButtonsFormatter = inlineEditFormatterFactory({
|
78
83
|
isEditing: additionalData => this.props.editMode,
|
@@ -85,7 +90,7 @@ class ParameterSelection extends React.Component {
|
|
85
90
|
<Icon type="pf" name="edit" />
|
86
91
|
</Button>
|
87
92
|
<DeleteTableEntry
|
88
|
-
hidden={
|
93
|
+
hidden={!allowRowAdjustment}
|
89
94
|
disabled={false}
|
90
95
|
onDeleteTableEntry={deleteParameter}
|
91
96
|
additionalData={additionalData}
|
@@ -98,7 +103,7 @@ class ParameterSelection extends React.Component {
|
|
98
103
|
<Icon type="pf" name="edit" />
|
99
104
|
</Button>
|
100
105
|
<DeleteTableEntry
|
101
|
-
hidden={
|
106
|
+
hidden={!allowRowAdjustment}
|
102
107
|
disabled={true}
|
103
108
|
onDeleteTableEntry={deleteParameter}
|
104
109
|
additionalData={additionalData}
|
@@ -152,6 +157,8 @@ class ParameterSelection extends React.Component {
|
|
152
157
|
),
|
153
158
|
};
|
154
159
|
|
160
|
+
// TODO: should we differentiate between paramType FOREMAN and ANSIBLE?
|
161
|
+
|
155
162
|
const inlineEditFormatter = inlineEditFormatterFactory({
|
156
163
|
isEditing: additionalData => this.isEditing(additionalData),
|
157
164
|
renderValue: (value, additionalData) => {
|
@@ -161,22 +168,25 @@ class ParameterSelection extends React.Component {
|
|
161
168
|
} else if (additionalData.property == 'value') {
|
162
169
|
switch (additionalData.rowData.type) {
|
163
170
|
case 'computeprofile':
|
164
|
-
prettyValue = transformForemanData(this.props.
|
171
|
+
prettyValue = transformForemanData(this.props.paramData['computeprofiles'])[value]
|
165
172
|
break;
|
166
173
|
case 'domain':
|
167
|
-
prettyValue = transformForemanData(this.props.
|
174
|
+
prettyValue = transformForemanData(this.props.paramData['domains'])[value]
|
168
175
|
break;
|
169
176
|
case 'lifecycleenv':
|
170
|
-
prettyValue = transformForemanData(this.props.
|
177
|
+
prettyValue = transformForemanData(this.props.paramData['lifecycle_environments'])[value]
|
171
178
|
break;
|
172
179
|
case 'ptable':
|
173
|
-
prettyValue = transformForemanData(this.props.
|
180
|
+
prettyValue = transformForemanData(this.props.paramData['ptables'])[value]
|
174
181
|
break;
|
175
182
|
case 'password':
|
176
183
|
prettyValue = '****************'
|
177
184
|
break;
|
178
185
|
case 'puppetenv':
|
179
|
-
prettyValue = transformForemanData(this.props.
|
186
|
+
prettyValue = transformForemanData(this.props.paramData['environments'])[value]
|
187
|
+
break;
|
188
|
+
case 'text':
|
189
|
+
prettyValue = value
|
180
190
|
break;
|
181
191
|
}
|
182
192
|
}
|
@@ -192,15 +202,15 @@ class ParameterSelection extends React.Component {
|
|
192
202
|
case 'value':
|
193
203
|
switch (additionalData.rowData.type) {
|
194
204
|
case 'computeprofile':
|
195
|
-
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.
|
205
|
+
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['computeprofiles']));
|
196
206
|
case 'domain':
|
197
|
-
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.
|
207
|
+
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['domains']));
|
198
208
|
case 'lifecycleenv':
|
199
|
-
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.
|
209
|
+
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['lifecycle_environments']));
|
200
210
|
case 'puppetenv':
|
201
|
-
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.
|
211
|
+
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['environments']));
|
202
212
|
case 'ptable':
|
203
|
-
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.
|
213
|
+
return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['ptables']));
|
204
214
|
case 'password':
|
205
215
|
return inlineEditFormatterImpl.renderEditText(value, additionalData, 'password');
|
206
216
|
case 'text':
|
@@ -215,9 +225,12 @@ class ParameterSelection extends React.Component {
|
|
215
225
|
this.inlineEditFormatter = inlineEditFormatter;
|
216
226
|
|
217
227
|
initParameterSelection(
|
218
|
-
|
219
|
-
|
228
|
+
paramType,
|
229
|
+
paramDefinition,
|
220
230
|
parameters,
|
231
|
+
useDefaultValue,
|
232
|
+
allowNameAdjustment,
|
233
|
+
allowDescriptionAdjustment,
|
221
234
|
this.sortingFormatter,
|
222
235
|
this.sortableTransform,
|
223
236
|
this.inlineEditFormatter,
|
@@ -230,10 +243,9 @@ class ParameterSelection extends React.Component {
|
|
230
243
|
|
231
244
|
render() {
|
232
245
|
const {
|
233
|
-
data: {
|
246
|
+
data: { allowRowAdjustment, applications },
|
234
247
|
location,
|
235
248
|
organization,
|
236
|
-
loadForemanDataUrl,
|
237
249
|
parameters,
|
238
250
|
columns,
|
239
251
|
sortingColumns,
|
@@ -241,8 +253,6 @@ class ParameterSelection extends React.Component {
|
|
241
253
|
addParameter,
|
242
254
|
confirmEditParameter,
|
243
255
|
cancelEditParameter,
|
244
|
-
loadForemanData,
|
245
|
-
serviceDefinition,
|
246
256
|
} = this.props;
|
247
257
|
|
248
258
|
let sortedParameters;
|
@@ -279,7 +289,7 @@ class ParameterSelection extends React.Component {
|
|
279
289
|
<div className="clearfix">
|
280
290
|
<div className="form-group">
|
281
291
|
<AddTableEntry
|
282
|
-
hidden={
|
292
|
+
hidden={!allowRowAdjustment}
|
283
293
|
disabled={ this.props.editMode }
|
284
294
|
onAddTableEntry={ addParameter }
|
285
295
|
/>
|
@@ -319,7 +329,7 @@ class ParameterSelection extends React.Component {
|
|
319
329
|
/>
|
320
330
|
</Table.PfProvider>
|
321
331
|
<AddTableEntry
|
322
|
-
hidden={
|
332
|
+
hidden={!allowRowAdjustment}
|
323
333
|
disabled={ this.props.editMode }
|
324
334
|
onAddTableEntry={ addParameter }
|
325
335
|
/>
|
@@ -334,7 +344,7 @@ ParameterSelection.defaultProps = {
|
|
334
344
|
error: {},
|
335
345
|
editMode: false,
|
336
346
|
loading: false,
|
337
|
-
|
347
|
+
paramData: {},
|
338
348
|
parameters: [],
|
339
349
|
columns: [],
|
340
350
|
sortingColumns: {},
|
@@ -342,18 +352,17 @@ ParameterSelection.defaultProps = {
|
|
342
352
|
|
343
353
|
ParameterSelection.propTypes = {
|
344
354
|
data: PropTypes.shape({
|
345
|
-
mode: PropTypes.string.isRequired,
|
346
355
|
parameters: PropTypes.array,
|
347
|
-
|
356
|
+
paramDefinition: PropTypes.object,
|
348
357
|
applications: PropTypes.object,
|
349
358
|
}).isRequired,
|
350
359
|
location: PropTypes.string.isRequired,
|
351
360
|
organization: PropTypes.string.isRequired,
|
352
|
-
|
361
|
+
paramDataUrl: PropTypes.string,
|
353
362
|
initParameterSelection: PropTypes.func,
|
354
363
|
editMode: PropTypes.bool.isRequired,
|
355
364
|
loading: PropTypes.bool.isRequired,
|
356
|
-
|
365
|
+
paramData: PropTypes.object.isRequired,
|
357
366
|
parameterTypes: PropTypes.object,
|
358
367
|
parameters: PropTypes.array,
|
359
368
|
sortingColumns: PropTypes.object,
|
@@ -365,8 +374,8 @@ ParameterSelection.propTypes = {
|
|
365
374
|
confirmEditParameter: PropTypes.func,
|
366
375
|
cancelEditParameter: PropTypes.func,
|
367
376
|
changeEditParameter: PropTypes.func,
|
368
|
-
|
369
|
-
|
377
|
+
loadParamData: PropTypes.func,
|
378
|
+
paramDefinition: PropTypes.object,
|
370
379
|
};
|
371
380
|
|
372
381
|
export default ParameterSelection;
|