foreman_acd 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -3
  3. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +17 -2
  4. data/app/controllers/foreman_acd/app_definitions_controller.rb +104 -7
  5. data/app/controllers/foreman_acd/app_instances_controller.rb +15 -30
  6. data/app/controllers/foreman_acd/concerns/app_instance_mixins.rb +36 -0
  7. data/app/controllers/ui_acd_controller.rb +38 -1
  8. data/app/lib/actions/foreman_acd/run_configurator.rb +1 -0
  9. data/app/models/concerns/foreman_acd/host_managed_extensions.rb +15 -27
  10. data/app/models/foreman_acd/app_instance.rb +47 -2
  11. data/app/models/foreman_acd/foreman_host.rb +8 -0
  12. data/app/services/foreman_acd/app_deployer.rb +19 -2
  13. data/app/services/foreman_acd/inventory_creator.rb +11 -1
  14. data/app/views/foreman_acd/app_definitions/import.html.erb +20 -1
  15. data/app/views/foreman_acd/app_definitions/index.html.erb +3 -6
  16. data/app/views/foreman_acd/app_instances/index.html.erb +15 -11
  17. data/app/views/foreman_acd/app_instances/report.html.erb +7 -2
  18. data/app/views/ui_acd/host_report.json.rabl +4 -0
  19. data/app/views/ui_acd/report_data.json.rabl +10 -0
  20. data/app/views/ui_acd/validate_hostname.json.rabl +6 -0
  21. data/config/routes.rb +3 -0
  22. data/db/migrate/20210818125913_add_is_existing_host_to_foreman_host.rb +8 -0
  23. data/db/migrate/20210902110645_add_initial_configure_task.rb +8 -0
  24. data/lib/foreman_acd/plugin.rb +6 -6
  25. data/lib/foreman_acd/version.rb +1 -1
  26. data/lib/foreman_acd.rb +27 -9
  27. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +2 -0
  28. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +28 -9
  29. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +6 -0
  30. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +1 -0
  31. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +30 -9
  32. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +3 -0
  33. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +1 -0
  34. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinition.test.js.snap +30 -5
  35. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +1 -1
  36. data/webpack/components/ApplicationDefinition/components/__tests__/__snapshots__/AnsiblePlaybookSelector.test.js.snap +3 -3
  37. data/webpack/components/ApplicationDefinition/index.js +6 -0
  38. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +214 -0
  39. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.scss +1 -0
  40. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +161 -0
  41. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +6 -0
  42. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +79 -0
  43. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +8 -0
  44. data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportConfData_1.fixtures.js +129 -0
  45. data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +29 -0
  46. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +20 -0
  47. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +43 -0
  48. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +29 -0
  49. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +62 -0
  50. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportReducer.test.js.snap +362 -0
  51. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +130 -0
  52. data/webpack/components/ApplicationDefinitionImport/index.js +32 -0
  53. data/webpack/components/ApplicationInstance/ApplicationInstance.js +96 -25
  54. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +112 -6
  55. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +4 -0
  56. data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +15 -0
  57. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +71 -30
  58. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +3 -0
  59. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +2 -0
  60. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +1 -0
  61. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +12 -0
  62. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +97 -7
  63. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +271 -0
  64. data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +1 -0
  65. data/webpack/components/ApplicationInstance/components/ServiceCounter.js +1 -1
  66. data/webpack/components/ApplicationInstance/helper.js +0 -0
  67. data/webpack/components/ApplicationInstance/index.js +6 -0
  68. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +81 -6
  69. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +35 -1
  70. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +3 -0
  71. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +19 -0
  72. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +4 -0
  73. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReport.test.js.snap +1 -124
  74. data/webpack/components/ApplicationInstanceReport/index.js +8 -1
  75. data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +104 -0
  76. data/webpack/components/ExistingHostSelection/ExistingHostSelection.scss +15 -0
  77. data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +71 -0
  78. data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +4 -0
  79. data/webpack/components/ExistingHostSelection/ExistingHostSelectionHelper.js +0 -0
  80. data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +90 -0
  81. data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -0
  82. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +191 -0
  83. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +203 -0
  84. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +19 -0
  85. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionReducer.test.js +59 -0
  86. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +36 -0
  87. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelection.test.js.snap +35 -0
  88. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionReducer.test.js.snap +614 -0
  89. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +27 -0
  90. data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +48 -0
  91. data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +35 -0
  92. data/webpack/components/ExistingHostSelection/components/__tests__/__snapshots__/ServiceSelector.test.js.snap +77 -0
  93. data/webpack/components/ExistingHostSelection/index.js +26 -0
  94. data/webpack/components/ParameterSelection/ParameterSelection.js +98 -1
  95. data/webpack/components/ParameterSelection/ParameterSelection.scss +7 -0
  96. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +36 -2
  97. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +2 -0
  98. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +49 -8
  99. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +1 -0
  100. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +2 -0
  101. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +96 -0
  102. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +5 -0
  103. data/webpack/components/ParameterSelection/index.js +2 -1
  104. data/webpack/components/SyncGitRepo/SyncGitRepo.js +2 -10
  105. data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +1 -2
  106. data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +0 -1
  107. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +1 -0
  108. data/webpack/components/SyncGitRepo/components/FormTextInput.js +1 -1
  109. data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +3 -2
  110. data/webpack/components/common/DeleteTableEntry.js +16 -2
  111. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +38 -0
  112. data/webpack/helper.js +5 -0
  113. data/webpack/index.js +5 -0
  114. data/webpack/js-yaml.js +3874 -0
  115. data/webpack/reducer.js +13 -2
  116. metadata +46 -2
@@ -1,6 +1,11 @@
1
1
  import React, { useState } from 'react'
2
2
  import PropTypes from 'prop-types';
3
3
 
4
+ import {
5
+ Icon,
6
+ Spinner,
7
+ } from 'patternfly-react';
8
+
4
9
  import {
5
10
  VerticalTabs,
6
11
  } from 'patternfly-react-extensions';
@@ -20,14 +25,42 @@ class ApplicationInstanceReport extends React.Component {
20
25
 
21
26
  componentDidMount() {
22
27
  const {
23
- data: { hosts, mode },
28
+ data: { hosts, deploymentState, initialConfigureState, initialConfigureJobUrl },
24
29
  initApplicationInstanceReport,
25
30
  setActiveHost,
26
31
  } = this.props;
27
32
 
28
- initApplicationInstanceReport(hosts);
33
+ initApplicationInstanceReport(hosts, deploymentState, initialConfigureState, initialConfigureJobUrl);
34
+ this.reloadReportData();
29
35
  };
30
36
 
37
+ reloadReportData() {
38
+ const {
39
+ data: { appInstanceId, reportDataUrl },
40
+ deploymentState, initialConfigureState,
41
+ loadReportData,
42
+ } = this.props;
43
+
44
+ // if both states are unknown, it means, that the component was just loaded. try again after a short timeout.
45
+ if (deploymentState == 'unknown' && initialConfigureState == 'unknown') {
46
+ setTimeout(() => {
47
+ this.reloadReportData();
48
+ }, 1000);
49
+
50
+ return;
51
+ }
52
+
53
+ if ((deploymentState != 'new' && deploymentState != 'finished' && deploymentState != 'failed') ||
54
+ (initialConfigureState == 'unconfigured' || initialConfigureState == 'scheduled' || initialConfigureState == 'pending')) {
55
+
56
+ loadReportData(reportDataUrl, appInstanceId);
57
+
58
+ setTimeout(() => {
59
+ this.reloadReportData();
60
+ }, 5000);
61
+ }
62
+ }
63
+
31
64
  isActive(id) {
32
65
  return (this.props.activeHostId === id);
33
66
  }
@@ -66,13 +99,20 @@ class ApplicationInstanceReport extends React.Component {
66
99
  </div>
67
100
  )
68
101
  } else {
102
+ const already_deployed_msg = __("Already existing host which was added to the application instance");
69
103
  return (
70
104
  <div>
71
105
  <span>Host: <a href={ host['hostUrl'] }>{ host['name'] }</a></span>
72
106
  <span>&nbsp;|&nbsp;</span>
73
107
  <span>State: { host['build'] == true ? "in Build" : "Deployed" }</span>
74
108
  <span>&nbsp;|&nbsp;</span>
75
- <span>Power Status: <PowerStatus key={ "power_status_"+ host['id'] } data={{ id: host['id'], url: host['powerStatusUrl'] }} /></span>
109
+ <span>Power Status: <PowerStatus key={ "power_status_"+ host['id'] } id={ host['id'] } url={ host['powerStatusUrl'] } data={{ id: host['id'], url: host['powerStatusUrl'] }} /></span>
110
+ {host['isExistingHost'] ? (
111
+ <span>
112
+ &nbsp;|&nbsp; Existing host &nbsp;
113
+ <Icon style={{marginRight: 8, marginLeft: 2}} type="pf" name="info" title={already_deployed_msg} />
114
+ </span>
115
+ ) : (<span></span>)}
76
116
  </div>
77
117
  )
78
118
  }
@@ -80,14 +120,22 @@ class ApplicationInstanceReport extends React.Component {
80
120
 
81
121
  render() {
82
122
  const {
83
- data: { hosts, mode, appInstanceName, deployTaskUrl, configureJobUrl },
84
- activeHostId,
123
+ data: { appInstanceId, appInstanceName, deployTaskUrl, configureJobUrl, reportDataUrl },
124
+ activeHostId, hosts,
125
+ deploymentState,
126
+ initialConfigureState, initialConfigureJobUrl, showInitialConfigureJob,
127
+ loadReportData,
85
128
  } = this.props;
86
129
 
87
130
  let tabs = [];
88
131
  let reportStatus = undefined;
89
132
  let report = undefined;
90
133
 
134
+ // This handles the first call to render() in which the state hosts is always empty
135
+ if (hosts.length == 0) {
136
+ return (<span>No host</span>);
137
+ }
138
+
91
139
  tabs = this.collectLastReportData(hosts);
92
140
  reportStatus = this.lastReportStatus(hosts[activeHostId]);
93
141
 
@@ -98,14 +146,32 @@ class ApplicationInstanceReport extends React.Component {
98
146
  return (
99
147
  <span>
100
148
  <div className="deploy_status">
149
+ <div>
150
+ <div className="deploy_status_head">Host deployment state</div>
151
+ <div className="deploy_status_content">
152
+ { (deploymentState != 'new' && deploymentState != 'finished' && deploymentState != 'failed') ? (<span><Spinner loading size='sm' /> &nbsp;</span>) : (<span></span>) }
153
+ { deploymentState }
154
+ </div>
155
+ </div>
101
156
  <div>
102
157
  <div className="deploy_status_head">Deployment task</div>
103
158
  <div className="deploy_status_content"><a href={ deployTaskUrl } >Last deployment task</a></div>
104
159
  </div>
160
+ { (showInitialConfigureJob == true) ? (
161
+ <div>
162
+ <div className="deploy_status_head">Configuration job</div>
163
+ <div className="deploy_status_content">
164
+ { (initialConfigureState == 'scheduled' || initialConfigureState == 'pending') ? (<span><Spinner loading size='sm' /> &nbsp;</span>) : (<span></span>) }
165
+ { (initialConfigureState != 'unconfigured' && initialConfigureState != 'scheduled') ? (<a href={ initialConfigureJobUrl }>Configuration job</a>) : (<span></span>) }
166
+ { (initialConfigureState != 'unconfigured') ? (<span>&nbsp; State: { initialConfigureState }</span>) : (<span></span>) }
167
+ </div>
168
+ </div>
169
+ ) : (
105
170
  <div>
106
171
  <div className="deploy_status_head">Configuration job</div>
107
172
  <div className="deploy_status_content"><a href={ configureJobUrl }>Configuration jobs</a></div>
108
173
  </div>
174
+ ) }
109
175
  </div>
110
176
  <div className="deploy_report_hosts">
111
177
  Hosts
@@ -131,6 +197,10 @@ ApplicationInstanceReport.defaultProps = {
131
197
  hosts: [],
132
198
  report: [],
133
199
  activeHostId: 0,
200
+ deploymentState: 'unknown',
201
+ initialConfigureState: 'unknown',
202
+ initialConfigureJobUrl: '',
203
+ showInitialConfigureJob: false,
134
204
  }
135
205
 
136
206
  ApplicationInstanceReport.propTypes = {
@@ -138,11 +208,16 @@ ApplicationInstanceReport.propTypes = {
138
208
  appInstanceName: PropTypes.string,
139
209
  deployTaskUrl: PropTypes.string,
140
210
  configureJobUrl: PropTypes.string,
211
+ deploymentState: PropTypes.string,
212
+ initialConfigureState: PropTypes.string,
213
+ initialConfigureJobUrl: PropTypes.string,
214
+ showInitialConfigureJob: PropTypes.bool,
141
215
  hosts: PropTypes.array,
216
+ deploymentState: PropTypes.string,
142
217
  report: PropTypes.array,
143
218
  setActiveHost: PropTypes.func,
219
+ loadReportData: PropTypes.func,
144
220
  activeHostId: PropTypes.number,
145
-
146
221
  };
147
222
 
148
223
  export default ApplicationInstanceReport;
@@ -13,14 +13,28 @@ import {
13
13
  import {
14
14
  APPLICATION_INSTANCE_REPORT_INIT,
15
15
  APPLICATION_INSTANCE_REPORT_SET_ACTIVE_HOST,
16
+ APPLICATION_INSTANCE_REPORT_LOAD_REPORT_REQUEST,
17
+ APPLICATION_INSTANCE_REPORT_LOAD_REPORT_SUCCESS,
18
+ APPLICATION_INSTANCE_REPORT_LOAD_REPORT_FAILURE,
16
19
  } from './ApplicationInstanceReportConstants';
17
20
 
18
21
  export const initApplicationInstanceReport = (
19
- hosts,
22
+ hosts, deploymentState, initialConfigureState, initialConfigureJobUrl,
20
23
  ) => dispatch => {
21
24
  const initialState = {};
22
25
 
23
26
  initialState.hosts = hosts;
27
+ initialState.deploymentState = deploymentState;
28
+ initialState.initialConfigureState = initialConfigureState;
29
+ initialState.initialConfigureJobUrl = initialConfigureJobUrl;
30
+
31
+ // Decide if it should show only the initial Configure job state + URL or
32
+ // the URL to all configuration jobs
33
+ if (initialConfigureState == 'unconfigured') {
34
+ initialState.showInitialConfigureJob = true;
35
+ } else {
36
+ initialState.showInitialConfigureJob = false;
37
+ }
24
38
 
25
39
  dispatch({
26
40
  type: APPLICATION_INSTANCE_REPORT_INIT,
@@ -28,6 +42,26 @@ export const initApplicationInstanceReport = (
28
42
  });
29
43
  };
30
44
 
45
+ export const loadReportData = (
46
+ reportDataUrl,
47
+ appInstanceId,
48
+ ) => dispatch => {
49
+ dispatch({ type: APPLICATION_INSTANCE_REPORT_LOAD_REPORT_REQUEST });
50
+
51
+ const baseUrl = reportDataUrl;
52
+ const realUrl = baseUrl.replace("__id__", appInstanceId);
53
+
54
+ return api
55
+ .get(realUrl, {}, {})
56
+ .then(({ data }) =>
57
+ dispatch({
58
+ type: APPLICATION_INSTANCE_REPORT_LOAD_REPORT_SUCCESS,
59
+ payload: { ...data }
60
+ })
61
+ )
62
+ .catch(error => dispatch(errorHandler(APPLICATION_INSTANCE_REPORT_LOAD_REPORT_FAILURE, error)));
63
+ };
64
+
31
65
  const errorHandler = (msg, err) => {
32
66
  const error = {
33
67
  errorMsg: 'Failed to fetch data from server.',
@@ -1,2 +1,5 @@
1
1
  export const APPLICATION_INSTANCE_REPORT_INIT = 'APPLICATION_INSTANCE_REPORT_INIT';
2
2
  export const APPLICATION_INSTANCE_REPORT_SET_ACTIVE_HOST = 'APPLICATION_INSTANCE_REPORT_SET_ACTIVE_HOST';
3
+ export const APPLICATION_INSTANCE_REPORT_LOAD_REPORT_REQUEST = 'APPLICATION_INSTANCE_REPORT_LOAD_REPORT_REQUEST';
4
+ export const APPLICATION_INSTANCE_REPORT_LOAD_REPORT_SUCCESS = 'APPLICATION_INSTANCE_REPORT_LOAD_REPORT_SUCCESS';
5
+ export const APPLICATION_INSTANCE_REPORT_LOAD_REPORT_FAILURE = 'APPLICATION_INSTANCE_REPORT_LOAD_REPORT_FAILURE';
@@ -9,6 +9,9 @@ import {
9
9
  import {
10
10
  APPLICATION_INSTANCE_REPORT_INIT,
11
11
  APPLICATION_INSTANCE_REPORT_SET_ACTIVE_HOST,
12
+ APPLICATION_INSTANCE_REPORT_LOAD_REPORT_REQUEST,
13
+ APPLICATION_INSTANCE_REPORT_LOAD_REPORT_SUCCESS,
14
+ APPLICATION_INSTANCE_REPORT_LOAD_REPORT_FAILURE,
12
15
  } from './ApplicationInstanceReportConstants';
13
16
 
14
17
  export const initialState = Immutable({
@@ -29,6 +32,22 @@ const applicationInstanceReport = (state = initialState, action) => {
29
32
  activeHostId: payload.activeHostId,
30
33
  })
31
34
  }
35
+ case APPLICATION_INSTANCE_REPORT_LOAD_REPORT_REQUEST: {
36
+ // Nothing to do
37
+ return state;
38
+ }
39
+ case APPLICATION_INSTANCE_REPORT_LOAD_REPORT_SUCCESS: {
40
+ return state.merge({
41
+ deploymentState: payload.deploymentState,
42
+ initialConfigureState: payload.initialConfigureState,
43
+ initialConfigureJobUrl: payload.initialConfigureJobUrl,
44
+ hosts: payload.hosts,
45
+ });
46
+ }
47
+ case APPLICATION_INSTANCE_REPORT_LOAD_REPORT_FAILURE: {
48
+ console.log("Error while loading report data: "+ payload.error);
49
+ return state.merge({ error: payload.error});
50
+ }
32
51
  default: {
33
52
  return state;
34
53
  }
@@ -2,3 +2,7 @@ const applicationInstanceReport = state => state.foremanAcd.applicationInstanceR
2
2
 
3
3
  export const selectHosts = state => applicationInstanceReport(state).hosts;
4
4
  export const selectActiveHostId = state => applicationInstanceReport(state).activeHostId;
5
+ export const selectDeploymentState = state => applicationInstanceReport(state).deploymentState;
6
+ export const selectInitialConfigureState = state => applicationInstanceReport(state).initialConfigureState;
7
+ export const selectInitialConfigureJobUrl = state => applicationInstanceReport(state).initialConfigureJobUrl;
8
+ export const selectShowInitialConfigureJob = state => applicationInstanceReport(state).showInitialConfigureJob;
@@ -2,129 +2,6 @@
2
2
 
3
3
  exports[`ApplicationInstanceReport should render application instance report 1`] = `
4
4
  <span>
5
- <div
6
- className="deploy_status"
7
- >
8
- <div>
9
- <div
10
- className="deploy_status_head"
11
- >
12
- Deployment task
13
- </div>
14
- <div
15
- className="deploy_status_content"
16
- >
17
- <a
18
- href="deploy/task/url"
19
- >
20
- Last deployment task
21
- </a>
22
- </div>
23
- </div>
24
- <div>
25
- <div
26
- className="deploy_status_head"
27
- >
28
- Configuration job
29
- </div>
30
- <div
31
- className="deploy_status_content"
32
- >
33
- <a
34
- href="configure/job/url"
35
- >
36
- Configuration jobs
37
- </a>
38
- </div>
39
- </div>
40
- </div>
41
- <div
42
- className="deploy_report_hosts"
43
- >
44
- Hosts
45
- <VerticalTabs
46
- activeTab={false}
47
- className=""
48
- id="vertical_tabs"
49
- restrictTabs={false}
50
- >
51
- <VerticalTabsTab
52
- active={true}
53
- className=""
54
- hasActiveDescendant={false}
55
- id={0}
56
- key="vt_tab_0"
57
- onActivate={[Function]}
58
- shown={false}
59
- title="great-web-app-db-1"
60
- wrapStyle="nowrap"
61
- />
62
- <VerticalTabsTab
63
- active={false}
64
- className=""
65
- hasActiveDescendant={false}
66
- id={1}
67
- key="vt_tab_1"
68
- onActivate={[Function]}
69
- shown={false}
70
- title="great-web-app-web-1"
71
- wrapStyle="nowrap"
72
- />
73
- <VerticalTabsTab
74
- active={false}
75
- className=""
76
- hasActiveDescendant={false}
77
- id={2}
78
- key="vt_tab_2"
79
- onActivate={[Function]}
80
- shown={false}
81
- title="great-web-app-web-2"
82
- wrapStyle="nowrap"
83
- />
84
- </VerticalTabs>
85
- </div>
86
- <div
87
- className="deploy_report_status"
88
- >
89
- <div>
90
- <span>
91
- Host:
92
- <a
93
- href="/hosts/great-web-app-db-1.deploy3.dev.atix"
94
- >
95
- great-web-app-db-1
96
- </a>
97
- </span>
98
- <span>
99
-  | 
100
- </span>
101
- <span>
102
- State:
103
- Deployed
104
- </span>
105
- <span>
106
-  | 
107
- </span>
108
- <span>
109
- Power Status:
110
- <Component
111
- data={
112
- Object {
113
- "id": 8,
114
- "url": "/api/v2/hosts/great-web-app-db-1.deploy3.dev.atix/power",
115
- }
116
- }
117
- key="power_status_8"
118
- />
119
- </span>
120
- </div>
121
- </div>
122
- <div
123
- className="deploy_report_tasks"
124
- >
125
- <ReportViewer
126
- report={Array []}
127
- />
128
- </div>
5
+ No host
129
6
  </span>
130
7
  `;
@@ -8,11 +8,19 @@ import * as ApplicationInstanceReportActions from './ApplicationInstanceReportAc
8
8
  import {
9
9
  selectHosts,
10
10
  selectActiveHostId,
11
+ selectDeploymentState,
12
+ selectInitialConfigureState,
13
+ selectInitialConfigureJobUrl,
14
+ selectShowInitialConfigureJob,
11
15
  } from './ApplicationInstanceReportSelectors';
12
16
 
13
17
  const mapStateToProps = state => ({
14
18
  hosts: selectHosts(state),
15
19
  activeHostId: selectActiveHostId(state),
20
+ deploymentState: selectDeploymentState(state),
21
+ initialConfigureState: selectInitialConfigureState(state),
22
+ initialConfigureJobUrl: selectInitialConfigureJobUrl(state),
23
+ showInitialConfigureJob: selectShowInitialConfigureJob(state),
16
24
  });
17
25
 
18
26
  const mapDispatchToProps = dispatch =>
@@ -22,4 +30,3 @@ export default connect(
22
30
  mapStateToProps,
23
31
  mapDispatchToProps
24
32
  )(ApplicationInstanceReport);
25
-
@@ -0,0 +1,104 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { orderBy } from 'lodash';
4
+ import ServiceSelector from './components/ServiceSelector';
5
+ import { arrayToObject } from '../../helper';
6
+
7
+ import {
8
+ cloneDeep,
9
+ } from 'lodash';
10
+
11
+ import {
12
+ Icon,
13
+ Button,
14
+ DualListControlled,
15
+ } from 'patternfly-react';
16
+
17
+ class ExistingHostSelection extends React.Component {
18
+
19
+ constructor(props) {
20
+ super(props);
21
+ }
22
+
23
+ componentDidMount() {
24
+ const {
25
+ location,
26
+ organization,
27
+ services,
28
+ initExistingHostSelection,
29
+ allHosts,
30
+ } = this.props;
31
+
32
+ initExistingHostSelection(allHosts);
33
+ }
34
+
35
+ render() {
36
+ const {
37
+ location,
38
+ organization,
39
+ services,
40
+ serviceId,
41
+ availableHosts,
42
+ alreadyUsedHosts,
43
+ loadHostsOfHostgroup,
44
+ hostSelectionChanged,
45
+ } = this.props;
46
+
47
+ const serviceList = arrayToObject(services, "id", "name");
48
+ const load_hostgroup_url = "/api/v2/hostgroups/__hostgroup_id__/hosts"
49
+
50
+ return(
51
+ <div>
52
+ <div className="row">
53
+ <ServiceSelector
54
+ label="Service"
55
+ hidden={ false }
56
+ selectValue={ this.props.serviceId ? this.props.serviceId.toString() : '0'}
57
+ options={ serviceList }
58
+ onChange={ loadHostsOfHostgroup }
59
+ additionalData={{ url: load_hostgroup_url, services: services }} />
60
+ </div>
61
+ <div className="row">
62
+ <label className="col-md-2 control-label">{ __("Hosts") }</label>
63
+ {this.props.serviceId != undefined ? (
64
+ <div className="col-md-6">
65
+ <DualListControlled
66
+ onChange={ hostSelectionChanged }
67
+ left={{
68
+ items: cloneDeep(availableHosts),
69
+ }}
70
+ right={{
71
+ items: cloneDeep(alreadyUsedHosts),
72
+ }}
73
+ allowHiddenInputs={false}
74
+ />
75
+ </div>) : (<span>{ __("Please select service first.") }</span>)}
76
+ </div>
77
+ </div>
78
+ );
79
+ }
80
+ }
81
+
82
+ ExistingHostSelection.defaultProps = {
83
+ serviceId: undefined,
84
+ hostsInHostgroup: {},
85
+ availableHosts: [],
86
+ alreadyUsedHosts: [],
87
+ selectedHosts: [],
88
+ };
89
+
90
+ ExistingHostSelection.propTypes = {
91
+ location: PropTypes.string.isRequired,
92
+ organization: PropTypes.string.isRequired,
93
+ services: PropTypes.array.isRequired,
94
+ initExistingHostSelection: PropTypes.func,
95
+ serviceId: PropTypes.number,
96
+ hostsInHostgroup: PropTypes.object,
97
+ availableHosts: PropTypes.array,
98
+ alreadyUsedHosts: PropTypes.array,
99
+ selectedHosts: PropTypes.array,
100
+ loadHostsOfHostgroup: PropTypes.func,
101
+ hostSelectionChanged: PropTypes.func,
102
+ };
103
+
104
+ export default ExistingHostSelection;
@@ -0,0 +1,15 @@
1
+ @import '~@theforeman/vendor/scss/variables';
2
+
3
+ .add_existing_hosts_modal {
4
+ margin-top: 0;
5
+ margin-bottom: 0;
6
+ height: 100%;
7
+ width: 80%;
8
+ max-width: none !important;
9
+ }
10
+
11
+ .row {
12
+ margin-left: 0;
13
+ margin-right: 0;
14
+ margin-bottom: 20px;
15
+ }
@@ -0,0 +1,71 @@
1
+ import React from 'react';
2
+ import * as sort from 'sortabular';
3
+ import { translate as __ } from 'foremanReact/common/I18n';
4
+
5
+ import api from 'foremanReact/API';
6
+
7
+ import {
8
+ propsToSnakeCase,
9
+ propsToCamelCase,
10
+ } from 'foremanReact/common/helpers';
11
+
12
+ import {
13
+ EXISTING_HOST_SELECTION_INIT,
14
+ EXISTING_HOST_SELECTION_LOAD_HOSTS_SUCCESS,
15
+ EXISTING_HOST_SELECTION_LOAD_HOSTS_FAILURE,
16
+ EXISTING_HOST_SELECTION_SELECTION_CHANGED,
17
+ } from './ExistingHostSelectionConstants';
18
+
19
+ export const initExistingHostSelection = (
20
+ allHosts,
21
+ ) => dispatch => {
22
+ const initialState = {};
23
+
24
+ initialState.alreadyUsedHosts = undefined;
25
+ initialState.serviceId = undefined;
26
+ initialState.selectedHosts = [];
27
+ initialState.hostsInHostgroup = {};
28
+ initialState.allHosts = allHosts;
29
+
30
+ dispatch({
31
+ type: EXISTING_HOST_SELECTION_INIT,
32
+ payload: initialState,
33
+ });
34
+ }
35
+
36
+ export const loadHostsOfHostgroup = (
37
+ serviceId,
38
+ additionalData
39
+ ) => dispatch => {
40
+
41
+ const selService = additionalData.services.filter(s => (s.id == serviceId))[0];
42
+ const realUrl = additionalData.url.replace("__hostgroup_id__", selService.hostgroup);
43
+
44
+ return api
45
+ .get(realUrl, {}, {})
46
+ .then(({ data }) =>
47
+ dispatch({
48
+ type: EXISTING_HOST_SELECTION_LOAD_HOSTS_SUCCESS,
49
+ payload: {
50
+ hosts: data.results,
51
+ serviceId: parseInt(serviceId),
52
+ }
53
+ })
54
+ )
55
+ .catch(error => dispatch(errorHandler(EXISTING_HOST_SELECTION_LOAD_HOSTS_FAILURE, error)));
56
+ };
57
+
58
+ export const hostSelectionChanged = ({ left, right }) => ({
59
+ type: EXISTING_HOST_SELECTION_SELECTION_CHANGED,
60
+ payload: {
61
+ selection: right.items,
62
+ }
63
+ });
64
+
65
+ const errorHandler = (msg, err) => {
66
+ const error = {
67
+ errorMsg: __('Failed to fetch data from server.'),
68
+ statusText: err,
69
+ };
70
+ return { type: msg, payload: { error } };
71
+ };
@@ -0,0 +1,4 @@
1
+ export const EXISTING_HOST_SELECTION_INIT = 'EXISTING_HOST_SELECTION_INIT';
2
+ export const EXISTING_HOST_SELECTION_LOAD_HOSTS_SUCCESS = 'EXISTING_HOST_SELECTION_LOAD_HOSTS_SUCCESS';
3
+ export const EXISTING_HOST_SELECTION_LOAD_HOSTS_FAILURE = 'EXISTING_HOST_SELECTION_LOAD_HOSTS_FAILURE';
4
+ export const EXISTING_HOST_SELECTION_SELECTION_CHANGED = 'EXISTING_HOST_SELECTION_SELECTION_CHANGED';