foreman_acd 0.2.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +107 -56
  3. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +199 -0
  4. data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +72 -0
  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 +62 -0
  7. data/app/controllers/foreman_acd/app_definitions_controller.rb +19 -10
  8. data/app/controllers/foreman_acd/app_instances_controller.rb +111 -137
  9. data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +23 -0
  10. data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
  11. data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
  12. data/app/controllers/foreman_acd/remote_execution_controller.rb +62 -0
  13. data/app/controllers/ui_acd_controller.rb +20 -3
  14. data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +47 -0
  15. data/app/lib/actions/foreman_acd/run_configurator.rb +44 -0
  16. data/app/models/concerns/foreman_acd/host_managed_extensions.rb +51 -0
  17. data/app/models/foreman_acd/acd_provider.rb +36 -0
  18. data/app/models/foreman_acd/ansible_playbook.rb +68 -0
  19. data/app/models/foreman_acd/app_definition.rb +25 -0
  20. data/app/models/foreman_acd/app_instance.rb +42 -0
  21. data/app/models/foreman_acd/foreman_host.rb +23 -0
  22. data/app/models/foreman_acd/taxonomy_extensions.rb +17 -0
  23. data/app/services/foreman_acd/acd_proxy_proxy_selector.rb +17 -0
  24. data/app/services/foreman_acd/app_configurator.rb +98 -0
  25. data/app/services/foreman_acd/app_deployer.rb +157 -0
  26. data/app/services/foreman_acd/inventory_creator.rb +68 -0
  27. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +64 -0
  28. data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +11 -0
  29. data/app/views/foreman_acd/ansible_playbooks/index.html.erb +30 -0
  30. data/app/views/foreman_acd/ansible_playbooks/new.html.erb +3 -0
  31. data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +5 -0
  32. data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +5 -0
  33. data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +9 -0
  34. data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +5 -0
  35. data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +5 -0
  36. data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +9 -0
  37. data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +5 -0
  38. data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +5 -0
  39. data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +5 -0
  40. data/app/views/foreman_acd/app_definitions/_form.html.erb +34 -12
  41. data/app/views/foreman_acd/app_definitions/edit.html.erb +10 -0
  42. data/app/views/foreman_acd/app_definitions/index.html.erb +4 -4
  43. data/app/views/foreman_acd/app_instances/_form.html.erb +11 -9
  44. data/app/views/foreman_acd/app_instances/edit.html.erb +10 -0
  45. data/app/views/foreman_acd/app_instances/index.html.erb +89 -10
  46. data/app/views/foreman_acd/app_instances/report.html.erb +6 -3
  47. data/app/views/templates/job/run_acd_ansible_playbook.erb +62 -0
  48. data/app/views/ui_acd/ansible_data.json.rabl +6 -0
  49. data/app/views/ui_acd/app.json.rabl +6 -2
  50. data/app/views/ui_acd/app_definition.json.rabl +1 -1
  51. data/app/views/ui_acd/{fdata.json.rabl → foreman_data.json.rabl} +1 -1
  52. data/config/routes.rb +32 -2
  53. data/db/migrate/20200916091018_create_ansible_playbooks.rb +20 -0
  54. data/db/migrate/20200917120220_add_ansible_playbook_id.rb +14 -0
  55. data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +8 -0
  56. data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +8 -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/seeds.d/62_acd_proxy_feature.rb +4 -0
  67. data/db/seeds.d/75-job_templates.rb +13 -0
  68. data/lib/foreman_acd.rb +12 -0
  69. data/lib/foreman_acd/engine.rb +43 -3
  70. data/lib/foreman_acd/plugin.rb +88 -22
  71. data/lib/foreman_acd/version.rb +1 -1
  72. data/lib/tasks/foreman_acd_tasks.rake +0 -12
  73. data/locale/en/foreman_acd.edit.po +326 -0
  74. data/locale/en/foreman_acd.po +232 -2
  75. data/locale/en/foreman_acd.po.time_stamp +0 -0
  76. data/locale/foreman_acd.pot +343 -8
  77. data/package.json +9 -9
  78. data/test/controllers/ansible_playbooks_controller_test.rb +27 -0
  79. data/test/controllers/app_instances_controller_test.rb +8 -3
  80. data/test/controllers/ui_acd_controller_test.rb +22 -6
  81. data/test/factories/foreman_acd_factories.rb +18 -4
  82. data/test/models/acd_provider_test.rb +37 -0
  83. data/test/models/ansible_playbook_test.rb +11 -0
  84. data/test/models/app_definition_test.rb +1 -1
  85. data/test/models/app_instance_test.rb +2 -0
  86. data/test/models/concerns/host_extensions_test.rb +26 -0
  87. data/test/models/foreman_host_test.rb +12 -0
  88. data/webpack/__mocks__/foremanReact/API.js +2 -0
  89. data/webpack/__mocks__/foremanReact/common/I18n.js +3 -0
  90. data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
  91. data/webpack/__mocks__/foremanReact/components/ForemanModal.js +7 -0
  92. data/webpack/__mocks__/foremanReact/components/common/forms/CommonForm.js +2 -0
  93. data/webpack/__mocks__/foremanReact/components/common/forms/TextInput.js +2 -0
  94. data/webpack/__mocks__/foremanReact/components/hosts/powerStatus.js +1 -0
  95. data/webpack/__snapshots__/helper.test.js.snap +14 -0
  96. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +159 -29
  97. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +106 -14
  98. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +8 -2
  99. data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +26 -0
  100. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +143 -21
  101. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +3 -0
  102. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionConfData_1.fixtures.js +288 -0
  103. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +79 -0
  104. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +25 -0
  105. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +119 -0
  106. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +41 -0
  107. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinition.test.js.snap +200 -0
  108. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +3033 -0
  109. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +299 -0
  110. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +50 -0
  111. data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +41 -0
  112. data/webpack/components/ApplicationDefinition/components/__tests__/__snapshots__/AnsiblePlaybookSelector.test.js.snap +121 -0
  113. data/webpack/components/ApplicationDefinition/index.js +6 -0
  114. data/webpack/components/ApplicationInstance/ApplicationInstance.js +151 -44
  115. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +47 -10
  116. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +5 -2
  117. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +114 -28
  118. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +3 -1
  119. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceConfData_1.fixtures.js +263 -0
  120. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +78 -0
  121. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +23 -0
  122. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +119 -0
  123. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +44 -0
  124. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +209 -0
  125. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +2719 -0
  126. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +276 -0
  127. data/webpack/components/ApplicationInstance/components/Service.js +1 -1
  128. data/webpack/components/ApplicationInstance/index.js +4 -0
  129. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +53 -60
  130. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +17 -0
  131. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +7 -51
  132. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +2 -4
  133. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +4 -18
  134. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +0 -1
  135. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportData_1.fixtures.js +349 -0
  136. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +20 -0
  137. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +47 -0
  138. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportReducer.test.js +41 -0
  139. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +26 -0
  140. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReport.test.js.snap +130 -0
  141. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +718 -0
  142. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +347 -0
  143. data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +1 -1
  144. data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +24 -0
  145. data/webpack/components/ApplicationInstanceReport/components/__tests__/__snapshots__/ReportViewer.test.js.snap +24 -0
  146. data/webpack/components/ApplicationInstanceReport/index.js +0 -2
  147. data/webpack/components/ParameterSelection/ParameterSelection.js +85 -50
  148. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +68 -62
  149. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +6 -3
  150. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +0 -32
  151. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +47 -35
  152. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -2
  153. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +116 -84
  154. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +10 -4
  155. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +36 -46
  156. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +31 -25
  157. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
  158. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +2 -126
  159. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +1483 -872
  160. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +117 -79
  161. data/webpack/components/ParameterSelection/index.js +4 -4
  162. data/webpack/components/SyncGitRepo/SyncGitRepo.js +210 -0
  163. data/webpack/components/SyncGitRepo/SyncGitRepo.scss +1 -0
  164. data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +124 -0
  165. data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +9 -0
  166. data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +80 -0
  167. data/webpack/components/SyncGitRepo/SyncGitRepoSelectors.js +6 -0
  168. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +7 -0
  169. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +44 -0
  170. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +27 -0
  171. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoReducer.test.js +95 -0
  172. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +32 -0
  173. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +30 -0
  174. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoReducer.test.js.snap +137 -0
  175. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +13 -0
  176. data/webpack/components/SyncGitRepo/components/FormTextInput.js +42 -0
  177. data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +46 -0
  178. data/webpack/components/SyncGitRepo/index.js +28 -0
  179. data/webpack/components/common/DeleteTableEntry.js +3 -3
  180. data/webpack/components/common/EditTableEntry.js +50 -0
  181. data/webpack/components/common/ExtTextInput.js +43 -0
  182. data/webpack/components/common/LockTableEntry.js +60 -0
  183. data/webpack/components/common/__tests__/EditTableEntry.test.js +53 -0
  184. data/webpack/components/common/__tests__/LockTableEntry.test.js +35 -0
  185. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +2 -2
  186. data/webpack/components/common/__tests__/__snapshots__/EditTableEntry.test.js.snap +81 -0
  187. data/webpack/components/common/__tests__/__snapshots__/LockTableEntry.test.js.snap +60 -0
  188. data/webpack/helper.js +15 -1
  189. data/webpack/helper.test.js +37 -0
  190. data/webpack/index.js +2 -0
  191. data/webpack/reducer.js +18 -11
  192. metadata +184 -10
  193. data/app/views/foreman_acd/app_instances/deploy.html.erb +0 -19
  194. data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +0 -35
  195. data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +0 -41
@@ -7,16 +7,22 @@ import * as ApplicationDefinitionActions from './ApplicationDefinitionActions';
7
7
 
8
8
  import {
9
9
  selectEditMode,
10
+ selectAnsiblePlaybook,
10
11
  selectServices,
11
12
  selectColumns,
12
13
  selectParametersData,
14
+ selectAnsibleVarsAll,
15
+ selectParamEditMode,
13
16
  } from './ApplicationDefinitionSelectors';
14
17
 
15
18
  const mapStateToProps = state => ({
16
19
  editMode: selectEditMode(state),
20
+ ansiblePlaybook: selectAnsiblePlaybook(state),
17
21
  services: selectServices(state),
18
22
  columns: selectColumns(state),
19
23
  parametersData: selectParametersData(state),
24
+ ansibleVarsAll: selectAnsibleVarsAll(state),
25
+ paramEditMode: selectParamEditMode(state),
20
26
  });
21
27
 
22
28
  const mapDispatchToProps = dispatch =>
@@ -6,14 +6,19 @@ import {
6
6
  } from 'patternfly-react';
7
7
  import * as resolve from 'table-resolver';
8
8
  import ForemanModal from 'foremanReact/components/ForemanModal';
9
+ import {
10
+ sprintf,
11
+ translate as __
12
+ } from 'foremanReact/common/I18n';
9
13
  import Select from 'foremanReact/components/common/forms/Select';
10
14
  import ParameterSelection from '../ParameterSelection';
11
15
  import AddTableEntry from '../common/AddTableEntry';
12
16
  import DeleteTableEntry from '../common/DeleteTableEntry';
13
- import RailsData from '../common/RailsData'
17
+ import RailsData from '../common/RailsData';
14
18
  import AppDefinitionSelector from './components/AppDefinitionSelector';
15
19
  import ServiceCounter from './components/ServiceCounter';
16
20
  import { arrayToObject } from '../../helper';
21
+ import { EasyHeaderFormatter } from '../../helper';
17
22
 
18
23
  import {
19
24
  Table,
@@ -21,6 +26,11 @@ import {
21
26
  inlineEditFormatterFactory,
22
27
  } from 'patternfly-react';
23
28
 
29
+ import {
30
+ PARAMETER_SELECTION_PARAM_TYPE_FOREMAN,
31
+ PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE,
32
+ } from '../ParameterSelection/ParameterSelectionConstants';
33
+
24
34
  class ApplicationInstance extends React.Component {
25
35
 
26
36
  constructor(props) {
@@ -31,16 +41,20 @@ class ApplicationInstance extends React.Component {
31
41
  return (rowData.backup !== undefined);
32
42
  }
33
43
 
44
+ addTableEntryAllowed() {
45
+ return this.props.editMode || this.props.appDefinition.id == ''
46
+ }
47
+
34
48
  validateParameters() {
35
49
  let result = true;
36
50
  let msg = "";
37
51
 
38
52
  this.props.hosts.forEach(h => {
39
- if (h.parameters.map(e => e.value).filter(i => i == "").length > 0) {
53
+ if (h.foremanParameters.map(e => e.value).filter(i => i == "").length > 0) {
40
54
  result = false;
41
55
 
42
56
  if (msg == "") {
43
- msg += "For some hosts the values for some parameters are missing. Check the values for these hosts:\n";
57
+ msg += __("For some hosts the values for some parameters are missing. Check the values for these hosts:\n");
44
58
  }
45
59
  msg += "- "+ h.hostname +"\n";
46
60
  }
@@ -55,33 +69,40 @@ class ApplicationInstance extends React.Component {
55
69
  if (msg != "") {
56
70
  msg += "\n";
57
71
  }
58
- msg += "Unachieved service counts: \n";
59
72
 
60
- invalidMinServices.map(s => { msg += "- service "+ s.name +" expects at least "+ s.minCount +" configured hosts" });
61
- invalidMaxServices.map(s => { msg += "- service "+ s.name +" expects no more than "+ s.maxCount +" configured hosts" });
73
+ msg += __("Unachieved service counts:");
74
+ msg += "\n";
75
+
76
+ invalidMinServices.map(s => { msg += sprintf(
77
+ __(`- service ${s.name} expects at ${s.minCount} least configured hosts\n`)
78
+ )});
79
+
80
+ invalidMaxServices.map(s => { msg += sprintf(
81
+ __(`- service ${s.name} expects no more than ${s.axCount} configured hosts\n`)
82
+ )});
62
83
  }
63
84
 
64
- if (result === false) {
65
- window.alert(msg);
85
+ return {
86
+ validateResult: result,
87
+ validateMsg: msg
66
88
  }
67
- return result;
68
89
  }
69
90
 
70
91
  componentDidMount() {
71
92
  const {
72
- data: { mode, appDefinition, hosts, loadAppDefinitionUrl },
93
+ data: { mode, appDefinition, hosts, ansibleVarsAll, appDefinitionUrl },
73
94
  initApplicationInstance,
74
95
  addApplicationInstanceHost,
75
96
  deleteApplicationInstanceHost,
76
97
  activateEditApplicationInstanceHost,
77
98
  changeEditApplicationInstanceHost,
78
- openParameterSelectionModal,
79
- closeParameterSelectionModal,
99
+ openForemanParameterSelectionModal,
100
+ openAnsibleParameterSelectionModal,
80
101
  loadApplicationDefinition,
81
102
  } = this.props;
82
103
 
83
104
  if (mode === 'editInstance') {
84
- loadApplicationDefinition(appDefinition.id, { url: loadAppDefinitionUrl });
105
+ loadApplicationDefinition(appDefinition.id, { url: appDefinitionUrl });
85
106
  }
86
107
 
87
108
  const inlineEditButtonsFormatter = inlineEditFormatterFactory({
@@ -92,14 +113,23 @@ class ApplicationInstance extends React.Component {
92
113
  bsStyle="default"
93
114
  onClick={() => activateEditApplicationInstanceHost(additionalData)}
94
115
  >
95
- <Icon type="pf" name="edit" />
116
+ <Icon type="pf" name="edit" title={__("edit entry")} />
117
+ </Button>
118
+ &nbsp;
119
+ <Button
120
+ bsStyle="default"
121
+ onClick={() => openForemanParameterSelectionModal(additionalData)}
122
+ >
123
+ <Icon type="pf" name="settings" title={__("change parameters")} />
96
124
  </Button>
125
+ &nbsp;
97
126
  <Button
98
127
  bsStyle="default"
99
- onClick={() => openParameterSelectionModal(additionalData)}
128
+ onClick={() => openAnsibleParameterSelectionModal(additionalData)}
100
129
  >
101
- <Icon type="pf" name="settings" />
130
+ <span title={__("change ansible variables")}>A</span>
102
131
  </Button>
132
+ &nbsp;
103
133
  <DeleteTableEntry
104
134
  hidden={false}
105
135
  disabled={false}
@@ -111,11 +141,17 @@ class ApplicationInstance extends React.Component {
111
141
  renderEdit: (value, additionalData) => (
112
142
  <td style={{ padding: '2px' }}>
113
143
  <Button bsStyle="default" disabled>
114
- <Icon type="pf" name="edit" />
144
+ <Icon type="pf" name={__("edit")} />
145
+ </Button>
146
+ &nbsp;
147
+ <Button bsStyle="default" disabled>
148
+ <Icon type="pf" name={__("settings")} />
115
149
  </Button>
150
+ &nbsp;
116
151
  <Button bsStyle="default" disabled>
117
- <Icon type="pf" name="settings" />
152
+ <span>A</span>
118
153
  </Button>
154
+ &nbsp;
119
155
  <DeleteTableEntry
120
156
  hidden={false}
121
157
  disabled={true}
@@ -127,8 +163,7 @@ class ApplicationInstance extends React.Component {
127
163
  });
128
164
  this.inlineEditButtonsFormatter = inlineEditButtonsFormatter;
129
165
 
130
- const headerFormatter = value => <Table.Heading>{value}</Table.Heading>;
131
- this.headerFormatter = headerFormatter;
166
+ this.headerFormatter = EasyHeaderFormatter;
132
167
 
133
168
  const inlineEditFormatterImpl = {
134
169
  renderValue: (value, additionalData) => (
@@ -180,6 +215,12 @@ class ApplicationInstance extends React.Component {
180
215
  prettyValue = serviceList[value];
181
216
  return inlineEditFormatterImpl.renderValue(prettyValue, additionalData)
182
217
  }
218
+ if (additionalData.property == 'hostname') {
219
+ if (additionalData.rowData.newEntry === true) {
220
+ return inlineEditFormatterImpl.renderEditText(value, additionalData);
221
+ }
222
+ return inlineEditFormatterImpl.renderValue(prettyValue, additionalData)
223
+ }
183
224
  return inlineEditFormatterImpl.renderEditText(prettyValue, additionalData);
184
225
  }
185
226
  });
@@ -188,6 +229,7 @@ class ApplicationInstance extends React.Component {
188
229
  initApplicationInstance(
189
230
  appDefinition,
190
231
  hosts,
232
+ ansibleVarsAll,
191
233
  this.headerFormatter,
192
234
  this.inlineEditFormatter,
193
235
  this.inlineEditButtonsFormatter,
@@ -196,7 +238,7 @@ class ApplicationInstance extends React.Component {
196
238
 
197
239
  render() {
198
240
  const {
199
- data: { mode, applications, organization, location, loadForemanDataUrl, loadAppDefinitionUrl },
241
+ data: { mode, applications, organization, location, foremanDataUrl, appDefinitionUrl },
200
242
  appDefinition,
201
243
  services,
202
244
  hosts,
@@ -204,16 +246,20 @@ class ApplicationInstance extends React.Component {
204
246
  addApplicationInstanceHost,
205
247
  confirmEditApplicationInstanceHost,
206
248
  cancelEditApplicationInstanceHost,
207
- openParameterSelectionModal,
208
- closeParameterSelectionModal,
209
- ParameterSelectionModal,
249
+ closeForemanParameterSelectionModal,
250
+ openAnsibleParameterSelectionModal,
251
+ closeAnsibleParameterSelectionModal,
252
+ changeParameterSelectionMode,
210
253
  loadApplicationDefinition,
211
254
  } = this.props;
212
255
 
213
- // Start from validation when pressing submit. This should be in componentDidMount() but
214
- // unfortunatley then the event wasn't fired. To make sure, that the on-click is only added
215
- // once, there is a workaround to check if a css class "bound" exists.
216
- $('input[type="submit"][name="commit"]:not(.bound)').addClass('bound').on('click', () => this.validateParameters());
256
+ let { validateResult, validateMsg } = this.validateParameters();
257
+
258
+ if (validateResult == false) {
259
+ $('input[type="submit"][name="commit"]').attr("disabled", true);
260
+ } else {
261
+ $('input[type="submit"][name="commit"]').attr("disabled", false);
262
+ }
217
263
 
218
264
  return (
219
265
  <span>
@@ -232,15 +278,15 @@ class ApplicationInstance extends React.Component {
232
278
  options={ applications }
233
279
  onChange={ loadApplicationDefinition }
234
280
  selectValue={ appDefinition.id.toString() }
235
- additionalData={{url: loadAppDefinitionUrl}}
281
+ additionalData={{url: appDefinitionUrl}}
236
282
  />
283
+ {appDefinition.id == '' ? (
284
+ <p style={{ paddingTop: 25 }}>
285
+ <pre>{ "App Definition can't be blank" }</pre>
286
+ </p>
287
+ ) : (<div></div>)}
237
288
  </div>
238
289
  <div className="form-group">
239
- <AddTableEntry
240
- hidden={ false }
241
- disabled={ this.props.editMode }
242
- onAddTableEntry={ addApplicationInstanceHost }
243
- />
244
290
  <Table.PfProvider
245
291
  striped
246
292
  bordered
@@ -269,43 +315,96 @@ class ApplicationInstance extends React.Component {
269
315
  />
270
316
  </Table.PfProvider>
271
317
  <AddTableEntry
272
- hidden={ false }
273
- disabled={ this.props.editMode }
274
- onAddTableEntry={ addApplicationInstanceHost }
318
+ hidden={ false }
319
+ disabled={ this.addTableEntryAllowed() }
320
+ onAddTableEntry={ addApplicationInstanceHost }
275
321
  />
322
+ <span style={{ marginLeft: 30 }}>
323
+ Ansible group vars 'all':
324
+ <Button
325
+ style={{ marginLeft: 10 }}
326
+ bsStyle="default"
327
+ disabled={ this.props.editMode }
328
+ onClick={() => openAnsibleParameterSelectionModal({
329
+ isAllGroup: true
330
+ })}
331
+ >
332
+ <span title={__("change ansible variables for 'all'")}>A</span>
333
+ </Button>
334
+ </span>
276
335
  </div>
277
336
  <div>
278
337
  <ForemanModal
279
- id="AppInstanceParamSelection"
338
+ id="AppInstanceForemanParamSelection"
280
339
  dialogClassName="param_selection_modal"
281
- title="Parameter specification for Application Instance"
340
+ title={__("Foreman Parameter specification for Application Instance")}
282
341
  >
283
342
  <ForemanModal.Header closeButton={false}>
284
343
  Parameter specification
285
344
  </ForemanModal.Header>
286
345
  {this.props.parametersData ? (
287
346
  <ParameterSelection
347
+ editModeCallback={ (hide) => changeParameterSelectionMode({ mode: hide })}
348
+ paramType={ PARAMETER_SELECTION_PARAM_TYPE_FOREMAN }
288
349
  location={ location }
289
350
  organization={ organization }
290
- loadForemanDataUrl= { loadForemanDataUrl }
351
+ paramDataUrl= { foremanDataUrl }
291
352
  data={ this.props.parametersData }
292
353
  />
293
354
  ) : (<span>Empty</span>)
294
355
  }
295
356
  <ForemanModal.Footer>
296
357
  <div>
297
- <Button bsStyle="primary" onClick={() => closeParameterSelectionModal({ mode: 'save' })}>Save</Button>
298
- <Button bsStyle="default" onClick={() => closeParameterSelectionModal({ mode: 'cancel' })}>Cancel</Button>
358
+ <Button bsStyle="primary" disabled={this.props.paramEditMode} onClick={() => closeForemanParameterSelectionModal({ mode: 'save' })}>{__("Save")}</Button>
359
+ <Button bsStyle="default" disabled={this.props.paramEditMode} onClick={() => closeForemanParameterSelectionModal({ mode: 'cancel' })}>{__("Cancel")}</Button>
299
360
  </div>
300
361
  </ForemanModal.Footer>
301
362
  </ForemanModal>
302
363
  </div>
364
+ <div>
365
+ <ForemanModal
366
+ id="AppInstanceAnsibleParamSelection"
367
+ dialogClassName="param_selection_modal"
368
+ title={__("Ansible group variables for Application Instance")}
369
+ >
370
+ <ForemanModal.Header closeButton={false}>
371
+ Parameter specification
372
+ </ForemanModal.Header>
373
+ {this.props.parametersData ? (
374
+ <ParameterSelection
375
+ editModeCallback={ (hide) => changeParameterSelectionMode({ mode: hide })}
376
+ paramType={ PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE }
377
+ location={ location }
378
+ organization={ organization }
379
+ data={ this.props.parametersData }
380
+ />
381
+ ) : (<span>Empty</span>)
382
+ }
383
+ <ForemanModal.Footer>
384
+ <div>
385
+ <Button bsStyle="primary" disabled={this.props.paramEditMode} onClick={() => closeAnsibleParameterSelectionModal({ mode: 'save' })}>{__("Save")}</Button>
386
+ <Button bsStyle="default" disabled={this.props.paramEditMode} onClick={() => closeAnsibleParameterSelectionModal({ mode: 'cancel' })}>{__("Cancel")}</Button>
387
+ </div>
388
+ </ForemanModal.Footer>
389
+ </ForemanModal>
390
+ </div>
391
+ {validateResult == false ? (
392
+ <p style={{ paddingTop: 25 }}>
393
+ <pre>{ validateMsg }</pre>
394
+ </p>
395
+ ) : (<div></div>)}
303
396
  <RailsData
304
397
  key='applications_instance'
305
398
  view='app_instance'
306
399
  parameter='hosts'
307
400
  value={JSON.stringify(this.props.hosts)}
308
401
  />
402
+ <RailsData
403
+ key='applications_instance'
404
+ view='app_instance'
405
+ parameter='ansible_vars_all'
406
+ value={JSON.stringify(this.props.ansibleVarsAll)}
407
+ />
309
408
  </span>
310
409
  )};
311
410
  }
@@ -316,9 +415,11 @@ ApplicationInstance.defaultProps = {
316
415
  editMode: false,
317
416
  services: [],
318
417
  hosts: [],
418
+ ansibleVarsAll: [],
319
419
  parametersData: {},
320
420
  columns: [],
321
421
  editParamsOfRowId: null,
422
+ paramEditMode: false,
322
423
  }
323
424
 
324
425
  ApplicationInstance.propTypes = {
@@ -327,6 +428,8 @@ ApplicationInstance.propTypes = {
327
428
  services: PropTypes.array,
328
429
  appDefinition: PropTypes.object,
329
430
  columns: PropTypes.array,
431
+ hosts: PropTypes.array,
432
+ ansibleVarsAll: PropTypes.array,
330
433
  loadApplicationDefinition: PropTypes.func,
331
434
  addApplicationInstanceHost: PropTypes.func,
332
435
  deleteApplicationInstanceHost: PropTypes.func,
@@ -334,9 +437,13 @@ ApplicationInstance.propTypes = {
334
437
  confirmEditApplicationInstanceHost: PropTypes.func,
335
438
  cancelEditApplicationInstanceHost: PropTypes.func,
336
439
  changeEditApplicationInstanceHost: PropTypes.func,
337
- openParameterSelectionModal: PropTypes.func,
338
- closeParameterSelectionModal: PropTypes.func,
440
+ openForemanParameterSelectionModal: PropTypes.func,
441
+ closeForemanParameterSelectionModal: PropTypes.func,
442
+ openAnsibleParameterSelectionModal: PropTypes.func,
443
+ closeAnsibleParameterSelectionModal: PropTypes.func,
444
+ changeParameterSelectionMode: PropTypes.func,
339
445
  parametersData: PropTypes.object,
446
+ paramEditMode: PropTypes.bool,
340
447
  };
341
448
 
342
449
  export default ApplicationInstance;
@@ -22,16 +22,20 @@ import {
22
22
  APPLICATION_INSTANCE_HOST_EDIT_CONFIRM,
23
23
  APPLICATION_INSTANCE_HOST_EDIT_CHANGE,
24
24
  APPLICATION_INSTANCE_HOST_EDIT_CANCEL,
25
- APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_OPEN,
26
- APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_CLOSE,
25
+ APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN,
26
+ APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE,
27
+ APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN,
28
+ APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE,
27
29
  APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_REQUEST,
28
30
  APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_SUCCESS,
29
31
  APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_FAILURE,
32
+ APPLICATION_INSTANCE_CHANGE_PARAMETER_SELECTION_MODE,
30
33
  } from './ApplicationInstanceConstants';
31
34
 
32
35
  export const initApplicationInstance = (
33
36
  appDefinition,
34
37
  hosts,
38
+ ansibleVarsAll,
35
39
  headerFormatter,
36
40
  inlineEditFormatter,
37
41
  inlineEditButtonsFormatter,
@@ -47,7 +51,7 @@ export const initApplicationInstance = (
47
51
  props: {
48
52
  index: 0,
49
53
  style: {
50
- width: '20%'
54
+ width: '30%'
51
55
  }
52
56
  },
53
57
  },
@@ -63,7 +67,7 @@ export const initApplicationInstance = (
63
67
  props: {
64
68
  index: 1,
65
69
  style: {
66
- width: '20%'
70
+ width: '30%'
67
71
  }
68
72
  },
69
73
  },
@@ -107,6 +111,7 @@ export const initApplicationInstance = (
107
111
 
108
112
  initialState.appDefinition = appDefinition;
109
113
  initialState.hosts = hosts;
114
+ initialState.ansibleVarsAll = ansibleVarsAll;
110
115
 
111
116
  dispatch({
112
117
  type: APPLICATION_INSTANCE_INIT,
@@ -184,27 +189,59 @@ export const changeEditApplicationInstanceHost = (value, additionalData) => ({
184
189
  },
185
190
  });
186
191
 
187
- export const openParameterSelectionModal = (additionalData) => dispatch => {
192
+ export const openForemanParameterSelectionModal = (additionalData) => dispatch => {
188
193
  dispatch({
189
- type: APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_OPEN,
194
+ type: APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN,
190
195
  payload: {
191
196
  ...additionalData,
192
197
  }
193
198
  });
194
199
  dispatch(
195
- setModalOpen({ id: 'AppInstanceParamSelection' })
200
+ setModalOpen({ id: 'AppInstanceForemanParamSelection' })
196
201
  );
197
202
  }
198
203
 
199
- export const closeParameterSelectionModal = (additionalData) => dispatch => {
204
+ export const closeForemanParameterSelectionModal = (additionalData) => dispatch => {
200
205
  dispatch({
201
- type: APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_CLOSE,
206
+ type: APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE,
202
207
  payload: {
203
208
  ...additionalData,
204
209
  }
205
210
  });
206
211
 
207
212
  dispatch(
208
- setModalClosed({ id: 'AppInstanceParamSelection' })
213
+ setModalClosed({ id: 'AppInstanceForemanParamSelection' })
209
214
  );
210
215
  }
216
+
217
+ export const openAnsibleParameterSelectionModal = (additionalData) => dispatch => {
218
+ dispatch({
219
+ type: APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN,
220
+ payload: {
221
+ ...additionalData,
222
+ }
223
+ });
224
+ dispatch(
225
+ setModalOpen({ id: 'AppInstanceAnsibleParamSelection' })
226
+ );
227
+ }
228
+
229
+ export const closeAnsibleParameterSelectionModal = (additionalData) => dispatch => {
230
+ dispatch({
231
+ type: APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE,
232
+ payload: {
233
+ ...additionalData,
234
+ }
235
+ });
236
+
237
+ dispatch(
238
+ setModalClosed({ id: 'AppInstanceAnsibleParamSelection' })
239
+ );
240
+ }
241
+
242
+ export const changeParameterSelectionMode = (additionalData) => ({
243
+ type: APPLICATION_INSTANCE_CHANGE_PARAMETER_SELECTION_MODE,
244
+ payload: {
245
+ ...additionalData,
246
+ },
247
+ })