foreman_acd 0.9.7 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -19
  3. data/app/controllers/ui_acd_controller.rb +1 -1
  4. data/db/migrate/20210503122809_add_git_url_to_ansible_playbooks.rb +1 -1
  5. data/lib/foreman_acd/engine.rb +4 -10
  6. data/lib/foreman_acd/plugin.rb +1 -1
  7. data/lib/foreman_acd/version.rb +1 -1
  8. data/package.json +5 -3
  9. data/test/controllers/ui_acd_controller_test.rb +1 -1
  10. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +210 -121
  11. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +79 -91
  12. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +30 -15
  13. data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +15 -15
  14. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +96 -63
  15. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +22 -11
  16. data/webpack/components/ApplicationDefinition/__fixtures__/{applicationDefinitionConfData_1.fixtures.js → applicationDefinitionConfData1.fixtures.js} +77 -105
  17. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +49 -29
  18. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +4 -4
  19. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionHelper.test.js +16 -0
  20. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +0 -5
  21. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +25 -25
  22. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +9 -1
  23. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +11 -11
  24. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +30 -25
  25. data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +3 -3
  26. data/webpack/components/ApplicationDefinition/index.js +0 -1
  27. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +91 -105
  28. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +59 -84
  29. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +12 -6
  30. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +21 -27
  31. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +14 -7
  32. data/webpack/components/ApplicationDefinitionImport/__fixtures__/{applicationDefinitionImportConfData_1.fixtures.js → applicationDefinitionImportConfData1.fixtures.js} +32 -40
  33. data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +14 -16
  34. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +38 -8
  35. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +0 -2
  36. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +9 -9
  37. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +116 -2
  38. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +3 -3
  39. data/webpack/components/ApplicationInstance/ApplicationInstance.js +344 -193
  40. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +92 -105
  41. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +34 -17
  42. data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +4 -7
  43. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +114 -74
  44. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +18 -9
  45. data/webpack/components/ApplicationInstance/__fixtures__/{applicationInstanceConfData_1.fixtures.js → applicationInstanceConfData1.fixtures.js} +68 -86
  46. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +24 -32
  47. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +75 -10
  48. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +0 -8
  49. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +27 -27
  50. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +606 -2
  51. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +12 -12
  52. data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +32 -25
  53. data/webpack/components/ApplicationInstance/components/Service.js +7 -18
  54. data/webpack/components/ApplicationInstance/components/ServiceCounter.js +25 -18
  55. data/webpack/components/ApplicationInstance/index.js +0 -1
  56. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +167 -110
  57. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +20 -25
  58. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +10 -5
  59. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +9 -12
  60. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +12 -6
  61. data/webpack/components/ApplicationInstanceReport/__fixtures__/{applicationInstanceReportData_1.fixtures.js → applicationInstanceReportData1.fixtures.js} +154 -101
  62. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +3 -10
  63. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +28 -22
  64. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +5 -7
  65. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +0 -1
  66. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +2 -2
  67. data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +9 -5
  68. data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +1 -3
  69. data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +35 -56
  70. data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +21 -28
  71. data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +6 -3
  72. data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +16 -19
  73. data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -4
  74. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData1.fixtures.js +187 -0
  75. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +13 -24
  76. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +3 -2
  77. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +11 -14
  78. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +5 -5
  79. data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +31 -25
  80. data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +3 -9
  81. data/webpack/components/ParameterSelection/ParameterSelection.js +258 -174
  82. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +110 -100
  83. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +22 -11
  84. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +13 -11
  85. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +63 -49
  86. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +10 -5
  87. data/webpack/components/ParameterSelection/__fixtures__/{parameterSelectionData_1.fixtures.js → parameterSelectionData1.fixtures.js} +67 -104
  88. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +22 -26
  89. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +50 -36
  90. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionHelper.test.js +76 -0
  91. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +0 -2
  92. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +23 -25
  93. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +100 -0
  94. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +99 -112
  95. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +18 -19
  96. data/webpack/components/ParameterSelection/index.js +1 -4
  97. data/webpack/components/SyncGitRepo/SyncGitRepo.js +124 -117
  98. data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +64 -74
  99. data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +17 -17
  100. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData1.fixtures.js +7 -0
  101. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +10 -18
  102. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +80 -6
  103. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +9 -11
  104. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +192 -1
  105. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +4 -4
  106. data/webpack/components/SyncGitRepo/components/FormTextInput.js +26 -21
  107. data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +29 -24
  108. data/webpack/components/SyncGitRepo/index.js +2 -5
  109. data/webpack/components/common/AddTableEntry.js +3 -10
  110. data/webpack/components/common/DeleteTableEntry.js +7 -15
  111. data/webpack/components/common/EditTableEntry.js +7 -7
  112. data/webpack/components/common/ExtSelect.js +12 -8
  113. data/webpack/components/common/ExtTextInput.js +12 -7
  114. data/webpack/components/common/LockTableEntry.js +6 -6
  115. data/webpack/components/common/RailsData.js +6 -16
  116. data/webpack/components/common/__tests__/ExtSelect.test.js +2 -2
  117. data/webpack/components/common/__tests__/RailsData.test.js +0 -2
  118. data/webpack/global_test_setup.js +11 -0
  119. data/webpack/helper.js +10 -21
  120. data/webpack/helper.test.js +17 -29
  121. data/webpack/index.js +25 -7
  122. data/webpack/js-yaml.js +1563 -1135
  123. data/webpack/reducer.js +52 -27
  124. metadata +16 -14
  125. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +0 -191
  126. data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +0 -153
  127. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +0 -7
@@ -1,85 +1,68 @@
1
- import $ from 'jquery';
2
1
  import React from 'react';
3
2
  import PropTypes from 'prop-types';
4
3
  import * as sort from 'sortabular';
5
- import { orderBy } from 'lodash';
4
+ import { orderBy, findIndex, cloneDeep } from 'lodash';
6
5
  import * as resolve from 'table-resolver';
6
+ import {
7
+ Button,
8
+ Table,
9
+ FormControl,
10
+ InputGroup,
11
+ customHeaderFormattersDefinition,
12
+ inlineEditFormatterFactory,
13
+ } from 'patternfly-react';
14
+
7
15
  import Select from 'foremanReact/components/common/forms/Select';
16
+ import { translate as __ } from 'foremanReact/common/I18n';
17
+ import ForemanModal from 'foremanReact/components/ForemanModal';
18
+
8
19
  import AddTableEntry from '../common/AddTableEntry';
9
20
  import EditTableEntry from '../common/EditTableEntry';
10
21
  import DeleteTableEntry from '../common/DeleteTableEntry';
11
22
  import LockTableEntry from '../common/LockTableEntry';
12
- import ForemanModal from 'foremanReact/components/ForemanModal';
13
23
  import * as YamlValidator from '../../js-yaml';
14
24
 
15
- import {
16
- transformForemanData,
17
- } from './ParameterSelectionHelper';
18
-
19
- import {
20
- dropRight,
21
- findIndex,
22
- cloneDeep,
23
- } from 'lodash';
25
+ import { transformForemanData } from './ParameterSelectionHelper';
24
26
 
25
27
  import {
26
28
  PARAMETER_SELECTION_TYPES,
27
29
  PARAMETER_SELECTION_PARAM_TYPE_FOREMAN,
28
- PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE,
29
30
  } from './ParameterSelectionConstants';
30
31
 
31
- import {
32
- Icon,
33
- Button,
34
- Table,
35
- FormControl,
36
- InputGroup,
37
- defaultSortingOrder,
38
- customHeaderFormattersDefinition,
39
- inlineEditFormatterFactory,
40
- } from 'patternfly-react';
41
-
42
- const theme = {
43
- scheme: 'foreman',
44
- backgroundColor: 'rgba(0, 0, 0, 255)',
45
- base00: 'rgba(0, 0, 0, 0)',
46
- };
47
-
48
32
  class ParameterSelection extends React.Component {
49
-
50
33
  constructor(props) {
51
34
  super(props);
52
- this.state = {textValue: ''};
35
+ this.state = { textValue: '' };
53
36
  }
54
37
 
55
38
  handleChange = event => {
56
- this.setState({textValue: event.target.value});
39
+ this.setState({ textValue: event.target.value });
57
40
  };
58
41
 
59
- isEditing({rowData}) {
60
- return (rowData.backup !== undefined);
42
+ static isEditing({ rowData }) {
43
+ return rowData.backup !== undefined;
61
44
  }
62
45
 
63
46
  yamlValidator() {
64
47
  let result = true;
65
- let msg = "";
48
+ let msg = '';
66
49
  try {
67
- const doc = YamlValidator.load(this.state.textValue);
50
+ YamlValidator.load(this.state.textValue);
68
51
  } catch (e) {
69
52
  result = false;
70
- msg = "Invalid Yaml: " + e.name + ": " + e.message;
53
+ msg = `Invalid Yaml: ${e.name}: ${e.message}`;
71
54
  }
72
55
  return {
73
56
  validateResult: result,
74
- validateMsg: msg
75
- }
57
+ validateMsg: msg,
58
+ };
76
59
  }
77
60
 
78
61
  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'];
62
+ if (this.props.editParamsRowIndex !== undefined) {
63
+ const id = this.props.editParamsRowIndex;
64
+ if (this.props.parameters[id] !== undefined) {
65
+ return this.props.parameters[id].value;
83
66
  }
84
67
  }
85
68
  return '';
@@ -90,9 +73,14 @@ class ParameterSelection extends React.Component {
90
73
 
91
74
  componentDidMount() {
92
75
  const {
93
- data: { useDefaultValue, allowRowAdjustment, allowNameAdjustment, allowDescriptionAdjustment, parameters, paramDefinition },
94
- location,
95
- organization,
76
+ data: {
77
+ useDefaultValue,
78
+ allowRowAdjustment,
79
+ allowNameAdjustment,
80
+ allowDescriptionAdjustment,
81
+ parameters,
82
+ paramDefinition,
83
+ },
96
84
  paramType,
97
85
  paramDataUrl,
98
86
  hiddenParameterTypes,
@@ -103,17 +91,21 @@ class ParameterSelection extends React.Component {
103
91
  activateEditParameter,
104
92
  changeEditParameter,
105
93
  openParameterSelectionDialogBox,
106
- closeParameterSelectionDialogBox,
107
94
  loadParamData,
108
95
  } = this.props;
109
96
 
110
97
  if (paramDataUrl !== undefined) {
111
98
  switch (paramType) {
112
99
  case PARAMETER_SELECTION_PARAM_TYPE_FOREMAN: {
113
- loadParamData({ paramDefinition: paramDefinition, url: paramDataUrl, dataType: paramType, clearParameters: false });
100
+ loadParamData({
101
+ paramDefinition,
102
+ url: paramDataUrl,
103
+ dataType: paramType,
104
+ clearParameters: false,
105
+ });
114
106
  break;
115
107
  }
116
- default: { }
108
+ default:
117
109
  }
118
110
  }
119
111
 
@@ -146,26 +138,28 @@ class ParameterSelection extends React.Component {
146
138
  renderEdit: (value, additionalData) => (
147
139
  <td style={{ padding: '2px' }}>
148
140
  <EditTableEntry
149
- disabled={true}
141
+ hidden={false}
142
+ handleLocking={false}
143
+ disabled
150
144
  onEditTableEntry={() => activateEditParameter(additionalData)}
151
145
  additionalData={additionalData}
152
146
  />
153
147
  &nbsp;
154
148
  <LockTableEntry
155
149
  hidden={!allowRowAdjustment}
156
- disabled={true}
150
+ disabled
157
151
  onLockTableEntry={lockParameter}
158
152
  additionalData={additionalData}
159
153
  />
160
154
  &nbsp;
161
155
  <DeleteTableEntry
162
156
  hidden={!allowRowAdjustment}
163
- disabled={true}
157
+ disabled
164
158
  onDeleteTableEntry={deleteParameter}
165
159
  additionalData={additionalData}
166
160
  />
167
161
  </td>
168
- )
162
+ ),
169
163
  });
170
164
  this.inlineEditButtonsFormatter = inlineEditButtonsFormatter;
171
165
 
@@ -173,7 +167,8 @@ class ParameterSelection extends React.Component {
173
167
 
174
168
  const sortableTransform = sort.sort({
175
169
  getSortingColumns,
176
- onSort: (selectedColumn, defaultSortingOrder) => sortParameter(selectedColumn, defaultSortingOrder),
170
+ onSort: (selectedColumn, defaultSortingOrder) =>
171
+ sortParameter(selectedColumn, defaultSortingOrder),
177
172
  strategy: sort.strategies.byProperty,
178
173
  });
179
174
  this.sortableTransform = sortableTransform;
@@ -191,36 +186,39 @@ class ParameterSelection extends React.Component {
191
186
  <span className="static">{value}</span>
192
187
  </td>
193
188
  ),
194
- renderEditText: (value, additionalData, subtype='text') => (
189
+ renderEditText: (value, additionalData, subtype = 'text') => (
195
190
  <td className="editing">
196
191
  <FormControl
197
192
  type={subtype}
198
193
  defaultValue={value}
199
- onBlur={e => changeEditParameter(e.target.value, additionalData) }
194
+ onBlur={e => changeEditParameter(e.target.value, additionalData)}
200
195
  />
201
196
  </td>
202
197
  ),
203
- renderEditComplexText: (value, additionalData, subtype='text') => (
198
+ renderEditComplexText: (value, additionalData, subtype = 'text') => (
204
199
  <td className="editing">
205
- <InputGroup>
206
- <FormControl
207
- type={subtype}
208
- defaultValue={additionalData.rowData.isYaml == true ? '' : value}
209
- onBlur={e => changeEditParameter(e.target.value, additionalData) }
210
- readOnly={additionalData.rowData.isYaml}
211
- placeholder={'Press YAML button for Yaml Data'}
212
- />
213
- <InputGroup.Button>
214
- <Button onClick= {e => openParameterSelectionDialogBox(e)}> YAML </Button>
215
- </InputGroup.Button>
216
- </InputGroup>
200
+ <InputGroup>
201
+ <FormControl
202
+ type={subtype}
203
+ defaultValue={additionalData.rowData.isYaml === true ? '' : value}
204
+ onBlur={e => changeEditParameter(e.target.value, additionalData)}
205
+ readOnly={additionalData.rowData.isYaml}
206
+ placeholder="Press YAML button for Yaml Data"
207
+ />
208
+ <InputGroup.Button>
209
+ <Button onClick={e => openParameterSelectionDialogBox(e)}>
210
+ {' '}
211
+ YAML{' '}
212
+ </Button>
213
+ </InputGroup.Button>
214
+ </InputGroup>
217
215
  </td>
218
216
  ),
219
217
  renderEditSelect: (value, additionalData, options) => (
220
218
  <td className="editing">
221
219
  <Select
222
220
  value={value.toString()}
223
- onChange={e => changeEditParameter(e.target.value, additionalData) }
221
+ onChange={e => changeEditParameter(e.target.value, additionalData)}
224
222
  options={options}
225
223
  allowClear
226
224
  key="key"
@@ -232,73 +230,127 @@ class ParameterSelection extends React.Component {
232
230
  // TODO: should we differentiate between paramType FOREMAN and ANSIBLE?
233
231
 
234
232
  const inlineEditFormatter = inlineEditFormatterFactory({
235
- isEditing: additionalData => this.isEditing(additionalData),
233
+ isEditing: additionalData => this.constructor.isEditing(additionalData),
236
234
  renderValue: (value, additionalData) => {
237
235
  let prettyValue = value;
238
- if (additionalData.property == 'type') {
236
+ if (additionalData.property === 'type') {
239
237
  prettyValue = PARAMETER_SELECTION_TYPES[value];
240
- } else if (additionalData.property == 'value') {
238
+ } else if (additionalData.property === 'value') {
241
239
  switch (additionalData.rowData.type) {
242
240
  case 'computeprofile':
243
- prettyValue = transformForemanData(this.props.paramData['computeprofiles'])[value]
241
+ prettyValue = transformForemanData(
242
+ this.props.paramData.computeprofiles
243
+ )[value];
244
244
  break;
245
245
  case 'domain':
246
- prettyValue = transformForemanData(this.props.paramData['domains'])[value]
246
+ prettyValue = transformForemanData(this.props.paramData.domains)[
247
+ value
248
+ ];
247
249
  break;
248
250
  case 'lifecycleenv':
249
- prettyValue = transformForemanData(this.props.paramData['lifecycle_environments'])[value]
251
+ prettyValue = transformForemanData(
252
+ this.props.paramData.lifecycle_environments
253
+ )[value];
250
254
  break;
251
255
  case 'ptable':
252
- prettyValue = transformForemanData(this.props.paramData['ptables'])[value]
256
+ prettyValue = transformForemanData(this.props.paramData.ptables)[
257
+ value
258
+ ];
253
259
  break;
254
260
  case 'password':
255
- prettyValue = '****************'
261
+ prettyValue = '****************';
256
262
  break;
257
263
  case 'puppetenv':
258
- prettyValue = transformForemanData(this.props.paramData['environments'])[value]
264
+ prettyValue = transformForemanData(
265
+ this.props.paramData.environments
266
+ )[value];
259
267
  break;
260
268
  case 'text':
261
- prettyValue = value
269
+ prettyValue = value;
262
270
  break;
263
271
  case 'complex':
264
- prettyValue = additionalData.rowData.isYaml ? 'YAML value' : value;
272
+ prettyValue = additionalData.rowData.isYaml
273
+ ? 'YAML value'
274
+ : value;
265
275
  break;
266
-
276
+ default:
267
277
  }
268
278
  }
269
- return inlineEditFormatterImpl.renderValue(prettyValue, additionalData)
279
+ return inlineEditFormatterImpl.renderValue(prettyValue, additionalData);
270
280
  },
271
281
  renderEdit: (value, additionalData) => {
272
282
  switch (additionalData.property) {
273
283
  case 'type':
274
284
  if (additionalData.rowData.newEntry === true) {
275
- return inlineEditFormatterImpl.renderEditSelect(value, additionalData, this.props.parameterTypes);
285
+ return inlineEditFormatterImpl.renderEditSelect(
286
+ value,
287
+ additionalData,
288
+ this.props.parameterTypes
289
+ );
276
290
  }
277
- return inlineEditFormatterImpl.renderValue(PARAMETER_SELECTION_TYPES[value], additionalData)
291
+ return inlineEditFormatterImpl.renderValue(
292
+ PARAMETER_SELECTION_TYPES[value],
293
+ additionalData
294
+ );
278
295
  case 'value':
279
296
  switch (additionalData.rowData.type) {
280
297
  case 'computeprofile':
281
- return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['computeprofiles']));
298
+ return inlineEditFormatterImpl.renderEditSelect(
299
+ value,
300
+ additionalData,
301
+ transformForemanData(this.props.paramData.computeprofiles)
302
+ );
282
303
  case 'domain':
283
- return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['domains']));
304
+ return inlineEditFormatterImpl.renderEditSelect(
305
+ value,
306
+ additionalData,
307
+ transformForemanData(this.props.paramData.domains)
308
+ );
284
309
  case 'lifecycleenv':
285
- return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['lifecycle_environments']));
310
+ return inlineEditFormatterImpl.renderEditSelect(
311
+ value,
312
+ additionalData,
313
+ transformForemanData(
314
+ this.props.paramData.lifecycle_environments
315
+ )
316
+ );
286
317
  case 'puppetenv':
287
- return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['environments']));
318
+ return inlineEditFormatterImpl.renderEditSelect(
319
+ value,
320
+ additionalData,
321
+ transformForemanData(this.props.paramData.environments)
322
+ );
288
323
  case 'ptable':
289
- return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['ptables']));
324
+ return inlineEditFormatterImpl.renderEditSelect(
325
+ value,
326
+ additionalData,
327
+ transformForemanData(this.props.paramData.ptables)
328
+ );
290
329
  case 'password':
291
- return inlineEditFormatterImpl.renderEditText(value, additionalData, 'password');
330
+ return inlineEditFormatterImpl.renderEditText(
331
+ value,
332
+ additionalData,
333
+ 'password'
334
+ );
292
335
  case 'text':
293
336
  case 'complex':
294
- return inlineEditFormatterImpl.renderEditComplexText(value, additionalData);
337
+ return inlineEditFormatterImpl.renderEditComplexText(
338
+ value,
339
+ additionalData
340
+ );
295
341
  default:
296
- return inlineEditFormatterImpl.renderEditText(value, additionalData);
342
+ return inlineEditFormatterImpl.renderEditText(
343
+ value,
344
+ additionalData
345
+ );
297
346
  }
298
347
  default:
299
- return inlineEditFormatterImpl.renderEditText(value, additionalData)
348
+ return inlineEditFormatterImpl.renderEditText(
349
+ value,
350
+ additionalData
351
+ );
300
352
  }
301
- }
353
+ },
302
354
  });
303
355
 
304
356
  this.inlineEditFormatter = inlineEditFormatter;
@@ -314,22 +366,23 @@ class ParameterSelection extends React.Component {
314
366
  this.sortingFormatter,
315
367
  this.sortableTransform,
316
368
  this.inlineEditFormatter,
317
- this.inlineEditButtonsFormatter,
369
+ this.inlineEditButtonsFormatter
318
370
  );
319
371
  }
320
372
 
321
373
  // workaround because Recompose JS doesn't work -> webpack issues
322
- compose = (...funcs) => funcs.reduce((a, b) => (...args) => a(b(...args)), arg => arg)
374
+ compose = (...funcs) =>
375
+ funcs.reduce(
376
+ (a, b) => (...args) => a(b(...args)),
377
+ arg => arg
378
+ );
323
379
 
324
380
  render() {
325
381
  const {
326
- data: { allowRowAdjustment, applications },
327
- location,
328
- organization,
382
+ data: { allowRowAdjustment },
329
383
  parameters,
330
384
  columns,
331
385
  sortingColumns,
332
- loading,
333
386
  addParameter,
334
387
  confirmEditParameter,
335
388
  cancelEditParameter,
@@ -352,7 +405,7 @@ class ParameterSelection extends React.Component {
352
405
  columns,
353
406
  sortingColumns,
354
407
  sort: orderBy,
355
- strategy: sort.strategies.byProperty
408
+ strategy: sort.strategies.byProperty,
356
409
  })
357
410
  )(tmpParameters);
358
411
  sortedParameters.push(newEntry);
@@ -362,7 +415,7 @@ class ParameterSelection extends React.Component {
362
415
  columns,
363
416
  sortingColumns,
364
417
  sort: orderBy,
365
- strategy: sort.strategies.byProperty
418
+ strategy: sort.strategies.byProperty,
366
419
  })
367
420
  )(parameters);
368
421
  }
@@ -373,9 +426,9 @@ class ParameterSelection extends React.Component {
373
426
  editModeCallback(this.props.editMode);
374
427
  }
375
428
 
376
- let { validateResult, validateMsg } = this.yamlValidator();
429
+ const { validateResult, validateMsg } = this.yamlValidator();
377
430
 
378
- return(
431
+ return (
379
432
  <div>
380
433
  <div className="clearfix">
381
434
  <div className="form-group">
@@ -392,13 +445,13 @@ class ParameterSelection extends React.Component {
392
445
  this.customHeaderFormatters({
393
446
  cellProps,
394
447
  columns,
395
- sortingColumns
396
- })
448
+ sortingColumns,
449
+ }),
397
450
  },
398
451
  body: {
399
452
  row: Table.InlineEditRow,
400
- cell: cellProps => cellProps.children
401
- }
453
+ cell: cellProps => cellProps.children,
454
+ },
402
455
  }}
403
456
  >
404
457
  <Table.Header headerRows={resolve.headerRows({ columns })} />
@@ -407,51 +460,72 @@ class ParameterSelection extends React.Component {
407
460
  rowKey="id"
408
461
  onRow={(rowData, { rowIndex }) => ({
409
462
  role: 'row',
410
- isEditing: () => this.isEditing({ rowData }),
463
+ isEditing: () => this.constructor.isEditing({ rowData }),
411
464
  onCancel: () => cancelEditParameter({ rowData, rowIndex }),
412
465
  onConfirm: () => confirmEditParameter({ rowData, rowIndex }),
413
- last: rowIndex === sortedParameters.length - 1
466
+ last: rowIndex === sortedParameters.length - 1,
414
467
  })}
415
468
  />
416
469
  </Table.PfProvider>
417
470
  <AddTableEntry
418
- hidden={!allowRowAdjustment}
419
- disabled={ this.props.editMode }
420
- onAddTableEntry={ addParameter }
471
+ hidden={!allowRowAdjustment}
472
+ disabled={this.props.editMode}
473
+ onAddTableEntry={addParameter}
421
474
  />
422
475
  </div>
423
476
  </div>
424
477
  <div>
425
- <ForemanModal
426
- id="ParameterSelectionComplexDataModal"
427
- dialogClassName="complex_data_modal"
428
- title={__("YAML Data Input")}
429
-
430
- >
431
- <ForemanModal.Header closeButton={false}>
432
- </ForemanModal.Header>
433
- <textarea id='yamlData'
434
- defaultValue= {this.yamlValue()}
435
- onChange={this.handleChange}
436
- style={{width: "550px", height: "350px", fontFamily: "Courier"}} />
437
- <ForemanModal.Footer>
438
- <div>
439
- {validateResult == false ? (
440
- <div className="form-group">
441
- <div class="alert alert-danger alert-dismissable">
442
- <button type="button" class="close" data-dismiss="alert" aria-label="Close">
443
- <span class="pficon pficon-close"></span>
444
- </button>
445
- <span class="pficon pficon-error-circle-o"></span>
446
- {validateMsg}
447
- </div>
448
- </div>
449
- ) : (<div></div>)}
450
- <Button bsStyle="primary" onClick ={() => closeParameterSelectionDialogBox({ mode: 'save' })}>{__("Save")}</Button>
451
- <Button bsStyle="default" onClick={() => closeParameterSelectionDialogBox({ mode: 'cancel' })}>{__("Cancel")}</Button>
452
- </div>
453
- </ForemanModal.Footer>
454
- </ForemanModal>
478
+ <ForemanModal
479
+ id="ParameterSelectionComplexDataModal"
480
+ dialogClassName="complex_data_modal"
481
+ title={__('YAML Data Input')}
482
+ >
483
+ <ForemanModal.Header closeButton={false} />
484
+ <textarea
485
+ id="yamlData"
486
+ defaultValue={this.yamlValue()}
487
+ onChange={this.handleChange}
488
+ style={{ width: '550px', height: '350px', fontFamily: 'Courier' }}
489
+ />
490
+ <ForemanModal.Footer>
491
+ <div>
492
+ {validateResult === false ? (
493
+ <div className="form-group">
494
+ <div className="alert alert-danger alert-dismissable">
495
+ <button
496
+ type="button"
497
+ className="close"
498
+ data-dismiss="alert"
499
+ aria-label="Close"
500
+ >
501
+ <span className="pficon pficon-close" />
502
+ </button>
503
+ <span className="pficon pficon-error-circle-o" />
504
+ {validateMsg}
505
+ </div>
506
+ </div>
507
+ ) : (
508
+ <div />
509
+ )}
510
+ <Button
511
+ bsStyle="primary"
512
+ onClick={() =>
513
+ closeParameterSelectionDialogBox({ mode: 'save' })
514
+ }
515
+ >
516
+ {__('Save')}
517
+ </Button>
518
+ <Button
519
+ bsStyle="default"
520
+ onClick={() =>
521
+ closeParameterSelectionDialogBox({ mode: 'cancel' })
522
+ }
523
+ >
524
+ {__('Cancel')}
525
+ </Button>
526
+ </div>
527
+ </ForemanModal.Footer>
528
+ </ForemanModal>
455
529
  </div>
456
530
  </div>
457
531
  );
@@ -459,51 +533,61 @@ class ParameterSelection extends React.Component {
459
533
  }
460
534
 
461
535
  ParameterSelection.defaultProps = {
462
- error: {},
463
- editMode: false,
464
- loading: false,
465
- paramData: {},
466
- parameters: [],
536
+ // error: {},
467
537
  columns: [],
538
+ editParamsRowIndex: undefined,
468
539
  hiddenParameterTypes: [],
540
+ paramData: {},
541
+ paramDataUrl: undefined,
542
+ paramDefinition: undefined,
543
+ parameters: [],
544
+ parameterTypes: {},
469
545
  sortingColumns: {},
470
- editParamsRowIndex: [],
471
- editModeCallback: undefined,
472
546
  };
473
547
 
474
548
  ParameterSelection.propTypes = {
549
+ // error: PropTypes.object,
550
+ paramDataUrl: PropTypes.string,
551
+ hiddenParameterTypes: PropTypes.array,
552
+
553
+ // from ParameterSelectionActions
554
+ initParameterSelection: PropTypes.func.isRequired,
555
+ addParameter: PropTypes.func.isRequired,
556
+ deleteParameter: PropTypes.func.isRequired,
557
+ lockParameter: PropTypes.func.isRequired,
558
+ activateEditParameter: PropTypes.func.isRequired,
559
+ confirmEditParameter: PropTypes.func.isRequired,
560
+ cancelEditParameter: PropTypes.func.isRequired,
561
+ changeEditParameter: PropTypes.func.isRequired,
562
+ sortParameter: PropTypes.func.isRequired,
563
+ openParameterSelectionDialogBox: PropTypes.func.isRequired,
564
+ closeParameterSelectionDialogBox: PropTypes.func.isRequired,
565
+ loadParamData: PropTypes.func.isRequired,
566
+
567
+ // from ApplicationInstance
568
+ editModeCallback: PropTypes.func.isRequired,
569
+ paramType: PropTypes.string.isRequired,
570
+ // location: PropTypes.string.isRequired,
571
+ // organization: PropTypes.string.isRequired,
475
572
  data: PropTypes.shape({
573
+ useDefaultValue: PropTypes.bool,
574
+ allowRowAdjustment: PropTypes.bool,
575
+ allowNameAdjustment: PropTypes.bool,
576
+ allowDescriptionAdjustment: PropTypes.bool,
476
577
  parameters: PropTypes.array,
477
578
  paramDefinition: PropTypes.object,
478
- applications: PropTypes.object,
479
579
  }).isRequired,
480
- location: PropTypes.string.isRequired,
481
- organization: PropTypes.string.isRequired,
482
- paramDataUrl: PropTypes.string,
483
- initParameterSelection: PropTypes.func,
580
+
581
+ // from redux-state
582
+ // loading: PropTypes.bool.isRequired,
484
583
  editMode: PropTypes.bool.isRequired,
485
- loading: PropTypes.bool.isRequired,
486
- paramData: PropTypes.object.isRequired,
487
- hiddenParameterTypes: PropTypes.array.isRequired,
488
- allowedParameterTypes: PropTypes.object,
584
+ paramData: PropTypes.object,
489
585
  parameterTypes: PropTypes.object,
490
586
  parameters: PropTypes.array,
491
587
  sortingColumns: PropTypes.object,
492
- editModeCallback: PropTypes.func,
493
588
  columns: PropTypes.array,
494
- sortParameter: PropTypes.func,
495
- addParameter: PropTypes.func,
496
- deleteParameter: PropTypes.func,
497
- lockParameter: PropTypes.func,
498
- activateEditParameter: PropTypes.func,
499
- confirmEditParameter: PropTypes.func,
500
- cancelEditParameter: PropTypes.func,
501
- changeEditParameter: PropTypes.func,
502
- openParameterSelectionDialogBox: PropTypes.func,
503
- closeParameterSelectionDialogBox: PropTypes.func,
504
- loadParamData: PropTypes.func,
505
589
  paramDefinition: PropTypes.object,
506
- editParamsRowIndex: PropTypes.array,
590
+ editParamsRowIndex: PropTypes.number,
507
591
  };
508
592
 
509
593
  export default ParameterSelection;