foreman_acd 0.6.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -5
  3. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +90 -0
  4. data/app/controllers/foreman_acd/app_definitions_controller.rb +104 -7
  5. data/app/controllers/foreman_acd/app_instances_controller.rb +34 -32
  6. data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +1 -1
  7. data/app/controllers/foreman_acd/concerns/app_instance_mixins.rb +36 -0
  8. data/app/controllers/foreman_acd/remote_execution_controller.rb +37 -21
  9. data/app/controllers/ui_acd_controller.rb +42 -3
  10. data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +12 -7
  11. data/app/lib/actions/foreman_acd/run_configurator.rb +11 -7
  12. data/app/models/concerns/foreman_acd/host_managed_extensions.rb +41 -28
  13. data/app/models/foreman_acd/acd_provider.rb +7 -1
  14. data/app/models/foreman_acd/ansible_playbook.rb +2 -1
  15. data/app/models/foreman_acd/app_instance.rb +48 -3
  16. data/app/models/foreman_acd/foreman_host.rb +8 -0
  17. data/app/services/foreman_acd/acd_proxy_proxy_selector.rb +17 -0
  18. data/app/services/foreman_acd/app_configurator.rb +59 -15
  19. data/app/services/foreman_acd/app_deployer.rb +27 -4
  20. data/app/services/foreman_acd/inventory_creator.rb +25 -1
  21. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +41 -7
  22. data/app/views/foreman_acd/app_definitions/_form.html.erb +5 -1
  23. data/app/views/foreman_acd/app_definitions/import.html.erb +20 -1
  24. data/app/views/foreman_acd/app_definitions/index.html.erb +3 -6
  25. data/app/views/foreman_acd/app_instances/_form.html.erb +5 -1
  26. data/app/views/foreman_acd/app_instances/index.html.erb +18 -12
  27. data/app/views/foreman_acd/app_instances/report.html.erb +8 -3
  28. data/app/views/templates/job/run_acd_ansible_playbook.erb +1 -1
  29. data/app/views/ui_acd/host_report.json.rabl +4 -0
  30. data/app/views/ui_acd/report_data.json.rabl +10 -0
  31. data/app/views/ui_acd/validate_hostname.json.rabl +6 -0
  32. data/config/routes.rb +6 -0
  33. data/db/migrate/20210316151145_add_git_commit_to_ansible_playbooks.rb +8 -0
  34. data/db/migrate/20210503122809_add_git_url_to_ansible_playbooks.rb +8 -0
  35. data/db/migrate/20210818125913_add_is_existing_host_to_foreman_host.rb +8 -0
  36. data/db/migrate/20210902110645_add_initial_configure_task.rb +8 -0
  37. data/db/seeds.d/75-job_templates.rb +1 -1
  38. data/lib/foreman_acd/engine.rb +26 -4
  39. data/lib/foreman_acd/plugin.rb +9 -18
  40. data/lib/foreman_acd/version.rb +1 -1
  41. data/lib/foreman_acd.rb +30 -0
  42. data/lib/tasks/foreman_acd_tasks.rake +0 -12
  43. data/package.json +8 -22
  44. data/test/controllers/ansible_playbooks_controller_test.rb +1 -1
  45. data/test/controllers/app_instances_controller_test.rb +8 -3
  46. data/test/controllers/ui_acd_controller_test.rb +25 -6
  47. data/test/factories/foreman_acd_factories.rb +18 -4
  48. data/test/models/acd_provider_test.rb +37 -0
  49. data/test/models/ansible_playbook_test.rb +11 -0
  50. data/test/models/app_definition_test.rb +1 -1
  51. data/test/models/app_instance_test.rb +2 -0
  52. data/test/models/concerns/host_extensions_test.rb +26 -0
  53. data/test/models/foreman_host_test.rb +12 -0
  54. data/webpack/__mocks__/foremanReact/API.js +2 -0
  55. data/webpack/__mocks__/foremanReact/common/I18n.js +3 -0
  56. data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
  57. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +2 -0
  58. data/webpack/__mocks__/foremanReact/components/ForemanModal.js +7 -0
  59. data/webpack/__mocks__/foremanReact/components/common/forms/CommonForm.js +2 -0
  60. data/webpack/__mocks__/foremanReact/components/common/forms/TextInput.js +2 -0
  61. data/webpack/__mocks__/foremanReact/components/hosts/powerStatus.js +1 -0
  62. data/webpack/__snapshots__/helper.test.js.snap +14 -0
  63. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +35 -11
  64. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +12 -0
  65. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +1 -0
  66. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +30 -9
  67. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +4 -0
  68. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionConfData_1.fixtures.js +288 -0
  69. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +79 -0
  70. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +26 -0
  71. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +119 -0
  72. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +53 -0
  73. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinition.test.js.snap +226 -0
  74. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +3033 -0
  75. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +307 -0
  76. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +2 -1
  77. data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +41 -0
  78. data/webpack/components/ApplicationDefinition/components/__tests__/__snapshots__/AnsiblePlaybookSelector.test.js.snap +121 -0
  79. data/webpack/components/ApplicationDefinition/index.js +8 -0
  80. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +214 -0
  81. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.scss +1 -0
  82. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +161 -0
  83. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +6 -0
  84. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +79 -0
  85. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +8 -0
  86. data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportConfData_1.fixtures.js +129 -0
  87. data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +29 -0
  88. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +20 -0
  89. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +43 -0
  90. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +29 -0
  91. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +62 -0
  92. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportReducer.test.js.snap +362 -0
  93. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +130 -0
  94. data/webpack/components/ApplicationDefinitionImport/index.js +32 -0
  95. data/webpack/components/ApplicationInstance/ApplicationInstance.js +105 -31
  96. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +118 -6
  97. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +4 -0
  98. data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +15 -0
  99. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +71 -30
  100. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +4 -0
  101. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceConfData_1.fixtures.js +263 -0
  102. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +80 -0
  103. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +24 -0
  104. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +131 -0
  105. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +56 -0
  106. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +300 -0
  107. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +2990 -0
  108. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +284 -0
  109. data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +1 -0
  110. data/webpack/components/ApplicationInstance/components/ServiceCounter.js +1 -1
  111. data/webpack/components/ApplicationInstance/helper.js +0 -0
  112. data/webpack/components/ApplicationInstance/index.js +8 -0
  113. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +81 -6
  114. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +35 -1
  115. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +3 -0
  116. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +19 -0
  117. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +4 -0
  118. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportData_1.fixtures.js +349 -0
  119. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +20 -0
  120. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +47 -0
  121. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportReducer.test.js +41 -0
  122. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +26 -0
  123. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReport.test.js.snap +7 -0
  124. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +718 -0
  125. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +347 -0
  126. data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +24 -0
  127. data/webpack/components/ApplicationInstanceReport/components/__tests__/__snapshots__/ReportViewer.test.js.snap +24 -0
  128. data/webpack/components/ApplicationInstanceReport/index.js +8 -1
  129. data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +104 -0
  130. data/webpack/components/ExistingHostSelection/ExistingHostSelection.scss +15 -0
  131. data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +71 -0
  132. data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +4 -0
  133. data/webpack/components/ExistingHostSelection/ExistingHostSelectionHelper.js +0 -0
  134. data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +90 -0
  135. data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -0
  136. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +191 -0
  137. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +203 -0
  138. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +19 -0
  139. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionReducer.test.js +59 -0
  140. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +36 -0
  141. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelection.test.js.snap +35 -0
  142. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionReducer.test.js.snap +614 -0
  143. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +27 -0
  144. data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +48 -0
  145. data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +35 -0
  146. data/webpack/components/ExistingHostSelection/components/__tests__/__snapshots__/ServiceSelector.test.js.snap +77 -0
  147. data/webpack/components/ExistingHostSelection/index.js +26 -0
  148. data/webpack/components/ParameterSelection/ParameterSelection.js +103 -1
  149. data/webpack/components/ParameterSelection/ParameterSelection.scss +7 -0
  150. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +46 -4
  151. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +2 -0
  152. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +5 -1
  153. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +51 -29
  154. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -0
  155. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +124 -84
  156. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +10 -4
  157. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +36 -46
  158. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +33 -25
  159. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +12 -6
  160. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +84 -112
  161. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +1589 -878
  162. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +130 -79
  163. data/webpack/components/ParameterSelection/index.js +4 -1
  164. data/webpack/components/SyncGitRepo/SyncGitRepo.js +202 -0
  165. data/webpack/components/SyncGitRepo/SyncGitRepo.scss +1 -0
  166. data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +123 -0
  167. data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +8 -0
  168. data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +80 -0
  169. data/webpack/components/SyncGitRepo/SyncGitRepoSelectors.js +6 -0
  170. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +7 -0
  171. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +44 -0
  172. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +27 -0
  173. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoReducer.test.js +95 -0
  174. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +32 -0
  175. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +31 -0
  176. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoReducer.test.js.snap +137 -0
  177. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +13 -0
  178. data/webpack/components/SyncGitRepo/components/FormTextInput.js +42 -0
  179. data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +47 -0
  180. data/webpack/components/SyncGitRepo/index.js +28 -0
  181. data/webpack/components/common/DeleteTableEntry.js +16 -2
  182. data/webpack/components/common/ExtTextInput.js +43 -0
  183. data/webpack/components/common/__tests__/EditTableEntry.test.js +53 -0
  184. data/webpack/components/common/__tests__/LockTableEntry.test.js +35 -0
  185. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +40 -2
  186. data/webpack/components/common/__tests__/__snapshots__/EditTableEntry.test.js.snap +81 -0
  187. data/webpack/components/common/__tests__/__snapshots__/LockTableEntry.test.js.snap +60 -0
  188. data/webpack/helper.js +35 -1
  189. data/webpack/helper.test.js +56 -0
  190. data/webpack/index.js +7 -0
  191. data/webpack/js-yaml.js +3874 -0
  192. data/webpack/reducer.js +16 -1
  193. data/webpack/test_setup.js +0 -2
  194. metadata +136 -11
  195. data/webpack/components/common/EasyHeaderFormatter.js +0 -18
  196. data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +0 -35
  197. data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +0 -41
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_plugin_helper'
4
+
5
+ module ForemanAcd
6
+ # ForemanHost Model tests
7
+ class ForemanHostTest < ActiveSupport::TestCase
8
+ should validate_presence_of(:hostname)
9
+ should belong_to(:app_instance)
10
+ should belong_to(:host)
11
+ end
12
+ end
@@ -0,0 +1,2 @@
1
+ const API = () => jest.fn();
2
+ export default API;
@@ -0,0 +1,3 @@
1
+ export const translate = s => s;
2
+ export const ngettext = s => s;
3
+ export const documentLocale = () => 'en';
@@ -0,0 +1,2 @@
1
+ export const propsToSnakeCase = s => s;
2
+ export const propsToCamelCase = s => s;
@@ -0,0 +1,2 @@
1
+ export const setModalOpen = () => jest.fn();
2
+ export const setModalClosed = () => jest.fn();
@@ -0,0 +1,7 @@
1
+ const ForemanModal = () => {};
2
+ const Header = s => s;
3
+ const Footer = s => s;
4
+
5
+ ForemanModal.Header = Header;
6
+ ForemanModal.Footer = Footer;
7
+ export default ForemanModal;
@@ -0,0 +1,2 @@
1
+ const CommonForm = () => jest.fn();
2
+ export default CommonForm;
@@ -0,0 +1,2 @@
1
+ const TextInput = () => jest.fn();
2
+ export default TextInput;
@@ -0,0 +1 @@
1
+ export const PowerStatus = () => jest.fn();
@@ -0,0 +1,14 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`helper formats a nice, easy header 1`] = `
4
+ <TableHeading
5
+ align=""
6
+ aria-label="TheLabel"
7
+ className=""
8
+ p1="1"
9
+ sort={false}
10
+ sortDirection=""
11
+ >
12
+ MyValue
13
+ </TableHeading>
14
+ `;
@@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
4
4
  import {
5
5
  Icon,
6
6
  Button,
7
+ MessageDialog,
7
8
  } from 'patternfly-react';
8
9
  import * as resolve from 'table-resolver';
9
10
  import ForemanModal from 'foremanReact/components/ForemanModal';
@@ -12,9 +13,9 @@ import ParameterSelection from '../ParameterSelection';
12
13
  import AddTableEntry from '../common/AddTableEntry';
13
14
  import DeleteTableEntry from '../common/DeleteTableEntry';
14
15
  import RailsData from '../common/RailsData';
15
- import EasyHeaderFormatter from '../common/EasyHeaderFormatter';
16
16
  import AnsiblePlaybookSelector from './components/AnsiblePlaybookSelector';
17
17
  import { translate as __ } from 'foremanReact/common/I18n';
18
+ import { EasyHeaderFormatter } from '../../helper';
18
19
 
19
20
  import {
20
21
  Table,
@@ -56,7 +57,7 @@ class ApplicationDefinition extends React.Component {
56
57
 
57
58
  componentDidMount() {
58
59
  const {
59
- data: { mode, ansiblePlaybook, ansibleDataUrl, services, ansibleVarsAll, hostgroups },
60
+ data: { mode, ansiblePlaybook, ansibleDataUrl, services, ansibleVarsAll, hostgroups, supportedPlugins },
60
61
  initApplicationDefinition,
61
62
  addApplicationDefinitionService,
62
63
  deleteApplicationDefinitionService,
@@ -75,21 +76,21 @@ class ApplicationDefinition extends React.Component {
75
76
  bsStyle="default"
76
77
  onClick={() => activateEditApplicationDefinitionService(additionalData)}
77
78
  >
78
- <Icon type="pf" name="edit" title={__("edit entry")} />
79
+ <Icon type="pf" name="edit" title={__("Edit entry")} />
79
80
  </Button>
80
81
  &nbsp;
81
82
  <Button
82
83
  bsStyle="default"
83
84
  onClick={() => openForemanParameterSelectionModal(additionalData)}
84
85
  >
85
- <Icon type="pf" name="settings" title={__("change parameters")} />
86
+ <Icon type="pf" name="settings" title={__("Change parameters")} />
86
87
  </Button>
87
88
  &nbsp;
88
89
  <Button
89
90
  bsStyle="default"
90
91
  onClick={() => openAnsibleParameterSelectionModal(additionalData)}
91
92
  >
92
- <span title={__("change ansible variables")}>A</span>
93
+ <span title={__("Change ansible variables")}>A</span>
93
94
  </Button>
94
95
  &nbsp;
95
96
  <DeleteTableEntry
@@ -193,6 +194,7 @@ class ApplicationDefinition extends React.Component {
193
194
  ansiblePlaybook,
194
195
  services,
195
196
  ansibleVarsAll,
197
+ supportedPlugins,
196
198
  this.headerFormatter,
197
199
  this.inlineEditFormatter,
198
200
  this.inlineEditButtonsFormatter,
@@ -202,9 +204,11 @@ class ApplicationDefinition extends React.Component {
202
204
  render() {
203
205
  const {
204
206
  data: { organization, location, mode, ansiblePlaybooks, foremanDataUrl, ansibleDataUrl },
207
+ showAlertModal, alertModalText, alertModalTitle, closeAlertModal,
205
208
  ansiblePlaybook,
206
209
  services,
207
210
  columns,
211
+ hiddenForemanParameterTypes,
208
212
  addApplicationDefinitionService,
209
213
  confirmEditApplicationDefinitionService,
210
214
  cancelEditApplicationDefinitionService,
@@ -216,12 +220,22 @@ class ApplicationDefinition extends React.Component {
216
220
  loadAnsibleData,
217
221
  } = this.props;
218
222
 
219
-
220
223
  return (
221
224
  <span>
225
+ <MessageDialog
226
+ show={showAlertModal}
227
+ onHide={closeAlertModal}
228
+ primaryAction={closeAlertModal}
229
+ primaryActionButtonContent={__('OK')}
230
+ primaryActionButtonBsStyle={"danger"}
231
+ icon={<Icon type="pf" name="error-circle-o" />}
232
+ title={alertModalTitle}
233
+ primaryContent={alertModalText}
234
+ />
222
235
  <div>
223
236
  <AnsiblePlaybookSelector
224
237
  label="Ansible Playbook"
238
+ hidden={ false }
225
239
  editable={ mode == 'newDefinition' }
226
240
  viewText={ ansiblePlaybook.name }
227
241
  options={ ansiblePlaybooks }
@@ -230,9 +244,9 @@ class ApplicationDefinition extends React.Component {
230
244
  additionalData={{url: ansibleDataUrl }}
231
245
  />
232
246
  {ansiblePlaybook.id == '' ? (
233
- <p style={{ paddingTop: 25 }}>
247
+ <div style={{ paddingTop: 25 }}>
234
248
  <pre>{ "Ansible Playbook can't be blank" }</pre>
235
- </p>
249
+ </div>
236
250
  ) : (<div></div>)}
237
251
 
238
252
  </div>
@@ -279,7 +293,7 @@ class ApplicationDefinition extends React.Component {
279
293
  isAllGroup: true
280
294
  })}
281
295
  >
282
- <span title={__("change ansible variables for 'all'")}>A</span>
296
+ <span title={__("Change ansible variables for 'all'")}>A</span>
283
297
  </Button>
284
298
  </span>
285
299
  </div>
@@ -296,6 +310,7 @@ class ApplicationDefinition extends React.Component {
296
310
  <ParameterSelection
297
311
  editModeCallback={ (hide) => changeParameterSelectionMode({ mode: hide })}
298
312
  paramType={ PARAMETER_SELECTION_PARAM_TYPE_FOREMAN }
313
+ hiddenParameterTypes={ hiddenForemanParameterTypes }
299
314
  location={ location }
300
315
  organization={ organization }
301
316
  paramDataUrl= { foremanDataUrl }
@@ -339,13 +354,13 @@ class ApplicationDefinition extends React.Component {
339
354
  </ForemanModal>
340
355
  </div>
341
356
  <RailsData
342
- key='applications_definition'
357
+ key='application_definition_services_data'
343
358
  view='app_definition'
344
359
  parameter='services'
345
360
  value={JSON.stringify(this.props.services)}
346
361
  />
347
362
  <RailsData
348
- key='applications_definition'
363
+ key='application_definition_ansible_data'
349
364
  view='app_definition'
350
365
  parameter='ansible_vars_all'
351
366
  value={JSON.stringify(this.props.ansibleVarsAll)}
@@ -356,23 +371,32 @@ class ApplicationDefinition extends React.Component {
356
371
 
357
372
  ApplicationDefinition.defaultProps = {
358
373
  error: {},
374
+ showAlertModal: false,
375
+ alertModalText: '',
376
+ alertModalTitle: '',
359
377
  editMode: false,
360
378
  ansiblePlaybook: { "id": '', "name": '' },
361
379
  services: [],
362
380
  ansibleVarsAll: [],
363
381
  parametersData: {},
364
382
  columns: [],
383
+ hiddenForemanParameterTypes: [],
365
384
  editParamsOfRowId: null,
366
385
  paramEditMode: false,
367
386
  }
368
387
 
369
388
  ApplicationDefinition.propTypes = {
370
389
  initApplicationDefinition: PropTypes.func,
390
+ showAlertModal: PropTypes.bool,
391
+ alertModalText: PropTypes.string,
392
+ alertModalTitle: PropTypes.string,
371
393
  editMode: PropTypes.bool.isRequired,
372
394
  ansiblePlaybook: PropTypes.object,
373
395
  services: PropTypes.array,
374
396
  ansibleVarsAll: PropTypes.array,
375
397
  columns: PropTypes.array,
398
+ hiddenForemanParameterTypes: PropTypes.array,
399
+ closeAlertModal: PropTypes.func,
376
400
  addApplicationDefinitionService: PropTypes.func,
377
401
  deleteApplicationDefinitionService: PropTypes.func,
378
402
  activateEditApplicationDefinitionService: PropTypes.func,
@@ -17,6 +17,7 @@ import {
17
17
 
18
18
  import {
19
19
  APPLICATION_DEFINITION_INIT,
20
+ APPLICATION_DEFINITION_CLOSE_ALERT_MODAL,
20
21
  APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_REQUEST,
21
22
  APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_SUCCESS,
22
23
  APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_FAILURE,
@@ -33,6 +34,10 @@ import {
33
34
  APPLICATION_DEFINITION_CHANGE_PARAMETER_SELECTION_MODE,
34
35
  } from './ApplicationDefinitionConstants';
35
36
 
37
+ import {
38
+ supportedPluginsToHiddenParameterTypes,
39
+ } from '../../helper';
40
+
36
41
  import {
37
42
  transformAnsiblePlaybook,
38
43
  } from './ApplicationDefinitionHelper';
@@ -41,6 +46,7 @@ export const initApplicationDefinition = (
41
46
  ansiblePlaybook,
42
47
  services,
43
48
  ansibleVarsAll,
49
+ supportedPlugins,
44
50
  headerFormatter,
45
51
  inlineEditFormatter,
46
52
  inlineEditButtonsFormatter,
@@ -167,6 +173,7 @@ export const initApplicationDefinition = (
167
173
  }
168
174
  initialState.services = services;
169
175
  initialState.ansibleVarsAll = ansibleVarsAll;
176
+ initialState.hiddenForemanParameterTypes = supportedPluginsToHiddenParameterTypes(supportedPlugins);
170
177
 
171
178
  dispatch({
172
179
  type: APPLICATION_DEFINITION_INIT,
@@ -182,6 +189,11 @@ const errorHandler = (msg, err) => {
182
189
  return { type: msg, payload: { error } };
183
190
  };
184
191
 
192
+ export const closeAlertModal = () => ({
193
+ type: APPLICATION_DEFINITION_CLOSE_ALERT_MODAL,
194
+ payload: {}
195
+ });
196
+
185
197
  export const loadAnsibleData = (
186
198
  ansiblePlaybookId,
187
199
  additionalData
@@ -1,4 +1,5 @@
1
1
  export const APPLICATION_DEFINITION_INIT = 'INIT_APPLICATION_DEFINITION_INIT';
2
+ export const APPLICATION_DEFINITION_CLOSE_ALERT_MODAL = 'APPLICATION_DEFINITION_CLOSE_ALERT_MODAL';
2
3
  export const APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_REQUEST = 'APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_REQUEST';
3
4
  export const APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_SUCCESS = 'APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_SUCCESS';
4
5
  export const APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_FAILURE = 'APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_FAILURE';
@@ -1,4 +1,5 @@
1
1
  import Immutable from 'seamless-immutable';
2
+ import { translate as __ } from 'foremanReact/common/I18n';
2
3
 
3
4
  import {
4
5
  cloneDeep,
@@ -8,6 +9,7 @@ import {
8
9
 
9
10
  import {
10
11
  APPLICATION_DEFINITION_INIT,
12
+ APPLICATION_DEFINITION_CLOSE_ALERT_MODAL,
11
13
  APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_REQUEST,
12
14
  APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_SUCCESS,
13
15
  APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_FAILURE,
@@ -45,8 +47,15 @@ const applicationDefinitionConf = (state = initialState, action) => {
45
47
  case APPLICATION_DEFINITION_INIT: {
46
48
  return state.merge(payload);
47
49
  }
48
-
50
+ case APPLICATION_DEFINITION_CLOSE_ALERT_MODAL: {
51
+ return state.merge({
52
+ showAlertModal: false,
53
+ alertModalTitle: '',
54
+ alertModalText: '',
55
+ });
56
+ }
49
57
  case APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_FAILURE: {
58
+ console.log("Error while loading ansible data: "+ payload.error);
50
59
  return state.merge({ error: payload.error, loading: false });
51
60
  }
52
61
  case APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_REQUEST: {
@@ -113,23 +122,35 @@ const applicationDefinitionConf = (state = initialState, action) => {
113
122
  const thisService = services[index];
114
123
 
115
124
  if (thisService.name == '') {
116
- window.alert("Every service needs to have a valid name.");
117
- return state;
125
+ return state.merge({
126
+ showAlertModal: true,
127
+ alertModalTitle: __("Error"),
128
+ alertModalText: __("Every service needs to have a valid name."),
129
+ });
118
130
  }
119
131
 
120
132
  if (thisService.hostgroup == '') {
121
- window.alert("Every service needs to be assigned to a hostgroup.");
122
- return state;
133
+ return state.merge({
134
+ showAlertModal: true,
135
+ alertModalTitle: __("Error"),
136
+ alertModalText: __("Every service needs to be assigned to a hostgroup."),
137
+ });
123
138
  }
124
139
 
125
140
  if (thisService.ansibleGroup == '') {
126
- window.alert("Every service needs to be assigned to a ansible group.");
127
- return state;
141
+ return state.merge({
142
+ showAlertModal: true,
143
+ alertModalTitle: __("Error"),
144
+ alertModalText: __("Every service needs to be assigned to an ansible group."),
145
+ });
128
146
  }
129
147
 
130
148
  if (state.services.filter(v => v.name === thisService.name && v.id != thisService.id).length > 0) {
131
- window.alert("Service name already used in this Application Definition. Please make sure that every service name is unique.");
132
- return state;
149
+ return state.merge({
150
+ showAlertModal: true,
151
+ alertModalTitle: __("Error"),
152
+ alertModalText: __("Service name already used in this Application Definition. Please make sure that every service name is unique."),
153
+ });
133
154
  }
134
155
 
135
156
  delete services[index].backup;
@@ -1,9 +1,13 @@
1
1
  const applicationDefinitionConf = state => state.foremanAcd.applicationDefinitionConf;
2
2
 
3
+ export const selectShowAlertModal = state => applicationDefinitionConf(state).showAlertModal;
4
+ export const selectAlertModalText = state => applicationDefinitionConf(state).alertModalText;
5
+ export const selectAlertModalTitle = state => applicationDefinitionConf(state).alertModalTitle;
3
6
  export const selectEditMode = state => applicationDefinitionConf(state).editMode;
4
7
  export const selectAnsiblePlaybook = state => applicationDefinitionConf(state).ansiblePlaybook;
5
8
  export const selectServices = state => applicationDefinitionConf(state).services;
6
9
  export const selectColumns = state => applicationDefinitionConf(state).columns;
10
+ export const selectHiddenForemanParameterTypes = state => applicationDefinitionConf(state).hiddenForemanParameterTypes;
7
11
  export const selectParametersData = state => applicationDefinitionConf(state).parametersData;
8
12
  export const selectAnsibleVarsAll = state => applicationDefinitionConf(state).ansibleVarsAll;
9
13
  export const selectParamEditMode = state => applicationDefinitionConf(state).paramEditMode;
@@ -0,0 +1,288 @@
1
+ export const applicationDefinitionConfData_1 = {
2
+ name: false,
3
+ error: {
4
+ errorMsg: '',
5
+ status: '',
6
+ statusText: ''
7
+ },
8
+ columns: [
9
+ {
10
+ property: 'name',
11
+ header: {
12
+ label: 'Name',
13
+ formatters: [
14
+ null
15
+ ],
16
+ props: {
17
+ index: 0,
18
+ style: {
19
+ width: '15%'
20
+ }
21
+ }
22
+ },
23
+ cell: {
24
+ formatters: [
25
+ null
26
+ ]
27
+ }
28
+ },
29
+ {
30
+ property: 'description',
31
+ header: {
32
+ label: 'Description',
33
+ formatters: [
34
+ null
35
+ ],
36
+ props: {
37
+ index: 1,
38
+ style: {
39
+ width: '10%'
40
+ }
41
+ }
42
+ },
43
+ cell: {
44
+ formatters: [
45
+ null
46
+ ]
47
+ }
48
+ },
49
+ {
50
+ property: 'hostgroup',
51
+ header: {
52
+ label: 'Hostgroup',
53
+ formatters: [
54
+ null
55
+ ],
56
+ props: {
57
+ index: 2,
58
+ style: {
59
+ width: '20%'
60
+ }
61
+ }
62
+ },
63
+ cell: {
64
+ formatters: [
65
+ null
66
+ ]
67
+ }
68
+ },
69
+ {
70
+ property: 'ansibleGroup',
71
+ header: {
72
+ label: 'Ansible Group',
73
+ formatters: [
74
+ null
75
+ ],
76
+ props: {
77
+ index: 3,
78
+ style: {
79
+ width: '20%'
80
+ }
81
+ }
82
+ },
83
+ cell: {
84
+ formatters: [
85
+ null
86
+ ]
87
+ }
88
+ },
89
+ {
90
+ property: 'minCount',
91
+ header: {
92
+ label: 'min count',
93
+ formatters: [
94
+ null
95
+ ],
96
+ props: {
97
+ index: 4,
98
+ style: {
99
+ width: '10%'
100
+ }
101
+ }
102
+ },
103
+ cell: {
104
+ formatters: [
105
+ null
106
+ ]
107
+ }
108
+ },
109
+ {
110
+ property: 'maxCount',
111
+ header: {
112
+ label: 'max count',
113
+ formatters: [
114
+ null
115
+ ],
116
+ props: {
117
+ index: 5,
118
+ style: {
119
+ width: '10%'
120
+ }
121
+ }
122
+ },
123
+ cell: {
124
+ formatters: [
125
+ null
126
+ ]
127
+ }
128
+ },
129
+ {
130
+ property: 'actions',
131
+ header: {
132
+ label: 'Actions',
133
+ formatters: [
134
+ null
135
+ ],
136
+ props: {
137
+ index: 6,
138
+ style: {
139
+ width: '15%'
140
+ }
141
+ }
142
+ },
143
+ cell: {
144
+ formatters: [
145
+ null
146
+ ]
147
+ }
148
+ }
149
+ ],
150
+ ansiblePlaybook: {
151
+ id: 2,
152
+ name: 'LAMP',
153
+ groups: {
154
+ webservers: [
155
+ {
156
+ id: 0,
157
+ name: 'dummy_var',
158
+ value: '0'
159
+ }
160
+ ],
161
+ dbservers: [
162
+ {
163
+ id: 0,
164
+ name: 'mysqlservice',
165
+ value: 'mysqld'
166
+ },
167
+ {
168
+ id: 1,
169
+ name: 'mysql_port',
170
+ value: '3306'
171
+ },
172
+ {
173
+ id: 2,
174
+ name: 'dbuser',
175
+ value: 'webapp'
176
+ },
177
+ {
178
+ id: 3,
179
+ name: 'dbname',
180
+ value: 'ANSAP01'
181
+ },
182
+ {
183
+ id: 4,
184
+ name: 'upassword',
185
+ value: 'Bond@007'
186
+ },
187
+ {
188
+ id: 5,
189
+ name: 'masterpassword',
190
+ value: 'MySQL@007'
191
+ }
192
+ ],
193
+ all: [
194
+ {
195
+ id: 0,
196
+ name: 'repository',
197
+ value: 'https://github.com/bennojoy/mywebapp.git'
198
+ }
199
+ ]
200
+ }
201
+ },
202
+ services: [
203
+ {
204
+ id: 1,
205
+ name: 'web',
206
+ description: '',
207
+ hostgroup: '1',
208
+ ansibleGroup: 'webservers',
209
+ minCount: '2',
210
+ maxCount: '',
211
+ foremanParameters: [
212
+ {
213
+ id: 1,
214
+ locked: false,
215
+ name: 'CP',
216
+ description: '',
217
+ type: 'computeprofile',
218
+ value: '1'
219
+ },
220
+ {
221
+ id: 2,
222
+ locked: true,
223
+ name: 'LE',
224
+ description: '',
225
+ type: 'lifecycleenv',
226
+ value: '1'
227
+ }
228
+ ],
229
+ ansibleParameters: [
230
+ {
231
+ id: 0,
232
+ name: 'dummy_var',
233
+ value: '0'
234
+ }
235
+ ]
236
+ },
237
+ {
238
+ id: 2,
239
+ name: 'db',
240
+ description: '',
241
+ hostgroup: '1',
242
+ ansibleGroup: 'dbservers',
243
+ minCount: '1',
244
+ maxCount: '',
245
+ foremanParameters: [],
246
+ ansibleParameters: [
247
+ {
248
+ id: 0,
249
+ name: 'mysqlservice',
250
+ value: 'mysqld'
251
+ },
252
+ {
253
+ id: 1,
254
+ name: 'mysql_port',
255
+ value: '3306',
256
+ locked: true
257
+ },
258
+ {
259
+ id: 2,
260
+ name: 'dbuser',
261
+ value: 'webapp'
262
+ },
263
+ {
264
+ id: 3,
265
+ name: 'dbname',
266
+ value: 'ANSAP01'
267
+ },
268
+ {
269
+ id: 4,
270
+ name: 'upassword',
271
+ value: 'Bond@007'
272
+ },
273
+ {
274
+ id: 5,
275
+ name: 'masterpassword',
276
+ value: 'MySQL@007'
277
+ }
278
+ ]
279
+ }
280
+ ],
281
+ ansibleVarsAll: [
282
+ {
283
+ id: 0,
284
+ name: 'repository',
285
+ value: 'https://github.com/bennojoy/mywebapp.git'
286
+ }
287
+ ]
288
+ }