foreman_acd 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -3
  3. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +17 -2
  4. data/app/controllers/foreman_acd/app_definitions_controller.rb +104 -7
  5. data/app/controllers/foreman_acd/app_instances_controller.rb +15 -30
  6. data/app/controllers/foreman_acd/concerns/app_instance_mixins.rb +36 -0
  7. data/app/controllers/ui_acd_controller.rb +38 -1
  8. data/app/lib/actions/foreman_acd/run_configurator.rb +1 -0
  9. data/app/models/concerns/foreman_acd/host_managed_extensions.rb +15 -27
  10. data/app/models/foreman_acd/app_instance.rb +47 -2
  11. data/app/models/foreman_acd/foreman_host.rb +8 -0
  12. data/app/services/foreman_acd/app_deployer.rb +19 -2
  13. data/app/services/foreman_acd/inventory_creator.rb +11 -1
  14. data/app/views/foreman_acd/app_definitions/import.html.erb +20 -1
  15. data/app/views/foreman_acd/app_definitions/index.html.erb +3 -6
  16. data/app/views/foreman_acd/app_instances/index.html.erb +15 -11
  17. data/app/views/foreman_acd/app_instances/report.html.erb +7 -2
  18. data/app/views/ui_acd/host_report.json.rabl +4 -0
  19. data/app/views/ui_acd/report_data.json.rabl +10 -0
  20. data/app/views/ui_acd/validate_hostname.json.rabl +6 -0
  21. data/config/routes.rb +3 -0
  22. data/db/migrate/20210818125913_add_is_existing_host_to_foreman_host.rb +8 -0
  23. data/db/migrate/20210902110645_add_initial_configure_task.rb +8 -0
  24. data/lib/foreman_acd/plugin.rb +6 -6
  25. data/lib/foreman_acd/version.rb +1 -1
  26. data/lib/foreman_acd.rb +27 -9
  27. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +2 -0
  28. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +28 -9
  29. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +6 -0
  30. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +1 -0
  31. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +30 -9
  32. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +3 -0
  33. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +1 -0
  34. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinition.test.js.snap +30 -5
  35. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +1 -1
  36. data/webpack/components/ApplicationDefinition/components/__tests__/__snapshots__/AnsiblePlaybookSelector.test.js.snap +3 -3
  37. data/webpack/components/ApplicationDefinition/index.js +6 -0
  38. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +214 -0
  39. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.scss +1 -0
  40. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +161 -0
  41. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +6 -0
  42. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +79 -0
  43. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +8 -0
  44. data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportConfData_1.fixtures.js +129 -0
  45. data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +29 -0
  46. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +20 -0
  47. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +43 -0
  48. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +29 -0
  49. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +62 -0
  50. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportReducer.test.js.snap +362 -0
  51. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +130 -0
  52. data/webpack/components/ApplicationDefinitionImport/index.js +32 -0
  53. data/webpack/components/ApplicationInstance/ApplicationInstance.js +96 -25
  54. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +112 -6
  55. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +4 -0
  56. data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +15 -0
  57. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +71 -30
  58. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +3 -0
  59. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +2 -0
  60. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +1 -0
  61. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +12 -0
  62. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +97 -7
  63. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +271 -0
  64. data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +1 -0
  65. data/webpack/components/ApplicationInstance/components/ServiceCounter.js +1 -1
  66. data/webpack/components/ApplicationInstance/helper.js +0 -0
  67. data/webpack/components/ApplicationInstance/index.js +6 -0
  68. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +81 -6
  69. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +35 -1
  70. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +3 -0
  71. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +19 -0
  72. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +4 -0
  73. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReport.test.js.snap +1 -124
  74. data/webpack/components/ApplicationInstanceReport/index.js +8 -1
  75. data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +104 -0
  76. data/webpack/components/ExistingHostSelection/ExistingHostSelection.scss +15 -0
  77. data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +71 -0
  78. data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +4 -0
  79. data/webpack/components/ExistingHostSelection/ExistingHostSelectionHelper.js +0 -0
  80. data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +90 -0
  81. data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -0
  82. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +191 -0
  83. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +203 -0
  84. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +19 -0
  85. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionReducer.test.js +59 -0
  86. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +36 -0
  87. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelection.test.js.snap +35 -0
  88. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionReducer.test.js.snap +614 -0
  89. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +27 -0
  90. data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +48 -0
  91. data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +35 -0
  92. data/webpack/components/ExistingHostSelection/components/__tests__/__snapshots__/ServiceSelector.test.js.snap +77 -0
  93. data/webpack/components/ExistingHostSelection/index.js +26 -0
  94. data/webpack/components/ParameterSelection/ParameterSelection.js +98 -1
  95. data/webpack/components/ParameterSelection/ParameterSelection.scss +7 -0
  96. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +36 -2
  97. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +2 -0
  98. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +49 -8
  99. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +1 -0
  100. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +2 -0
  101. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +96 -0
  102. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +5 -0
  103. data/webpack/components/ParameterSelection/index.js +2 -1
  104. data/webpack/components/SyncGitRepo/SyncGitRepo.js +2 -10
  105. data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +1 -2
  106. data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +0 -1
  107. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +1 -0
  108. data/webpack/components/SyncGitRepo/components/FormTextInput.js +1 -1
  109. data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +3 -2
  110. data/webpack/components/common/DeleteTableEntry.js +16 -2
  111. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +38 -0
  112. data/webpack/helper.js +5 -0
  113. data/webpack/index.js +5 -0
  114. data/webpack/js-yaml.js +3874 -0
  115. data/webpack/reducer.js +13 -2
  116. metadata +46 -2
@@ -0,0 +1,35 @@
1
+ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import ServiceSelector from '../ServiceSelector';
4
+
5
+ const noop = () => {};
6
+
7
+ const data = [
8
+ { name: 'report 1', status: 'done' },
9
+ { name: 'report 2', status: 'pending' }
10
+ ];
11
+
12
+ const fixtures = {
13
+ 'should render the service selector': {
14
+ hidden: false,
15
+ label: 'Test Label',
16
+ viewText: 'view service',
17
+ selectValue: '1',
18
+ onChange: noop,
19
+ options: { first: 'first', second: 'second'},
20
+ additionalData: { moreData: 'moooore' },
21
+ },
22
+ 'should render the hidden service selector': {
23
+ hidden: true,
24
+ label: 'Test Label',
25
+ viewText: 'view service',
26
+ selectValue: '1',
27
+ onChange: noop,
28
+ options: { first: 'first', second: 'second'},
29
+ additionalData: { },
30
+ },
31
+ };
32
+
33
+ describe('ServiceSelector', () =>
34
+ testComponentSnapshotsWithFixtures(ServiceSelector, fixtures));
35
+
@@ -0,0 +1,77 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ServiceSelector should render the hidden service selector 1`] = `
4
+ <div
5
+ className="form-group"
6
+ >
7
+ <label
8
+ className="col-md-2 control-label"
9
+ >
10
+ Test Label
11
+ </label>
12
+ <div
13
+ className="col-md-4"
14
+ >
15
+ <ExtSelect
16
+ additionalData={Object {}}
17
+ editable={true}
18
+ hidden={true}
19
+ onChange={[Function]}
20
+ options={
21
+ Object {
22
+ "first": "first",
23
+ "second": "second",
24
+ }
25
+ }
26
+ selectValue="1"
27
+ viewText="view service"
28
+ />
29
+ <RailsData
30
+ key="service_id"
31
+ parameter="service_id"
32
+ value="1"
33
+ view="existing_host_selection"
34
+ />
35
+ </div>
36
+ </div>
37
+ `;
38
+
39
+ exports[`ServiceSelector should render the service selector 1`] = `
40
+ <div
41
+ className="form-group"
42
+ >
43
+ <label
44
+ className="col-md-2 control-label"
45
+ >
46
+ Test Label
47
+ </label>
48
+ <div
49
+ className="col-md-4"
50
+ >
51
+ <ExtSelect
52
+ additionalData={
53
+ Object {
54
+ "moreData": "moooore",
55
+ }
56
+ }
57
+ editable={true}
58
+ hidden={false}
59
+ onChange={[Function]}
60
+ options={
61
+ Object {
62
+ "first": "first",
63
+ "second": "second",
64
+ }
65
+ }
66
+ selectValue="1"
67
+ viewText="view service"
68
+ />
69
+ <RailsData
70
+ key="service_id"
71
+ parameter="service_id"
72
+ value="1"
73
+ view="existing_host_selection"
74
+ />
75
+ </div>
76
+ </div>
77
+ `;
@@ -0,0 +1,26 @@
1
+ import { bindActionCreators } from 'redux';
2
+ import { connect } from 'react-redux';
3
+
4
+ import './ExistingHostSelection.scss';
5
+ import ExistingHostSelection from './ExistingHostSelection';
6
+ import * as ExistingHostSelectionActions from './ExistingHostSelectionActions';
7
+
8
+ import {
9
+ selectServiceId,
10
+ selectAvailableHosts,
11
+ selectAlreadyUsedHosts,
12
+ } from './ExistingHostSelectionSelectors';
13
+
14
+ const mapStateToProps = state => ({
15
+ serviceId: selectServiceId(state),
16
+ availableHosts: selectAvailableHosts(state),
17
+ alreadyUsedHosts: selectAlreadyUsedHosts(state),
18
+ });
19
+
20
+ const mapDispatchToProps = dispatch =>
21
+ bindActionCreators(ExistingHostSelectionActions, dispatch);
22
+
23
+ export default connect(
24
+ mapStateToProps,
25
+ mapDispatchToProps
26
+ )(ExistingHostSelection);
@@ -9,7 +9,8 @@ import AddTableEntry from '../common/AddTableEntry';
9
9
  import EditTableEntry from '../common/EditTableEntry';
10
10
  import DeleteTableEntry from '../common/DeleteTableEntry';
11
11
  import LockTableEntry from '../common/LockTableEntry';
12
- import ExtSelect from '../common/ExtSelect';
12
+ import ForemanModal from 'foremanReact/components/ForemanModal';
13
+ import * as YamlValidator from '../../js-yaml';
13
14
 
14
15
  import {
15
16
  transformForemanData,
@@ -32,6 +33,7 @@ import {
32
33
  Button,
33
34
  Table,
34
35
  FormControl,
36
+ InputGroup,
35
37
  defaultSortingOrder,
36
38
  customHeaderFormattersDefinition,
37
39
  inlineEditFormatterFactory,
@@ -47,12 +49,42 @@ class ParameterSelection extends React.Component {
47
49
 
48
50
  constructor(props) {
49
51
  super(props);
52
+ this.state = {textValue: ''};
50
53
  }
51
54
 
55
+ handleChange = event => {
56
+ this.setState({textValue: event.target.value});
57
+ };
58
+
52
59
  isEditing({rowData}) {
53
60
  return (rowData.backup !== undefined);
54
61
  }
55
62
 
63
+ yamlValidator() {
64
+ let result = true;
65
+ let msg = "";
66
+ try {
67
+ const doc = YamlValidator.load(this.state.textValue);
68
+ } catch (e) {
69
+ result = false;
70
+ msg = "Invalid Yaml: " + e.name + ": " + e.message;
71
+ }
72
+ return {
73
+ validateResult: result,
74
+ validateMsg: msg
75
+ }
76
+ }
77
+
78
+ yamlValue() {
79
+ if (this.props.editParamsRowIndex != undefined) {
80
+ let id = this.props.editParamsRowIndex;
81
+ if (this.props.parameters[id] != undefined) {
82
+ return this.props.parameters[id]['value'];
83
+ }
84
+ }
85
+ return '';
86
+ }
87
+
56
88
  // enables our custom header formatters extensions to reactabular
57
89
  customHeaderFormatters = customHeaderFormattersDefinition;
58
90
 
@@ -69,6 +101,8 @@ class ParameterSelection extends React.Component {
69
101
  lockParameter,
70
102
  activateEditParameter,
71
103
  changeEditParameter,
104
+ openParameterSelectionDialogBox,
105
+ closeParameterSelectionDialogBox,
72
106
  loadParamData,
73
107
  } = this.props;
74
108
 
@@ -165,6 +199,22 @@ class ParameterSelection extends React.Component {
165
199
  />
166
200
  </td>
167
201
  ),
202
+ renderEditComplexText: (value, additionalData, subtype='text') => (
203
+ <td className="editing">
204
+ <InputGroup>
205
+ <FormControl
206
+ type={subtype}
207
+ defaultValue={additionalData.rowData.isYaml == true ? '' : value}
208
+ onBlur={e => changeEditParameter(e.target.value, additionalData) }
209
+ readOnly={additionalData.rowData.isYaml}
210
+ placeholder={'Press YAML button for Yaml Data'}
211
+ />
212
+ <InputGroup.Button>
213
+ <Button onClick= {e => openParameterSelectionDialogBox(e)}> YAML </Button>
214
+ </InputGroup.Button>
215
+ </InputGroup>
216
+ </td>
217
+ ),
168
218
  renderEditSelect: (value, additionalData, options) => (
169
219
  <td className="editing">
170
220
  <Select
@@ -209,6 +259,10 @@ class ParameterSelection extends React.Component {
209
259
  case 'text':
210
260
  prettyValue = value
211
261
  break;
262
+ case 'complex':
263
+ prettyValue = additionalData.rowData.isYaml ? 'YAML value' : value;
264
+ break;
265
+
212
266
  }
213
267
  }
214
268
  return inlineEditFormatterImpl.renderValue(prettyValue, additionalData)
@@ -235,6 +289,8 @@ class ParameterSelection extends React.Component {
235
289
  case 'password':
236
290
  return inlineEditFormatterImpl.renderEditText(value, additionalData, 'password');
237
291
  case 'text':
292
+ case 'complex':
293
+ return inlineEditFormatterImpl.renderEditComplexText(value, additionalData);
238
294
  default:
239
295
  return inlineEditFormatterImpl.renderEditText(value, additionalData);
240
296
  }
@@ -243,6 +299,7 @@ class ParameterSelection extends React.Component {
243
299
  }
244
300
  }
245
301
  });
302
+
246
303
  this.inlineEditFormatter = inlineEditFormatter;
247
304
 
248
305
  initParameterSelection(
@@ -274,6 +331,7 @@ class ParameterSelection extends React.Component {
274
331
  addParameter,
275
332
  confirmEditParameter,
276
333
  cancelEditParameter,
334
+ closeParameterSelectionDialogBox,
277
335
  editModeCallback,
278
336
  } = this.props;
279
337
 
@@ -282,6 +340,7 @@ class ParameterSelection extends React.Component {
282
340
 
283
341
  if (newEntryIndex >= 0) {
284
342
  const newEntry = parameters[newEntryIndex];
343
+
285
344
  // sort all elements, besides the newEntry which will be
286
345
  // added to the end of the Array
287
346
  const tmpParameters = cloneDeep(parameters);
@@ -312,6 +371,8 @@ class ParameterSelection extends React.Component {
312
371
  editModeCallback(this.props.editMode);
313
372
  }
314
373
 
374
+ let { validateResult, validateMsg } = this.yamlValidator();
375
+
315
376
  return(
316
377
  <div>
317
378
  <div className="clearfix">
@@ -358,6 +419,38 @@ class ParameterSelection extends React.Component {
358
419
  />
359
420
  </div>
360
421
  </div>
422
+ <div>
423
+ <ForemanModal
424
+ id="ParameterSelectionComplexDataModal"
425
+ dialogClassName="complex_data_modal"
426
+ title={__("YAML Data Input")}
427
+
428
+ >
429
+ <ForemanModal.Header closeButton={false}>
430
+ </ForemanModal.Header>
431
+ <textarea id='yamlData'
432
+ defaultValue= {this.yamlValue()}
433
+ onChange={this.handleChange}
434
+ style={{width: "550px", height: "350px", fontFamily: "Courier"}} />
435
+ <ForemanModal.Footer>
436
+ <div>
437
+ {validateResult == false ? (
438
+ <div className="form-group">
439
+ <div class="alert alert-danger alert-dismissable">
440
+ <button type="button" class="close" data-dismiss="alert" aria-label="Close">
441
+ <span class="pficon pficon-close"></span>
442
+ </button>
443
+ <span class="pficon pficon-error-circle-o"></span>
444
+ {validateMsg}
445
+ </div>
446
+ </div>
447
+ ) : (<div></div>)}
448
+ <Button bsStyle="primary" onClick ={() => closeParameterSelectionDialogBox({ mode: 'save' })}>{__("Save")}</Button>
449
+ <Button bsStyle="default" onClick={() => closeParameterSelectionDialogBox({ mode: 'cancel' })}>{__("Cancel")}</Button>
450
+ </div>
451
+ </ForemanModal.Footer>
452
+ </ForemanModal>
453
+ </div>
361
454
  </div>
362
455
  );
363
456
  }
@@ -371,6 +464,7 @@ ParameterSelection.defaultProps = {
371
464
  parameters: [],
372
465
  columns: [],
373
466
  sortingColumns: {},
467
+ editParamsRowIndex: [],
374
468
  editModeCallback: undefined,
375
469
  };
376
470
 
@@ -400,8 +494,11 @@ ParameterSelection.propTypes = {
400
494
  confirmEditParameter: PropTypes.func,
401
495
  cancelEditParameter: PropTypes.func,
402
496
  changeEditParameter: PropTypes.func,
497
+ openParameterSelectionDialogBox: PropTypes.func,
498
+ closeParameterSelectionDialogBox: PropTypes.func,
403
499
  loadParamData: PropTypes.func,
404
500
  paramDefinition: PropTypes.object,
501
+ editParamsRowIndex: PropTypes.array,
405
502
  };
406
503
 
407
504
  export default ParameterSelection;
@@ -8,3 +8,10 @@
8
8
  max-width: none !important;
9
9
  }
10
10
 
11
+ .complex_data_modal {
12
+ margin-top: 0;
13
+ margin-bottom: 0;
14
+ height: 80%;
15
+ width: 40%;
16
+ max-width: none !important;
17
+ }
@@ -20,6 +20,11 @@ import {
20
20
  filterUsedParameterTypes,
21
21
  } from './ParameterSelectionHelper';
22
22
 
23
+ import {
24
+ setModalOpen,
25
+ setModalClosed,
26
+ } from 'foremanReact/components/ForemanModal/ForemanModalActions';
27
+
23
28
  import {
24
29
  PARAMETER_SELECTION_INIT,
25
30
  PARAMETER_SELECTION_TYPES,
@@ -36,6 +41,8 @@ import {
36
41
  PARAMETER_SELECTION_LOAD_PARAM_DATA_REQUEST,
37
42
  PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS,
38
43
  PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE,
44
+ PARAMETER_SELECTION_COMPLEX_DATA_MODAL_OPEN,
45
+ PARAMETER_SELECTION_COMPLEX_DATA_MODAL_CLOSE,
39
46
  } from './ParameterSelectionConstants';
40
47
 
41
48
  export const initParameterSelection = (
@@ -177,6 +184,8 @@ export const initParameterSelection = (
177
184
  initialState.parameterTypes = filterUsedParameterTypes(PARAMETER_SELECTION_TYPES, parameters);
178
185
  }
179
186
 
187
+ initialState.paramType = paramType;
188
+
180
189
  dispatch({
181
190
  type: PARAMETER_SELECTION_INIT,
182
191
  payload: initialState,
@@ -198,7 +207,33 @@ export const lockParameter = (additionalData) => ({
198
207
  },
199
208
  });
200
209
 
201
- export const addParameter = (additionalData) => ({
210
+ export const openParameterSelectionDialogBox = (additionalData) => dispatch => {
211
+ dispatch({
212
+ type: PARAMETER_SELECTION_COMPLEX_DATA_MODAL_OPEN,
213
+ payload: {
214
+ ...additionalData,
215
+ }
216
+ });
217
+ dispatch(
218
+ setModalOpen({ id: 'ParameterSelectionComplexDataModal' })
219
+ );
220
+ };
221
+
222
+ export const closeParameterSelectionDialogBox = (additionalData) => dispatch => {
223
+ dispatch({
224
+ type: PARAMETER_SELECTION_COMPLEX_DATA_MODAL_CLOSE,
225
+ payload: {
226
+ ...additionalData,
227
+ }
228
+ });
229
+
230
+ dispatch(
231
+ setModalClosed({ id: 'ParameterSelectionComplexDataModal' })
232
+ );
233
+ };
234
+
235
+ export const addParameter = (additionalData) => (
236
+ {
202
237
  type: PARAMETER_SELECTION_ADD,
203
238
  payload: {
204
239
  ...additionalData,
@@ -268,4 +303,3 @@ export const loadParamData = (attr) => dispatch => {
268
303
  )
269
304
  .catch(error => dispatch(errorHandler(PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE, error)));
270
305
  };
271
-
@@ -12,6 +12,8 @@ export const PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS = 'PARAMETER_SELECTION_
12
12
  export const PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE = 'PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE';
13
13
  export const PARAMETER_SELECTION_PARAM_TYPE_FOREMAN = 'PARAMETER_SELECTION_PARAM_TYPE_FOREMAN';
14
14
  export const PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE = 'PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE';
15
+ export const PARAMETER_SELECTION_COMPLEX_DATA_MODAL_OPEN = 'PARAMETER_SELECTION_COMPLEX_DATA_MODAL_OPEN';
16
+ export const PARAMETER_SELECTION_COMPLEX_DATA_MODAL_CLOSE = 'PARAMETER_SELECTION_COMPLEX_DATA_MODAL_CLOSE';
15
17
 
16
18
  // Make sure the object is sorted by value
17
19
  // (Compute Profile -> Partition table -> Root password)
@@ -28,6 +28,8 @@ import {
28
28
  PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE,
29
29
  PARAMETER_SELECTION_PARAM_TYPE_FOREMAN,
30
30
  PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE,
31
+ PARAMETER_SELECTION_COMPLEX_DATA_MODAL_OPEN,
32
+ PARAMETER_SELECTION_COMPLEX_DATA_MODAL_CLOSE,
31
33
  } from './ParameterSelectionConstants';
32
34
 
33
35
  export const initialState = Immutable({
@@ -51,13 +53,16 @@ const parameterSelectionParameters = (state = initialState, action) => {
51
53
  index = Math.max(...parameters.map(e => e.id)) + 1;
52
54
  }
53
55
 
54
- const newRow = {id: index, locked: false, name: "", description: '', type: '', value: '', newEntry: true };
56
+ const newRow = {id: index, locked: false, name: "", description: '', type: '', value: '', isYaml: false, newEntry: true };
57
+ if (state.paramType == 'PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE') {
58
+ newRow['type'] = 'complex';
59
+ }
55
60
  newRow.backup = cloneDeep(newRow)
56
61
  parameters.push(newRow);
57
-
58
62
  return state.merge({
59
63
  editMode: true,
60
- parameters: parameters
64
+ parameters: parameters,
65
+ editParamsRowIndex: index,
61
66
  });
62
67
  }
63
68
  case PARAMETER_SELECTION_LOCK: {
@@ -86,10 +91,10 @@ const parameterSelectionParameters = (state = initialState, action) => {
86
91
  const index = findIndex(parameters, { id: payload.rowData.id });
87
92
 
88
93
  parameters[index].backup = cloneDeep(parameters[index]);
89
-
90
94
  return state.merge({
91
95
  editMode: true,
92
- parameters: parameters
96
+ parameters: parameters,
97
+ editParamsRowIndex: index,
93
98
  });
94
99
  }
95
100
  case PARAMETER_SELECTION_EDIT_CONFIRM: {
@@ -109,9 +114,15 @@ const parameterSelectionParameters = (state = initialState, action) => {
109
114
  const parameters = cloneDeep(state.parameters);
110
115
  const index = findIndex(parameters, { id: payload.rowData.id });
111
116
 
112
- parameters[index][payload.property] = payload.value;
113
-
114
- return state.set('parameters', parameters);
117
+ if (!parameters[index]['isYaml'] && payload.property == 'value') {
118
+ parameters[index]['value'] = payload.value;
119
+ } else if (payload.property != 'value') {
120
+ parameters[index][payload.property] = payload.value;
121
+ }
122
+ return state.merge({
123
+ parameters: parameters,
124
+ editParamsRowIndex: index
125
+ });
115
126
  }
116
127
  case PARAMETER_SELECTION_EDIT_CANCEL: {
117
128
  const parameters = cloneDeep(state.parameters);
@@ -180,6 +191,36 @@ const parameterSelectionParameters = (state = initialState, action) => {
180
191
 
181
192
  return state.merge(newState);
182
193
  }
194
+ case PARAMETER_SELECTION_COMPLEX_DATA_MODAL_OPEN: {
195
+ return state;
196
+ }
197
+ case PARAMETER_SELECTION_COMPLEX_DATA_MODAL_CLOSE: {
198
+ let str;
199
+ let element = document.getElementById('yamlData');
200
+ if (element != null) {
201
+ str = element.value;
202
+ }
203
+ else {
204
+ str = '';
205
+ }
206
+ let newState = {};
207
+ let index = state.editParamsRowIndex;
208
+ const parameters = cloneDeep(state.parameters);
209
+ if (payload.mode == 'save') {
210
+ parameters[index]['value'] = str;
211
+ if (str == '') {
212
+ parameters[index]['isYaml'] = false;
213
+ } else {
214
+ parameters[index]['isYaml'] = true;
215
+ }
216
+ newState = {
217
+ parameters: parameters,
218
+ };
219
+ } else {
220
+ newState = {};
221
+ }
222
+ return state.merge(newState);
223
+ }
183
224
  default:
184
225
  return state;
185
226
  }
@@ -9,3 +9,4 @@ export const selectSortingColumns = state => parameterState(state).sortingColumn
9
9
  export const selectColumns = state => parameterState(state).columns;
10
10
  export const selectParamDefinition = state => parameterState(state).paramDefinition;
11
11
  export const selectHostgroupId = state => parameterState(state).hostgroupId;
12
+ export const selectEditParamsRowIndex = state => parameterState(state).editParamsRowIndex;
@@ -31,6 +31,8 @@ import {
31
31
  PARAMETER_SELECTION_LOAD_PARAM_DATA_REQUEST,
32
32
  PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS,
33
33
  PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE,
34
+ PARAMETER_SELECTION_COMPLEX_DATA_MODAL_OPEN,
35
+ PARAMETER_SELECTION_COMPLEX_DATA_MODAL_CLOSE,
34
36
  } from '../ParameterSelectionConstants';
35
37
 
36
38
  const fixtures = {
@@ -49,6 +49,54 @@ exports[`ParameterSelection should render ansible parameter selection 1`] = `
49
49
  />
50
50
  </div>
51
51
  </div>
52
+ <div>
53
+ <ForemanModal
54
+ dialogClassName="complex_data_modal"
55
+ id="ParameterSelectionComplexDataModal"
56
+ title="YAML Data Input"
57
+ >
58
+ <Header
59
+ closeButton={false}
60
+ />
61
+ <textarea
62
+ defaultValue=""
63
+ id="yamlData"
64
+ onChange={[Function]}
65
+ style={
66
+ Object {
67
+ "fontFamily": "Courier",
68
+ "height": "350px",
69
+ "width": "550px",
70
+ }
71
+ }
72
+ />
73
+ <Footer>
74
+ <div>
75
+ <div />
76
+ <Button
77
+ active={false}
78
+ block={false}
79
+ bsClass="btn"
80
+ bsStyle="primary"
81
+ disabled={false}
82
+ onClick={[Function]}
83
+ >
84
+ Save
85
+ </Button>
86
+ <Button
87
+ active={false}
88
+ block={false}
89
+ bsClass="btn"
90
+ bsStyle="default"
91
+ disabled={false}
92
+ onClick={[Function]}
93
+ >
94
+ Cancel
95
+ </Button>
96
+ </div>
97
+ </Footer>
98
+ </ForemanModal>
99
+ </div>
52
100
  </div>
53
101
  `;
54
102
 
@@ -101,5 +149,53 @@ exports[`ParameterSelection should render foreman parameter selection 1`] = `
101
149
  />
102
150
  </div>
103
151
  </div>
152
+ <div>
153
+ <ForemanModal
154
+ dialogClassName="complex_data_modal"
155
+ id="ParameterSelectionComplexDataModal"
156
+ title="YAML Data Input"
157
+ >
158
+ <Header
159
+ closeButton={false}
160
+ />
161
+ <textarea
162
+ defaultValue=""
163
+ id="yamlData"
164
+ onChange={[Function]}
165
+ style={
166
+ Object {
167
+ "fontFamily": "Courier",
168
+ "height": "350px",
169
+ "width": "550px",
170
+ }
171
+ }
172
+ />
173
+ <Footer>
174
+ <div>
175
+ <div />
176
+ <Button
177
+ active={false}
178
+ block={false}
179
+ bsClass="btn"
180
+ bsStyle="primary"
181
+ disabled={false}
182
+ onClick={[Function]}
183
+ >
184
+ Save
185
+ </Button>
186
+ <Button
187
+ active={false}
188
+ block={false}
189
+ bsClass="btn"
190
+ bsStyle="default"
191
+ disabled={false}
192
+ onClick={[Function]}
193
+ >
194
+ Cancel
195
+ </Button>
196
+ </div>
197
+ </Footer>
198
+ </ForemanModal>
199
+ </div>
104
200
  </div>
105
201
  `;
@@ -136,6 +136,7 @@ Object {
136
136
  },
137
137
  ],
138
138
  "editMode": true,
139
+ "editParamsRowIndex": 1,
139
140
  "error": Object {
140
141
  "errorMsg": "",
141
142
  "status": "",
@@ -373,6 +374,7 @@ Object {
373
374
  },
374
375
  ],
375
376
  "editMode": true,
377
+ "editParamsRowIndex": 3,
376
378
  "error": Object {
377
379
  "errorMsg": "",
378
380
  "status": "",
@@ -460,6 +462,7 @@ Object {
460
462
  "backup": Object {
461
463
  "description": "",
462
464
  "id": 3,
465
+ "isYaml": false,
463
466
  "locked": false,
464
467
  "name": "",
465
468
  "newEntry": true,
@@ -468,6 +471,7 @@ Object {
468
471
  },
469
472
  "description": "",
470
473
  "id": 3,
474
+ "isYaml": false,
471
475
  "locked": false,
472
476
  "name": "",
473
477
  "newEntry": true,
@@ -849,6 +853,7 @@ Object {
849
853
  },
850
854
  ],
851
855
  "editMode": false,
856
+ "editParamsRowIndex": 1,
852
857
  "error": Object {
853
858
  "errorMsg": "",
854
859
  "status": "",