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,50 +1,43 @@
1
- import $ from 'jquery';
2
- import React, { useState } from 'react'
1
+ import React from 'react';
3
2
  import PropTypes from 'prop-types';
4
3
  import {
5
4
  Icon,
6
5
  Button,
7
6
  MessageDialog,
7
+ Table,
8
+ FormControl,
9
+ inlineEditFormatterFactory,
8
10
  } from 'patternfly-react';
9
11
  import * as resolve from 'table-resolver';
10
12
  import ForemanModal from 'foremanReact/components/ForemanModal';
11
13
  import Select from 'foremanReact/components/common/forms/Select';
14
+ import { translate as __ } from 'foremanReact/common/I18n';
12
15
  import ParameterSelection from '../ParameterSelection';
13
16
  import AddTableEntry from '../common/AddTableEntry';
14
17
  import DeleteTableEntry from '../common/DeleteTableEntry';
15
18
  import RailsData from '../common/RailsData';
16
19
  import AnsiblePlaybookSelector from './components/AnsiblePlaybookSelector';
17
- import { translate as __ } from 'foremanReact/common/I18n';
18
20
  import { EasyHeaderFormatter } from '../../helper';
19
21
 
20
- import {
21
- Table,
22
- FormControl,
23
- inlineEditFormatterFactory,
24
- } from 'patternfly-react';
25
-
26
22
  import {
27
23
  PARAMETER_SELECTION_PARAM_TYPE_FOREMAN,
28
24
  PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE,
29
25
  } from '../ParameterSelection/ParameterSelectionConstants';
30
26
 
31
27
  class ApplicationDefinition extends React.Component {
32
-
33
- constructor(props) {
34
- super(props);
35
- }
36
-
37
- isEditing({rowData}) {
38
- return (rowData.backup !== undefined);
28
+ static isEditing({ rowData }) {
29
+ return rowData.backup !== undefined;
39
30
  }
40
31
 
41
- createAnsibleGroupObject(ansibleGroups, withAll=false) {
32
+ static createAnsibleGroupObject(ansibleGroups, withAll = false) {
42
33
  const ansibleGroupObj = {};
43
34
 
44
35
  const ansibleGroupArray = Object.keys(ansibleGroups);
45
- ansibleGroupArray.forEach(e => (ansibleGroupObj[e] = e));
36
+ ansibleGroupArray.forEach(e => {
37
+ ansibleGroupObj[e] = e;
38
+ });
46
39
 
47
- if ((withAll === false) && (ansibleGroupObj.hasOwnProperty('all'))) {
40
+ if (withAll === false && ansibleGroupObj.hasOwnProperty('all')) {
48
41
  delete ansibleGroupObj.all;
49
42
  }
50
43
 
@@ -52,20 +45,24 @@ class ApplicationDefinition extends React.Component {
52
45
  }
53
46
 
54
47
  addTableEntryAllowed() {
55
- return this.props.editMode || this.props.ansiblePlaybook.id == ''
48
+ return this.props.editMode || this.props.ansiblePlaybook.id === '';
56
49
  }
57
50
 
58
51
  componentDidMount() {
59
52
  const {
60
- data: { mode, ansiblePlaybook, ansibleDataUrl, services, ansibleVarsAll, hostgroups, supportedPlugins },
53
+ data: {
54
+ ansiblePlaybook,
55
+ services,
56
+ ansibleVarsAll,
57
+ hostgroups,
58
+ supportedPlugins,
59
+ },
61
60
  initApplicationDefinition,
62
- addApplicationDefinitionService,
63
61
  deleteApplicationDefinitionService,
64
62
  activateEditApplicationDefinitionService,
65
63
  changeEditApplicationDefinitionService,
66
64
  openForemanParameterSelectionModal,
67
65
  openAnsibleParameterSelectionModal,
68
- loadAnsibleData,
69
66
  } = this.props;
70
67
 
71
68
  const inlineEditButtonsFormatter = inlineEditFormatterFactory({
@@ -74,23 +71,25 @@ class ApplicationDefinition extends React.Component {
74
71
  <td style={{ padding: '2px' }}>
75
72
  <Button
76
73
  bsStyle="default"
77
- onClick={() => activateEditApplicationDefinitionService(additionalData)}
74
+ onClick={() =>
75
+ activateEditApplicationDefinitionService(additionalData)
76
+ }
78
77
  >
79
- <Icon type="pf" name="edit" title={__("Edit entry")} />
78
+ <Icon type="pf" name="edit" title={__('Edit entry')} />
80
79
  </Button>
81
80
  &nbsp;
82
81
  <Button
83
82
  bsStyle="default"
84
83
  onClick={() => openForemanParameterSelectionModal(additionalData)}
85
84
  >
86
- <Icon type="pf" name="settings" title={__("Change parameters")} />
85
+ <Icon type="pf" name="settings" title={__('Change parameters')} />
87
86
  </Button>
88
87
  &nbsp;
89
88
  <Button
90
89
  bsStyle="default"
91
90
  onClick={() => openAnsibleParameterSelectionModal(additionalData)}
92
91
  >
93
- <span title={__("Change ansible variables")}>A</span>
92
+ <span title={__('Change ansible variables')}>A</span>
94
93
  </Button>
95
94
  &nbsp;
96
95
  <DeleteTableEntry
@@ -104,26 +103,25 @@ class ApplicationDefinition extends React.Component {
104
103
  renderEdit: (value, additionalData) => (
105
104
  <td style={{ padding: '2px' }}>
106
105
  <Button bsStyle="default" disabled>
107
- <Icon type="pf" name={__("edit")} />
106
+ <Icon type="pf" name={__('edit')} />
108
107
  </Button>
109
108
  &nbsp;
110
109
  <Button bsStyle="default" disabled>
111
- <Icon type="pf" name={__("settings")} />
110
+ <Icon type="pf" name={__('settings')} />
112
111
  </Button>
113
112
  &nbsp;
114
- <Button
115
- bsStyle="default" disabled>
113
+ <Button bsStyle="default" disabled>
116
114
  <span>A</span>
117
115
  </Button>
118
116
  &nbsp;
119
117
  <DeleteTableEntry
120
118
  hidden={false}
121
- disabled={true}
119
+ disabled
122
120
  onDeleteTableEntry={deleteApplicationDefinitionService}
123
121
  additionalData={additionalData}
124
122
  />
125
123
  </td>
126
- )
124
+ ),
127
125
  });
128
126
  this.inlineEditButtonsFormatter = inlineEditButtonsFormatter;
129
127
 
@@ -135,12 +133,17 @@ class ApplicationDefinition extends React.Component {
135
133
  <span className="static">{value}</span>
136
134
  </td>
137
135
  ),
138
- renderEditText: (value, additionalData, subtype='text') => (
136
+ renderEditText: (value, additionalData, subtype = 'text') => (
139
137
  <td className="editing">
140
138
  <FormControl
141
139
  type={subtype}
142
140
  defaultValue={value}
143
- onBlur={e => changeEditApplicationDefinitionService(e.target.value, additionalData) }
141
+ onBlur={e =>
142
+ changeEditApplicationDefinitionService(
143
+ e.target.value,
144
+ additionalData
145
+ )
146
+ }
144
147
  />
145
148
  </td>
146
149
  ),
@@ -148,45 +151,63 @@ class ApplicationDefinition extends React.Component {
148
151
  <td className="editing">
149
152
  <Select
150
153
  value={value.toString()}
151
- onChange={e => changeEditApplicationDefinitionService(e.target.value, additionalData) }
154
+ onChange={e =>
155
+ changeEditApplicationDefinitionService(
156
+ e.target.value,
157
+ additionalData
158
+ )
159
+ }
152
160
  options={options}
153
161
  allowClear
154
162
  key="key"
155
163
  />
156
164
  </td>
157
- )
165
+ ),
158
166
  };
159
167
 
160
168
  const inlineEditFormatter = inlineEditFormatterFactory({
161
- isEditing: additionalData => this.isEditing(additionalData),
169
+ isEditing: additionalData => this.constructor.isEditing(additionalData),
162
170
  renderValue: (value, additionalData) => {
163
171
  let prettyValue = value;
164
- if (additionalData.property == 'hostgroup') {
172
+ if (additionalData.property === 'hostgroup') {
165
173
  prettyValue = hostgroups[value];
166
- }
167
- else if (additionalData.property == 'ansibleGroup') {
168
- const ag = this.createAnsibleGroupObject(this.props.ansiblePlaybook.groups);
174
+ } else if (additionalData.property === 'ansibleGroup') {
175
+ const ag = this.constructor.createAnsibleGroupObject(
176
+ this.props.ansiblePlaybook.groups
177
+ );
169
178
  prettyValue = ag[value];
170
179
  }
171
- return inlineEditFormatterImpl.renderValue(prettyValue, additionalData)
180
+ return inlineEditFormatterImpl.renderValue(prettyValue, additionalData);
172
181
  },
173
182
  renderEdit: (value, additionalData) => {
174
- if (additionalData.property == 'hostgroup') {
183
+ if (additionalData.property === 'hostgroup') {
175
184
  if (additionalData.rowData.newEntry === true) {
176
- return inlineEditFormatterImpl.renderEditSelect(value, additionalData, hostgroups);
185
+ return inlineEditFormatterImpl.renderEditSelect(
186
+ value,
187
+ additionalData,
188
+ hostgroups
189
+ );
177
190
  }
178
- return inlineEditFormatterImpl.renderValue(hostgroups[value], additionalData)
179
- }
180
- else if (additionalData.property == 'ansibleGroup') {
181
- const ag = this.createAnsibleGroupObject(this.props.ansiblePlaybook.groups);
191
+ return inlineEditFormatterImpl.renderValue(
192
+ hostgroups[value],
193
+ additionalData
194
+ );
195
+ } else if (additionalData.property === 'ansibleGroup') {
196
+ const ag = this.constructor.createAnsibleGroupObject(
197
+ this.props.ansiblePlaybook.groups
198
+ );
182
199
 
183
200
  if (additionalData.rowData.newEntry === true) {
184
- return inlineEditFormatterImpl.renderEditSelect(value, additionalData, ag);
201
+ return inlineEditFormatterImpl.renderEditSelect(
202
+ value,
203
+ additionalData,
204
+ ag
205
+ );
185
206
  }
186
207
  return inlineEditFormatterImpl.renderValue(ag[value], additionalData);
187
208
  }
188
209
  return inlineEditFormatterImpl.renderEditText(value, additionalData);
189
- }
210
+ },
190
211
  });
191
212
  this.inlineEditFormatter = inlineEditFormatter;
192
213
 
@@ -197,14 +218,24 @@ class ApplicationDefinition extends React.Component {
197
218
  supportedPlugins,
198
219
  this.headerFormatter,
199
220
  this.inlineEditFormatter,
200
- this.inlineEditButtonsFormatter,
221
+ this.inlineEditButtonsFormatter
201
222
  );
202
- };
223
+ }
203
224
 
204
225
  render() {
205
226
  const {
206
- data: { organization, location, mode, ansiblePlaybooks, foremanDataUrl, ansibleDataUrl },
207
- showAlertModal, alertModalText, alertModalTitle, closeAlertModal,
227
+ data: {
228
+ organization,
229
+ location,
230
+ mode,
231
+ ansiblePlaybooks,
232
+ foremanDataUrl,
233
+ ansibleDataUrl,
234
+ },
235
+ showAlertModal,
236
+ alertModalText,
237
+ alertModalTitle,
238
+ closeAlertModal,
208
239
  ansiblePlaybook,
209
240
  services,
210
241
  columns,
@@ -216,7 +247,6 @@ class ApplicationDefinition extends React.Component {
216
247
  openAnsibleParameterSelectionModal,
217
248
  closeAnsibleParameterSelectionModal,
218
249
  changeParameterSelectionMode,
219
- ParameterSelectionModal,
220
250
  loadAnsibleData,
221
251
  } = this.props;
222
252
 
@@ -227,7 +257,7 @@ class ApplicationDefinition extends React.Component {
227
257
  onHide={closeAlertModal}
228
258
  primaryAction={closeAlertModal}
229
259
  primaryActionButtonContent={__('OK')}
230
- primaryActionButtonBsStyle={"danger"}
260
+ primaryActionButtonBsStyle="danger"
231
261
  icon={<Icon type="pf" name="error-circle-o" />}
232
262
  title={alertModalTitle}
233
263
  primaryContent={alertModalText}
@@ -235,20 +265,21 @@ class ApplicationDefinition extends React.Component {
235
265
  <div>
236
266
  <AnsiblePlaybookSelector
237
267
  label="Ansible Playbook"
238
- hidden={ false }
239
- editable={ mode == 'newDefinition' }
240
- viewText={ ansiblePlaybook.name }
241
- options={ ansiblePlaybooks }
242
- onChange={ loadAnsibleData }
243
- selectValue={ ansiblePlaybook.id.toString() }
244
- additionalData={{url: ansibleDataUrl }}
268
+ hidden={false}
269
+ editable={mode === 'newDefinition'}
270
+ viewText={ansiblePlaybook.name}
271
+ options={ansiblePlaybooks}
272
+ onChange={loadAnsibleData}
273
+ selectValue={ansiblePlaybook.id.toString()}
274
+ additionalData={{ url: ansibleDataUrl }}
245
275
  />
246
- {ansiblePlaybook.id == '' ? (
247
- <div style={{ paddingTop: 25 }}>
248
- <pre>{ "Ansible Playbook can't be blank" }</pre>
249
- </div>
250
- ) : (<div></div>)}
251
-
276
+ {ansiblePlaybook.id === '' ? (
277
+ <div style={{ paddingTop: 25 }}>
278
+ <pre>Ansible Playbook can&apos;t be blank</pre>
279
+ </div>
280
+ ) : (
281
+ <div />
282
+ )}
252
283
  </div>
253
284
  <div className="form-group">
254
285
  <Table.PfProvider
@@ -261,8 +292,8 @@ class ApplicationDefinition extends React.Component {
261
292
  components={{
262
293
  body: {
263
294
  row: Table.InlineEditRow,
264
- cell: cellProps => cellProps.children
265
- }
295
+ cell: cellProps => cellProps.children,
296
+ },
266
297
  }}
267
298
  >
268
299
  <Table.Header headerRows={resolve.headerRows({ columns })} />
@@ -271,27 +302,34 @@ class ApplicationDefinition extends React.Component {
271
302
  rowKey="id"
272
303
  onRow={(rowData, { rowIndex }) => ({
273
304
  role: 'row',
274
- isEditing: () => this.isEditing({ rowData }),
275
- onCancel: () => cancelEditApplicationDefinitionService({ rowData, rowIndex }),
276
- onConfirm: () => confirmEditApplicationDefinitionService({ rowData, rowIndex }),
277
- last: rowIndex === services.length - 1
305
+ isEditing: () => this.constructor.isEditing({ rowData }),
306
+ onCancel: () =>
307
+ cancelEditApplicationDefinitionService({ rowData, rowIndex }),
308
+ onConfirm: () =>
309
+ confirmEditApplicationDefinitionService({
310
+ rowData,
311
+ rowIndex,
312
+ }),
313
+ last: rowIndex === services.length - 1,
278
314
  })}
279
315
  />
280
316
  </Table.PfProvider>
281
317
  <AddTableEntry
282
- hidden={ false }
283
- disabled={ this.addTableEntryAllowed() }
284
- onAddTableEntry={ addApplicationDefinitionService }
318
+ hidden={false}
319
+ disabled={this.addTableEntryAllowed()}
320
+ onAddTableEntry={addApplicationDefinitionService}
285
321
  />
286
322
  <span style={{ marginLeft: 30 }}>
287
- Ansible group vars 'all':
323
+ Ansible group vars &apos;all&apos;:
288
324
  <Button
289
325
  style={{ marginLeft: 10 }}
290
326
  bsStyle="default"
291
- disabled={ this.props.editMode }
292
- onClick={() => openAnsibleParameterSelectionModal({
293
- isAllGroup: true
294
- })}
327
+ disabled={this.props.editMode}
328
+ onClick={() =>
329
+ openAnsibleParameterSelectionModal({
330
+ isAllGroup: true,
331
+ })
332
+ }
295
333
  >
296
334
  <span title={__("Change ansible variables for 'all'")}>A</span>
297
335
  </Button>
@@ -301,27 +339,48 @@ class ApplicationDefinition extends React.Component {
301
339
  <ForemanModal
302
340
  id="AppDefinitionForemanParamSelection"
303
341
  dialogClassName="param_selection_modal"
304
- title={__("Foreman Parameter definition for Application Definition")}
342
+ title={__(
343
+ 'Foreman Parameter definition for Application Definition'
344
+ )}
305
345
  >
306
346
  <ForemanModal.Header closeButton={false}>
307
347
  Parameter definition
308
348
  </ForemanModal.Header>
309
349
  {this.props.parametersData ? (
310
350
  <ParameterSelection
311
- editModeCallback={ (hide) => changeParameterSelectionMode({ mode: hide })}
312
- paramType={ PARAMETER_SELECTION_PARAM_TYPE_FOREMAN }
313
- hiddenParameterTypes={ hiddenForemanParameterTypes }
314
- location={ location }
315
- organization={ organization }
316
- paramDataUrl= { foremanDataUrl }
317
- data={ this.props.parametersData }
351
+ editModeCallback={hide =>
352
+ changeParameterSelectionMode({ mode: hide })
353
+ }
354
+ paramType={PARAMETER_SELECTION_PARAM_TYPE_FOREMAN}
355
+ hiddenParameterTypes={hiddenForemanParameterTypes}
356
+ location={location}
357
+ organization={organization}
358
+ paramDataUrl={foremanDataUrl}
359
+ data={this.props.parametersData}
318
360
  />
319
- ) : (<span>Empty</span>)
320
- }
361
+ ) : (
362
+ <span>Empty</span>
363
+ )}
321
364
  <ForemanModal.Footer>
322
365
  <div>
323
- <Button bsStyle="primary" disabled={this.props.paramEditMode} onClick={() => closeForemanParameterSelectionModal({ mode: 'save' })}>{__("Save")}</Button>
324
- <Button bsStyle="default" disabled={this.props.paramEditMode} onClick={() => closeForemanParameterSelectionModal({ mode: 'cancel' })}>{__("Cancel")}</Button>
366
+ <Button
367
+ bsStyle="primary"
368
+ disabled={this.props.paramEditMode}
369
+ onClick={() =>
370
+ closeForemanParameterSelectionModal({ mode: 'save' })
371
+ }
372
+ >
373
+ {__('Save')}
374
+ </Button>
375
+ <Button
376
+ bsStyle="default"
377
+ disabled={this.props.paramEditMode}
378
+ onClick={() =>
379
+ closeForemanParameterSelectionModal({ mode: 'cancel' })
380
+ }
381
+ >
382
+ {__('Cancel')}
383
+ </Button>
325
384
  </div>
326
385
  </ForemanModal.Footer>
327
386
  </ForemanModal>
@@ -330,74 +389,104 @@ class ApplicationDefinition extends React.Component {
330
389
  <ForemanModal
331
390
  id="AppDefinitionAnsibleParamSelection"
332
391
  dialogClassName="param_selection_modal"
333
- title={__("Ansible variables for Application Definition")}
392
+ title={__('Ansible variables for Application Definition')}
334
393
  >
335
394
  <ForemanModal.Header closeButton={false}>
336
395
  Parameter definition
337
396
  </ForemanModal.Header>
338
397
  {this.props.parametersData ? (
339
398
  <ParameterSelection
340
- editModeCallback={ (hide) => changeParameterSelectionMode({ mode: hide })}
341
- paramType={ PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE }
342
- location={ location }
343
- organization={ organization }
344
- data={ this.props.parametersData }
399
+ editModeCallback={hide =>
400
+ changeParameterSelectionMode({ mode: hide })
401
+ }
402
+ paramType={PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE}
403
+ location={location}
404
+ organization={organization}
405
+ data={this.props.parametersData}
345
406
  />
346
- ) : (<span>Empty</span>)
347
- }
407
+ ) : (
408
+ <span>Empty</span>
409
+ )}
348
410
  <ForemanModal.Footer>
349
411
  <div>
350
- <Button bsStyle="primary" disabled={this.props.paramEditMode} onClick={() => closeAnsibleParameterSelectionModal({ mode: 'save' })}>{__("Save")}</Button>
351
- <Button bsStyle="default" disabled={this.props.paramEditMode} onClick={() => closeAnsibleParameterSelectionModal({ mode: 'cancel' })}>{__("Cancel")}</Button>
412
+ <Button
413
+ bsStyle="primary"
414
+ disabled={this.props.paramEditMode}
415
+ onClick={() =>
416
+ closeAnsibleParameterSelectionModal({ mode: 'save' })
417
+ }
418
+ >
419
+ {__('Save')}
420
+ </Button>
421
+ <Button
422
+ bsStyle="default"
423
+ disabled={this.props.paramEditMode}
424
+ onClick={() =>
425
+ closeAnsibleParameterSelectionModal({ mode: 'cancel' })
426
+ }
427
+ >
428
+ {__('Cancel')}
429
+ </Button>
352
430
  </div>
353
431
  </ForemanModal.Footer>
354
432
  </ForemanModal>
355
433
  </div>
356
434
  <RailsData
357
- key='application_definition_services_data'
358
- view='app_definition'
359
- parameter='services'
435
+ key="application_definition_services_data"
436
+ view="app_definition"
437
+ parameter="services"
360
438
  value={JSON.stringify(this.props.services)}
361
439
  />
362
440
  <RailsData
363
- key='application_definition_ansible_data'
364
- view='app_definition'
365
- parameter='ansible_vars_all'
441
+ key="application_definition_ansible_data"
442
+ view="app_definition"
443
+ parameter="ansible_vars_all"
366
444
  value={JSON.stringify(this.props.ansibleVarsAll)}
367
445
  />
368
446
  </span>
369
- )};
447
+ );
448
+ }
370
449
  }
371
450
 
372
451
  ApplicationDefinition.defaultProps = {
373
- error: {},
374
452
  showAlertModal: false,
375
453
  alertModalText: '',
376
454
  alertModalTitle: '',
377
455
  editMode: false,
378
- ansiblePlaybook: { "id": '', "name": '' },
456
+ ansiblePlaybook: { id: '', name: '' },
379
457
  services: [],
380
458
  ansibleVarsAll: [],
381
459
  parametersData: {},
382
460
  columns: [],
383
461
  hiddenForemanParameterTypes: [],
384
- editParamsOfRowId: null,
385
462
  paramEditMode: false,
386
- }
463
+ deleteApplicationDefinitionService: undefined,
464
+ activateEditApplicationDefinitionService: undefined,
465
+ confirmEditApplicationDefinitionService: undefined,
466
+ cancelEditApplicationDefinitionService: undefined,
467
+ changeEditApplicationDefinitionService: undefined,
468
+ openForemanParameterSelectionModal: undefined,
469
+ closeForemanParameterSelectionModal: undefined,
470
+ openAnsibleParameterSelectionModal: undefined,
471
+ closeAnsibleParameterSelectionModal: undefined,
472
+ changeParameterSelectionMode: undefined,
473
+ };
387
474
 
388
475
  ApplicationDefinition.propTypes = {
389
- initApplicationDefinition: PropTypes.func,
476
+ data: PropTypes.object.isRequired,
477
+ loadAnsibleData: PropTypes.func.isRequired,
478
+ initApplicationDefinition: PropTypes.func.isRequired,
390
479
  showAlertModal: PropTypes.bool,
391
480
  alertModalText: PropTypes.string,
392
481
  alertModalTitle: PropTypes.string,
393
- editMode: PropTypes.bool.isRequired,
482
+ editMode: PropTypes.bool,
394
483
  ansiblePlaybook: PropTypes.object,
395
484
  services: PropTypes.array,
396
485
  ansibleVarsAll: PropTypes.array,
397
486
  columns: PropTypes.array,
398
487
  hiddenForemanParameterTypes: PropTypes.array,
399
- closeAlertModal: PropTypes.func,
400
- addApplicationDefinitionService: PropTypes.func,
488
+ closeAlertModal: PropTypes.func.isRequired,
489
+ addApplicationDefinitionService: PropTypes.func.isRequired,
401
490
  deleteApplicationDefinitionService: PropTypes.func,
402
491
  activateEditApplicationDefinitionService: PropTypes.func,
403
492
  confirmEditApplicationDefinitionService: PropTypes.func,