foreman_acd 0.0.6 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -2
  3. data/app/controllers/foreman_acd/app_definitions_controller.rb +29 -1
  4. data/app/controllers/foreman_acd/app_instances_controller.rb +70 -21
  5. data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
  6. data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
  7. data/app/controllers/ui_acd_controller.rb +0 -1
  8. data/app/models/foreman_acd/app_definition.rb +0 -1
  9. data/app/views/foreman_acd/app_definitions/_form.html.erb +6 -14
  10. data/app/views/foreman_acd/app_definitions/import.html.erb +18 -0
  11. data/app/views/foreman_acd/app_definitions/index.html.erb +9 -5
  12. data/app/views/foreman_acd/app_instances/_form.html.erb +5 -5
  13. data/app/views/foreman_acd/app_instances/deploy.html.erb +19 -0
  14. data/app/views/foreman_acd/app_instances/index.html.erb +6 -5
  15. data/app/views/foreman_acd/app_instances/report.html.erb +19 -0
  16. data/app/views/ui_acd/app_definition.json.rabl +1 -1
  17. data/config/routes.rb +7 -0
  18. data/db/migrate/20190610202252_create_app_definitions.rb +1 -3
  19. data/db/migrate/20190625140305_create_app_instances.rb +1 -1
  20. data/lib/foreman_acd/plugin.rb +19 -2
  21. data/lib/foreman_acd/version.rb +1 -1
  22. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +261 -0
  23. data/webpack/components/ApplicationDefinition/ApplicationDefinition.scss +1 -0
  24. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +211 -0
  25. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +9 -0
  26. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +147 -0
  27. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +6 -0
  28. data/webpack/components/ApplicationDefinition/index.js +29 -0
  29. data/webpack/components/ApplicationInstance/ApplicationInstance.js +342 -0
  30. data/webpack/components/ApplicationInstance/ApplicationInstance.scss +11 -0
  31. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +210 -0
  32. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +12 -0
  33. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +223 -0
  34. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +8 -0
  35. data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +49 -0
  36. data/webpack/components/ApplicationInstance/components/Service.js +30 -0
  37. data/webpack/components/ApplicationInstance/components/ServiceCounter.js +37 -0
  38. data/webpack/components/ApplicationInstance/index.js +33 -0
  39. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +155 -0
  40. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +27 -0
  41. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +86 -0
  42. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +4 -0
  43. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +52 -0
  44. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +5 -0
  45. data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +26 -0
  46. data/webpack/components/ApplicationInstanceReport/index.js +27 -0
  47. data/webpack/components/ParameterSelection/ParameterSelection.js +65 -161
  48. data/webpack/components/ParameterSelection/ParameterSelection.scss +9 -0
  49. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +42 -71
  50. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +12 -19
  51. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +3 -3
  52. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +76 -75
  53. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -6
  54. data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +12 -21
  55. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +1 -1
  56. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +3 -45
  57. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +20 -0
  58. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +22 -46
  59. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
  60. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +40 -265
  61. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +11 -96
  62. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +3 -9
  63. data/webpack/components/ParameterSelection/index.js +4 -6
  64. data/webpack/components/common/AddTableEntry.js +30 -0
  65. data/webpack/components/common/DeleteTableEntry.js +39 -0
  66. data/webpack/components/common/ExtSelect.js +43 -0
  67. data/webpack/components/common/RailsData.js +27 -0
  68. data/webpack/components/common/__tests__/AddTableEntry.test.js +26 -0
  69. data/webpack/components/common/__tests__/DeleteTableEntry.test.js +29 -0
  70. data/webpack/components/common/__tests__/ExtSelect.test.js +38 -0
  71. data/webpack/components/common/__tests__/RailsData.test.js +16 -0
  72. data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +35 -0
  73. data/webpack/components/common/__tests__/__snapshots__/AddTableEntry.test.js.snap +35 -0
  74. data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +41 -0
  75. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +41 -0
  76. data/webpack/components/common/__tests__/__snapshots__/ExtSelect.test.js.snap +18 -0
  77. data/webpack/components/common/__tests__/__snapshots__/RailsData.test.js.snap +10 -0
  78. data/webpack/helper.js +20 -0
  79. data/webpack/index.js +6 -0
  80. data/webpack/reducer.js +40 -3
  81. metadata +47 -46
@@ -1 +1,10 @@
1
1
  @import '~@theforeman/vendor/scss/variables';
2
+
3
+ .param_selection_modal {
4
+ margin-top: 0;
5
+ margin-bottom: 0;
6
+ height: 100%;
7
+ width: 80%;
8
+ max-width: none !important;
9
+ }
10
+
@@ -26,26 +26,23 @@ import {
26
26
  } from './ParameterSelectionHelper';
27
27
 
28
28
  import {
29
- INIT_PARAMETER_SELECTION,
30
- PARAMETER_TYPES,
31
- PARAMETER_DELETE,
32
- PARAMETER_ADD,
33
- PARAMETER_EDIT_ACTIVATE,
34
- PARAMETER_EDIT_CONFIRM,
35
- PARAMETER_EDIT_CHANGE,
36
- PARAMETER_EDIT_CANCEL,
37
- PARAMETER_SORT,
38
- LOAD_PARAMETER_SELECTION_REQUEST,
39
- LOAD_PARAMETER_SELECTION_SUCCESS,
40
- LOAD_PARAMETER_SELECTION_FAILURE,
41
- LOAD_FOREMAN_DATA_REQUEST,
42
- LOAD_FOREMAN_DATA_SUCCESS,
43
- LOAD_FOREMAN_DATA_FAILURE,
29
+ PARAMETER_SELECTION_INIT,
30
+ PARAMETER_SELECTION_TYPES,
31
+ PARAMETER_SELECTION_DELETE,
32
+ PARAMETER_SELECTION_ADD,
33
+ PARAMETER_SELECTION_EDIT_ACTIVATE,
34
+ PARAMETER_SELECTION_EDIT_CONFIRM,
35
+ PARAMETER_SELECTION_EDIT_CHANGE,
36
+ PARAMETER_SELECTION_EDIT_CANCEL,
37
+ PARAMETER_SELECTION_SORT,
38
+ PARAMETER_SELECTION_LOAD_FOREMAN_DATA_REQUEST,
39
+ PARAMETER_SELECTION_LOAD_FOREMAN_DATA_SUCCESS,
40
+ PARAMETER_SELECTION_LOAD_FOREMAN_DATA_FAILURE,
44
41
  } from './ParameterSelectionConstants';
45
42
 
46
43
  export const initParameterSelection = (
47
44
  mode,
48
- appDefinition,
45
+ serviceDefinition,
49
46
  parameters,
50
47
  sortingFormatter,
51
48
  sortableTransform,
@@ -60,9 +57,9 @@ export const initParameterSelection = (
60
57
  position: 0
61
58
  }
62
59
  };
63
- initialState.appDefinition = appDefinition;
60
+ initialState.serviceDefinition = serviceDefinition;
64
61
 
65
- var valueLabel = 'Value';
62
+ let valueLabel = 'Value';
66
63
  if (isDefinition(mode)) {
67
64
  valueLabel = 'Default value';
68
65
  }
@@ -95,7 +92,7 @@ export const initParameterSelection = (
95
92
  index: 1,
96
93
  sort: true,
97
94
  style: {
98
- width: '25%'
95
+ width: '20%'
99
96
  }
100
97
  },
101
98
  transforms: [sortableTransform],
@@ -125,9 +122,6 @@ export const initParameterSelection = (
125
122
  customFormatters: [sortableHeaderCellFormatter]
126
123
  },
127
124
  cell: {
128
- props: {
129
- index: 2
130
- },
131
125
  // we are always using the inlineEditFormatter so that
132
126
  // the well formatted type name is shown
133
127
  formatters: [inlineEditFormatter]
@@ -141,7 +135,7 @@ export const initParameterSelection = (
141
135
  index: 3,
142
136
  sort: true,
143
137
  style: {
144
- width: '25%'
138
+ width: '20%'
145
139
  }
146
140
  },
147
141
  transforms: [sortableTransform],
@@ -149,9 +143,6 @@ export const initParameterSelection = (
149
143
  customFormatters: [sortableHeaderCellFormatter]
150
144
  },
151
145
  cell: {
152
- props: {
153
- index: 3
154
- },
155
146
  formatters: [inlineEditFormatter]
156
147
  }
157
148
  },
@@ -160,36 +151,36 @@ export const initParameterSelection = (
160
151
  header: {
161
152
  label: 'Actions',
162
153
  props: {
163
- index: 4
154
+ index: 4,
155
+ style: {
156
+ width: '20%'
157
+ }
164
158
  },
165
159
  formatters: [actionHeaderCellFormatter]
166
160
  },
167
161
  cell: {
168
- props: {
169
- index: 4
170
- },
171
162
  formatters: [inlineEditButtonsFormatter]
172
163
  }
173
164
  }
174
165
  ];
175
166
 
176
- if ((isNewDefinition(mode)) || (isNewInstance(mode))) {
177
- initialState.rows = [];
178
- } else if ((isEditDefinition(mode)) || (isEditInstance(mode))) {
179
- initialState.rows = parameters;
180
- initialState.hostgroupId = appDefinition.hostgroup_id;
167
+ if (isNewDefinition(mode)) {
168
+ initialState.parameters = [];
169
+ } else if ((isEditDefinition(mode)) || (isInstance(mode))) {
170
+ initialState.parameters = parameters;
171
+ initialState.hostgroupId = serviceDefinition.hostgroup_id;
181
172
  } else {
182
173
  // FIXME: should never ever happen
183
174
  }
184
175
 
185
- if (isNewDefinition(mode) || isNewInstance(mode)) {
186
- initialState.parameterTypes = PARAMETER_TYPES;
176
+ if (isNewDefinition(mode)) {
177
+ initialState.parameterTypes = PARAMETER_SELECTION_TYPES;
187
178
  } else {
188
- initialState.parameterTypes = filterUsedParameterTypes(PARAMETER_TYPES, parameters);
179
+ initialState.parameterTypes = filterUsedParameterTypes(PARAMETER_SELECTION_TYPES, parameters);
189
180
  }
190
181
 
191
182
  dispatch({
192
- type: INIT_PARAMETER_SELECTION,
183
+ type: PARAMETER_SELECTION_INIT,
193
184
  payload: initialState,
194
185
  });
195
186
  }
@@ -203,42 +194,42 @@ const errorHandler = (msg, err) => {
203
194
  };
204
195
 
205
196
  export const addParameter = (additionalData) => ({
206
- type: PARAMETER_ADD,
197
+ type: PARAMETER_SELECTION_ADD,
207
198
  payload: {
208
199
  ...additionalData,
209
200
  },
210
201
  });
211
202
 
212
203
  export const deleteParameter = (additionalData) => ({
213
- type: PARAMETER_DELETE,
204
+ type: PARAMETER_SELECTION_DELETE,
214
205
  payload: {
215
206
  ...additionalData,
216
207
  },
217
208
  });
218
209
 
219
210
  export const activateEditParameter = (additionalData) => ({
220
- type: PARAMETER_EDIT_ACTIVATE,
211
+ type: PARAMETER_SELECTION_EDIT_ACTIVATE,
221
212
  payload: {
222
213
  ...additionalData,
223
214
  },
224
215
  });
225
216
 
226
217
  export const confirmEditParameter = (rowData) => ({
227
- type: PARAMETER_EDIT_CONFIRM,
218
+ type: PARAMETER_SELECTION_EDIT_CONFIRM,
228
219
  payload: {
229
220
  ...rowData,
230
221
  },
231
222
  });
232
223
 
233
224
  export const cancelEditParameter = (rowData) => ({
234
- type: PARAMETER_EDIT_CANCEL,
225
+ type: PARAMETER_SELECTION_EDIT_CANCEL,
235
226
  payload: {
236
227
  ...rowData,
237
228
  },
238
229
  });
239
230
 
240
231
  export const changeEditParameter = (value, additionalData) => ({
241
- type: PARAMETER_EDIT_CHANGE,
232
+ type: PARAMETER_SELECTION_EDIT_CHANGE,
242
233
  payload: {
243
234
  value,
244
235
  ...additionalData,
@@ -246,49 +237,29 @@ export const changeEditParameter = (value, additionalData) => ({
246
237
  });
247
238
 
248
239
  export const sortParameter = (selectedColumn, defaultSortingOrder) => ({
249
- type: PARAMETER_SORT,
240
+ type: PARAMETER_SELECTION_SORT,
250
241
  payload: {
251
242
  selectedColumn,
252
243
  defaultSortingOrder,
253
244
  },
254
245
  });
255
246
 
256
- export const loadParameterSelection = (
257
- url,
258
- applicationDefinitionId
259
- ) => dispatch => {
260
- dispatch({ type: LOAD_PARAMETER_SELECTION_REQUEST });
261
-
262
- var realUrl = url.replace("__id__", applicationDefinitionId);
263
-
264
- return api
265
- .get(realUrl, {}, {})
266
- .then(({ data }) =>
267
- dispatch({
268
- type: LOAD_PARAMETER_SELECTION_SUCCESS,
269
- payload: data,
270
- })
271
- )
272
- .catch(error => dispatch(errorHandler(LOAD_PARAMETER_SELECTION_FAILURE, error)));
273
- };
274
-
275
247
  export const loadForemanData = (
276
- url,
277
248
  hostgroupId,
278
- clearRows = false,
249
+ additionalData,
279
250
  ) => dispatch => {
280
- dispatch({ type: LOAD_FOREMAN_DATA_REQUEST, payload: { clearRows: clearRows } });
251
+ dispatch({ type: PARAMETER_SELECTION_LOAD_FOREMAN_DATA_REQUEST, payload: { clearParameters: additionalData.clearParameters } });
281
252
 
282
- var realUrl = url.replace("__id__", hostgroupId);
253
+ const realUrl = additionalData.url.replace("__id__", hostgroupId);
283
254
 
284
255
  return api
285
256
  .get(realUrl, {}, {})
286
257
  .then(({ data }) =>
287
258
  dispatch({
288
- type: LOAD_FOREMAN_DATA_SUCCESS,
259
+ type: PARAMETER_SELECTION_LOAD_FOREMAN_DATA_SUCCESS,
289
260
  payload: data,
290
261
  })
291
262
  )
292
- .catch(error => dispatch(errorHandler(LOAD_FOREMAN_DATA_FAILURE, error)));
263
+ .catch(error => dispatch(errorHandler(PARAMETER_SELECTION_LOAD_FOREMAN_DATA_FAILURE, error)));
293
264
  };
294
265
 
@@ -1,27 +1,20 @@
1
- export const INIT_PARAMETER_SELECTION = 'INIT_PARAMETER_SELECTION';
2
-
3
- export const PARAMETER_DELETE = 'PARAMETER_DELETE';
4
- export const PARAMETER_ADD = 'PARAMETER_ADD';
5
- export const PARAMETER_EDIT_ACTIVATE = 'PARAMETER_EDIT_ACTIVATE';
6
- export const PARAMETER_EDIT_CONFIRM = 'PARAMETER_EDIT_CONFIRM';
7
- export const PARAMETER_EDIT_CHANGE = 'PARAMETER_EDIT_CHANGE';
8
- export const PARAMETER_EDIT_CANCEL = 'PARAMETER_EDIT_CANCEL';
9
- export const PARAMETER_SORT = 'PARAMETER_SORT';
10
-
11
- export const LOAD_PARAMETER_SELECTION_REQUEST = 'LOAD_PARAMETER_SELECTION_REQUEST';
12
- export const LOAD_PARAMETER_SELECTION_SUCCESS = 'LOAD_PARAMETER_SELECTION_SUCCESS';
13
- export const LOAD_PARAMETER_SELECTION_FAILURE = 'LOAD_PARAMETER_SELECTION_FAILURE';
14
-
15
- export const LOAD_FOREMAN_DATA_REQUEST = 'LOAD_FOREMAN_DATA_REQUEST';
16
- export const LOAD_FOREMAN_DATA_SUCCESS = 'LOAD_FOREMAN_DATA_SUCCESS';
17
- export const LOAD_FOREMAN_DATA_FAILURE = 'LOAD_FOREMAN_DATA_FAILURE';
1
+ export const PARAMETER_SELECTION_INIT = 'INIT_PARAMETER_SELECTION_INIT';
2
+ export const PARAMETER_SELECTION_DELETE = 'PARAMETER_SELECTION_DELETE';
3
+ export const PARAMETER_SELECTION_ADD = 'PARAMETER_SELECTION_ADD';
4
+ export const PARAMETER_SELECTION_EDIT_ACTIVATE = 'PARAMETER_SELECTION_EDIT_ACTIVATE';
5
+ export const PARAMETER_SELECTION_EDIT_CONFIRM = 'PARAMETER_SELECTION_EDIT_CONFIRM';
6
+ export const PARAMETER_SELECTION_EDIT_CHANGE = 'PARAMETER_SELECTION_EDIT_CHANGE';
7
+ export const PARAMETER_SELECTION_EDIT_CANCEL = 'PARAMETER_SELECTION_EDIT_CANCEL';
8
+ export const PARAMETER_SELECTION_SORT = 'PARAMETER_SELECTION_SORT';
9
+ export const PARAMETER_SELECTION_LOAD_FOREMAN_DATA_REQUEST = 'PARAMETER_SELECTION_LOAD_FOREMAN_DATA_REQUEST';
10
+ export const PARAMETER_SELECTION_LOAD_FOREMAN_DATA_SUCCESS = 'PARAMETER_SELECTION_LOAD_FOREMAN_DATA_SUCCESS';
11
+ export const PARAMETER_SELECTION_LOAD_FOREMAN_DATA_FAILURE = 'PARAMETER_SELECTION_LOAD_FOREMAN_DATA_FAILURE';
18
12
 
19
13
  // Make sure the object is sorted by value
20
14
  // (Compute Profile -> Partition table -> Root password)
21
- export const PARAMETER_TYPES = {
15
+ export const PARAMETER_SELECTION_TYPES = {
22
16
  computeprofile: 'Compute profile',
23
17
  domain: 'Domain',
24
- hostname: 'Hostname',
25
18
  hostparam: 'Host parameter',
26
19
  ip: 'IP',
27
20
  lifecycleenv: 'Lifecycle environment',
@@ -38,15 +38,15 @@ export const transformForemanData = (fdata) => {
38
38
  if (fdata === undefined) {
39
39
  return "";
40
40
  }
41
- var result = {};
41
+ const result = {};
42
42
  fdata.map(item => result[item.id] = item.name)
43
43
  return (result);
44
44
  }
45
45
 
46
46
  export const filterUsedParameterTypes = (options, parameters) => {
47
- var newOptions = cloneDeep(options);
47
+ const newOptions = cloneDeep(options);
48
48
  // hostparam can be used multiple times
49
- var alreadyUsed = parameters.map(item => item["type"]).filter(item => item != 'hostparam');
49
+ const alreadyUsed = parameters.map(item => item["type"]).filter(item => item != 'hostparam');
50
50
  alreadyUsed.forEach(item => delete newOptions[item])
51
51
  return newOptions;
52
52
  }
@@ -13,23 +13,24 @@ import {
13
13
  import * as sort from 'sortabular';
14
14
 
15
15
  import {
16
- INIT_PARAMETER_SELECTION,
17
- PARAMETER_TYPES,
18
- PARAMETER_DELETE,
19
- PARAMETER_ADD,
20
- PARAMETER_EDIT_ACTIVATE,
21
- PARAMETER_EDIT_CONFIRM,
22
- PARAMETER_EDIT_CHANGE,
23
- PARAMETER_EDIT_CANCEL,
24
- PARAMETER_SORT,
25
- LOAD_PARAMETER_SELECTION_REQUEST,
26
- LOAD_PARAMETER_SELECTION_SUCCESS,
27
- LOAD_PARAMETER_SELECTION_FAILURE,
28
- LOAD_FOREMAN_DATA_REQUEST,
29
- LOAD_FOREMAN_DATA_SUCCESS,
30
- LOAD_FOREMAN_DATA_FAILURE,
16
+ PARAMETER_SELECTION_INIT,
17
+ PARAMETER_SELECTION_TYPES,
18
+ PARAMETER_SELECTION_DELETE,
19
+ PARAMETER_SELECTION_ADD,
20
+ PARAMETER_SELECTION_EDIT_ACTIVATE,
21
+ PARAMETER_SELECTION_EDIT_CONFIRM,
22
+ PARAMETER_SELECTION_EDIT_CHANGE,
23
+ PARAMETER_SELECTION_EDIT_CANCEL,
24
+ PARAMETER_SELECTION_SORT,
25
+ PARAMETER_SELECTION_LOAD_FOREMAN_DATA_REQUEST,
26
+ PARAMETER_SELECTION_LOAD_FOREMAN_DATA_SUCCESS,
27
+ PARAMETER_SELECTION_LOAD_FOREMAN_DATA_FAILURE,
31
28
  } from './ParameterSelectionConstants';
32
29
 
30
+ import {
31
+ APPLICATION_DEFINITION_PARAMETER_SELECTION_MODAL_CLOSE,
32
+ } from '../ApplicationDefinition/ApplicationDefinitionConstants';
33
+
33
34
  export const initialState = Immutable({
34
35
  editMode: false,
35
36
  error: { errorMsg: '', status: '', statusText: '' },
@@ -39,83 +40,83 @@ const parameterSelectionParameters = (state = initialState, action) => {
39
40
  const { payload } = action;
40
41
 
41
42
  switch (action.type) {
42
- case INIT_PARAMETER_SELECTION: {
43
+ case PARAMETER_SELECTION_INIT: {
43
44
  return state.merge(payload);
44
45
  }
45
- case PARAMETER_ADD: {
46
- var rows = [];
47
- var index = 0;
46
+ case PARAMETER_SELECTION_ADD: {
47
+ let parameters = [];
48
+ let index = 1;
48
49
 
49
- if ('rows' in state && state.rows !== undefined && state.rows.length > 0) {
50
- rows = cloneDeep(state.rows);
51
- index = Math.max(...rows.map(e => e.id)) + 1;
50
+ if ('parameters' in state && state.parameters !== undefined && state.parameters.length > 0) {
51
+ parameters = cloneDeep(state.parameters);
52
+ index = Math.max(...parameters.map(e => e.id)) + 1;
52
53
  }
53
54
 
54
55
  const newRow = {id: index, name: "", description: '', type: '', value: '', newEntry: true };
55
56
  newRow.backup = cloneDeep(newRow)
56
- rows.push(newRow);
57
+ parameters.push(newRow);
57
58
 
58
59
  return state.merge({
59
60
  editMode: true,
60
- rows: rows
61
+ parameters: parameters
61
62
  });
62
63
  }
63
- case PARAMETER_DELETE: {
64
- var rows = state.rows.filter(v => v.id !== payload.rowData.id);
64
+ case PARAMETER_SELECTION_DELETE: {
65
+ const parameters = state.parameters.filter(v => v.id !== payload.rowData.id);
65
66
  return state.merge({
66
- rows: rows,
67
- parameterTypes: filterUsedParameterTypes(PARAMETER_TYPES, rows),
67
+ parameters: parameters,
68
+ parameterTypes: filterUsedParameterTypes(PARAMETER_SELECTION_TYPES, parameters),
68
69
  })
69
70
  }
70
- case PARAMETER_EDIT_ACTIVATE: {
71
- const rows = cloneDeep(state.rows);
72
- const index = findIndex(rows, { id: payload.rowData.id });
71
+ case PARAMETER_SELECTION_EDIT_ACTIVATE: {
72
+ const parameters = cloneDeep(state.parameters);
73
+ const index = findIndex(parameters, { id: payload.rowData.id });
73
74
 
74
- rows[index].backup = cloneDeep(rows[index]);
75
+ parameters[index].backup = cloneDeep(parameters[index]);
75
76
 
76
77
  return state.merge({
77
78
  editMode: true,
78
- rows: rows
79
+ parameters: parameters
79
80
  });
80
81
  }
81
- case PARAMETER_EDIT_CONFIRM: {
82
- const rows = cloneDeep(state.rows);
83
- const index = findIndex(rows, { id: payload.rowData.id });
82
+ case PARAMETER_SELECTION_EDIT_CONFIRM: {
83
+ const parameters = cloneDeep(state.parameters);
84
+ const index = findIndex(parameters, { id: payload.rowData.id });
84
85
 
85
- delete rows[index].backup;
86
- delete rows[index].newEntry;
86
+ delete parameters[index].backup;
87
+ delete parameters[index].newEntry;
87
88
 
88
89
  return state.merge({
89
90
  editMode: false,
90
- parameterTypes: filterUsedParameterTypes(PARAMETER_TYPES, rows),
91
- rows: rows
91
+ parameterTypes: filterUsedParameterTypes(PARAMETER_SELECTION_TYPES, parameters),
92
+ parameters: parameters
92
93
  });
93
94
  }
94
- case PARAMETER_EDIT_CHANGE: {
95
- const rows = cloneDeep(state.rows);
96
- const index = findIndex(rows, { id: payload.rowData.id });
95
+ case PARAMETER_SELECTION_EDIT_CHANGE: {
96
+ const parameters = cloneDeep(state.parameters);
97
+ const index = findIndex(parameters, { id: payload.rowData.id });
97
98
 
98
- rows[index][payload.property] = payload.value;
99
+ parameters[index][payload.property] = payload.value;
99
100
 
100
- return state.set('rows', rows);
101
+ return state.set('parameters', parameters);
101
102
  }
102
- case PARAMETER_EDIT_CANCEL: {
103
- const rows = cloneDeep(state.rows);
104
- const index = findIndex(rows, { id: payload.rowData.id });
103
+ case PARAMETER_SELECTION_EDIT_CANCEL: {
104
+ const parameters = cloneDeep(state.parameters);
105
+ const index = findIndex(parameters, { id: payload.rowData.id });
105
106
 
106
- rows[index] = cloneDeep(rows[index].backup);
107
- delete rows[index].backup;
107
+ parameters[index] = cloneDeep(parameters[index].backup);
108
+ delete parameters[index].backup;
108
109
 
109
- if (rows[index].newEntry === true) {
110
- rows.splice(index, 1);
110
+ if (parameters[index].newEntry === true) {
111
+ parameters.splice(index, 1);
111
112
  }
112
113
 
113
114
  return state.merge({
114
115
  editMode: false,
115
- rows: rows
116
+ parameters: parameters
116
117
  });
117
118
  }
118
- case PARAMETER_SORT: {
119
+ case PARAMETER_SELECTION_SORT: {
119
120
  const selectedColumn = payload.selectedColumn;
120
121
  return state.set(
121
122
  'sortingColumns',
@@ -126,47 +127,47 @@ const parameterSelectionParameters = (state = initialState, action) => {
126
127
  })
127
128
  );
128
129
  }
129
- case LOAD_PARAMETER_SELECTION_FAILURE: {
130
- return state.merge({ error: payload.error, loading: false });
131
- }
132
- case LOAD_PARAMETER_SELECTION_REQUEST: {
133
- return state.set('loading', true);
134
- }
135
- case LOAD_PARAMETER_SELECTION_SUCCESS: {
136
- return state.merge({
137
- appDefinition: payload.app_definition,
138
- loading: false,
139
- rows: JSON.parse(payload.app_definition.parameters),
140
- hostgroupId: payload.app_definition.hostgroup_id,
141
- foremanData: payload.fdata,
142
- });
143
- }
144
- case LOAD_FOREMAN_DATA_FAILURE: {
130
+ case PARAMETER_SELECTION_LOAD_FOREMAN_DATA_FAILURE: {
145
131
  return state.merge({
146
132
  error: payload.error,
147
133
  loading: false
148
134
  });
149
135
  }
150
- case LOAD_FOREMAN_DATA_REQUEST: {
151
- var newState = {
136
+ case PARAMETER_SELECTION_LOAD_FOREMAN_DATA_REQUEST: {
137
+ const newState = {
152
138
  foremanData: {},
153
139
  hostgroupId: -1,
154
140
  loading: true
155
141
  };
156
142
 
157
- if (payload.clearRows === true) {
158
- Object.assign(newState, { rows: [] });
143
+ if (payload.clearParameters === true) {
144
+ Object.assign(newState, { parameters: [] });
159
145
  }
160
146
 
161
147
  return state.merge(newState);
162
148
  }
163
- case LOAD_FOREMAN_DATA_SUCCESS: {
149
+ case PARAMETER_SELECTION_LOAD_FOREMAN_DATA_SUCCESS: {
164
150
  return state.merge({
165
151
  loading: false,
166
152
  foremanData: payload,
167
153
  hostgroupId: payload.hostgroup_id,
168
154
  });
169
155
  }
156
+ case APPLICATION_DEFINITION_PARAMETER_SELECTION_MODAL_CLOSE: {
157
+ const parameters = cloneDeep(state.parameters);
158
+
159
+ parameters.forEach((param, index) => {
160
+ delete parameters[index].backup;
161
+ if (parameters[index].newEntry === true) {
162
+ parameters.splice(index, 1);
163
+ }
164
+ });
165
+
166
+ return state.merge({
167
+ editMode: false,
168
+ parameters: parameters
169
+ });
170
+ }
170
171
  default:
171
172
  return state;
172
173
  }