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.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +122 -0
  3. data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +54 -0
  4. data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +54 -0
  5. data/app/controllers/foreman_acd/api/v2/app_playbooks_controller.rb +0 -0
  6. data/app/controllers/foreman_acd/app_definitions_controller.rb +7 -4
  7. data/app/controllers/foreman_acd/app_instances_controller.rb +33 -126
  8. data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +23 -0
  9. data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
  10. data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
  11. data/app/controllers/ui_acd_controller.rb +11 -3
  12. data/app/models/foreman_acd/ansible_playbook.rb +50 -0
  13. data/app/models/foreman_acd/app_definition.rb +2 -0
  14. data/app/models/foreman_acd/app_instance.rb +7 -0
  15. data/app/services/foreman_acd/app_configurator.rb +70 -0
  16. data/app/services/foreman_acd/app_deployer.rb +143 -0
  17. data/app/services/foreman_acd/inventory_creator.rb +67 -0
  18. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +21 -0
  19. data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +3 -0
  20. data/app/views/foreman_acd/ansible_playbooks/index.html.erb +30 -0
  21. data/app/views/foreman_acd/ansible_playbooks/new.html.erb +3 -0
  22. data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +3 -0
  23. data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +3 -0
  24. data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +3 -0
  25. data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +3 -0
  26. data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +3 -0
  27. data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +3 -0
  28. data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +3 -0
  29. data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +3 -0
  30. data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +3 -0
  31. data/app/views/foreman_acd/app_definitions/_form.html.erb +24 -10
  32. data/app/views/foreman_acd/app_definitions/edit.html.erb +5 -0
  33. data/app/views/foreman_acd/app_instances/_form.html.erb +7 -5
  34. data/app/views/foreman_acd/app_instances/index.html.erb +5 -1
  35. data/app/views/templates/job/run_acd_ansible_playbook.erb +49 -0
  36. data/app/views/ui_acd/ansible_data.json.rabl +6 -0
  37. data/app/views/ui_acd/app.json.rabl +6 -2
  38. data/app/views/ui_acd/app_definition.json.rabl +1 -1
  39. data/app/views/ui_acd/{fdata.json.rabl → foreman_data.json.rabl} +1 -1
  40. data/config/routes.rb +24 -1
  41. data/db/migrate/20200916091018_create_ansible_playbooks.rb +20 -0
  42. data/db/migrate/20200917120220_add_ansible_playbook_id.rb +14 -0
  43. data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +5 -0
  44. data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +5 -0
  45. data/db/seeds.d/75-job_templates.rb +8 -0
  46. data/lib/foreman_acd/engine.rb +3 -0
  47. data/lib/foreman_acd/plugin.rb +53 -2
  48. data/lib/foreman_acd/version.rb +1 -1
  49. data/package.json +1 -1
  50. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +137 -22
  51. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +95 -11
  52. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +7 -2
  53. data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +26 -0
  54. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +117 -21
  55. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +2 -0
  56. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +49 -0
  57. data/webpack/components/ApplicationDefinition/index.js +4 -0
  58. data/webpack/components/ApplicationInstance/ApplicationInstance.js +92 -22
  59. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +37 -8
  60. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +4 -2
  61. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +98 -26
  62. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +2 -1
  63. data/webpack/components/ApplicationInstance/index.js +2 -0
  64. data/webpack/components/ParameterSelection/ParameterSelection.js +46 -37
  65. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +49 -52
  66. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +5 -3
  67. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +0 -32
  68. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +32 -16
  69. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -2
  70. data/webpack/components/ParameterSelection/index.js +4 -4
  71. data/webpack/components/common/DeleteTableEntry.js +1 -1
  72. data/webpack/reducer.js +14 -11
  73. 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
- APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_OPEN,
26
- APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_CLOSE,
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 openParameterSelectionModal = (additionalData) => dispatch => {
191
+ export const openForemanParameterSelectionModal = (additionalData) => dispatch => {
188
192
  dispatch({
189
- type: APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_OPEN,
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: 'AppInstanceParamSelection' })
199
+ setModalOpen({ id: 'AppInstanceForemanParamSelection' })
196
200
  );
197
201
  }
198
202
 
199
- export const closeParameterSelectionModal = (additionalData) => dispatch => {
203
+ export const closeForemanParameterSelectionModal = (additionalData) => dispatch => {
200
204
  dispatch({
201
- type: APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_CLOSE,
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: 'AppInstanceParamSelection' })
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 APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_OPEN = 'APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_OPEN';
12
- export const APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_CLOSE = 'APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_CLOSE';
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
- APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_OPEN,
21
- APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_CLOSE,
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
- return state.merge({
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: '', parameters: [], newEntry: true };
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].parameters = selectedService.parameters;
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 APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_OPEN: {
194
+ case APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN: {
179
195
  let parametersData = {};
180
196
 
181
- if (payload && payload.rowData) {
182
- const selectedService = state.services.filter(entry => entry.id == payload.rowData.service)[0];
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 APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_CLOSE: {
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.serviceDefinition.hostId });
206
- hosts[index].parameters = cloneDeep(payload.hostParameterSelection);
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: { mode, parameters, serviceDefinition },
59
+ data: { useDefaultValue, allowRowAdjustment, allowNameAdjustment, allowDescriptionAdjustment, parameters, paramDefinition },
64
60
  location,
65
61
  organization,
66
- loadForemanDataUrl,
62
+ paramType,
63
+ paramDataUrl,
67
64
  initParameterSelection,
68
65
  sortParameter,
69
66
  deleteParameter,
70
67
  activateEditParameter,
71
68
  changeEditParameter,
72
- loadForemanData,
69
+ loadParamData,
73
70
  } = this.props;
74
71
 
75
- loadForemanData(serviceDefinition.hostgroup_id, { url: loadForemanDataUrl, clearParameters: false });
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={isInstance(mode)}
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={isInstance(mode)}
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.foremanData['computeprofiles'])[value]
171
+ prettyValue = transformForemanData(this.props.paramData['computeprofiles'])[value]
165
172
  break;
166
173
  case 'domain':
167
- prettyValue = transformForemanData(this.props.foremanData['domains'])[value]
174
+ prettyValue = transformForemanData(this.props.paramData['domains'])[value]
168
175
  break;
169
176
  case 'lifecycleenv':
170
- prettyValue = transformForemanData(this.props.foremanData['lifecycle_environments'])[value]
177
+ prettyValue = transformForemanData(this.props.paramData['lifecycle_environments'])[value]
171
178
  break;
172
179
  case 'ptable':
173
- prettyValue = transformForemanData(this.props.foremanData['ptables'])[value]
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.foremanData['environments'])[value]
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.foremanData['computeprofiles']));
205
+ return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['computeprofiles']));
196
206
  case 'domain':
197
- return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.foremanData['domains']));
207
+ return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['domains']));
198
208
  case 'lifecycleenv':
199
- return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.foremanData['lifecycle_environments']));
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.foremanData['environments']));
211
+ return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['environments']));
202
212
  case 'ptable':
203
- return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.foremanData['ptables']));
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
- mode,
219
- serviceDefinition,
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: { mode, applications },
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={isInstance(mode)}
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={isInstance(mode)}
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
- foremanData: {},
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
- serviceDefinition: PropTypes.object,
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
- loadForemanDataUrl: PropTypes.string,
361
+ paramDataUrl: PropTypes.string,
353
362
  initParameterSelection: PropTypes.func,
354
363
  editMode: PropTypes.bool.isRequired,
355
364
  loading: PropTypes.bool.isRequired,
356
- foremanData: PropTypes.object.isRequired,
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
- loadForemanData: PropTypes.func,
369
- serviceDefinition: PropTypes.object,
377
+ loadParamData: PropTypes.func,
378
+ paramDefinition: PropTypes.object,
370
379
  };
371
380
 
372
381
  export default ParameterSelection;