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
@@ -1,27 +1,58 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`ParameterSelectionSelectors should return ParamDefinition from parameterSelectionData_1 fixtures 1`] = `
4
+ Object {
5
+ "dataId": "1",
6
+ "id": 1,
7
+ "name": "web",
8
+ }
9
+ `;
10
+
3
11
  exports[`ParameterSelectionSelectors should return columns from parameterSelectionData_1 fixtures 1`] = `
4
12
  Array [
5
13
  Object {
14
+ "cell": Object {
15
+ "formatters": Array [
16
+ null,
17
+ ],
18
+ },
6
19
  "header": Object {
20
+ "customFormatters": Array [
21
+ null,
22
+ ],
23
+ "formatters": Array [
24
+ null,
25
+ ],
7
26
  "label": "Name",
8
27
  "props": Object {
9
28
  "index": 0,
10
29
  "sort": true,
11
30
  "style": Object {
12
- "width": "20%",
31
+ "width": "25%",
13
32
  },
14
33
  },
34
+ "transforms": Array [
35
+ null,
36
+ ],
15
37
  },
16
38
  "property": "name",
17
39
  },
18
40
  Object {
19
41
  "cell": Object {
42
+ "formatters": Array [
43
+ null,
44
+ ],
20
45
  "props": Object {
21
46
  "index": 1,
22
47
  },
23
48
  },
24
49
  "header": Object {
50
+ "customFormatters": Array [
51
+ null,
52
+ ],
53
+ "formatters": Array [
54
+ null,
55
+ ],
25
56
  "label": "Description",
26
57
  "props": Object {
27
58
  "index": 1,
@@ -30,16 +61,25 @@ Array [
30
61
  "width": "25%",
31
62
  },
32
63
  },
64
+ "transforms": Array [
65
+ null,
66
+ ],
33
67
  },
34
68
  "property": "description",
35
69
  },
36
70
  Object {
37
71
  "cell": Object {
38
- "props": Object {
39
- "index": 2,
40
- },
72
+ "formatters": Array [
73
+ null,
74
+ ],
41
75
  },
42
76
  "header": Object {
77
+ "customFormatters": Array [
78
+ null,
79
+ ],
80
+ "formatters": Array [
81
+ null,
82
+ ],
43
83
  "label": "Type",
44
84
  "props": Object {
45
85
  "index": 2,
@@ -48,37 +88,55 @@ Array [
48
88
  "width": "20%",
49
89
  },
50
90
  },
91
+ "transforms": Array [
92
+ null,
93
+ ],
51
94
  },
52
95
  "property": "type",
53
96
  },
54
97
  Object {
55
98
  "cell": Object {
56
- "props": Object {
57
- "index": 3,
58
- },
99
+ "formatters": Array [
100
+ null,
101
+ ],
59
102
  },
60
103
  "header": Object {
104
+ "customFormatters": Array [
105
+ null,
106
+ ],
107
+ "formatters": Array [
108
+ null,
109
+ ],
61
110
  "label": "Default value",
62
111
  "props": Object {
63
112
  "index": 3,
64
113
  "sort": true,
65
114
  "style": Object {
66
- "width": "25%",
115
+ "width": "20%",
67
116
  },
68
117
  },
118
+ "transforms": Array [
119
+ null,
120
+ ],
69
121
  },
70
122
  "property": "value",
71
123
  },
72
124
  Object {
73
125
  "cell": Object {
74
- "props": Object {
75
- "index": 4,
76
- },
126
+ "formatters": Array [
127
+ null,
128
+ ],
77
129
  },
78
130
  "header": Object {
131
+ "formatters": Array [
132
+ null,
133
+ ],
79
134
  "label": "Actions",
80
135
  "props": Object {
81
136
  "index": 4,
137
+ "style": Object {
138
+ "width": "10%",
139
+ },
82
140
  },
83
141
  },
84
142
  "property": "actions",
@@ -88,45 +146,67 @@ Array [
88
146
 
89
147
  exports[`ParameterSelectionSelectors should return editMode from parameterSelectionData_1 fixtures 1`] = `false`;
90
148
 
91
- exports[`ParameterSelectionSelectors should return foremanData from parameterSelectionData_1 fixtures 1`] = `
149
+ exports[`ParameterSelectionSelectors should return hostgroupId from parameterSelectionData_1 fixtures 1`] = `1`;
150
+
151
+ exports[`ParameterSelectionSelectors should return loading from parameterSelectionData_1 fixtures 1`] = `false`;
152
+
153
+ exports[`ParameterSelectionSelectors should return paramData from parameterSelectionData_1 fixtures 1`] = `
92
154
  Object {
93
- "computeprofiles": Array [],
94
- "domains": Array [],
95
- "environments": Array [
155
+ "computeprofiles": Array [
96
156
  Object {
97
157
  "id": 1,
98
- "name": "production",
158
+ "name": "1-Small",
99
159
  },
100
160
  Object {
101
161
  "id": 2,
102
- "name": "test",
162
+ "name": "2-Medium",
163
+ },
164
+ Object {
165
+ "id": 3,
166
+ "name": "3-Large",
167
+ },
168
+ Object {
169
+ "id": 4,
170
+ "name": "Orchahosts-VM",
171
+ },
172
+ ],
173
+ "dataType": "PARAMETER_SELECTION_PARAM_TYPE_FOREMAN",
174
+ "domains": Array [
175
+ Object {
176
+ "id": 1,
177
+ "name": "deploy3.dev.atix",
178
+ },
179
+ ],
180
+ "environments": Array [
181
+ Object {
182
+ "id": 1,
183
+ "name": "production",
103
184
  },
104
185
  ],
105
186
  "hostgroup_id": 1,
106
- "lifecycle_environments": Array [],
107
- "ptables": Array [
187
+ "lifecycle_environments": Array [
108
188
  Object {
109
- "id": 105,
110
- "name": "Kickstart default",
189
+ "id": 1,
190
+ "name": "Library",
111
191
  },
192
+ ],
193
+ "ptables": Array [
112
194
  Object {
113
- "id": 104,
114
- "name": "Kickstart default thin",
195
+ "id": 125,
196
+ "name": "Kickstart default",
115
197
  },
116
198
  ],
117
199
  }
118
200
  `;
119
201
 
120
- exports[`ParameterSelectionSelectors should return hostgroupId from parameterSelectionData_1 fixtures 1`] = `1`;
121
-
122
- exports[`ParameterSelectionSelectors should return loading from parameterSelectionData_1 fixtures 1`] = `false`;
123
-
124
202
  exports[`ParameterSelectionSelectors should return parameterTypes from parameterSelectionData_1 fixtures 1`] = `
125
203
  Object {
126
- "computeprofile": "Compute profile",
127
204
  "domain": "Domain",
128
205
  "hostparam": "Host parameter",
129
- "lifecycleenv": "Lifecycle environment",
206
+ "ip": "IP",
207
+ "password": "Root password",
208
+ "ptable": "Partition table",
209
+ "puppetenv": "Puppet environment",
130
210
  }
131
211
  `;
132
212
 
@@ -135,64 +215,22 @@ Array [
135
215
  Object {
136
216
  "description": "",
137
217
  "id": 1,
138
- "name": "PuppetEnv",
139
- "type": "puppetenv",
140
- "value": "2",
218
+ "locked": false,
219
+ "name": "CP",
220
+ "type": "computeprofile",
221
+ "value": "1",
141
222
  },
142
223
  Object {
143
224
  "description": "",
144
225
  "id": 2,
145
- "name": "PW",
146
- "type": "password",
147
- "value": "rooot",
148
- },
149
- Object {
150
- "description": "",
151
- "id": 3,
152
- "name": "Blub",
153
- "type": "hostparam",
154
- "value": "awesome",
155
- },
156
- Object {
157
- "description": "",
158
- "id": 4,
159
- "name": "111allo",
160
- "type": "ip",
161
- "value": "1.1.1.1",
162
- },
163
- Object {
164
- "description": "",
165
- "id": 5,
166
- "name": "1111aasdfasf",
167
- "type": "hostname",
168
- "value": "dername",
169
- },
170
- Object {
171
- "description": "",
172
- "id": 6,
173
- "name": "222nocheiner",
174
- "type": "hostparam",
175
- "value": "",
176
- },
177
- Object {
178
- "description": "aa",
179
- "id": 7,
180
- "name": "aaaaa",
181
- "type": "ptable",
182
- "value": "",
183
- },
184
- Object {
185
- "description": "",
186
- "id": 8,
187
- "name": "aaa",
188
- "type": "hostparam",
189
- "value": "2134234",
226
+ "locked": true,
227
+ "name": "LE",
228
+ "type": "lifecycleenv",
229
+ "value": "1",
190
230
  },
191
231
  ]
192
232
  `;
193
233
 
194
- exports[`ParameterSelectionSelectors should return serviceDefinition from parameterSelectionData_1 fixtures 1`] = `undefined`;
195
-
196
234
  exports[`ParameterSelectionSelectors should return sortingColumns from parameterSelectionData_1 fixtures 1`] = `
197
235
  Object {
198
236
  "name": Object {
@@ -14,6 +14,7 @@ import {
14
14
  selectSortingColumns,
15
15
  selectColumns,
16
16
  selectParamDefinition,
17
+ selectEditParamsRowIndex,
17
18
  } from './ParameterSelectionSelectors';
18
19
 
19
20
  const mapStateToProps = state => ({
@@ -25,6 +26,7 @@ const mapStateToProps = state => ({
25
26
  sortingColumns: selectSortingColumns(state),
26
27
  columns: selectColumns(state),
27
28
  paramDefinition: selectParamDefinition(state),
29
+ editParamsRowIndex: selectEditParamsRowIndex(state),
28
30
  });
29
31
 
30
32
  const mapDispatchToProps = dispatch =>
@@ -34,4 +36,3 @@ export default connect(
34
36
  mapStateToProps,
35
37
  mapDispatchToProps
36
38
  )(ParameterSelection);
37
-
@@ -0,0 +1,202 @@
1
+ import React, { useState } from 'react'
2
+ import PropTypes from 'prop-types';
3
+ import {
4
+ Icon,
5
+ Button,
6
+ } from 'patternfly-react';
7
+ import {
8
+ sprintf,
9
+ translate as __
10
+ } from 'foremanReact/common/I18n';
11
+ import {Select, TextInput} from 'foremanReact/components/common/forms/Select';
12
+ import ScmTypeSelector from './components/ScmTypeSelector';
13
+ import FormTextInput from './components/FormTextInput'
14
+ import { arrayToObject } from '../../helper';
15
+ import CommonForm from 'foremanReact/components/common/forms/CommonForm';
16
+ import $ from 'jquery';
17
+
18
+ import {
19
+ FormControl,
20
+ inlineEditFormatterFactory,
21
+ } from 'patternfly-react';
22
+
23
+ class SyncGitRepo extends React.Component {
24
+ constructor(props) {
25
+ super(props);
26
+ }
27
+
28
+ validateParameters() {
29
+ let result = true;
30
+ let msg = "";
31
+
32
+ if (this.props.path === "" && this.props.scmType === 'directory') {
33
+ result = false;
34
+
35
+ if (msg == "") {
36
+ msg += __("Directory path cannot be blank");
37
+ }
38
+ }
39
+
40
+ if (this.props.scmType === 'git') {
41
+ if (this.props.gitUrl === "") {
42
+ result = false;
43
+
44
+ if (msg == "") {
45
+ msg += __("Git URL cannot be blank");
46
+ }
47
+ }
48
+ }
49
+
50
+ if (this.props.scmType !== "git" && this.props.scmType !== "directory" ) {
51
+ result = false;
52
+
53
+ if (msg == "") {
54
+ msg += __("SCM Type cannot be blank");
55
+ }
56
+ }
57
+
58
+ return {
59
+ validateResult: result,
60
+ validateMsg: msg
61
+ }
62
+ }
63
+
64
+ componentDidMount() {
65
+ const {
66
+ data: {mode, scmType, path, gitCommit, gitUrl, appDefinitions},
67
+ initSyncGitRepo,
68
+ loadScmType,
69
+ loadPath,
70
+ loadGitCommit,
71
+ loadGitUrl,
72
+ handleGitRepoSync,
73
+ } = this.props;
74
+
75
+ if (mode === 'editInstance') {
76
+ loadScmType(scmType);
77
+ loadPath(path);
78
+ loadGitCommit(gitCommit);
79
+ loadGitUrl(gitUrl);
80
+ handleGitRepoSync(this.props.scmType, this.props.path, this.props.gitCommit)
81
+ }
82
+
83
+ initSyncGitRepo(
84
+ scmType,
85
+ path,
86
+ gitCommit,
87
+ gitUrl,
88
+ );
89
+ };
90
+
91
+ render() {
92
+ const {
93
+ data: {mode, scmTypes, organization, location, appDefinitions},
94
+ scmType,
95
+ path,
96
+ gitCommit,
97
+ gitUrl,
98
+ loadScmType,
99
+ loadPath,
100
+ loadGitCommit,
101
+ loadGitUrl,
102
+ handleGitRepoSync,
103
+ } = this.props;
104
+
105
+ var url_validator = /^(ftp|http|https):\/\/[^ "]+$/;
106
+
107
+ let { validateResult, validateMsg } = this.validateParameters();
108
+
109
+ if (validateResult === false) {
110
+ $('input[type="submit"][name="commit"]').attr("disabled", true);
111
+ } else {
112
+ $('input[type="submit"][name="commit"]').attr("disabled", false);
113
+ }
114
+
115
+ return (
116
+ <span>
117
+ <div>
118
+ <ScmTypeSelector
119
+ label="SCM Type *"
120
+ hidden={ false }
121
+ editable={ appDefinitions.length == 0 }
122
+ viewText={ scmTypes[scmType] }
123
+ options={ scmTypes }
124
+ onChange={ loadScmType }
125
+ selectValue={ scmType }
126
+ />
127
+ {(scmType === 'directory') ? (
128
+ <FormTextInput
129
+ label= 'Directory Path *'
130
+ editable= { appDefinitions.length == 0 }
131
+ viewText={ path }
132
+ onChange={ loadPath }
133
+ parameter="path"
134
+ /> ) : null }
135
+ {(scmType === 'git') ? (
136
+ <FormTextInput
137
+ label= 'Git Url *'
138
+ editable= { appDefinitions.length == 0 }
139
+ viewText={ gitUrl }
140
+ onChange={ loadGitUrl }
141
+ parameter="git_url"
142
+ /> ) : null }
143
+ {(!url_validator.test(gitUrl) && gitUrl)? (
144
+ <div className="form-group">
145
+ <div className="col-md-2"></div>
146
+ <div className="col-md-4"><pre>{ __("Git URL is wrong") }</pre></div>
147
+ </div>
148
+ ) : (<div></div>)}
149
+ {validateResult == false ? (
150
+ <div className="form-group">
151
+ <div className="col-md-2"></div>
152
+ <div className="col-md-4"><pre>{validateMsg}</pre></div>
153
+ </div>
154
+ ) : (<div></div>)}
155
+ {(scmType === "git") ? (
156
+ <FormTextInput
157
+ label="Git Branch/Commit/Tag"
158
+ editable= { appDefinitions.length == 0 }
159
+ viewText={ gitCommit }
160
+ onChange={ loadGitCommit }
161
+ parameter="git_commit"
162
+ /> ) : null }
163
+ {(scmType === "git") ? (
164
+ <CommonForm>
165
+ <span className="help-block help-inline">
166
+ <Button
167
+ bsStyle="default"
168
+ onClick={ (e) => handleGitRepoSync(gitUrl, gitCommit, scmType, e) }
169
+ >
170
+ {__('Sync Repository')} </Button>
171
+ </span>
172
+ </CommonForm>
173
+ ) : null }
174
+
175
+ </div>
176
+ </span>
177
+ )};
178
+ }
179
+
180
+ SyncGitRepo.defaultProps = {
181
+ error: {},
182
+ scmType: "",
183
+ path: "",
184
+ gitCommit: "",
185
+ gitUrl: "",
186
+
187
+ }
188
+
189
+ SyncGitRepo.propTypes = {
190
+ initSyncGitRepo: PropTypes.func,
191
+ loadScmType: PropTypes.func,
192
+ loadGitCommit: PropTypes.func,
193
+ loadPath: PropTypes.func,
194
+ loadGitUrl: PropTypes.func,
195
+ handleGitRepoSync: PropTypes.func,
196
+ scmType: PropTypes.string.isRequired,
197
+ path: PropTypes.string.isRequired,
198
+ gitCommit: PropTypes.string,
199
+ gitUrl: PropTypes.string,
200
+ };
201
+
202
+ export default SyncGitRepo;
@@ -0,0 +1 @@
1
+ @import '~@theforeman/vendor/scss/variables';
@@ -0,0 +1,123 @@
1
+ import React from 'react';
2
+ import { API, actionTypeGenerator } from 'foremanReact/redux/API';
3
+ import { sprintf, translate as __ } from 'foremanReact/common/I18n';
4
+ import { addToast } from 'foremanReact/redux/actions/toasts';
5
+
6
+ import {
7
+ SYNC_GIT_REPO_INIT,
8
+ SYNC_GIT_REPO_LOAD_SCM_TYPE,
9
+ SYNC_GIT_REPO_LOAD_PATH,
10
+ SYNC_GIT_REPO_LOAD_GIT_COMMIT,
11
+ SYNC_GIT_REPO_LOAD_GIT_URL,
12
+ SYNC_GIT_REPO_REQUEST,
13
+ SYNC_GIT_REPO_FAILURE,
14
+ SYNC_GIT_REPO_SUCCESS,
15
+ } from './SyncGitRepoConstants';
16
+
17
+ export const initSyncGitRepo = (
18
+ scmType,
19
+ path,
20
+ gitCommit,
21
+ gitUrl,
22
+ ) => dispatch => {
23
+ const initialState = {};
24
+
25
+ initialState.scmType = scmType;
26
+ initialState.path = path;
27
+ initialState.gitCommit = gitCommit;
28
+ initialState.gitUrl = gitUrl;
29
+
30
+ dispatch({
31
+ type: SYNC_GIT_REPO_INIT,
32
+ payload: initialState,
33
+ });
34
+ };
35
+
36
+ const errorHandler = (msg, err) => {
37
+ const error = {
38
+ errorMsg: __('Failed to fetch data from server.'),
39
+ statusText: err,
40
+ };
41
+ return { type: msg, payload: { error } };
42
+ };
43
+
44
+ export const handleGitRepoSync = (
45
+ gitUrl, gitCommit, scmType, e,
46
+ ) => async dispatch => {
47
+ e.preventDefault();
48
+ //const { REQUEST, SUCCESS, FAILURE } = actionTypeGenerator(SYNC_GIT_REPOSITORY);
49
+ dispatch({
50
+ type: SYNC_GIT_REPO_REQUEST,
51
+ payload: {
52
+ git_commit: gitCommit,
53
+ scm_type: scmType,
54
+ git_url: gitUrl,
55
+ }});
56
+ try {
57
+ const { data } = await API.post(
58
+ '/acd/ansible_playbooks/sync_git_repo', {"ansible_playbook": {"git_commit":gitCommit, "scm_type":scmType, "git_url":gitUrl}}
59
+ );
60
+ dispatch(
61
+ addToast({
62
+ type: 'success',
63
+ message: sprintf(
64
+ __('Sucessfully synced git repository ')
65
+ ),
66
+ key: SYNC_GIT_REPO_SUCCESS,
67
+ })
68
+ );
69
+ return dispatch({
70
+ type: SYNC_GIT_REPO_SUCCESS,
71
+ payload: {
72
+ git_commit: gitCommit,
73
+ git_url: gitUrl,
74
+ scm_type: scmType,
75
+ },
76
+ response: data,
77
+ });
78
+ } catch (error) {
79
+ dispatch(
80
+ addToast({
81
+ type: 'error',
82
+ message: sprintf(__('Error occurred while syncing git repository: %s'), error.response.data.message),
83
+ key: SYNC_GIT_REPO_FAILURE,
84
+ })
85
+ );
86
+ return dispatch({
87
+ type: SYNC_GIT_REPO_FAILURE,
88
+ payload: {
89
+ error: error,
90
+ },
91
+ response: error,
92
+ });
93
+ }
94
+ };
95
+
96
+
97
+ export const loadScmType = (scmType) => {
98
+ return ({
99
+ type: SYNC_GIT_REPO_LOAD_SCM_TYPE,
100
+ scmType: scmType,
101
+ })
102
+ };
103
+
104
+ export const loadPath = (path) => {
105
+ return ({
106
+ type: SYNC_GIT_REPO_LOAD_PATH,
107
+ path: path,
108
+ })
109
+ };
110
+
111
+ export const loadGitCommit = (gitCommit) => {
112
+ return ({
113
+ type: SYNC_GIT_REPO_LOAD_GIT_COMMIT,
114
+ gitCommit: gitCommit,
115
+ })
116
+ };
117
+
118
+ export const loadGitUrl = (gitUrl) => {
119
+ return ({
120
+ type: SYNC_GIT_REPO_LOAD_GIT_URL,
121
+ gitUrl: gitUrl,
122
+ })
123
+ };
@@ -0,0 +1,8 @@
1
+ export const SYNC_GIT_REPO_INIT = 'SYNC_GIT_REPO_INIT';
2
+ export const SYNC_GIT_REPO_LOAD_PATH = 'SYNC_GIT_REPO_LOAD_PATH';
3
+ export const SYNC_GIT_REPO_LOAD_SCM_TYPE = 'SYNC_GIT_REPO_LOAD_SCM_TYPE';
4
+ export const SYNC_GIT_REPO_LOAD_GIT_COMMIT = 'SYNC_GIT_REPO_LOAD_GIT_COMMIT';
5
+ export const SYNC_GIT_REPO_LOAD_GIT_URL = 'SYNC_GIT_REPO_LOAD_GIT_URL';
6
+ export const SYNC_GIT_REPO_REQUEST = 'SYNC_GIT_REPO_REQUEST';
7
+ export const SYNC_GIT_REPO_SUCCESS = 'SYNC_GIT_REPO_SUCCESS';
8
+ export const SYNC_GIT_REPO_FAILURE = 'SYNC_GIT_REPO_FAILURE';