foreman_acd 0.4.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +84 -84
  3. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +103 -11
  4. data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +21 -3
  5. data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -0
  6. data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +9 -1
  7. data/app/controllers/foreman_acd/app_definitions_controller.rb +117 -15
  8. data/app/controllers/foreman_acd/app_instances_controller.rb +104 -30
  9. data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +1 -1
  10. data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
  11. data/app/controllers/foreman_acd/concerns/app_instance_mixins.rb +36 -0
  12. data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
  13. data/app/controllers/foreman_acd/remote_execution_controller.rb +36 -23
  14. data/app/controllers/ui_acd_controller.rb +46 -0
  15. data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +47 -0
  16. data/app/lib/actions/foreman_acd/run_configurator.rb +45 -0
  17. data/app/models/concerns/foreman_acd/host_managed_extensions.rb +39 -0
  18. data/app/models/foreman_acd/acd_provider.rb +36 -0
  19. data/app/models/foreman_acd/ansible_playbook.rb +32 -14
  20. data/app/models/foreman_acd/app_definition.rb +24 -1
  21. data/app/models/foreman_acd/app_instance.rb +85 -5
  22. data/app/models/foreman_acd/foreman_host.rb +31 -0
  23. data/app/models/foreman_acd/taxonomy_extensions.rb +17 -0
  24. data/app/services/foreman_acd/acd_proxy_proxy_selector.rb +17 -0
  25. data/app/services/foreman_acd/app_configurator.rb +64 -36
  26. data/app/services/foreman_acd/app_deployer.rb +83 -48
  27. data/app/services/foreman_acd/inventory_creator.rb +36 -25
  28. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +50 -7
  29. data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +9 -1
  30. data/app/views/foreman_acd/ansible_playbooks/index.html.erb +3 -3
  31. data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +2 -0
  32. data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +2 -0
  33. data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +6 -0
  34. data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +2 -0
  35. data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +2 -0
  36. data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +6 -0
  37. data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +3 -1
  38. data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +2 -0
  39. data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +2 -0
  40. data/app/views/foreman_acd/app_definitions/_form.html.erb +9 -1
  41. data/app/views/foreman_acd/app_definitions/edit.html.erb +10 -5
  42. data/app/views/foreman_acd/app_definitions/import.html.erb +20 -1
  43. data/app/views/foreman_acd/app_definitions/index.html.erb +5 -8
  44. data/app/views/foreman_acd/app_instances/_form.html.erb +4 -4
  45. data/app/views/foreman_acd/app_instances/edit.html.erb +10 -0
  46. data/app/views/foreman_acd/app_instances/index.html.erb +93 -14
  47. data/app/views/foreman_acd/app_instances/report.html.erb +12 -4
  48. data/app/views/templates/job/run_acd_ansible_playbook.erb +28 -15
  49. data/app/views/ui_acd/app_definition.json.rabl +1 -1
  50. data/app/views/ui_acd/host_report.json.rabl +4 -0
  51. data/app/views/ui_acd/report_data.json.rabl +10 -0
  52. data/app/views/ui_acd/validate_hostname.json.rabl +6 -0
  53. data/config/routes.rb +12 -3
  54. data/db/migrate/20200917120220_add_ansible_playbook_id.rb +1 -1
  55. data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +3 -0
  56. data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +3 -0
  57. data/db/migrate/20210112111548_add_organization_to_app_instance.rb +22 -0
  58. data/db/migrate/20210112113853_add_location_to_app_instance.rb +8 -0
  59. data/db/migrate/20210202141658_create_foreman_hosts.rb +24 -0
  60. data/db/migrate/20210204111306_remove_hosts_from_app_instances.rb +8 -0
  61. data/db/migrate/20210209091014_rename_acd_tables.rb +16 -0
  62. data/db/migrate/20210216083522_add_last_progress_report.rb +8 -0
  63. data/db/migrate/20210216091529_add_last_deploy_task.rb +8 -0
  64. data/db/migrate/20210316151145_add_git_commit_to_ansible_playbooks.rb +8 -0
  65. data/db/migrate/20210503122809_add_git_url_to_ansible_playbooks.rb +8 -0
  66. data/db/migrate/20210818125913_add_is_existing_host_to_foreman_host.rb +8 -0
  67. data/db/migrate/20210902110645_add_initial_configure_task.rb +8 -0
  68. data/db/seeds.d/62_acd_proxy_feature.rb +4 -0
  69. data/db/seeds.d/75-job_templates.rb +6 -1
  70. data/lib/foreman_acd/engine.rb +40 -3
  71. data/lib/foreman_acd/plugin.rb +60 -45
  72. data/lib/foreman_acd/version.rb +1 -1
  73. data/lib/foreman_acd.rb +30 -0
  74. data/lib/tasks/foreman_acd_tasks.rake +0 -12
  75. data/locale/en/foreman_acd.edit.po +326 -0
  76. data/locale/en/foreman_acd.po +232 -2
  77. data/{app/controllers/foreman_acd/api/v2/app_playbooks_controller.rb → locale/en/foreman_acd.po.time_stamp} +0 -0
  78. data/locale/foreman_acd.pot +343 -8
  79. data/package.json +8 -8
  80. data/test/controllers/ansible_playbooks_controller_test.rb +27 -0
  81. data/test/controllers/app_instances_controller_test.rb +8 -3
  82. data/test/controllers/ui_acd_controller_test.rb +22 -6
  83. data/test/factories/foreman_acd_factories.rb +18 -4
  84. data/test/models/acd_provider_test.rb +37 -0
  85. data/test/models/ansible_playbook_test.rb +11 -0
  86. data/test/models/app_definition_test.rb +1 -1
  87. data/test/models/app_instance_test.rb +2 -0
  88. data/test/models/concerns/host_extensions_test.rb +26 -0
  89. data/test/models/foreman_host_test.rb +12 -0
  90. data/webpack/__mocks__/foremanReact/API.js +2 -0
  91. data/webpack/__mocks__/foremanReact/common/I18n.js +3 -0
  92. data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
  93. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +2 -0
  94. data/webpack/__mocks__/foremanReact/components/ForemanModal.js +7 -0
  95. data/webpack/__mocks__/foremanReact/components/common/forms/CommonForm.js +2 -0
  96. data/webpack/__mocks__/foremanReact/components/common/forms/TextInput.js +2 -0
  97. data/webpack/__mocks__/foremanReact/components/hosts/powerStatus.js +1 -0
  98. data/webpack/__snapshots__/helper.test.js.snap +14 -0
  99. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +55 -21
  100. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +14 -0
  101. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +2 -0
  102. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +48 -1
  103. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +4 -0
  104. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionConfData_1.fixtures.js +288 -0
  105. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +79 -0
  106. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +26 -0
  107. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +119 -0
  108. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +41 -0
  109. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinition.test.js.snap +225 -0
  110. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +3033 -0
  111. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +299 -0
  112. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +2 -1
  113. data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +41 -0
  114. data/webpack/components/ApplicationDefinition/components/__tests__/__snapshots__/AnsiblePlaybookSelector.test.js.snap +121 -0
  115. data/webpack/components/ApplicationDefinition/index.js +8 -0
  116. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +214 -0
  117. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.scss +1 -0
  118. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +161 -0
  119. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +6 -0
  120. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +79 -0
  121. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +8 -0
  122. data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportConfData_1.fixtures.js +129 -0
  123. data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +29 -0
  124. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +20 -0
  125. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +43 -0
  126. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +29 -0
  127. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +62 -0
  128. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportReducer.test.js.snap +362 -0
  129. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +130 -0
  130. data/webpack/components/ApplicationDefinitionImport/index.js +32 -0
  131. data/webpack/components/ApplicationInstance/ApplicationInstance.js +153 -45
  132. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +120 -6
  133. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +5 -0
  134. data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +15 -0
  135. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +77 -22
  136. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +4 -0
  137. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceConfData_1.fixtures.js +263 -0
  138. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +80 -0
  139. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +24 -0
  140. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +131 -0
  141. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +44 -0
  142. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +299 -0
  143. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +2990 -0
  144. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +276 -0
  145. data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +1 -0
  146. data/webpack/components/ApplicationInstance/components/Service.js +1 -1
  147. data/webpack/components/ApplicationInstance/components/ServiceCounter.js +1 -1
  148. data/webpack/components/ApplicationInstance/helper.js +0 -0
  149. data/webpack/components/ApplicationInstance/index.js +8 -0
  150. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +128 -60
  151. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +17 -0
  152. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +40 -50
  153. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +5 -4
  154. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +19 -14
  155. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +4 -1
  156. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportData_1.fixtures.js +349 -0
  157. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +20 -0
  158. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +47 -0
  159. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportReducer.test.js +41 -0
  160. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +26 -0
  161. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReport.test.js.snap +7 -0
  162. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +718 -0
  163. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +347 -0
  164. data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +1 -1
  165. data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +24 -0
  166. data/webpack/components/ApplicationInstanceReport/components/__tests__/__snapshots__/ReportViewer.test.js.snap +24 -0
  167. data/webpack/components/ApplicationInstanceReport/index.js +8 -3
  168. data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +104 -0
  169. data/webpack/components/ExistingHostSelection/ExistingHostSelection.scss +15 -0
  170. data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +71 -0
  171. data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +4 -0
  172. data/webpack/components/ExistingHostSelection/ExistingHostSelectionHelper.js +0 -0
  173. data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +90 -0
  174. data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -0
  175. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +191 -0
  176. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +203 -0
  177. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +19 -0
  178. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionReducer.test.js +59 -0
  179. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +36 -0
  180. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelection.test.js.snap +35 -0
  181. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionReducer.test.js.snap +614 -0
  182. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +27 -0
  183. data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +48 -0
  184. data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +35 -0
  185. data/webpack/components/ExistingHostSelection/components/__tests__/__snapshots__/ServiceSelector.test.js.snap +77 -0
  186. data/webpack/components/ExistingHostSelection/index.js +26 -0
  187. data/webpack/components/ParameterSelection/ParameterSelection.js +138 -15
  188. data/webpack/components/ParameterSelection/ParameterSelection.scss +7 -0
  189. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +52 -9
  190. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +3 -0
  191. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +62 -25
  192. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +1 -0
  193. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +116 -84
  194. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +10 -4
  195. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +36 -46
  196. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +33 -25
  197. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
  198. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +84 -112
  199. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +1488 -872
  200. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +117 -79
  201. data/webpack/components/ParameterSelection/index.js +2 -1
  202. data/webpack/components/SyncGitRepo/SyncGitRepo.js +202 -0
  203. data/webpack/components/SyncGitRepo/SyncGitRepo.scss +1 -0
  204. data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +123 -0
  205. data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +8 -0
  206. data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +80 -0
  207. data/webpack/components/SyncGitRepo/SyncGitRepoSelectors.js +6 -0
  208. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +7 -0
  209. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +44 -0
  210. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +27 -0
  211. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoReducer.test.js +95 -0
  212. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +32 -0
  213. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +31 -0
  214. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoReducer.test.js.snap +137 -0
  215. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +13 -0
  216. data/webpack/components/SyncGitRepo/components/FormTextInput.js +42 -0
  217. data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +47 -0
  218. data/webpack/components/SyncGitRepo/index.js +28 -0
  219. data/webpack/components/common/DeleteTableEntry.js +18 -4
  220. data/webpack/components/common/EditTableEntry.js +50 -0
  221. data/webpack/components/common/ExtTextInput.js +43 -0
  222. data/webpack/components/common/LockTableEntry.js +60 -0
  223. data/webpack/components/common/__tests__/EditTableEntry.test.js +53 -0
  224. data/webpack/components/common/__tests__/LockTableEntry.test.js +35 -0
  225. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +40 -2
  226. data/webpack/components/common/__tests__/__snapshots__/EditTableEntry.test.js.snap +81 -0
  227. data/webpack/components/common/__tests__/__snapshots__/LockTableEntry.test.js.snap +60 -0
  228. data/webpack/helper.js +20 -1
  229. data/webpack/helper.test.js +37 -0
  230. data/webpack/index.js +7 -0
  231. data/webpack/js-yaml.js +3874 -0
  232. data/webpack/reducer.js +16 -1
  233. metadata +182 -11
  234. data/app/views/foreman_acd/app_instances/deploy.html.erb +0 -19
  235. data/webpack/components/common/EasyHeaderFormatter.js +0 -18
  236. data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +0 -35
  237. data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +0 -41
@@ -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 creates a object from an array 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,8 +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
+ import { translate as __ } from 'foremanReact/common/I18n';
18
+ import { EasyHeaderFormatter } from '../../helper';
17
19
 
18
20
  import {
19
21
  Table,
@@ -49,6 +51,10 @@ class ApplicationDefinition extends React.Component {
49
51
  return ansibleGroupObj;
50
52
  }
51
53
 
54
+ addTableEntryAllowed() {
55
+ return this.props.editMode || this.props.ansiblePlaybook.id == ''
56
+ }
57
+
52
58
  componentDidMount() {
53
59
  const {
54
60
  data: { mode, ansiblePlaybook, ansibleDataUrl, services, ansibleVarsAll, hostgroups },
@@ -70,22 +76,23 @@ class ApplicationDefinition extends React.Component {
70
76
  bsStyle="default"
71
77
  onClick={() => activateEditApplicationDefinitionService(additionalData)}
72
78
  >
73
- <Icon type="pf" name="edit" title="edit entry" />
79
+ <Icon type="pf" name="edit" title={__("Edit entry")} />
74
80
  </Button>
75
81
  &nbsp;
76
82
  <Button
77
83
  bsStyle="default"
78
84
  onClick={() => openForemanParameterSelectionModal(additionalData)}
79
85
  >
80
- <Icon type="pf" name="settings" title="change parameters" />
86
+ <Icon type="pf" name="settings" title={__("Change parameters")} />
81
87
  </Button>
82
88
  &nbsp;
83
89
  <Button
84
90
  bsStyle="default"
85
91
  onClick={() => openAnsibleParameterSelectionModal(additionalData)}
86
92
  >
87
- <span title="change ansible variables">A</span>
93
+ <span title={__("Change ansible variables")}>A</span>
88
94
  </Button>
95
+ &nbsp;
89
96
  <DeleteTableEntry
90
97
  hidden={false}
91
98
  disabled={false}
@@ -97,17 +104,18 @@ class ApplicationDefinition extends React.Component {
97
104
  renderEdit: (value, additionalData) => (
98
105
  <td style={{ padding: '2px' }}>
99
106
  <Button bsStyle="default" disabled>
100
- <Icon type="pf" name="edit" />
107
+ <Icon type="pf" name={__("edit")} />
101
108
  </Button>
102
109
  &nbsp;
103
110
  <Button bsStyle="default" disabled>
104
- <Icon type="pf" name="settings" />
111
+ <Icon type="pf" name={__("settings")} />
105
112
  </Button>
106
113
  &nbsp;
107
114
  <Button
108
115
  bsStyle="default" disabled>
109
116
  <span>A</span>
110
117
  </Button>
118
+ &nbsp;
111
119
  <DeleteTableEntry
112
120
  hidden={false}
113
121
  disabled={true}
@@ -195,6 +203,7 @@ class ApplicationDefinition extends React.Component {
195
203
  render() {
196
204
  const {
197
205
  data: { organization, location, mode, ansiblePlaybooks, foremanDataUrl, ansibleDataUrl },
206
+ showAlertModal, alertModalText, alertModalTitle, closeAlertModal,
198
207
  ansiblePlaybook,
199
208
  services,
200
209
  columns,
@@ -204,15 +213,27 @@ class ApplicationDefinition extends React.Component {
204
213
  closeForemanParameterSelectionModal,
205
214
  openAnsibleParameterSelectionModal,
206
215
  closeAnsibleParameterSelectionModal,
216
+ changeParameterSelectionMode,
207
217
  ParameterSelectionModal,
208
218
  loadAnsibleData,
209
219
  } = this.props;
210
220
 
211
221
  return (
212
222
  <span>
223
+ <MessageDialog
224
+ show={showAlertModal}
225
+ onHide={closeAlertModal}
226
+ primaryAction={closeAlertModal}
227
+ primaryActionButtonContent={__('OK')}
228
+ primaryActionButtonBsStyle={"danger"}
229
+ icon={<Icon type="pf" name="error-circle-o" />}
230
+ title={alertModalTitle}
231
+ primaryContent={alertModalText}
232
+ />
213
233
  <div>
214
234
  <AnsiblePlaybookSelector
215
235
  label="Ansible Playbook"
236
+ hidden={ false }
216
237
  editable={ mode == 'newDefinition' }
217
238
  viewText={ ansiblePlaybook.name }
218
239
  options={ ansiblePlaybooks }
@@ -220,13 +241,14 @@ class ApplicationDefinition extends React.Component {
220
241
  selectValue={ ansiblePlaybook.id.toString() }
221
242
  additionalData={{url: ansibleDataUrl }}
222
243
  />
244
+ {ansiblePlaybook.id == '' ? (
245
+ <div style={{ paddingTop: 25 }}>
246
+ <pre>{ "Ansible Playbook can't be blank" }</pre>
247
+ </div>
248
+ ) : (<div></div>)}
249
+
223
250
  </div>
224
251
  <div className="form-group">
225
- <AddTableEntry
226
- hidden={ false }
227
- disabled={ this.props.editMode }
228
- onAddTableEntry={ addApplicationDefinitionService }
229
- />
230
252
  <Table.PfProvider
231
253
  striped
232
254
  bordered
@@ -256,7 +278,7 @@ class ApplicationDefinition extends React.Component {
256
278
  </Table.PfProvider>
257
279
  <AddTableEntry
258
280
  hidden={ false }
259
- disabled={ this.props.editMode }
281
+ disabled={ this.addTableEntryAllowed() }
260
282
  onAddTableEntry={ addApplicationDefinitionService }
261
283
  />
262
284
  <span style={{ marginLeft: 30 }}>
@@ -269,7 +291,7 @@ class ApplicationDefinition extends React.Component {
269
291
  isAllGroup: true
270
292
  })}
271
293
  >
272
- <span title="change ansible variables for 'all'">A</span>
294
+ <span title={__("Change ansible variables for 'all'")}>A</span>
273
295
  </Button>
274
296
  </span>
275
297
  </div>
@@ -277,13 +299,14 @@ class ApplicationDefinition extends React.Component {
277
299
  <ForemanModal
278
300
  id="AppDefinitionForemanParamSelection"
279
301
  dialogClassName="param_selection_modal"
280
- title="Foreman Parameter definition for Application Definition"
302
+ title={__("Foreman Parameter definition for Application Definition")}
281
303
  >
282
304
  <ForemanModal.Header closeButton={false}>
283
305
  Parameter definition
284
306
  </ForemanModal.Header>
285
307
  {this.props.parametersData ? (
286
308
  <ParameterSelection
309
+ editModeCallback={ (hide) => changeParameterSelectionMode({ mode: hide })}
287
310
  paramType={ PARAMETER_SELECTION_PARAM_TYPE_FOREMAN }
288
311
  location={ location }
289
312
  organization={ organization }
@@ -294,8 +317,8 @@ class ApplicationDefinition extends React.Component {
294
317
  }
295
318
  <ForemanModal.Footer>
296
319
  <div>
297
- <Button bsStyle="primary" onClick={() => closeForemanParameterSelectionModal({ mode: 'save' })}>Save</Button>
298
- <Button bsStyle="default" onClick={() => closeForemanParameterSelectionModal({ mode: 'cancel' })}>Cancel</Button>
320
+ <Button bsStyle="primary" disabled={this.props.paramEditMode} onClick={() => closeForemanParameterSelectionModal({ mode: 'save' })}>{__("Save")}</Button>
321
+ <Button bsStyle="default" disabled={this.props.paramEditMode} onClick={() => closeForemanParameterSelectionModal({ mode: 'cancel' })}>{__("Cancel")}</Button>
299
322
  </div>
300
323
  </ForemanModal.Footer>
301
324
  </ForemanModal>
@@ -304,13 +327,14 @@ class ApplicationDefinition extends React.Component {
304
327
  <ForemanModal
305
328
  id="AppDefinitionAnsibleParamSelection"
306
329
  dialogClassName="param_selection_modal"
307
- title="Ansible variables for Application Definition"
330
+ title={__("Ansible variables for Application Definition")}
308
331
  >
309
332
  <ForemanModal.Header closeButton={false}>
310
333
  Parameter definition
311
334
  </ForemanModal.Header>
312
335
  {this.props.parametersData ? (
313
336
  <ParameterSelection
337
+ editModeCallback={ (hide) => changeParameterSelectionMode({ mode: hide })}
314
338
  paramType={ PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE }
315
339
  location={ location }
316
340
  organization={ organization }
@@ -320,20 +344,20 @@ class ApplicationDefinition extends React.Component {
320
344
  }
321
345
  <ForemanModal.Footer>
322
346
  <div>
323
- <Button bsStyle="primary" onClick={() => closeAnsibleParameterSelectionModal({ mode: 'save' })}>Save</Button>
324
- <Button bsStyle="default" onClick={() => closeAnsibleParameterSelectionModal({ mode: 'cancel' })}>Cancel</Button>
347
+ <Button bsStyle="primary" disabled={this.props.paramEditMode} onClick={() => closeAnsibleParameterSelectionModal({ mode: 'save' })}>{__("Save")}</Button>
348
+ <Button bsStyle="default" disabled={this.props.paramEditMode} onClick={() => closeAnsibleParameterSelectionModal({ mode: 'cancel' })}>{__("Cancel")}</Button>
325
349
  </div>
326
350
  </ForemanModal.Footer>
327
351
  </ForemanModal>
328
352
  </div>
329
353
  <RailsData
330
- key='applications_definition'
354
+ key='application_definition_services_data'
331
355
  view='app_definition'
332
356
  parameter='services'
333
357
  value={JSON.stringify(this.props.services)}
334
358
  />
335
359
  <RailsData
336
- key='applications_definition'
360
+ key='application_definition_ansible_data'
337
361
  view='app_definition'
338
362
  parameter='ansible_vars_all'
339
363
  value={JSON.stringify(this.props.ansibleVarsAll)}
@@ -344,6 +368,9 @@ class ApplicationDefinition extends React.Component {
344
368
 
345
369
  ApplicationDefinition.defaultProps = {
346
370
  error: {},
371
+ showAlertModal: false,
372
+ alertModalText: '',
373
+ alertModalTitle: '',
347
374
  editMode: false,
348
375
  ansiblePlaybook: { "id": '', "name": '' },
349
376
  services: [],
@@ -351,15 +378,20 @@ ApplicationDefinition.defaultProps = {
351
378
  parametersData: {},
352
379
  columns: [],
353
380
  editParamsOfRowId: null,
381
+ paramEditMode: false,
354
382
  }
355
383
 
356
384
  ApplicationDefinition.propTypes = {
357
385
  initApplicationDefinition: PropTypes.func,
386
+ showAlertModal: PropTypes.bool,
387
+ alertModalText: PropTypes.string,
388
+ alertModalTitle: PropTypes.string,
358
389
  editMode: PropTypes.bool.isRequired,
359
390
  ansiblePlaybook: PropTypes.object,
360
391
  services: PropTypes.array,
361
392
  ansibleVarsAll: PropTypes.array,
362
393
  columns: PropTypes.array,
394
+ closeAlertModal: PropTypes.func,
363
395
  addApplicationDefinitionService: PropTypes.func,
364
396
  deleteApplicationDefinitionService: PropTypes.func,
365
397
  activateEditApplicationDefinitionService: PropTypes.func,
@@ -370,7 +402,9 @@ ApplicationDefinition.propTypes = {
370
402
  closeForemanParameterSelectionModal: PropTypes.func,
371
403
  openAnsibleParameterSelectionModal: PropTypes.func,
372
404
  closeAnsibleParameterSelectionModal: PropTypes.func,
405
+ changeParameterSelectionMode: PropTypes.func,
373
406
  parametersData: PropTypes.object,
407
+ paramEditMode: PropTypes.bool,
374
408
  };
375
409
 
376
410
  export default ApplicationDefinition;
@@ -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,
@@ -30,6 +31,7 @@ import {
30
31
  APPLICATION_DEFINITION_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE,
31
32
  APPLICATION_DEFINITION_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN,
32
33
  APPLICATION_DEFINITION_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE,
34
+ APPLICATION_DEFINITION_CHANGE_PARAMETER_SELECTION_MODE,
33
35
  } from './ApplicationDefinitionConstants';
34
36
 
35
37
  import {
@@ -181,6 +183,11 @@ const errorHandler = (msg, err) => {
181
183
  return { type: msg, payload: { error } };
182
184
  };
183
185
 
186
+ export const closeAlertModal = () => ({
187
+ type: APPLICATION_DEFINITION_CLOSE_ALERT_MODAL,
188
+ payload: {}
189
+ });
190
+
184
191
  export const loadAnsibleData = (
185
192
  ansiblePlaybookId,
186
193
  additionalData
@@ -293,3 +300,10 @@ export const closeAnsibleParameterSelectionModal = (additionalData) => dispatch
293
300
  setModalClosed({ id: 'AppDefinitionAnsibleParamSelection' })
294
301
  );
295
302
  }
303
+
304
+ export const changeParameterSelectionMode = (additionalData) => ({
305
+ type: APPLICATION_DEFINITION_CHANGE_PARAMETER_SELECTION_MODE,
306
+ payload: {
307
+ ...additionalData,
308
+ },
309
+ })
@@ -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';
@@ -12,3 +13,4 @@ export const APPLICATION_DEFINITION_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN = 'AP
12
13
  export const APPLICATION_DEFINITION_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE = 'APPLICATION_DEFINITION_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE';
13
14
  export const APPLICATION_DEFINITION_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN = 'APPLICATION_DEFINITION_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN';
14
15
  export const APPLICATION_DEFINITION_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE = 'APPLICATION_DEFINITION_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE';
16
+ export const APPLICATION_DEFINITION_CHANGE_PARAMETER_SELECTION_MODE = 'APPLICATION_DEFINITION_CHANGE_PARAMETER_SELECTION_MODE';
@@ -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,
@@ -21,6 +23,7 @@ import {
21
23
  APPLICATION_DEFINITION_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE,
22
24
  APPLICATION_DEFINITION_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN,
23
25
  APPLICATION_DEFINITION_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE,
26
+ APPLICATION_DEFINITION_CHANGE_PARAMETER_SELECTION_MODE,
24
27
  } from './ApplicationDefinitionConstants';
25
28
 
26
29
  import {
@@ -44,8 +47,15 @@ const applicationDefinitionConf = (state = initialState, action) => {
44
47
  case APPLICATION_DEFINITION_INIT: {
45
48
  return state.merge(payload);
46
49
  }
47
-
50
+ case APPLICATION_DEFINITION_CLOSE_ALERT_MODAL: {
51
+ return state.merge({
52
+ showAlertModal: false,
53
+ alertModalTitle: '',
54
+ alertModalText: '',
55
+ });
56
+ }
48
57
  case APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_FAILURE: {
58
+ console.log("Error while loading ansible data: "+ payload.error);
49
59
  return state.merge({ error: payload.error, loading: false });
50
60
  }
51
61
  case APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_REQUEST: {
@@ -109,6 +119,40 @@ const applicationDefinitionConf = (state = initialState, action) => {
109
119
  const services = cloneDeep(state.services);
110
120
  const index = findIndex(services, { id: payload.rowData.id });
111
121
 
122
+ const thisService = services[index];
123
+
124
+ if (thisService.name == '') {
125
+ return state.merge({
126
+ showAlertModal: true,
127
+ alertModalTitle: __("Error"),
128
+ alertModalText: __("Every service needs to have a valid name."),
129
+ });
130
+ }
131
+
132
+ if (thisService.hostgroup == '') {
133
+ return state.merge({
134
+ showAlertModal: true,
135
+ alertModalTitle: __("Error"),
136
+ alertModalText: __("Every service needs to be assigned to a hostgroup."),
137
+ });
138
+ }
139
+
140
+ if (thisService.ansibleGroup == '') {
141
+ return state.merge({
142
+ showAlertModal: true,
143
+ alertModalTitle: __("Error"),
144
+ alertModalText: __("Every service needs to be assigned to an ansible group."),
145
+ });
146
+ }
147
+
148
+ if (state.services.filter(v => v.name === thisService.name && v.id != thisService.id).length > 0) {
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
+ });
154
+ }
155
+
112
156
  delete services[index].backup;
113
157
  delete services[index].newEntry;
114
158
 
@@ -235,6 +279,9 @@ const applicationDefinitionConf = (state = initialState, action) => {
235
279
  }
236
280
  return state.merge(newState);
237
281
  }
282
+ case APPLICATION_DEFINITION_CHANGE_PARAMETER_SELECTION_MODE: {
283
+ return state.merge({ paramEditMode: payload.mode });
284
+ }
238
285
  default:
239
286
  return state;
240
287
  }
@@ -1,8 +1,12 @@
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;
7
10
  export const selectParametersData = state => applicationDefinitionConf(state).parametersData;
8
11
  export const selectAnsibleVarsAll = state => applicationDefinitionConf(state).ansibleVarsAll;
12
+ export const selectParamEditMode = state => applicationDefinitionConf(state).paramEditMode;