foreman_acd 0.9.7 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/lib/foreman_acd/version.rb +1 -1
  3. data/package.json +5 -3
  4. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +210 -121
  5. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +79 -91
  6. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +30 -15
  7. data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +15 -15
  8. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +96 -63
  9. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +22 -11
  10. data/webpack/components/ApplicationDefinition/__fixtures__/{applicationDefinitionConfData_1.fixtures.js → applicationDefinitionConfData1.fixtures.js} +77 -105
  11. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +49 -29
  12. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +4 -4
  13. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionHelper.test.js +16 -0
  14. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +0 -5
  15. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +25 -25
  16. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +9 -1
  17. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +11 -11
  18. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +30 -25
  19. data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +3 -3
  20. data/webpack/components/ApplicationDefinition/index.js +0 -1
  21. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +91 -105
  22. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +59 -84
  23. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +12 -6
  24. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +21 -27
  25. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +14 -7
  26. data/webpack/components/ApplicationDefinitionImport/__fixtures__/{applicationDefinitionImportConfData_1.fixtures.js → applicationDefinitionImportConfData1.fixtures.js} +32 -40
  27. data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +14 -16
  28. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +38 -8
  29. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +0 -2
  30. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +9 -9
  31. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +116 -2
  32. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +3 -3
  33. data/webpack/components/ApplicationInstance/ApplicationInstance.js +344 -193
  34. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +92 -105
  35. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +34 -17
  36. data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +4 -7
  37. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +114 -74
  38. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +18 -9
  39. data/webpack/components/ApplicationInstance/__fixtures__/{applicationInstanceConfData_1.fixtures.js → applicationInstanceConfData1.fixtures.js} +68 -86
  40. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +24 -32
  41. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +75 -10
  42. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +0 -8
  43. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +27 -27
  44. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +606 -2
  45. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +12 -12
  46. data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +32 -25
  47. data/webpack/components/ApplicationInstance/components/Service.js +7 -18
  48. data/webpack/components/ApplicationInstance/components/ServiceCounter.js +25 -18
  49. data/webpack/components/ApplicationInstance/index.js +0 -1
  50. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +167 -110
  51. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +20 -25
  52. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +10 -5
  53. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +9 -12
  54. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +12 -6
  55. data/webpack/components/ApplicationInstanceReport/__fixtures__/{applicationInstanceReportData_1.fixtures.js → applicationInstanceReportData1.fixtures.js} +154 -101
  56. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +3 -10
  57. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +28 -22
  58. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +5 -7
  59. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +0 -1
  60. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +2 -2
  61. data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +9 -5
  62. data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +1 -3
  63. data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +35 -56
  64. data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +21 -28
  65. data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +6 -3
  66. data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +16 -19
  67. data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -4
  68. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData1.fixtures.js +187 -0
  69. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +13 -24
  70. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +3 -2
  71. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +11 -14
  72. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +5 -5
  73. data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +31 -25
  74. data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +3 -9
  75. data/webpack/components/ParameterSelection/ParameterSelection.js +258 -174
  76. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +110 -100
  77. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +22 -11
  78. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +13 -11
  79. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +63 -49
  80. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +10 -5
  81. data/webpack/components/ParameterSelection/__fixtures__/{parameterSelectionData_1.fixtures.js → parameterSelectionData1.fixtures.js} +67 -104
  82. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +22 -26
  83. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +50 -36
  84. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionHelper.test.js +76 -0
  85. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +0 -2
  86. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +23 -25
  87. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +100 -0
  88. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +99 -112
  89. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +18 -19
  90. data/webpack/components/ParameterSelection/index.js +1 -4
  91. data/webpack/components/SyncGitRepo/SyncGitRepo.js +124 -117
  92. data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +64 -74
  93. data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +17 -17
  94. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData1.fixtures.js +7 -0
  95. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +10 -18
  96. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +80 -6
  97. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +9 -11
  98. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +192 -1
  99. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +4 -4
  100. data/webpack/components/SyncGitRepo/components/FormTextInput.js +26 -21
  101. data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +29 -24
  102. data/webpack/components/SyncGitRepo/index.js +2 -5
  103. data/webpack/components/common/AddTableEntry.js +3 -10
  104. data/webpack/components/common/DeleteTableEntry.js +7 -15
  105. data/webpack/components/common/EditTableEntry.js +7 -7
  106. data/webpack/components/common/ExtSelect.js +12 -8
  107. data/webpack/components/common/ExtTextInput.js +12 -7
  108. data/webpack/components/common/LockTableEntry.js +6 -6
  109. data/webpack/components/common/RailsData.js +6 -16
  110. data/webpack/components/common/__tests__/ExtSelect.test.js +2 -2
  111. data/webpack/components/common/__tests__/RailsData.test.js +0 -2
  112. data/webpack/global_test_setup.js +11 -0
  113. data/webpack/helper.js +10 -21
  114. data/webpack/helper.test.js +17 -29
  115. data/webpack/index.js +25 -7
  116. data/webpack/js-yaml.js +1563 -1135
  117. data/webpack/reducer.js +52 -27
  118. metadata +13 -11
  119. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +0 -191
  120. data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +0 -153
  121. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +0 -7
@@ -1,13 +1,9 @@
1
1
  import Immutable from 'seamless-immutable';
2
+ import { cloneDeep, findIndex } from 'lodash';
3
+
2
4
  import { translate as __ } from 'foremanReact/common/I18n';
3
5
  import { calculateServiceUsage } from './ApplicationInstanceHelper';
4
6
 
5
- import {
6
- cloneDeep,
7
- findIndex,
8
- findLastIndex,
9
- } from 'lodash';
10
-
11
7
  import {
12
8
  APPLICATION_INSTANCE_INIT,
13
9
  APPLICATION_INSTANCE_CLOSE_ALERT_MODAL,
@@ -54,40 +50,43 @@ const applicationInstanceConf = (state = initialState, action) => {
54
50
  alertModalText: '',
55
51
  });
56
52
  }
57
- case APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_FAILURE: {
58
- console.log("Error while loading application definition data: "+ payload.error);
59
- return state.merge({ error: payload.error, loading: false });
53
+ case APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_FAILURE: {
54
+ return state.merge({
55
+ error: payload.error,
56
+ loading: false,
57
+ });
60
58
  }
61
59
  case APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_REQUEST: {
62
60
  return state.set('loading', true);
63
61
  }
64
62
  case APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_SUCCESS: {
65
- let newState = {};
66
63
  const services = JSON.parse(payload.app_definition.services);
67
64
 
68
65
  // initialize all services count with 0
69
- services.map(serv => {
70
- serv['currentCount'] = 0;
71
- })
66
+ services.forEach(serv => {
67
+ serv.currentCount = 0;
68
+ });
72
69
 
73
70
  // Update count
74
71
  if (state.hosts !== undefined) {
75
- state.hosts.map((host, index) => {
72
+ state.hosts.forEach(host => {
76
73
  const hostServiceId = Number(host.service);
77
- const service = services.find(serv => serv['id'] == hostServiceId);
78
- service['currentCount'] += 1;
74
+ const service = services.find(serv => serv.id === hostServiceId);
75
+ service.currentCount += 1;
79
76
  });
80
77
  }
81
78
 
82
- newState = {
79
+ const newState = {
83
80
  appDefinition: payload.app_definition,
84
- services: services,
81
+ services,
85
82
  loading: false,
86
83
  };
87
84
 
88
85
  // Initialize ansibleVarsAll if there is no data available in app instance
89
86
  if (state.ansibleVarsAll.length <= 0) {
90
- newState['ansibleVarsAll'] = JSON.parse(payload.app_definition.ansible_vars_all);
87
+ newState.ansibleVarsAll = JSON.parse(
88
+ payload.app_definition.ansible_vars_all
89
+ );
91
90
  }
92
91
 
93
92
  return state.merge(newState);
@@ -96,34 +95,47 @@ const applicationInstanceConf = (state = initialState, action) => {
96
95
  let hosts = [];
97
96
  let index = 1;
98
97
 
99
- if ('hosts' in state && state.hosts !== undefined && state.hosts.length > 0) {
98
+ if (
99
+ 'hosts' in state &&
100
+ state.hosts !== undefined &&
101
+ state.hosts.length > 0
102
+ ) {
100
103
  hosts = cloneDeep(state.hosts);
101
104
  index = Math.max(...hosts.map(e => e.id)) + 1;
102
105
  }
103
106
 
104
- const newRow = {id: index, hostname: "", description: '', service: '', isExistingHost: false, foremanParameters: [], ansibleParameters: [], newEntry: true };
105
- newRow.backup = cloneDeep(newRow)
107
+ const newRow = {
108
+ id: index,
109
+ hostname: '',
110
+ description: '',
111
+ service: '',
112
+ isExistingHost: false,
113
+ foremanParameters: [],
114
+ ansibleParameters: [],
115
+ newEntry: true,
116
+ };
117
+ newRow.backup = cloneDeep(newRow);
106
118
  hosts.push(newRow);
107
119
 
108
120
  return state.merge({
109
121
  editMode: true,
110
- hosts: hosts
122
+ hosts,
111
123
  });
112
124
  }
113
125
  case APPLICATION_INSTANCE_HOST_DELETE: {
114
126
  const services = cloneDeep(state.services);
115
- const host = state.hosts.find(v => v.id == payload.rowData.id);
127
+ const host = state.hosts.find(v => v.id === payload.rowData.id);
116
128
  const hostServiceId = Number(host.service);
117
129
  const hosts = state.hosts.filter(v => v.id !== host.id);
118
130
 
119
131
  // Update count
120
- const service = services.find(serv => serv['id'] == hostServiceId);
121
- service['currentCount'] -= 1;
132
+ const service = services.find(serv => serv.id === hostServiceId);
133
+ service.currentCount -= 1;
122
134
 
123
135
  return state.merge({
124
- hosts: hosts,
125
- services: services,
126
- })
136
+ hosts,
137
+ services,
138
+ });
127
139
  }
128
140
  case APPLICATION_INSTANCE_HOST_EDIT_ACTIVATE: {
129
141
  const hosts = cloneDeep(state.hosts);
@@ -133,7 +145,7 @@ const applicationInstanceConf = (state = initialState, action) => {
133
145
 
134
146
  return state.merge({
135
147
  editMode: true,
136
- hosts: hosts
148
+ hosts,
137
149
  });
138
150
  }
139
151
  case APPLICATION_INSTANCE_HOST_EDIT_CONFIRM: {
@@ -146,21 +158,29 @@ const applicationInstanceConf = (state = initialState, action) => {
146
158
  // hostnames are lower case
147
159
  thisHost.hostname = thisHost.hostname.toLowerCase();
148
160
 
149
- if (state.hosts.filter(v => v.hostname === thisHost.hostname && v.id != thisHost.id).length > 0) {
161
+ if (
162
+ state.hosts.filter(
163
+ v => v.hostname === thisHost.hostname && v.id !== thisHost.id
164
+ ).length > 0
165
+ ) {
150
166
  return state.merge({
151
167
  showAlertModal: true,
152
- alertModalTitle: __("Error"),
153
- alertModalText: __("Host name already used in this Application Instance. Please make sure that every host name is unique."),
168
+ alertModalTitle: __('Error'),
169
+ alertModalText: __(
170
+ 'Host name already used in this Application Instance. Please make sure that every host name is unique.'
171
+ ),
154
172
  });
155
173
  }
156
174
 
157
175
  // Initialize the new Instance with the parameters of the Application Definition.
158
176
  if (thisHost.newEntry === true) {
159
- const hostServiceId = Number(thisHost.service);
160
- const selectedService = services.filter(entry => entry.id == hostServiceId)[0];
161
- hosts[index].foremanParameters = selectedService.foremanParameters;
162
- hosts[index].ansibleParameters = selectedService.ansibleParameters;
163
- services = calculateServiceUsage(hostServiceId, services);
177
+ const hostServiceId = Number(thisHost.service);
178
+ const selectedService = services.filter(
179
+ entry => entry.id === hostServiceId
180
+ )[0];
181
+ hosts[index].foremanParameters = selectedService.foremanParameters;
182
+ hosts[index].ansibleParameters = selectedService.ansibleParameters;
183
+ services = calculateServiceUsage(hostServiceId, services);
164
184
  }
165
185
 
166
186
  delete hosts[index].backup;
@@ -168,8 +188,8 @@ const applicationInstanceConf = (state = initialState, action) => {
168
188
 
169
189
  return state.merge({
170
190
  editMode: false,
171
- services: services,
172
- hosts: hosts
191
+ services,
192
+ hosts,
173
193
  });
174
194
  }
175
195
  case APPLICATION_INSTANCE_HOST_EDIT_CHANGE: {
@@ -193,20 +213,22 @@ const applicationInstanceConf = (state = initialState, action) => {
193
213
 
194
214
  return state.merge({
195
215
  editMode: false,
196
- hosts: hosts
216
+ hosts,
197
217
  });
198
218
  }
199
219
  case APPLICATION_INSTANCE_HOST_EDIT_ERROR: {
200
220
  return state.merge({
201
221
  showAlertModal: true,
202
- alertModalTitle: __("Error"),
222
+ alertModalTitle: __('Error'),
203
223
  alertModalText: payload,
204
224
  });
205
225
  }
206
226
  case APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN: {
207
- let parametersData = {};
227
+ const parametersData = {};
208
228
 
209
- const selectedService = state.services.filter(entry => entry.id == payload.rowData.service)[0];
229
+ const selectedService = state.services.filter(
230
+ entry => entry.id === payload.rowData.service
231
+ )[0];
210
232
 
211
233
  parametersData.paramDefinition = {
212
234
  id: selectedService.id,
@@ -214,7 +236,7 @@ const applicationInstanceConf = (state = initialState, action) => {
214
236
  dataId: selectedService.hostgroup,
215
237
  hostId: payload.rowData.id,
216
238
  // TODO: is this really correct? Guess it shoud be dataId and we should get rid of them
217
- //hostgroup_id: selectedService.hostgroup,
239
+ // hostgroup_id: selectedService.hostgroup,
218
240
  };
219
241
  parametersData.type = PARAMETER_SELECTION_PARAM_TYPE_FOREMAN;
220
242
  parametersData.parameters = payload.rowData.foremanParameters;
@@ -224,42 +246,45 @@ const applicationInstanceConf = (state = initialState, action) => {
224
246
  parametersData.allowDescriptionAdjustment = false;
225
247
 
226
248
  return state.merge({
227
- parametersData: parametersData,
249
+ parametersData,
228
250
  });
229
251
  }
230
252
  case APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE: {
231
- if (payload.mode == 'save') {
253
+ if (payload.mode === 'save') {
232
254
  const hosts = cloneDeep(state.hosts);
233
- const index = findIndex(hosts, { id: state.parametersData.paramDefinition.hostId });
255
+ const index = findIndex(hosts, {
256
+ id: state.parametersData.paramDefinition.hostId,
257
+ });
234
258
  hosts[index].foremanParameters = cloneDeep(payload.parameterSelection);
235
259
 
236
260
  return state.merge({
237
261
  parametersData: null,
238
- hosts: hosts
239
- });
240
- } else {
241
- return state.merge({
242
- parametersData: null,
262
+ hosts,
243
263
  });
244
264
  }
265
+ return state.merge({
266
+ parametersData: null,
267
+ });
245
268
  }
246
269
  case APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN: {
247
- let parametersData = {};
270
+ const parametersData = {};
248
271
 
249
- if ((payload.hasOwnProperty('isAllGroup')) && (payload.isAllGroup == true)) {
272
+ if (payload.hasOwnProperty('isAllGroup') && payload.isAllGroup === true) {
250
273
  parametersData.parameters = state.ansibleVarsAll;
251
274
  parametersData.paramDefinition = {
252
275
  isAllGroup: true,
253
- }
276
+ };
254
277
  } else {
255
- const selectedService = state.services.filter(entry => entry.id == payload.rowData.service)[0];
278
+ const selectedService = state.services.filter(
279
+ entry => entry.id === payload.rowData.service
280
+ )[0];
256
281
 
257
282
  parametersData.paramDefinition = {
258
283
  id: selectedService.id,
259
284
  name: selectedService.name,
260
285
  hostId: payload.rowData.id,
261
286
  // TODO: is this really correct? Guess it shoud be dataId and we should get rid of them
262
- //hostgroup_id: selectedService.hostgroup,
287
+ // hostgroup_id: selectedService.hostgroup,
263
288
  };
264
289
  parametersData.parameters = payload.rowData.ansibleParameters;
265
290
  }
@@ -271,25 +296,32 @@ const applicationInstanceConf = (state = initialState, action) => {
271
296
  parametersData.allowDescriptionAdjustment = false;
272
297
 
273
298
  return state.merge({
274
- parametersData: parametersData,
299
+ parametersData,
275
300
  });
276
301
  }
277
302
  case APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE: {
278
303
  let newState = {};
279
- if (payload.mode == 'save') {
280
- if ((state.parametersData.paramDefinition.hasOwnProperty('isAllGroup')) && (state.parametersData.paramDefinition.isAllGroup == true)) {
304
+ if (payload.mode === 'save') {
305
+ if (
306
+ state.parametersData.paramDefinition.hasOwnProperty('isAllGroup') &&
307
+ state.parametersData.paramDefinition.isAllGroup === true
308
+ ) {
281
309
  newState = {
282
310
  parametersData: null,
283
311
  ansibleVarsAll: cloneDeep(payload.parameterSelection),
284
312
  };
285
313
  } else {
286
314
  const hosts = cloneDeep(state.hosts);
287
- const index = findIndex(hosts, { id: state.parametersData.paramDefinition.hostId });
288
- hosts[index].ansibleParameters = cloneDeep(payload.parameterSelection);
315
+ const index = findIndex(hosts, {
316
+ id: state.parametersData.paramDefinition.hostId,
317
+ });
318
+ hosts[index].ansibleParameters = cloneDeep(
319
+ payload.parameterSelection
320
+ );
289
321
 
290
322
  newState = {
291
323
  parametersData: null,
292
- hosts: hosts
324
+ hosts,
293
325
  };
294
326
  }
295
327
  } else {
@@ -300,23 +332,32 @@ const applicationInstanceConf = (state = initialState, action) => {
300
332
  return state.merge(newState);
301
333
  }
302
334
  case APPLICATION_INSTANCE_ADD_EXISTING_HOSTS_MODAL_OPEN: {
335
+ return state;
303
336
  }
304
337
  case APPLICATION_INSTANCE_ADD_EXISTING_HOSTS_MODAL_CLOSE: {
305
- if (payload.mode == 'save') {
306
- let newState;
338
+ if (payload.mode === 'save') {
307
339
  let hosts = [];
308
340
  let index = 1;
309
341
  let services = cloneDeep(state.services);
310
342
 
311
- if ('hosts' in state && state.hosts !== undefined && state.hosts.length > 0) {
343
+ if (
344
+ 'hosts' in state &&
345
+ state.hosts !== undefined &&
346
+ state.hosts.length > 0
347
+ ) {
312
348
  hosts = cloneDeep(state.hosts);
313
349
  index = Math.max(...hosts.map(e => e.id));
314
350
  }
315
351
 
316
352
  payload.selectedHosts.forEach(host => {
317
- if ((state.hosts == undefined) || (state.hosts.find(h => h.hostname == host.hostname) == undefined)) {
353
+ if (
354
+ state.hosts === undefined ||
355
+ state.hosts.find(h => h.hostname === host.hostname) === undefined
356
+ ) {
318
357
  index += 1;
319
- const selectedService = services.filter(entry => entry.id == host.serviceId)[0];
358
+ const selectedService = services.filter(
359
+ entry => entry.id === host.serviceId
360
+ )[0];
320
361
  const newRow = {
321
362
  id: index,
322
363
  hostname: host.hostname,
@@ -325,19 +366,18 @@ const applicationInstanceConf = (state = initialState, action) => {
325
366
  isExistingHost: true,
326
367
  foremanParameters: [], // we will never set this because we don't want to change a already existing host.
327
368
  ansibleParameters: selectedService.ansibleParameters,
328
- }
369
+ };
329
370
  hosts.push(newRow);
330
371
  services = calculateServiceUsage(host.serviceId, services);
331
372
  }
332
373
  });
333
374
 
334
375
  return state.merge({
335
- hosts: hosts,
336
- services, services
376
+ hosts,
377
+ services,
337
378
  });
338
- } else {
339
- return state;
340
379
  }
380
+ return state;
341
381
  }
342
382
  case APPLICATION_INSTANCE_CHANGE_PARAMETER_SELECTION_MODE: {
343
383
  return state.merge({ paramEditMode: payload.mode });
@@ -1,14 +1,23 @@
1
- const applicationInstanceConf = state => state.foremanAcd.applicationInstanceConf;
1
+ const applicationInstanceConf = state =>
2
+ state.foremanAcd.applicationInstanceConf;
2
3
 
3
- export const selectShowAlertModal = state => applicationInstanceConf(state).showAlertModal;
4
- export const selectAlertModalText = state => applicationInstanceConf(state).alertModalText;
5
- export const selectAlertModalTitle = state => applicationInstanceConf(state).alertModalTitle;
4
+ export const selectShowAlertModal = state =>
5
+ applicationInstanceConf(state).showAlertModal;
6
+ export const selectAlertModalText = state =>
7
+ applicationInstanceConf(state).alertModalText;
8
+ export const selectAlertModalTitle = state =>
9
+ applicationInstanceConf(state).alertModalTitle;
6
10
  export const selectEditMode = state => applicationInstanceConf(state).editMode;
7
- export const selectAppDefinition = state => applicationInstanceConf(state).appDefinition;
11
+ export const selectAppDefinition = state =>
12
+ applicationInstanceConf(state).appDefinition;
8
13
  export const selectHosts = state => applicationInstanceConf(state).hosts;
9
14
  export const selectColumns = state => applicationInstanceConf(state).columns;
10
- export const selectHiddenForemanParameterTypes = state => applicationInstanceConf(state).hiddenForemanParameterTypes;
15
+ export const selectHiddenForemanParameterTypes = state =>
16
+ applicationInstanceConf(state).hiddenForemanParameterTypes;
11
17
  export const selectServices = state => applicationInstanceConf(state).services;
12
- export const selectParametersData = state => applicationInstanceConf(state).parametersData;
13
- export const selectAnsibleVarsAll = state => applicationInstanceConf(state).ansibleVarsAll;
14
- export const selectParamEditMode = state => applicationInstanceConf(state).paramEditMode;
18
+ export const selectParametersData = state =>
19
+ applicationInstanceConf(state).parametersData;
20
+ export const selectAnsibleVarsAll = state =>
21
+ applicationInstanceConf(state).ansibleVarsAll;
22
+ export const selectParamEditMode = state =>
23
+ applicationInstanceConf(state).paramEditMode;