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,35 @@
1
+ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import ServiceSelector from '../ServiceSelector';
4
+
5
+ const noop = () => {};
6
+
7
+ const data = [
8
+ { name: 'report 1', status: 'done' },
9
+ { name: 'report 2', status: 'pending' }
10
+ ];
11
+
12
+ const fixtures = {
13
+ 'should render the service selector': {
14
+ hidden: false,
15
+ label: 'Test Label',
16
+ viewText: 'view service',
17
+ selectValue: '1',
18
+ onChange: noop,
19
+ options: { first: 'first', second: 'second'},
20
+ additionalData: { moreData: 'moooore' },
21
+ },
22
+ 'should render the hidden service selector': {
23
+ hidden: true,
24
+ label: 'Test Label',
25
+ viewText: 'view service',
26
+ selectValue: '1',
27
+ onChange: noop,
28
+ options: { first: 'first', second: 'second'},
29
+ additionalData: { },
30
+ },
31
+ };
32
+
33
+ describe('ServiceSelector', () =>
34
+ testComponentSnapshotsWithFixtures(ServiceSelector, fixtures));
35
+
@@ -0,0 +1,77 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ServiceSelector should render the hidden service selector 1`] = `
4
+ <div
5
+ className="form-group"
6
+ >
7
+ <label
8
+ className="col-md-2 control-label"
9
+ >
10
+ Test Label
11
+ </label>
12
+ <div
13
+ className="col-md-4"
14
+ >
15
+ <ExtSelect
16
+ additionalData={Object {}}
17
+ editable={true}
18
+ hidden={true}
19
+ onChange={[Function]}
20
+ options={
21
+ Object {
22
+ "first": "first",
23
+ "second": "second",
24
+ }
25
+ }
26
+ selectValue="1"
27
+ viewText="view service"
28
+ />
29
+ <RailsData
30
+ key="service_id"
31
+ parameter="service_id"
32
+ value="1"
33
+ view="existing_host_selection"
34
+ />
35
+ </div>
36
+ </div>
37
+ `;
38
+
39
+ exports[`ServiceSelector should render the service selector 1`] = `
40
+ <div
41
+ className="form-group"
42
+ >
43
+ <label
44
+ className="col-md-2 control-label"
45
+ >
46
+ Test Label
47
+ </label>
48
+ <div
49
+ className="col-md-4"
50
+ >
51
+ <ExtSelect
52
+ additionalData={
53
+ Object {
54
+ "moreData": "moooore",
55
+ }
56
+ }
57
+ editable={true}
58
+ hidden={false}
59
+ onChange={[Function]}
60
+ options={
61
+ Object {
62
+ "first": "first",
63
+ "second": "second",
64
+ }
65
+ }
66
+ selectValue="1"
67
+ viewText="view service"
68
+ />
69
+ <RailsData
70
+ key="service_id"
71
+ parameter="service_id"
72
+ value="1"
73
+ view="existing_host_selection"
74
+ />
75
+ </div>
76
+ </div>
77
+ `;
@@ -0,0 +1,26 @@
1
+ import { bindActionCreators } from 'redux';
2
+ import { connect } from 'react-redux';
3
+
4
+ import './ExistingHostSelection.scss';
5
+ import ExistingHostSelection from './ExistingHostSelection';
6
+ import * as ExistingHostSelectionActions from './ExistingHostSelectionActions';
7
+
8
+ import {
9
+ selectServiceId,
10
+ selectAvailableHosts,
11
+ selectAlreadyUsedHosts,
12
+ } from './ExistingHostSelectionSelectors';
13
+
14
+ const mapStateToProps = state => ({
15
+ serviceId: selectServiceId(state),
16
+ availableHosts: selectAvailableHosts(state),
17
+ alreadyUsedHosts: selectAlreadyUsedHosts(state),
18
+ });
19
+
20
+ const mapDispatchToProps = dispatch =>
21
+ bindActionCreators(ExistingHostSelectionActions, dispatch);
22
+
23
+ export default connect(
24
+ mapStateToProps,
25
+ mapDispatchToProps
26
+ )(ExistingHostSelection);
@@ -6,8 +6,11 @@ import { orderBy } from 'lodash';
6
6
  import * as resolve from 'table-resolver';
7
7
  import Select from 'foremanReact/components/common/forms/Select';
8
8
  import AddTableEntry from '../common/AddTableEntry';
9
+ import EditTableEntry from '../common/EditTableEntry';
9
10
  import DeleteTableEntry from '../common/DeleteTableEntry';
10
- import ExtSelect from '../common/ExtSelect';
11
+ import LockTableEntry from '../common/LockTableEntry';
12
+ import ForemanModal from 'foremanReact/components/ForemanModal';
13
+ import * as YamlValidator from '../../js-yaml';
11
14
 
12
15
  import {
13
16
  transformForemanData,
@@ -30,6 +33,7 @@ import {
30
33
  Button,
31
34
  Table,
32
35
  FormControl,
36
+ InputGroup,
33
37
  defaultSortingOrder,
34
38
  customHeaderFormattersDefinition,
35
39
  inlineEditFormatterFactory,
@@ -45,12 +49,42 @@ class ParameterSelection extends React.Component {
45
49
 
46
50
  constructor(props) {
47
51
  super(props);
52
+ this.state = {textValue: ''};
48
53
  }
49
54
 
55
+ handleChange = event => {
56
+ this.setState({textValue: event.target.value});
57
+ };
58
+
50
59
  isEditing({rowData}) {
51
60
  return (rowData.backup !== undefined);
52
61
  }
53
62
 
63
+ yamlValidator() {
64
+ let result = true;
65
+ let msg = "";
66
+ try {
67
+ const doc = YamlValidator.load(this.state.textValue);
68
+ } catch (e) {
69
+ result = false;
70
+ msg = "Invalid Yaml: " + e.name + ": " + e.message;
71
+ }
72
+ return {
73
+ validateResult: result,
74
+ validateMsg: msg
75
+ }
76
+ }
77
+
78
+ yamlValue() {
79
+ if (this.props.editParamsRowIndex != undefined) {
80
+ let id = this.props.editParamsRowIndex;
81
+ if (this.props.parameters[id] != undefined) {
82
+ return this.props.parameters[id]['value'];
83
+ }
84
+ }
85
+ return '';
86
+ }
87
+
54
88
  // enables our custom header formatters extensions to reactabular
55
89
  customHeaderFormatters = customHeaderFormattersDefinition;
56
90
 
@@ -64,8 +98,11 @@ class ParameterSelection extends React.Component {
64
98
  initParameterSelection,
65
99
  sortParameter,
66
100
  deleteParameter,
101
+ lockParameter,
67
102
  activateEditParameter,
68
103
  changeEditParameter,
104
+ openParameterSelectionDialogBox,
105
+ closeParameterSelectionDialogBox,
69
106
  loadParamData,
70
107
  } = this.props;
71
108
 
@@ -83,12 +120,20 @@ class ParameterSelection extends React.Component {
83
120
  isEditing: additionalData => this.props.editMode,
84
121
  renderValue: (value, additionalData) => (
85
122
  <td style={{ padding: '2px' }}>
86
- <Button
87
- bsStyle="default"
88
- onClick={() => activateEditParameter(additionalData)}
89
- >
90
- <Icon type="pf" name="edit" />
91
- </Button>
123
+ <EditTableEntry
124
+ disabled={false}
125
+ handleLocking={!allowRowAdjustment}
126
+ onEditTableEntry={() => activateEditParameter(additionalData)}
127
+ additionalData={additionalData}
128
+ />
129
+ &nbsp;
130
+ <LockTableEntry
131
+ hidden={!allowRowAdjustment}
132
+ disabled={!allowRowAdjustment}
133
+ onLockTableEntry={lockParameter}
134
+ additionalData={additionalData}
135
+ />
136
+ &nbsp;
92
137
  <DeleteTableEntry
93
138
  hidden={!allowRowAdjustment}
94
139
  disabled={false}
@@ -99,9 +144,19 @@ class ParameterSelection extends React.Component {
99
144
  ),
100
145
  renderEdit: (value, additionalData) => (
101
146
  <td style={{ padding: '2px' }}>
102
- <Button bsStyle="default" disabled>
103
- <Icon type="pf" name="edit" />
104
- </Button>
147
+ <EditTableEntry
148
+ disabled={true}
149
+ onEditTableEntry={() => activateEditParameter(additionalData)}
150
+ additionalData={additionalData}
151
+ />
152
+ &nbsp;
153
+ <LockTableEntry
154
+ hidden={!allowRowAdjustment}
155
+ disabled={true}
156
+ onLockTableEntry={lockParameter}
157
+ additionalData={additionalData}
158
+ />
159
+ &nbsp;
105
160
  <DeleteTableEntry
106
161
  hidden={!allowRowAdjustment}
107
162
  disabled={true}
@@ -144,6 +199,22 @@ class ParameterSelection extends React.Component {
144
199
  />
145
200
  </td>
146
201
  ),
202
+ renderEditComplexText: (value, additionalData, subtype='text') => (
203
+ <td className="editing">
204
+ <InputGroup>
205
+ <FormControl
206
+ type={subtype}
207
+ defaultValue={additionalData.rowData.isYaml == true ? '' : value}
208
+ onBlur={e => changeEditParameter(e.target.value, additionalData) }
209
+ readOnly={additionalData.rowData.isYaml}
210
+ placeholder={'Press YAML button for Yaml Data'}
211
+ />
212
+ <InputGroup.Button>
213
+ <Button onClick= {e => openParameterSelectionDialogBox(e)}> YAML </Button>
214
+ </InputGroup.Button>
215
+ </InputGroup>
216
+ </td>
217
+ ),
147
218
  renderEditSelect: (value, additionalData, options) => (
148
219
  <td className="editing">
149
220
  <Select
@@ -188,6 +259,10 @@ class ParameterSelection extends React.Component {
188
259
  case 'text':
189
260
  prettyValue = value
190
261
  break;
262
+ case 'complex':
263
+ prettyValue = additionalData.rowData.isYaml ? 'YAML value' : value;
264
+ break;
265
+
191
266
  }
192
267
  }
193
268
  return inlineEditFormatterImpl.renderValue(prettyValue, additionalData)
@@ -214,6 +289,8 @@ class ParameterSelection extends React.Component {
214
289
  case 'password':
215
290
  return inlineEditFormatterImpl.renderEditText(value, additionalData, 'password');
216
291
  case 'text':
292
+ case 'complex':
293
+ return inlineEditFormatterImpl.renderEditComplexText(value, additionalData);
217
294
  default:
218
295
  return inlineEditFormatterImpl.renderEditText(value, additionalData);
219
296
  }
@@ -222,6 +299,7 @@ class ParameterSelection extends React.Component {
222
299
  }
223
300
  }
224
301
  });
302
+
225
303
  this.inlineEditFormatter = inlineEditFormatter;
226
304
 
227
305
  initParameterSelection(
@@ -253,6 +331,8 @@ class ParameterSelection extends React.Component {
253
331
  addParameter,
254
332
  confirmEditParameter,
255
333
  cancelEditParameter,
334
+ closeParameterSelectionDialogBox,
335
+ editModeCallback,
256
336
  } = this.props;
257
337
 
258
338
  let sortedParameters;
@@ -260,6 +340,7 @@ class ParameterSelection extends React.Component {
260
340
 
261
341
  if (newEntryIndex >= 0) {
262
342
  const newEntry = parameters[newEntryIndex];
343
+
263
344
  // sort all elements, besides the newEntry which will be
264
345
  // added to the end of the Array
265
346
  const tmpParameters = cloneDeep(parameters);
@@ -284,15 +365,18 @@ class ParameterSelection extends React.Component {
284
365
  )(parameters);
285
366
  }
286
367
 
368
+ // Make sure that the component which includes the
369
+ // ParameterSelection is aware of the current editMode state
370
+ if (editModeCallback !== undefined) {
371
+ editModeCallback(this.props.editMode);
372
+ }
373
+
374
+ let { validateResult, validateMsg } = this.yamlValidator();
375
+
287
376
  return(
288
377
  <div>
289
378
  <div className="clearfix">
290
379
  <div className="form-group">
291
- <AddTableEntry
292
- hidden={!allowRowAdjustment}
293
- disabled={ this.props.editMode }
294
- onAddTableEntry={ addParameter }
295
- />
296
380
  <Table.PfProvider
297
381
  striped
298
382
  bordered
@@ -335,6 +419,38 @@ class ParameterSelection extends React.Component {
335
419
  />
336
420
  </div>
337
421
  </div>
422
+ <div>
423
+ <ForemanModal
424
+ id="ParameterSelectionComplexDataModal"
425
+ dialogClassName="complex_data_modal"
426
+ title={__("YAML Data Input")}
427
+
428
+ >
429
+ <ForemanModal.Header closeButton={false}>
430
+ </ForemanModal.Header>
431
+ <textarea id='yamlData'
432
+ defaultValue= {this.yamlValue()}
433
+ onChange={this.handleChange}
434
+ style={{width: "550px", height: "350px", fontFamily: "Courier"}} />
435
+ <ForemanModal.Footer>
436
+ <div>
437
+ {validateResult == false ? (
438
+ <div className="form-group">
439
+ <div class="alert alert-danger alert-dismissable">
440
+ <button type="button" class="close" data-dismiss="alert" aria-label="Close">
441
+ <span class="pficon pficon-close"></span>
442
+ </button>
443
+ <span class="pficon pficon-error-circle-o"></span>
444
+ {validateMsg}
445
+ </div>
446
+ </div>
447
+ ) : (<div></div>)}
448
+ <Button bsStyle="primary" onClick ={() => closeParameterSelectionDialogBox({ mode: 'save' })}>{__("Save")}</Button>
449
+ <Button bsStyle="default" onClick={() => closeParameterSelectionDialogBox({ mode: 'cancel' })}>{__("Cancel")}</Button>
450
+ </div>
451
+ </ForemanModal.Footer>
452
+ </ForemanModal>
453
+ </div>
338
454
  </div>
339
455
  );
340
456
  }
@@ -348,6 +464,8 @@ ParameterSelection.defaultProps = {
348
464
  parameters: [],
349
465
  columns: [],
350
466
  sortingColumns: {},
467
+ editParamsRowIndex: [],
468
+ editModeCallback: undefined,
351
469
  };
352
470
 
353
471
  ParameterSelection.propTypes = {
@@ -366,16 +484,21 @@ ParameterSelection.propTypes = {
366
484
  parameterTypes: PropTypes.object,
367
485
  parameters: PropTypes.array,
368
486
  sortingColumns: PropTypes.object,
487
+ editModeCallback: PropTypes.func,
369
488
  columns: PropTypes.array,
370
489
  sortParameter: PropTypes.func,
371
490
  addParameter: PropTypes.func,
372
491
  deleteParameter: PropTypes.func,
492
+ lockParameter: PropTypes.func,
373
493
  activateEditParameter: PropTypes.func,
374
494
  confirmEditParameter: PropTypes.func,
375
495
  cancelEditParameter: PropTypes.func,
376
496
  changeEditParameter: PropTypes.func,
497
+ openParameterSelectionDialogBox: PropTypes.func,
498
+ closeParameterSelectionDialogBox: PropTypes.func,
377
499
  loadParamData: PropTypes.func,
378
500
  paramDefinition: PropTypes.object,
501
+ editParamsRowIndex: PropTypes.array,
379
502
  };
380
503
 
381
504
  export default ParameterSelection;
@@ -8,3 +8,10 @@
8
8
  max-width: none !important;
9
9
  }
10
10
 
11
+ .complex_data_modal {
12
+ margin-top: 0;
13
+ margin-bottom: 0;
14
+ height: 80%;
15
+ width: 40%;
16
+ max-width: none !important;
17
+ }
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import * as sort from 'sortabular';
3
+ import { translate as __ } from 'foremanReact/common/I18n';
3
4
 
4
5
  import {
5
6
  actionHeaderCellFormatter,
@@ -19,9 +20,15 @@ import {
19
20
  filterUsedParameterTypes,
20
21
  } from './ParameterSelectionHelper';
21
22
 
23
+ import {
24
+ setModalOpen,
25
+ setModalClosed,
26
+ } from 'foremanReact/components/ForemanModal/ForemanModalActions';
27
+
22
28
  import {
23
29
  PARAMETER_SELECTION_INIT,
24
30
  PARAMETER_SELECTION_TYPES,
31
+ PARAMETER_SELECTION_LOCK,
25
32
  PARAMETER_SELECTION_DELETE,
26
33
  PARAMETER_SELECTION_ADD,
27
34
  PARAMETER_SELECTION_EDIT_ACTIVATE,
@@ -34,6 +41,8 @@ import {
34
41
  PARAMETER_SELECTION_LOAD_PARAM_DATA_REQUEST,
35
42
  PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS,
36
43
  PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE,
44
+ PARAMETER_SELECTION_COMPLEX_DATA_MODAL_OPEN,
45
+ PARAMETER_SELECTION_COMPLEX_DATA_MODAL_CLOSE,
37
46
  } from './ParameterSelectionConstants';
38
47
 
39
48
  export const initParameterSelection = (
@@ -58,9 +67,9 @@ export const initParameterSelection = (
58
67
  };
59
68
  initialState.paramDefinition = paramDefinition;
60
69
 
61
- let valueLabel = 'Value';
70
+ let valueLabel = __('Value');
62
71
  if (useDefaultValue) {
63
- valueLabel = 'Default value';
72
+ valueLabel = __('Default value');
64
73
  }
65
74
 
66
75
  initialState.columns = []
@@ -73,7 +82,7 @@ export const initParameterSelection = (
73
82
  addToColumns( {
74
83
  property: 'name',
75
84
  header: {
76
- label: 'Name',
85
+ label: __('Name'),
77
86
  props: {
78
87
  sort: true,
79
88
  style: {
@@ -92,7 +101,7 @@ export const initParameterSelection = (
92
101
  addToColumns( {
93
102
  property: 'description',
94
103
  header: {
95
- label: 'Description',
104
+ label: __('Description'),
96
105
  props: {
97
106
  sort: true,
98
107
  style: {
@@ -115,7 +124,7 @@ export const initParameterSelection = (
115
124
  addToColumns( {
116
125
  property: 'type',
117
126
  header: {
118
- label: 'Type',
127
+ label: __('Type'),
119
128
  props: {
120
129
  sort: true,
121
130
  style: {
@@ -156,7 +165,7 @@ export const initParameterSelection = (
156
165
  addToColumns( {
157
166
  property: 'actions',
158
167
  header: {
159
- label: 'Actions',
168
+ label: __('Actions'),
160
169
  props: {
161
170
  style: {
162
171
  width: '10%'
@@ -175,6 +184,8 @@ export const initParameterSelection = (
175
184
  initialState.parameterTypes = filterUsedParameterTypes(PARAMETER_SELECTION_TYPES, parameters);
176
185
  }
177
186
 
187
+ initialState.paramType = paramType;
188
+
178
189
  dispatch({
179
190
  type: PARAMETER_SELECTION_INIT,
180
191
  payload: initialState,
@@ -183,13 +194,46 @@ export const initParameterSelection = (
183
194
 
184
195
  const errorHandler = (msg, err) => {
185
196
  const error = {
186
- errorMsg: 'Failed to fetch data from server.',
197
+ errorMsg: __('Failed to fetch data from server.'),
187
198
  statusText: err,
188
199
  };
189
200
  return { type: msg, payload: { error } };
190
201
  };
191
202
 
192
- export const addParameter = (additionalData) => ({
203
+ export const lockParameter = (additionalData) => ({
204
+ type: PARAMETER_SELECTION_LOCK,
205
+ payload: {
206
+ ...additionalData,
207
+ },
208
+ });
209
+
210
+ export const openParameterSelectionDialogBox = (additionalData) => dispatch => {
211
+ dispatch({
212
+ type: PARAMETER_SELECTION_COMPLEX_DATA_MODAL_OPEN,
213
+ payload: {
214
+ ...additionalData,
215
+ }
216
+ });
217
+ dispatch(
218
+ setModalOpen({ id: 'ParameterSelectionComplexDataModal' })
219
+ );
220
+ };
221
+
222
+ export const closeParameterSelectionDialogBox = (additionalData) => dispatch => {
223
+ dispatch({
224
+ type: PARAMETER_SELECTION_COMPLEX_DATA_MODAL_CLOSE,
225
+ payload: {
226
+ ...additionalData,
227
+ }
228
+ });
229
+
230
+ dispatch(
231
+ setModalClosed({ id: 'ParameterSelectionComplexDataModal' })
232
+ );
233
+ };
234
+
235
+ export const addParameter = (additionalData) => (
236
+ {
193
237
  type: PARAMETER_SELECTION_ADD,
194
238
  payload: {
195
239
  ...additionalData,
@@ -259,4 +303,3 @@ export const loadParamData = (attr) => dispatch => {
259
303
  )
260
304
  .catch(error => dispatch(errorHandler(PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE, error)));
261
305
  };
262
-
@@ -1,4 +1,5 @@
1
1
  export const PARAMETER_SELECTION_INIT = 'INIT_PARAMETER_SELECTION_INIT';
2
+ export const PARAMETER_SELECTION_LOCK = 'PARAMETER_SELECTION_LOCK';
2
3
  export const PARAMETER_SELECTION_DELETE = 'PARAMETER_SELECTION_DELETE';
3
4
  export const PARAMETER_SELECTION_ADD = 'PARAMETER_SELECTION_ADD';
4
5
  export const PARAMETER_SELECTION_EDIT_ACTIVATE = 'PARAMETER_SELECTION_EDIT_ACTIVATE';
@@ -11,6 +12,8 @@ export const PARAMETER_SELECTION_LOAD_PARAM_DATA_SUCCESS = 'PARAMETER_SELECTION_
11
12
  export const PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE = 'PARAMETER_SELECTION_LOAD_PARAM_DATA_FAILURE';
12
13
  export const PARAMETER_SELECTION_PARAM_TYPE_FOREMAN = 'PARAMETER_SELECTION_PARAM_TYPE_FOREMAN';
13
14
  export const PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE = 'PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE';
15
+ export const PARAMETER_SELECTION_COMPLEX_DATA_MODAL_OPEN = 'PARAMETER_SELECTION_COMPLEX_DATA_MODAL_OPEN';
16
+ export const PARAMETER_SELECTION_COMPLEX_DATA_MODAL_CLOSE = 'PARAMETER_SELECTION_COMPLEX_DATA_MODAL_CLOSE';
14
17
 
15
18
  // Make sure the object is sorted by value
16
19
  // (Compute Profile -> Partition table -> Root password)