foreman_acd 0.0.6 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +107 -56
  3. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +124 -0
  4. data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +72 -0
  5. data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +2 -2
  6. data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +62 -0
  7. data/app/controllers/foreman_acd/app_definitions_controller.rb +46 -9
  8. data/app/controllers/foreman_acd/app_instances_controller.rb +96 -90
  9. data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +23 -0
  10. data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
  11. data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
  12. data/app/controllers/foreman_acd/remote_execution_controller.rb +46 -0
  13. data/app/controllers/ui_acd_controller.rb +20 -4
  14. data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +42 -0
  15. data/app/lib/actions/foreman_acd/run_configurator.rb +41 -0
  16. data/app/models/concerns/foreman_acd/host_managed_extensions.rb +51 -0
  17. data/app/models/foreman_acd/acd_provider.rb +30 -0
  18. data/app/models/foreman_acd/ansible_playbook.rb +67 -0
  19. data/app/models/foreman_acd/app_definition.rb +25 -1
  20. data/app/models/foreman_acd/app_instance.rb +42 -0
  21. data/app/models/foreman_acd/foreman_host.rb +23 -0
  22. data/app/models/foreman_acd/taxonomy_extensions.rb +17 -0
  23. data/app/services/foreman_acd/app_configurator.rb +54 -0
  24. data/app/services/foreman_acd/app_deployer.rb +151 -0
  25. data/app/services/foreman_acd/inventory_creator.rb +54 -0
  26. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +30 -0
  27. data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +11 -0
  28. data/app/views/foreman_acd/ansible_playbooks/index.html.erb +30 -0
  29. data/app/views/foreman_acd/ansible_playbooks/new.html.erb +3 -0
  30. data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +5 -0
  31. data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +5 -0
  32. data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +9 -0
  33. data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +5 -0
  34. data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +5 -0
  35. data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +9 -0
  36. data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +5 -0
  37. data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +5 -0
  38. data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +5 -0
  39. data/app/views/foreman_acd/app_definitions/_form.html.erb +34 -20
  40. data/app/views/foreman_acd/app_definitions/edit.html.erb +10 -0
  41. data/app/views/foreman_acd/app_definitions/import.html.erb +18 -0
  42. data/app/views/foreman_acd/app_definitions/index.html.erb +10 -6
  43. data/app/views/foreman_acd/app_instances/_form.html.erb +12 -10
  44. data/app/views/foreman_acd/app_instances/edit.html.erb +10 -0
  45. data/app/views/foreman_acd/app_instances/index.html.erb +87 -9
  46. data/app/views/foreman_acd/app_instances/report.html.erb +22 -0
  47. data/app/views/templates/job/run_acd_ansible_playbook.erb +62 -0
  48. data/app/views/ui_acd/ansible_data.json.rabl +6 -0
  49. data/app/views/ui_acd/app.json.rabl +6 -2
  50. data/app/views/ui_acd/app_definition.json.rabl +1 -1
  51. data/app/views/ui_acd/{fdata.json.rabl → foreman_data.json.rabl} +1 -1
  52. data/config/routes.rb +35 -1
  53. data/db/migrate/20190610202252_create_app_definitions.rb +1 -3
  54. data/db/migrate/20190625140305_create_app_instances.rb +1 -1
  55. data/db/migrate/20200916091018_create_ansible_playbooks.rb +20 -0
  56. data/db/migrate/20200917120220_add_ansible_playbook_id.rb +14 -0
  57. data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +8 -0
  58. data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +8 -0
  59. data/db/migrate/20210112111548_add_organization_to_app_instance.rb +22 -0
  60. data/db/migrate/20210112113853_add_location_to_app_instance.rb +8 -0
  61. data/db/migrate/20210202141658_create_foreman_hosts.rb +24 -0
  62. data/db/migrate/20210204111306_remove_hosts_from_app_instances.rb +8 -0
  63. data/db/migrate/20210209091014_rename_acd_tables.rb +16 -0
  64. data/db/migrate/20210216083522_add_last_progress_report.rb +8 -0
  65. data/db/migrate/20210216091529_add_last_deploy_task.rb +8 -0
  66. data/db/seeds.d/62_acd_proxy_feature.rb +4 -0
  67. data/db/seeds.d/75-job_templates.rb +13 -0
  68. data/lib/foreman_acd/engine.rb +21 -3
  69. data/lib/foreman_acd/plugin.rb +112 -20
  70. data/lib/foreman_acd/version.rb +1 -1
  71. data/locale/en/foreman_acd.edit.po +326 -0
  72. data/locale/en/foreman_acd.po +232 -2
  73. data/locale/en/foreman_acd.po.time_stamp +0 -0
  74. data/locale/foreman_acd.pot +343 -8
  75. data/package.json +1 -1
  76. data/test/controllers/ansible_playbooks_controller_test.rb +27 -0
  77. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +391 -0
  78. data/webpack/components/ApplicationDefinition/ApplicationDefinition.scss +1 -0
  79. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +303 -0
  80. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +15 -0
  81. data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +26 -0
  82. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +269 -0
  83. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +9 -0
  84. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +49 -0
  85. data/webpack/components/ApplicationDefinition/index.js +35 -0
  86. data/webpack/components/ApplicationInstance/ApplicationInstance.js +451 -0
  87. data/webpack/components/ApplicationInstance/ApplicationInstance.scss +11 -0
  88. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +247 -0
  89. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +15 -0
  90. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +309 -0
  91. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +10 -0
  92. data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +49 -0
  93. data/webpack/components/ApplicationInstance/components/Service.js +30 -0
  94. data/webpack/components/ApplicationInstance/components/ServiceCounter.js +37 -0
  95. data/webpack/components/ApplicationInstance/index.js +37 -0
  96. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +148 -0
  97. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +44 -0
  98. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +42 -0
  99. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +2 -0
  100. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +38 -0
  101. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +4 -0
  102. data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +26 -0
  103. data/webpack/components/ApplicationInstanceReport/index.js +25 -0
  104. data/webpack/components/ParameterSelection/ParameterSelection.js +131 -192
  105. data/webpack/components/ParameterSelection/ParameterSelection.scss +9 -0
  106. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +87 -110
  107. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +15 -19
  108. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +3 -35
  109. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +116 -84
  110. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +3 -7
  111. data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +12 -21
  112. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +1 -1
  113. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +3 -45
  114. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +20 -0
  115. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +22 -46
  116. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
  117. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +40 -265
  118. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +11 -96
  119. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +3 -9
  120. data/webpack/components/ParameterSelection/index.js +6 -8
  121. data/webpack/components/common/AddTableEntry.js +30 -0
  122. data/webpack/components/common/DeleteTableEntry.js +39 -0
  123. data/webpack/components/common/EasyHeaderFormatter.js +18 -0
  124. data/webpack/components/common/EditTableEntry.js +50 -0
  125. data/webpack/components/common/ExtSelect.js +43 -0
  126. data/webpack/components/common/LockTableEntry.js +60 -0
  127. data/webpack/components/common/RailsData.js +27 -0
  128. data/webpack/components/common/__tests__/AddTableEntry.test.js +26 -0
  129. data/webpack/components/common/__tests__/DeleteTableEntry.test.js +29 -0
  130. data/webpack/components/common/__tests__/ExtSelect.test.js +38 -0
  131. data/webpack/components/common/__tests__/RailsData.test.js +16 -0
  132. data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +35 -0
  133. data/webpack/components/common/__tests__/__snapshots__/AddTableEntry.test.js.snap +35 -0
  134. data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +41 -0
  135. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +41 -0
  136. data/webpack/components/common/__tests__/__snapshots__/ExtSelect.test.js.snap +18 -0
  137. data/webpack/components/common/__tests__/__snapshots__/RailsData.test.js.snap +10 -0
  138. data/webpack/helper.js +20 -0
  139. data/webpack/index.js +6 -0
  140. data/webpack/reducer.js +43 -3
  141. metadata +114 -20
@@ -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
+
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import * as sort from 'sortabular';
3
+ import { translate as __ } from 'foremanReact/common/I18n';
3
4
 
4
5
  import {
5
6
  actionHeaderCellFormatter,
@@ -16,37 +17,34 @@ import {
16
17
  } from 'foremanReact/common/helpers';
17
18
 
18
19
  import {
19
- isNewDefinition,
20
- isEditDefinition,
21
- isDefinition,
22
- isNewInstance,
23
- isEditInstance,
24
- isInstance,
25
20
  filterUsedParameterTypes,
26
21
  } from './ParameterSelectionHelper';
27
22
 
28
23
  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,
24
+ PARAMETER_SELECTION_INIT,
25
+ PARAMETER_SELECTION_TYPES,
26
+ PARAMETER_SELECTION_LOCK,
27
+ PARAMETER_SELECTION_DELETE,
28
+ PARAMETER_SELECTION_ADD,
29
+ PARAMETER_SELECTION_EDIT_ACTIVATE,
30
+ PARAMETER_SELECTION_EDIT_CONFIRM,
31
+ PARAMETER_SELECTION_EDIT_CHANGE,
32
+ PARAMETER_SELECTION_EDIT_CANCEL,
33
+ PARAMETER_SELECTION_SORT,
34
+ PARAMETER_SELECTION_PARAM_TYPE_FOREMAN,
35
+ PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE,
36
+ PARAMETER_SELECTION_LOAD_PARAM_DATA_REQUEST,
37
+ PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS,
38
+ PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE,
44
39
  } from './ParameterSelectionConstants';
45
40
 
46
41
  export const initParameterSelection = (
47
- mode,
48
- appDefinition,
42
+ paramType,
43
+ paramDefinition,
49
44
  parameters,
45
+ useDefaultValue,
46
+ allowNameAdjustment,
47
+ allowDescriptionAdjustment,
50
48
  sortingFormatter,
51
49
  sortableTransform,
52
50
  inlineEditFormatter,
@@ -60,23 +58,28 @@ export const initParameterSelection = (
60
58
  position: 0
61
59
  }
62
60
  };
63
- initialState.appDefinition = appDefinition;
61
+ initialState.paramDefinition = paramDefinition;
64
62
 
65
- var valueLabel = 'Value';
66
- if (isDefinition(mode)) {
67
- valueLabel = 'Default value';
63
+ let valueLabel = __('Value');
64
+ if (useDefaultValue) {
65
+ valueLabel = __('Default value');
68
66
  }
69
67
 
70
- initialState.columns = [
71
- {
68
+ initialState.columns = []
69
+ const addToColumns = (obj, idx) => {
70
+ obj.header.props.index = idx;
71
+ initialState.columns.push(obj);
72
+ }
73
+
74
+ let idx = 0;
75
+ addToColumns( {
72
76
  property: 'name',
73
77
  header: {
74
- label: 'Name',
78
+ label: __('Name'),
75
79
  props: {
76
- index: 0,
77
80
  sort: true,
78
81
  style: {
79
- width: '20%'
82
+ width: '25%'
80
83
  }
81
84
  },
82
85
  transforms: [sortableTransform],
@@ -84,15 +87,15 @@ export const initParameterSelection = (
84
87
  customFormatters: [sortableHeaderCellFormatter]
85
88
  },
86
89
  cell: {
87
- formatters: [isDefinition(mode) ? inlineEditFormatter : tableCellFormatter]
90
+ formatters: [allowNameAdjustment ? inlineEditFormatter : tableCellFormatter]
88
91
  }
89
- },
90
- {
92
+ }, idx++);
93
+
94
+ addToColumns( {
91
95
  property: 'description',
92
96
  header: {
93
- label: 'Description',
97
+ label: __('Description'),
94
98
  props: {
95
- index: 1,
96
99
  sort: true,
97
100
  style: {
98
101
  width: '25%'
@@ -106,15 +109,16 @@ export const initParameterSelection = (
106
109
  props: {
107
110
  index: 1
108
111
  },
109
- formatters: [isDefinition(mode) ? inlineEditFormatter : tableCellFormatter]
112
+ formatters: [allowDescriptionAdjustment ? inlineEditFormatter : tableCellFormatter]
110
113
  }
111
- },
112
- {
114
+ }, idx++);
115
+
116
+ if (paramType == PARAMETER_SELECTION_PARAM_TYPE_FOREMAN) {
117
+ addToColumns( {
113
118
  property: 'type',
114
119
  header: {
115
- label: 'Type',
120
+ label: __('Type'),
116
121
  props: {
117
- index: 2,
118
122
  sort: true,
119
123
  style: {
120
124
  width: '20%'
@@ -125,23 +129,21 @@ export const initParameterSelection = (
125
129
  customFormatters: [sortableHeaderCellFormatter]
126
130
  },
127
131
  cell: {
128
- props: {
129
- index: 2
130
- },
131
132
  // we are always using the inlineEditFormatter so that
132
133
  // the well formatted type name is shown
133
134
  formatters: [inlineEditFormatter]
134
135
  }
135
- },
136
- {
136
+ }, idx++);
137
+ }
138
+
139
+ addToColumns( {
137
140
  property: 'value',
138
141
  header: {
139
142
  label: valueLabel,
140
143
  props: {
141
- index: 3,
142
144
  sort: true,
143
145
  style: {
144
- width: '25%'
146
+ width: '20%'
145
147
  }
146
148
  },
147
149
  transforms: [sortableTransform],
@@ -149,96 +151,90 @@ export const initParameterSelection = (
149
151
  customFormatters: [sortableHeaderCellFormatter]
150
152
  },
151
153
  cell: {
152
- props: {
153
- index: 3
154
- },
155
154
  formatters: [inlineEditFormatter]
156
155
  }
157
- },
158
- {
156
+ }, idx++);
157
+
158
+ addToColumns( {
159
159
  property: 'actions',
160
160
  header: {
161
- label: 'Actions',
161
+ label: __('Actions'),
162
162
  props: {
163
- index: 4
163
+ style: {
164
+ width: '10%'
165
+ }
164
166
  },
165
167
  formatters: [actionHeaderCellFormatter]
166
168
  },
167
169
  cell: {
168
- props: {
169
- index: 4
170
- },
171
170
  formatters: [inlineEditButtonsFormatter]
172
171
  }
173
- }
174
- ];
172
+ }, idx++);
175
173
 
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;
181
- } else {
182
- // FIXME: should never ever happen
183
- }
174
+ initialState.parameters = parameters;
184
175
 
185
- if (isNewDefinition(mode) || isNewInstance(mode)) {
186
- initialState.parameterTypes = PARAMETER_TYPES;
187
- } else {
188
- initialState.parameterTypes = filterUsedParameterTypes(PARAMETER_TYPES, parameters);
176
+ if ((paramType == PARAMETER_SELECTION_PARAM_TYPE_FOREMAN) && (parameters)) {
177
+ initialState.parameterTypes = filterUsedParameterTypes(PARAMETER_SELECTION_TYPES, parameters);
189
178
  }
190
179
 
191
180
  dispatch({
192
- type: INIT_PARAMETER_SELECTION,
181
+ type: PARAMETER_SELECTION_INIT,
193
182
  payload: initialState,
194
183
  });
195
184
  }
196
185
 
197
186
  const errorHandler = (msg, err) => {
198
187
  const error = {
199
- errorMsg: 'Failed to fetch data from server.',
188
+ errorMsg: __('Failed to fetch data from server.'),
200
189
  statusText: err,
201
190
  };
202
191
  return { type: msg, payload: { error } };
203
192
  };
204
193
 
194
+ export const lockParameter = (additionalData) => ({
195
+ type: PARAMETER_SELECTION_LOCK,
196
+ payload: {
197
+ ...additionalData,
198
+ },
199
+ });
200
+
205
201
  export const addParameter = (additionalData) => ({
206
- type: PARAMETER_ADD,
202
+ type: PARAMETER_SELECTION_ADD,
207
203
  payload: {
208
204
  ...additionalData,
209
205
  },
210
206
  });
211
207
 
212
208
  export const deleteParameter = (additionalData) => ({
213
- type: PARAMETER_DELETE,
209
+ type: PARAMETER_SELECTION_DELETE,
214
210
  payload: {
215
211
  ...additionalData,
216
212
  },
217
213
  });
218
214
 
219
215
  export const activateEditParameter = (additionalData) => ({
220
- type: PARAMETER_EDIT_ACTIVATE,
216
+ type: PARAMETER_SELECTION_EDIT_ACTIVATE,
221
217
  payload: {
222
218
  ...additionalData,
223
219
  },
224
220
  });
225
221
 
226
222
  export const confirmEditParameter = (rowData) => ({
227
- type: PARAMETER_EDIT_CONFIRM,
223
+ type: PARAMETER_SELECTION_EDIT_CONFIRM,
228
224
  payload: {
229
225
  ...rowData,
230
226
  },
231
227
  });
232
228
 
233
229
  export const cancelEditParameter = (rowData) => ({
234
- type: PARAMETER_EDIT_CANCEL,
230
+ type: PARAMETER_SELECTION_EDIT_CANCEL,
235
231
  payload: {
236
232
  ...rowData,
237
233
  },
238
234
  });
239
235
 
240
236
  export const changeEditParameter = (value, additionalData) => ({
241
- type: PARAMETER_EDIT_CHANGE,
237
+ type: PARAMETER_SELECTION_EDIT_CHANGE,
242
238
  payload: {
243
239
  value,
244
240
  ...additionalData,
@@ -246,49 +242,30 @@ export const changeEditParameter = (value, additionalData) => ({
246
242
  });
247
243
 
248
244
  export const sortParameter = (selectedColumn, defaultSortingOrder) => ({
249
- type: PARAMETER_SORT,
245
+ type: PARAMETER_SELECTION_SORT,
250
246
  payload: {
251
247
  selectedColumn,
252
248
  defaultSortingOrder,
253
249
  },
254
250
  });
255
251
 
256
- export const loadParameterSelection = (
257
- url,
258
- applicationDefinitionId
259
- ) => dispatch => {
260
- dispatch({ type: LOAD_PARAMETER_SELECTION_REQUEST });
252
+ export const loadParamData = (attr) => dispatch => {
253
+ dispatch( { type: PARAMETER_SELECTION_LOAD_PARAM_DATA_REQUEST, payload: { dataType: attr.dataType, clearParameters: attr.clearParameters } });
261
254
 
262
- var realUrl = url.replace("__id__", applicationDefinitionId);
255
+ let realUrl = attr.url.replace("__id__", attr.paramDefinition.dataId);
263
256
 
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
- export const loadForemanData = (
276
- url,
277
- hostgroupId,
278
- clearRows = false,
279
- ) => dispatch => {
280
- dispatch({ type: LOAD_FOREMAN_DATA_REQUEST, payload: { clearRows: clearRows } });
281
-
282
- var realUrl = url.replace("__id__", hostgroupId);
257
+ if (attr.paramDefinition.hasOwnProperty('dataSubId')) {
258
+ realUrl = realUrl.replace("__subid__", attr.paramDefinition.dataSubId);
259
+ }
283
260
 
284
261
  return api
285
262
  .get(realUrl, {}, {})
286
263
  .then(({ data }) =>
287
264
  dispatch({
288
- type: LOAD_FOREMAN_DATA_SUCCESS,
289
- payload: data,
265
+ type: PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS,
266
+ payload: { ...data, dataType: attr.dataType }
290
267
  })
291
268
  )
292
- .catch(error => dispatch(errorHandler(LOAD_FOREMAN_DATA_FAILURE, error)));
269
+ .catch(error => dispatch(errorHandler(PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE, error)));
293
270
  };
294
271
 
@@ -1,27 +1,23 @@
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_LOCK = 'PARAMETER_SELECTION_LOCK';
3
+ export const PARAMETER_SELECTION_DELETE = 'PARAMETER_SELECTION_DELETE';
4
+ export const PARAMETER_SELECTION_ADD = 'PARAMETER_SELECTION_ADD';
5
+ export const PARAMETER_SELECTION_EDIT_ACTIVATE = 'PARAMETER_SELECTION_EDIT_ACTIVATE';
6
+ export const PARAMETER_SELECTION_EDIT_CONFIRM = 'PARAMETER_SELECTION_EDIT_CONFIRM';
7
+ export const PARAMETER_SELECTION_EDIT_CHANGE = 'PARAMETER_SELECTION_EDIT_CHANGE';
8
+ export const PARAMETER_SELECTION_EDIT_CANCEL = 'PARAMETER_SELECTION_EDIT_CANCEL';
9
+ export const PARAMETER_SELECTION_SORT = 'PARAMETER_SELECTION_SORT';
10
+ export const PARAMETER_SELECTION_LOAD_PARAM_DATA_REQUEST = 'PARAMETER_SELECTION_LOAD_PARAM_DATA_REQUEST';
11
+ export const PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS = 'PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS';
12
+ export const PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE = 'PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE';
13
+ export const PARAMETER_SELECTION_PARAM_TYPE_FOREMAN = 'PARAMETER_SELECTION_PARAM_TYPE_FOREMAN';
14
+ export const PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE = 'PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE';
18
15
 
19
16
  // Make sure the object is sorted by value
20
17
  // (Compute Profile -> Partition table -> Root password)
21
- export const PARAMETER_TYPES = {
18
+ export const PARAMETER_SELECTION_TYPES = {
22
19
  computeprofile: 'Compute profile',
23
20
  domain: 'Domain',
24
- hostname: 'Hostname',
25
21
  hostparam: 'Host parameter',
26
22
  ip: 'IP',
27
23
  lifecycleenv: 'Lifecycle environment',
@@ -2,51 +2,19 @@ import {
2
2
  cloneDeep,
3
3
  } from 'lodash';
4
4
 
5
- export const isNewDefinition = (mode) => {
6
- if (mode == "newDefinition")
7
- return true;
8
- return false;
9
- }
10
-
11
- export const isEditDefinition = (mode) => {
12
- if (mode == "editDefinition")
13
- return true;
14
- return false;
15
- }
16
-
17
- export const isDefinition = (mode) => {
18
- return (isNewDefinition(mode) || isEditDefinition(mode))
19
- }
20
-
21
- export const isNewInstance = (mode) => {
22
- if (mode == "newInstance")
23
- return true;
24
- return false;
25
- }
26
-
27
- export const isEditInstance = (mode) => {
28
- if (mode == "editInstance")
29
- return true;
30
- return false;
31
- }
32
-
33
- export const isInstance = (mode) => {
34
- return (isNewInstance(mode) || isEditInstance(mode))
35
- }
36
-
37
5
  export const transformForemanData = (fdata) => {
38
6
  if (fdata === undefined) {
39
7
  return "";
40
8
  }
41
- var result = {};
9
+ const result = {};
42
10
  fdata.map(item => result[item.id] = item.name)
43
11
  return (result);
44
12
  }
45
13
 
46
14
  export const filterUsedParameterTypes = (options, parameters) => {
47
- var newOptions = cloneDeep(options);
15
+ const newOptions = cloneDeep(options);
48
16
  // hostparam can be used multiple times
49
- var alreadyUsed = parameters.map(item => item["type"]).filter(item => item != 'hostparam');
17
+ const alreadyUsed = parameters.map(item => item["type"]).filter(item => item != 'hostparam');
50
18
  alreadyUsed.forEach(item => delete newOptions[item])
51
19
  return newOptions;
52
20
  }