foreman_acd 0.0.5 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +82 -27
  3. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +122 -0
  4. data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +71 -0
  5. data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -2
  6. data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +54 -0
  7. data/app/controllers/foreman_acd/api/v2/app_playbooks_controller.rb +0 -0
  8. data/app/controllers/foreman_acd/app_definitions_controller.rb +36 -4
  9. data/app/controllers/foreman_acd/app_instances_controller.rb +24 -90
  10. data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +23 -0
  11. data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
  12. data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
  13. data/app/controllers/foreman_acd/remote_execution_controller.rb +49 -0
  14. data/app/controllers/ui_acd_controller.rb +11 -4
  15. data/app/models/foreman_acd/acd_provider.rb +27 -0
  16. data/app/models/foreman_acd/ansible_playbook.rb +50 -0
  17. data/app/models/foreman_acd/app_definition.rb +2 -1
  18. data/app/models/foreman_acd/app_instance.rb +7 -0
  19. data/app/services/foreman_acd/app_configurator.rb +57 -0
  20. data/app/services/foreman_acd/app_deployer.rb +139 -0
  21. data/app/services/foreman_acd/inventory_creator.rb +67 -0
  22. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +21 -0
  23. data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +3 -0
  24. data/app/views/foreman_acd/ansible_playbooks/index.html.erb +30 -0
  25. data/app/views/foreman_acd/ansible_playbooks/new.html.erb +3 -0
  26. data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +3 -0
  27. data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +3 -0
  28. data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +3 -0
  29. data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +3 -0
  30. data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +3 -0
  31. data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +3 -0
  32. data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +3 -0
  33. data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +3 -0
  34. data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +3 -0
  35. data/app/views/foreman_acd/app_definitions/_form.html.erb +25 -19
  36. data/app/views/foreman_acd/app_definitions/edit.html.erb +5 -0
  37. data/app/views/foreman_acd/app_definitions/import.html.erb +18 -0
  38. data/app/views/foreman_acd/app_definitions/index.html.erb +9 -5
  39. data/app/views/foreman_acd/app_instances/_form.html.erb +10 -8
  40. data/app/views/foreman_acd/app_instances/deploy.html.erb +19 -0
  41. data/app/views/foreman_acd/app_instances/index.html.erb +10 -5
  42. data/app/views/foreman_acd/app_instances/report.html.erb +19 -0
  43. data/app/views/templates/job/run_acd_ansible_playbook.erb +49 -0
  44. data/app/views/ui_acd/ansible_data.json.rabl +6 -0
  45. data/app/views/ui_acd/app.json.rabl +6 -2
  46. data/app/views/ui_acd/app_definition.json.rabl +1 -1
  47. data/app/views/ui_acd/{fdata.json.rabl → foreman_data.json.rabl} +1 -1
  48. data/config/routes.rb +36 -1
  49. data/db/migrate/20190610202252_create_app_definitions.rb +1 -3
  50. data/db/migrate/20190625140305_create_app_instances.rb +1 -1
  51. data/db/migrate/20200916091018_create_ansible_playbooks.rb +20 -0
  52. data/db/migrate/20200917120220_add_ansible_playbook_id.rb +14 -0
  53. data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +5 -0
  54. data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +5 -0
  55. data/db/seeds.d/62_acd_proxy_feature.rb +6 -0
  56. data/db/seeds.d/75-job_templates.rb +8 -0
  57. data/lib/foreman_acd/engine.rb +7 -0
  58. data/lib/foreman_acd/plugin.rb +84 -13
  59. data/lib/foreman_acd/version.rb +1 -1
  60. data/package.json +1 -2
  61. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +378 -0
  62. data/webpack/components/ApplicationDefinition/ApplicationDefinition.scss +1 -0
  63. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +295 -0
  64. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +14 -0
  65. data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +26 -0
  66. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +243 -0
  67. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +8 -0
  68. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +49 -0
  69. data/webpack/components/ApplicationDefinition/index.js +33 -0
  70. data/webpack/components/ApplicationInstance/ApplicationInstance.js +414 -0
  71. data/webpack/components/ApplicationInstance/ApplicationInstance.scss +11 -0
  72. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +239 -0
  73. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +14 -0
  74. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +295 -0
  75. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +9 -0
  76. data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +49 -0
  77. data/webpack/components/ApplicationInstance/components/Service.js +30 -0
  78. data/webpack/components/ApplicationInstance/components/ServiceCounter.js +37 -0
  79. data/webpack/components/ApplicationInstance/index.js +35 -0
  80. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +155 -0
  81. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +27 -0
  82. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +86 -0
  83. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +4 -0
  84. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +52 -0
  85. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +5 -0
  86. data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +26 -0
  87. data/webpack/components/ApplicationInstanceReport/index.js +27 -0
  88. data/webpack/components/ParameterSelection/ParameterSelection.js +121 -192
  89. data/webpack/components/ParameterSelection/ParameterSelection.scss +9 -0
  90. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +80 -104
  91. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +15 -19
  92. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +3 -35
  93. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +116 -84
  94. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +3 -7
  95. data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +12 -21
  96. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +1 -1
  97. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +3 -45
  98. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +20 -0
  99. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +22 -46
  100. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
  101. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +40 -265
  102. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +11 -96
  103. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +3 -9
  104. data/webpack/components/ParameterSelection/index.js +6 -8
  105. data/webpack/components/common/AddTableEntry.js +30 -0
  106. data/webpack/components/common/DeleteTableEntry.js +38 -0
  107. data/webpack/components/common/EasyHeaderFormatter.js +18 -0
  108. data/webpack/components/common/EditTableEntry.js +49 -0
  109. data/webpack/components/common/ExtSelect.js +43 -0
  110. data/webpack/components/common/LockTableEntry.js +59 -0
  111. data/webpack/components/common/RailsData.js +27 -0
  112. data/webpack/components/common/__tests__/AddTableEntry.test.js +26 -0
  113. data/webpack/components/common/__tests__/DeleteTableEntry.test.js +29 -0
  114. data/webpack/components/common/__tests__/ExtSelect.test.js +38 -0
  115. data/webpack/components/common/__tests__/RailsData.test.js +16 -0
  116. data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +35 -0
  117. data/webpack/components/common/__tests__/__snapshots__/AddTableEntry.test.js.snap +35 -0
  118. data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +41 -0
  119. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +41 -0
  120. data/webpack/components/common/__tests__/__snapshots__/ExtSelect.test.js.snap +18 -0
  121. data/webpack/components/common/__tests__/__snapshots__/RailsData.test.js.snap +10 -0
  122. data/webpack/helper.js +20 -0
  123. data/webpack/index.js +6 -0
  124. data/webpack/reducer.js +43 -3
  125. metadata +91 -39
@@ -0,0 +1,5 @@
1
+ const applicationInstanceReport = state => state.foremanAcd.applicationInstanceReport;
2
+
3
+ export const selectHosts = state => applicationInstanceReport(state).hosts;
4
+ export const selectReport = state => applicationInstanceReport(state).report;
5
+ export const selectActiveHostId = state => applicationInstanceReport(state).activeHostId;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ const ReportViewer= ({
5
+ hidden,
6
+ report,
7
+ }) =>{
8
+ if (hidden) {
9
+ return null;
10
+ }
11
+
12
+ if (report === undefined) {
13
+ return null;
14
+ }
15
+
16
+ return report.map((task, id) => (
17
+ <div key={"report_task_"+id} className="report_task">{task.name}</div>
18
+ ));
19
+ };
20
+
21
+ ReportViewer.propTypes = {
22
+ hidden: PropTypes.bool,
23
+ report: PropTypes.array,
24
+ };
25
+
26
+ export default ReportViewer;
@@ -0,0 +1,27 @@
1
+ import { bindActionCreators } from 'redux';
2
+ import { connect } from 'react-redux';
3
+
4
+ import './ApplicationInstanceReport.scss';
5
+ import ApplicationInstanceReport from './ApplicationInstanceReport';
6
+ import * as ApplicationInstanceReportActions from './ApplicationInstanceReportActions';
7
+
8
+ import {
9
+ selectHosts,
10
+ selectReport,
11
+ selectActiveHostId,
12
+ } from './ApplicationInstanceReportSelectors';
13
+
14
+ const mapStateToProps = state => ({
15
+ hosts: selectHosts(state),
16
+ report: selectReport(state),
17
+ activeHostId: selectActiveHostId(state),
18
+ });
19
+
20
+ const mapDispatchToProps = dispatch =>
21
+ bindActionCreators(ApplicationInstanceReportActions, dispatch);
22
+
23
+ export default connect(
24
+ mapStateToProps,
25
+ mapDispatchToProps
26
+ )(ApplicationInstanceReport);
27
+
@@ -5,14 +5,13 @@ import * as sort from 'sortabular';
5
5
  import { orderBy } from 'lodash';
6
6
  import * as resolve from 'table-resolver';
7
7
  import Select from 'foremanReact/components/common/forms/Select';
8
+ import AddTableEntry from '../common/AddTableEntry';
9
+ import EditTableEntry from '../common/EditTableEntry';
10
+ import DeleteTableEntry from '../common/DeleteTableEntry';
11
+ import LockTableEntry from '../common/LockTableEntry';
12
+ import ExtSelect from '../common/ExtSelect';
8
13
 
9
14
  import {
10
- isNewDefinition,
11
- isEditDefinition,
12
- isDefinition,
13
- isNewInstance,
14
- isEditInstance,
15
- isInstance,
16
15
  transformForemanData,
17
16
  } from './ParameterSelectionHelper';
18
17
 
@@ -22,9 +21,10 @@ import {
22
21
  cloneDeep,
23
22
  } from 'lodash';
24
23
 
25
-
26
24
  import {
27
- PARAMETER_TYPES,
25
+ PARAMETER_SELECTION_TYPES,
26
+ PARAMETER_SELECTION_PARAM_TYPE_FOREMAN,
27
+ PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE,
28
28
  } from './ParameterSelectionConstants';
29
29
 
30
30
  import {
@@ -43,86 +43,12 @@ const theme = {
43
43
  base00: 'rgba(0, 0, 0, 0)',
44
44
  };
45
45
 
46
-
47
46
  class ParameterSelection extends React.Component {
48
47
 
49
48
  constructor(props) {
50
49
  super(props);
51
50
  }
52
51
 
53
- renderAddButton(mode, addParameter) {
54
- if (isInstance(mode))
55
- return null;
56
-
57
- return (
58
- <Button bsStyle="default" disabled={ this.props.editMode || this.props.hostgroupId <= 0 } onClick={() => addParameter()}>
59
- <Icon type="fa" name="plus" />
60
- </Button>
61
- );
62
- }
63
-
64
- renderDeleteButton(mode, deleteParameter, additionalData, disabled=false) {
65
- if (isInstance(mode))
66
- return null;
67
-
68
- return (
69
- <span>
70
- &nbsp;
71
- <Button
72
- bsStyle="default"
73
- disabled={disabled}
74
- onClick={() => window.confirm("Are you sure you wish to delete this item?") && deleteParameter(additionalData) }
75
- >
76
- <Icon type="pf" name="delete" />
77
- </Button>
78
- </span>
79
- );
80
- }
81
-
82
- renderSelectApplication(applications, url, loadParameterSelection, appDefinition) {
83
- return (
84
- <Select
85
- value={appDefinition.id.toString()}
86
- onChange={e => loadParameterSelection(url, e.target.value) }
87
- options={applications}
88
- allowClear
89
- key="key"
90
- />
91
- );
92
- }
93
-
94
- renderSelectHostgroup(hostgroups, url, loadForemanData, hostgroupId) {
95
- return (
96
- <Select
97
- value={hostgroupId.toString()}
98
- onChange={e => loadForemanData(url, e.target.value, true) }
99
- options={hostgroups}
100
- allowClear
101
- key="key"
102
- />
103
- );
104
- }
105
-
106
- renderRailsInputHidden(view, parameter, value) {
107
- var id = "foreman_acd_"+ view +"_"+ parameter;
108
- var name = "foreman_acd_"+ view +"["+ parameter +"]";
109
-
110
- return (
111
- <input
112
- id={id}
113
- name={name}
114
- value={value}
115
- type="hidden"
116
- />
117
- );
118
- }
119
-
120
- renderShowDivText(text) {
121
- return (
122
- <div>{text}</div>
123
- );
124
- }
125
-
126
52
  isEditing({rowData}) {
127
53
  return (rowData.backup !== undefined);
128
54
  }
@@ -130,52 +56,78 @@ class ParameterSelection extends React.Component {
130
56
  // enables our custom header formatters extensions to reactabular
131
57
  customHeaderFormatters = customHeaderFormattersDefinition;
132
58
 
133
- validateRows() {
134
- var result = (this.props.rows.map(e => e.value).filter(i => i == "").length == 0);
135
- if (result === false) {
136
- window.alert("All parameters need to have a value!");
137
- }
138
- return result;
139
- }
140
-
141
59
  componentDidMount() {
142
60
  const {
143
- data: { mode, appDefinition, location, organization, loadForemanDataUrl, parameters },
61
+ data: { useDefaultValue, allowRowAdjustment, allowNameAdjustment, allowDescriptionAdjustment, parameters, paramDefinition },
62
+ location,
63
+ organization,
64
+ paramType,
65
+ paramDataUrl,
144
66
  initParameterSelection,
145
67
  sortParameter,
146
68
  deleteParameter,
69
+ lockParameter,
147
70
  activateEditParameter,
148
71
  changeEditParameter,
149
- loadForemanData,
72
+ loadParamData,
150
73
  } = this.props;
151
74
 
152
- if (isEditDefinition(mode) || isEditInstance(mode)) {
153
- loadForemanData(loadForemanDataUrl, appDefinition.hostgroup_id);
154
- }
155
-
156
- if (isInstance(mode)) {
157
- $('input[type="submit"][name="commit"]').on('click', () => this.validateRows());
75
+ if (paramDataUrl !== undefined) {
76
+ switch (paramType) {
77
+ case PARAMETER_SELECTION_PARAM_TYPE_FOREMAN: {
78
+ loadParamData({ paramDefinition: paramDefinition, url: paramDataUrl, dataType: paramType, clearParameters: false });
79
+ break;
80
+ }
81
+ default: { }
82
+ }
158
83
  }
159
84
 
160
85
  const inlineEditButtonsFormatter = inlineEditFormatterFactory({
161
86
  isEditing: additionalData => this.props.editMode,
162
87
  renderValue: (value, additionalData) => (
163
88
  <td style={{ padding: '2px' }}>
164
- <Button
165
- bsStyle="default"
166
- onClick={() => activateEditParameter(additionalData)}
167
- >
168
- <Icon type="pf" name="edit" />
169
- </Button>
170
- {this.renderDeleteButton(mode, deleteParameter, additionalData)}
89
+ <EditTableEntry
90
+ disabled={false}
91
+ handleLocking={!allowRowAdjustment}
92
+ onEditTableEntry={() => activateEditParameter(additionalData)}
93
+ additionalData={additionalData}
94
+ />
95
+ &nbsp;
96
+ <LockTableEntry
97
+ hidden={!allowRowAdjustment}
98
+ disabled={!allowRowAdjustment}
99
+ onLockTableEntry={lockParameter}
100
+ additionalData={additionalData}
101
+ />
102
+ &nbsp;
103
+ <DeleteTableEntry
104
+ hidden={!allowRowAdjustment}
105
+ disabled={false}
106
+ onDeleteTableEntry={deleteParameter}
107
+ additionalData={additionalData}
108
+ />
171
109
  </td>
172
110
  ),
173
111
  renderEdit: (value, additionalData) => (
174
112
  <td style={{ padding: '2px' }}>
175
- <Button bsStyle="default" disabled>
176
- <Icon type="pf" name="edit" />
177
- </Button>
178
- {this.renderDeleteButton(mode, deleteParameter, additionalData, true)}
113
+ <EditTableEntry
114
+ disabled={true}
115
+ onEditTableEntry={() => activateEditParameter(additionalData)}
116
+ additionalData={additionalData}
117
+ />
118
+ &nbsp;
119
+ <LockTableEntry
120
+ disabled={true}
121
+ onLockTableEntry={lockParameter}
122
+ additionalData={additionalData}
123
+ />
124
+ &nbsp;
125
+ <DeleteTableEntry
126
+ hidden={!allowRowAdjustment}
127
+ disabled={true}
128
+ onDeleteTableEntry={deleteParameter}
129
+ additionalData={additionalData}
130
+ />
179
131
  </td>
180
132
  )
181
133
  });
@@ -225,28 +177,36 @@ class ParameterSelection extends React.Component {
225
177
  ),
226
178
  };
227
179
 
180
+ // TODO: should we differentiate between paramType FOREMAN and ANSIBLE?
181
+
228
182
  const inlineEditFormatter = inlineEditFormatterFactory({
229
183
  isEditing: additionalData => this.isEditing(additionalData),
230
184
  renderValue: (value, additionalData) => {
231
- var prettyValue = value;
185
+ let prettyValue = value;
232
186
  if (additionalData.property == 'type') {
233
- prettyValue = PARAMETER_TYPES[value];
187
+ prettyValue = PARAMETER_SELECTION_TYPES[value];
234
188
  } else if (additionalData.property == 'value') {
235
189
  switch (additionalData.rowData.type) {
236
190
  case 'computeprofile':
237
- prettyValue = transformForemanData(this.props.foremanData['computeprofiles'])[value]
191
+ prettyValue = transformForemanData(this.props.paramData['computeprofiles'])[value]
238
192
  break;
239
193
  case 'domain':
240
- prettyValue = transformForemanData(this.props.foremanData['domains'])[value]
194
+ prettyValue = transformForemanData(this.props.paramData['domains'])[value]
241
195
  break;
242
196
  case 'lifecycleenv':
243
- prettyValue = transformForemanData(this.props.foremanData['lifecycle_environments'])[value]
197
+ prettyValue = transformForemanData(this.props.paramData['lifecycle_environments'])[value]
244
198
  break;
245
199
  case 'ptable':
246
- prettyValue = transformForemanData(this.props.foremanData['ptables'])[value]
200
+ prettyValue = transformForemanData(this.props.paramData['ptables'])[value]
201
+ break;
202
+ case 'password':
203
+ prettyValue = '****************'
247
204
  break;
248
205
  case 'puppetenv':
249
- prettyValue = transformForemanData(this.props.foremanData['environments'])[value]
206
+ prettyValue = transformForemanData(this.props.paramData['environments'])[value]
207
+ break;
208
+ case 'text':
209
+ prettyValue = value
250
210
  break;
251
211
  }
252
212
  }
@@ -258,19 +218,21 @@ class ParameterSelection extends React.Component {
258
218
  if (additionalData.rowData.newEntry === true) {
259
219
  return inlineEditFormatterImpl.renderEditSelect(value, additionalData, this.props.parameterTypes);
260
220
  }
261
- return inlineEditFormatterImpl.renderValue(PARAMETER_TYPES[value], additionalData)
221
+ return inlineEditFormatterImpl.renderValue(PARAMETER_SELECTION_TYPES[value], additionalData)
262
222
  case 'value':
263
223
  switch (additionalData.rowData.type) {
264
224
  case 'computeprofile':
265
- return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.foremanData['computeprofiles']));
225
+ return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['computeprofiles']));
266
226
  case 'domain':
267
- return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.foremanData['domains']));
227
+ return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['domains']));
268
228
  case 'lifecycleenv':
269
- return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.foremanData['lifecycle_environments']));
229
+ return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['lifecycle_environments']));
270
230
  case 'puppetenv':
271
- return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.foremanData['environments']));
231
+ return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['environments']));
272
232
  case 'ptable':
273
- return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.foremanData['ptables']));
233
+ return inlineEditFormatterImpl.renderEditSelect(value, additionalData, transformForemanData(this.props.paramData['ptables']));
234
+ case 'password':
235
+ return inlineEditFormatterImpl.renderEditText(value, additionalData, 'password');
274
236
  case 'text':
275
237
  default:
276
238
  return inlineEditFormatterImpl.renderEditText(value, additionalData);
@@ -283,9 +245,12 @@ class ParameterSelection extends React.Component {
283
245
  this.inlineEditFormatter = inlineEditFormatter;
284
246
 
285
247
  initParameterSelection(
286
- mode,
287
- appDefinition,
248
+ paramType,
249
+ paramDefinition,
288
250
  parameters,
251
+ useDefaultValue,
252
+ allowNameAdjustment,
253
+ allowDescriptionAdjustment,
289
254
  this.sortingFormatter,
290
255
  this.sortableTransform,
291
256
  this.inlineEditFormatter,
@@ -298,84 +263,51 @@ class ParameterSelection extends React.Component {
298
263
 
299
264
  render() {
300
265
  const {
301
- data: { mode, applications, hostgroups, loadParameterSelectionUrl, loadForemanDataUrl },
302
- rows,
266
+ data: { allowRowAdjustment, applications },
267
+ location,
268
+ organization,
269
+ parameters,
303
270
  columns,
304
271
  sortingColumns,
305
272
  loading,
306
273
  addParameter,
307
274
  confirmEditParameter,
308
275
  cancelEditParameter,
309
- loadParameterSelection,
310
- loadForemanData,
311
- appDefinition,
312
- hostgroupId,
313
276
  } = this.props;
314
277
 
315
- var sortedRows;
316
- var newEntryIndex = findIndex(rows, 'newEntry');
278
+ let sortedParameters;
279
+ const newEntryIndex = findIndex(parameters, 'newEntry');
317
280
 
318
281
  if (newEntryIndex >= 0) {
319
- let newEntry = rows[newEntryIndex];
282
+ const newEntry = parameters[newEntryIndex];
320
283
  // sort all elements, besides the newEntry which will be
321
284
  // added to the end of the Array
322
- var tmpRows = cloneDeep(rows);
323
- tmpRows.splice(newEntryIndex, 1);
324
- sortedRows = this.compose(
285
+ const tmpParameters = cloneDeep(parameters);
286
+ tmpParameters.splice(newEntryIndex, 1);
287
+ sortedParameters = this.compose(
325
288
  sort.sorter({
326
289
  columns,
327
290
  sortingColumns,
328
291
  sort: orderBy,
329
292
  strategy: sort.strategies.byProperty
330
293
  })
331
- )(tmpRows);
332
- sortedRows.push(newEntry);
294
+ )(tmpParameters);
295
+ sortedParameters.push(newEntry);
333
296
  } else {
334
- sortedRows = this.compose(
297
+ sortedParameters = this.compose(
335
298
  sort.sorter({
336
299
  columns,
337
300
  sortingColumns,
338
301
  sort: orderBy,
339
302
  strategy: sort.strategies.byProperty
340
303
  })
341
- )(rows);
304
+ )(parameters);
342
305
  }
343
306
 
344
307
  return(
345
308
  <div>
346
- {isDefinition(mode) ? (
347
- <div className="clearfix">
348
- <div className="form-group">
349
- <label className="col-md-2 control-label">Host Group</label>
350
- <div className="col-md-4">
351
- {isNewDefinition(mode) && this.renderSelectHostgroup(hostgroups, loadForemanDataUrl, loadForemanData, hostgroupId) }
352
- {isEditDefinition(mode) && this.renderShowDivText(hostgroups[hostgroupId]) }
353
- {this.renderRailsInputHidden('app_definition', 'hostgroup_id', hostgroupId) }
354
- </div>
355
- </div>
356
- </div>
357
- ) : (
358
- <div className="clearfix">
359
- <div className="form-group">
360
- <label className="col-md-2 control-label">Application Definition</label>
361
- <div className="col-md-4">
362
- {isNewInstance(mode) && this.renderSelectApplication(applications, loadParameterSelectionUrl, loadParameterSelection, appDefinition)}
363
- {isEditInstance(mode) && this.renderShowDivText(appDefinition.name)}
364
- {isInstance(mode) && this.renderRailsInputHidden('app_instance', 'app_definition_id', appDefinition.id)}
365
- </div>
366
- </div>
367
- </div>
368
- )}
369
- <div className="clearfix">
370
- <div className="form-group">
371
- <label className="col-md-1 control-label">Application parameters</label>
372
- <div className="col-md-5">&nbsp;</div>
373
- </div>
374
- </div>
375
-
376
309
  <div className="clearfix">
377
310
  <div className="form-group">
378
- {this.renderAddButton(mode, addParameter)}
379
311
  <Table.PfProvider
380
312
  striped
381
313
  bordered
@@ -400,20 +332,23 @@ class ParameterSelection extends React.Component {
400
332
  >
401
333
  <Table.Header headerRows={resolve.headerRows({ columns })} />
402
334
  <Table.Body
403
- rows={sortedRows}
335
+ rows={sortedParameters}
404
336
  rowKey="id"
405
337
  onRow={(rowData, { rowIndex }) => ({
406
338
  role: 'row',
407
339
  isEditing: () => this.isEditing({ rowData }),
408
340
  onCancel: () => cancelEditParameter({ rowData, rowIndex }),
409
341
  onConfirm: () => confirmEditParameter({ rowData, rowIndex }),
410
- last: rowIndex === sortedRows.length - 1
342
+ last: rowIndex === sortedParameters.length - 1
411
343
  })}
412
344
  />
413
345
  </Table.PfProvider>
414
- {this.renderAddButton(mode, addParameter)}
346
+ <AddTableEntry
347
+ hidden={!allowRowAdjustment}
348
+ disabled={ this.props.editMode }
349
+ onAddTableEntry={ addParameter }
350
+ />
415
351
  </div>
416
- {this.renderRailsInputHidden(isDefinition(mode) ? 'app_definition' : 'app_instance', 'parameters', JSON.stringify(this.props.rows))}
417
352
  </div>
418
353
  </div>
419
354
  );
@@ -424,45 +359,39 @@ ParameterSelection.defaultProps = {
424
359
  error: {},
425
360
  editMode: false,
426
361
  loading: false,
427
- foremanData: {},
428
- rows: [],
362
+ paramData: {},
363
+ parameters: [],
429
364
  columns: [],
430
365
  sortingColumns: {},
431
- appDefinition: { "id": '', "name": '', "hostgroup_id": '', "parameters": [] },
432
- hostgroupId: -1,
433
366
  };
434
367
 
435
368
  ParameterSelection.propTypes = {
436
369
  data: PropTypes.shape({
437
- mode: PropTypes.string.isRequired,
438
- location: PropTypes.string.isRequired,
439
- organization: PropTypes.string.isRequired,
440
370
  parameters: PropTypes.array,
441
- appDefinition: PropTypes.object,
371
+ paramDefinition: PropTypes.object,
442
372
  applications: PropTypes.object,
443
- hostgroups: PropTypes.object,
444
- loadParameterSelectionUrl: PropTypes.string,
445
- loadForemanDataUrl: PropTypes.string,
446
373
  }).isRequired,
374
+ location: PropTypes.string.isRequired,
375
+ organization: PropTypes.string.isRequired,
376
+ paramDataUrl: PropTypes.string,
447
377
  initParameterSelection: PropTypes.func,
448
378
  editMode: PropTypes.bool.isRequired,
449
379
  loading: PropTypes.bool.isRequired,
450
- foremanData: PropTypes.object.isRequired,
380
+ paramData: PropTypes.object.isRequired,
451
381
  parameterTypes: PropTypes.object,
452
- rows: PropTypes.array,
382
+ parameters: PropTypes.array,
453
383
  sortingColumns: PropTypes.object,
454
384
  columns: PropTypes.array,
455
385
  sortParameter: PropTypes.func,
456
386
  addParameter: PropTypes.func,
457
387
  deleteParameter: PropTypes.func,
388
+ lockParameter: PropTypes.func,
458
389
  activateEditParameter: PropTypes.func,
459
390
  confirmEditParameter: PropTypes.func,
460
391
  cancelEditParameter: PropTypes.func,
461
392
  changeEditParameter: PropTypes.func,
462
- loadParameterSelection: PropTypes.func,
463
- loadForemanData: PropTypes.func,
464
- appDefinition: PropTypes.object,
465
- hostgroupId: PropTypes.number,
393
+ loadParamData: PropTypes.func,
394
+ paramDefinition: PropTypes.object,
466
395
  };
467
396
 
468
397
  export default ParameterSelection;