foreman_acd 0.9.7 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/lib/foreman_acd/version.rb +1 -1
  3. data/package.json +5 -3
  4. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +210 -121
  5. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +79 -91
  6. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +30 -15
  7. data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +15 -15
  8. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +96 -63
  9. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +22 -11
  10. data/webpack/components/ApplicationDefinition/__fixtures__/{applicationDefinitionConfData_1.fixtures.js → applicationDefinitionConfData1.fixtures.js} +77 -105
  11. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +49 -29
  12. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +4 -4
  13. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionHelper.test.js +16 -0
  14. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +0 -5
  15. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +25 -25
  16. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +9 -1
  17. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +11 -11
  18. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +30 -25
  19. data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +3 -3
  20. data/webpack/components/ApplicationDefinition/index.js +0 -1
  21. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +91 -105
  22. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +59 -84
  23. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +12 -6
  24. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +21 -27
  25. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +14 -7
  26. data/webpack/components/ApplicationDefinitionImport/__fixtures__/{applicationDefinitionImportConfData_1.fixtures.js → applicationDefinitionImportConfData1.fixtures.js} +32 -40
  27. data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +14 -16
  28. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +38 -8
  29. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +0 -2
  30. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +9 -9
  31. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +116 -2
  32. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +3 -3
  33. data/webpack/components/ApplicationInstance/ApplicationInstance.js +344 -193
  34. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +92 -105
  35. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +34 -17
  36. data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +4 -7
  37. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +114 -74
  38. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +18 -9
  39. data/webpack/components/ApplicationInstance/__fixtures__/{applicationInstanceConfData_1.fixtures.js → applicationInstanceConfData1.fixtures.js} +68 -86
  40. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +24 -32
  41. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +75 -10
  42. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +0 -8
  43. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +27 -27
  44. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +606 -2
  45. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +12 -12
  46. data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +32 -25
  47. data/webpack/components/ApplicationInstance/components/Service.js +7 -18
  48. data/webpack/components/ApplicationInstance/components/ServiceCounter.js +25 -18
  49. data/webpack/components/ApplicationInstance/index.js +0 -1
  50. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +167 -110
  51. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +20 -25
  52. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +10 -5
  53. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +9 -12
  54. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +12 -6
  55. data/webpack/components/ApplicationInstanceReport/__fixtures__/{applicationInstanceReportData_1.fixtures.js → applicationInstanceReportData1.fixtures.js} +154 -101
  56. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +3 -10
  57. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +28 -22
  58. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +5 -7
  59. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +0 -1
  60. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +2 -2
  61. data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +9 -5
  62. data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +1 -3
  63. data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +35 -56
  64. data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +21 -28
  65. data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +6 -3
  66. data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +16 -19
  67. data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -4
  68. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData1.fixtures.js +187 -0
  69. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +13 -24
  70. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +3 -2
  71. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +11 -14
  72. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +5 -5
  73. data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +31 -25
  74. data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +3 -9
  75. data/webpack/components/ParameterSelection/ParameterSelection.js +258 -174
  76. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +110 -100
  77. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +22 -11
  78. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +13 -11
  79. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +63 -49
  80. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +10 -5
  81. data/webpack/components/ParameterSelection/__fixtures__/{parameterSelectionData_1.fixtures.js → parameterSelectionData1.fixtures.js} +67 -104
  82. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +22 -26
  83. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +50 -36
  84. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionHelper.test.js +76 -0
  85. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +0 -2
  86. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +23 -25
  87. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +100 -0
  88. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +99 -112
  89. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +18 -19
  90. data/webpack/components/ParameterSelection/index.js +1 -4
  91. data/webpack/components/SyncGitRepo/SyncGitRepo.js +124 -117
  92. data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +64 -74
  93. data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +17 -17
  94. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData1.fixtures.js +7 -0
  95. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +10 -18
  96. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +80 -6
  97. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +9 -11
  98. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +192 -1
  99. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +4 -4
  100. data/webpack/components/SyncGitRepo/components/FormTextInput.js +26 -21
  101. data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +29 -24
  102. data/webpack/components/SyncGitRepo/index.js +2 -5
  103. data/webpack/components/common/AddTableEntry.js +3 -10
  104. data/webpack/components/common/DeleteTableEntry.js +7 -15
  105. data/webpack/components/common/EditTableEntry.js +7 -7
  106. data/webpack/components/common/ExtSelect.js +12 -8
  107. data/webpack/components/common/ExtTextInput.js +12 -7
  108. data/webpack/components/common/LockTableEntry.js +6 -6
  109. data/webpack/components/common/RailsData.js +6 -16
  110. data/webpack/components/common/__tests__/ExtSelect.test.js +2 -2
  111. data/webpack/components/common/__tests__/RailsData.test.js +0 -2
  112. data/webpack/global_test_setup.js +11 -0
  113. data/webpack/helper.js +10 -21
  114. data/webpack/helper.test.js +17 -29
  115. data/webpack/index.js +25 -7
  116. data/webpack/js-yaml.js +1563 -1135
  117. data/webpack/reducer.js +52 -27
  118. metadata +13 -11
  119. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +0 -191
  120. data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +0 -153
  121. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +0 -7
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import ExtSelect from '../../common/ExtSelect';
4
- import RailsData from '../../common/RailsData'
4
+ import RailsData from '../../common/RailsData';
5
5
 
6
- const AppDefinitionSelector= ({
6
+ const AppDefinitionSelector = ({
7
7
  label,
8
8
  hidden,
9
9
  editable,
@@ -12,33 +12,32 @@ const AppDefinitionSelector= ({
12
12
  onChange,
13
13
  options,
14
14
  additionalData,
15
- }) =>{
16
- return (
17
- <div className="form-group">
18
- <label className="col-md-2 control-label">{label}</label>
19
- <div className="col-md-4">
20
- <ExtSelect
21
- hidden={hidden}
22
- editable={editable}
23
- viewText={viewText}
24
- selectValue={selectValue}
25
- onChange={onChange}
26
- options={options}
27
- additionalData={additionalData}
28
- />
29
- <RailsData
30
- key='app_instance_id'
31
- view='app_instance'
32
- parameter='app_definition_id'
33
- value={selectValue}
34
- />
35
- </div>
15
+ }) => (
16
+ <div className="form-group">
17
+ <label className="col-md-2 control-label">{label}</label>
18
+ <div className="col-md-4">
19
+ <ExtSelect
20
+ hidden={hidden}
21
+ editable={editable}
22
+ viewText={viewText}
23
+ selectValue={selectValue}
24
+ onChange={onChange}
25
+ options={options}
26
+ additionalData={additionalData}
27
+ />
28
+ <RailsData
29
+ key="app_instance_id"
30
+ view="app_instance"
31
+ parameter="app_definition_id"
32
+ value={selectValue}
33
+ />
36
34
  </div>
37
- );
38
- };
35
+ </div>
36
+ );
39
37
 
40
38
  AppDefinitionSelector.propTypes = {
41
39
  label: PropTypes.string.isRequired,
40
+ hidden: PropTypes.bool,
42
41
  editable: PropTypes.bool.isRequired,
43
42
  viewText: PropTypes.string,
44
43
  selectValue: PropTypes.string,
@@ -47,4 +46,12 @@ AppDefinitionSelector.propTypes = {
47
46
  additionalData: PropTypes.object,
48
47
  };
49
48
 
49
+ AppDefinitionSelector.defaultProps = {
50
+ hidden: false,
51
+ viewText: undefined,
52
+ selectValue: undefined,
53
+ options: undefined,
54
+ additionalData: undefined,
55
+ };
56
+
50
57
  export default AppDefinitionSelector;
@@ -1,24 +1,13 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
+ import { translate as __ } from 'foremanReact/common/I18n';
3
4
 
4
- const Service= ({
5
- name,
6
- currentCount,
7
- minCount,
8
- maxCount,
9
- }) =>{
10
- return (
11
- <div>
12
- <label>{name}:</label> {currentCount} ({__("Min/Max")}: {minCount}/{maxCount})
13
- </div>
14
- );
15
- };
16
-
17
- Service.defaultProps = {
18
- minCount: 0,
19
- maxCount: 0,
20
- currentCount: 0,
21
- };
5
+ const Service = ({ name, currentCount, minCount, maxCount }) => (
6
+ <div>
7
+ <label>{name}:</label> {currentCount} ({__('Min/Max')}: {minCount}/
8
+ {maxCount})
9
+ </div>
10
+ );
22
11
 
23
12
  Service.propTypes = {
24
13
  name: PropTypes.string.isRequired,
@@ -1,37 +1,44 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Service from './Service';
4
- import { arrayToObjectObj } from '../../../helper';
5
- import { cloneDeep } from 'lodash';
6
4
 
7
- const ServiceCounter= ({
8
- title,
9
- serviceList,
10
- }) =>{
11
- if (serviceList == undefined || serviceList.length == 0) {
5
+ const ServiceCounter = ({ title, serviceList }) => {
6
+ if (serviceList === undefined || serviceList.length === 0) {
12
7
  return null;
13
8
  }
14
- const services = cloneDeep(arrayToObjectObj(serviceList, "id"));
9
+ const services = serviceList.map(service => (
10
+ <Service
11
+ key={service.id}
12
+ name={service.name}
13
+ currentCount={service.currentCount}
14
+ minCount={Number(service.minCount)}
15
+ maxCount={Number(service.maxCount)}
16
+ />
17
+ ));
15
18
 
16
19
  return (
17
20
  <div>
18
21
  <label className="service-counter-title">{title}</label>
19
- {Object.keys(services).map(key => (
20
- <Service
21
- key={services[key].id}
22
- name={services[key].name}
23
- currentCount={services[key].currentCount}
24
- minCount={Number(services[key].minCount)}
25
- maxCount={Number(services[key].maxCount)}
26
- />)
27
- )}
22
+ {services}
28
23
  </div>
29
24
  );
30
25
  };
31
26
 
32
27
  ServiceCounter.propTypes = {
33
28
  title: PropTypes.string.isRequired,
34
- serviceList: PropTypes.array,
29
+ serviceList: PropTypes.arrayOf(
30
+ PropTypes.shape({
31
+ id: PropTypes.number.isRequired,
32
+ name: PropTypes.string.isRequired,
33
+ currentCount: PropTypes.number.isRequired,
34
+ minCount: PropTypes.string.isRequired,
35
+ maxCount: PropTypes.string.isRequired,
36
+ })
37
+ ),
38
+ };
39
+
40
+ ServiceCounter.defaultProps = {
41
+ serviceList: undefined,
35
42
  };
36
43
 
37
44
  export default ServiceCounter;
@@ -42,4 +42,3 @@ export default connect(
42
42
  mapStateToProps,
43
43
  mapDispatchToProps
44
44
  )(ApplicationInstance);
45
-
@@ -1,48 +1,46 @@
1
- import React, { useState } from 'react'
1
+ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
 
4
- import {
5
- Icon,
6
- Spinner,
7
- } from 'patternfly-react';
4
+ import { Icon, Spinner } from 'patternfly-react';
8
5
 
9
- import {
10
- VerticalTabs,
11
- } from 'patternfly-react-extensions';
6
+ import { VerticalTabs } from 'patternfly-react-extensions';
12
7
 
13
- import {
14
- translate as __
15
- } from 'foremanReact/common/I18n';
8
+ import { translate as __ } from 'foremanReact/common/I18n';
16
9
 
17
10
  import PowerStatus from 'foremanReact/components/hosts/powerStatus';
18
11
  import ReportViewer from './components/ReportViewer';
19
12
 
20
13
  class ApplicationInstanceReport extends React.Component {
21
-
22
- constructor(props) {
23
- super(props);
24
- }
25
-
26
14
  componentDidMount() {
27
15
  const {
28
- data: { hosts, deploymentState, initialConfigureState, initialConfigureJobUrl },
16
+ data: {
17
+ hosts,
18
+ deploymentState,
19
+ initialConfigureState,
20
+ initialConfigureJobUrl,
21
+ },
29
22
  initApplicationInstanceReport,
30
- setActiveHost,
31
23
  } = this.props;
32
24
 
33
- initApplicationInstanceReport(hosts, deploymentState, initialConfigureState, initialConfigureJobUrl);
25
+ initApplicationInstanceReport(
26
+ hosts,
27
+ deploymentState,
28
+ initialConfigureState,
29
+ initialConfigureJobUrl
30
+ );
34
31
  this.reloadReportData();
35
- };
32
+ }
36
33
 
37
34
  reloadReportData() {
38
35
  const {
39
36
  data: { appInstanceId, reportDataUrl },
40
- deploymentState, initialConfigureState,
37
+ deploymentState,
38
+ initialConfigureState,
41
39
  loadReportData,
42
40
  } = this.props;
43
41
 
44
42
  // 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') {
43
+ if (deploymentState === 'unknown' && initialConfigureState === 'unknown') {
46
44
  setTimeout(() => {
47
45
  this.reloadReportData();
48
46
  }, 1000);
@@ -50,9 +48,14 @@ class ApplicationInstanceReport extends React.Component {
50
48
  return;
51
49
  }
52
50
 
53
- if ((deploymentState != 'new' && deploymentState != 'finished' && deploymentState != 'failed') ||
54
- (initialConfigureState == 'unconfigured' || initialConfigureState == 'scheduled' || initialConfigureState == 'pending')) {
55
-
51
+ if (
52
+ (deploymentState !== 'new' &&
53
+ deploymentState !== 'finished' &&
54
+ deploymentState !== 'failed') ||
55
+ initialConfigureState === 'unconfigured' ||
56
+ initialConfigureState === 'scheduled' ||
57
+ initialConfigureState === 'pending'
58
+ ) {
56
59
  loadReportData(reportDataUrl, appInstanceId);
57
60
 
58
61
  setTimeout(() => {
@@ -62,85 +65,104 @@ class ApplicationInstanceReport extends React.Component {
62
65
  }
63
66
 
64
67
  isActive(id) {
65
- return (this.props.activeHostId === id);
68
+ return this.props.activeHostId === id;
66
69
  }
67
70
 
68
71
  collectLastReportData(hosts) {
69
- const {
70
- setActiveHost,
71
- } = this.props;
72
+ const { setActiveHost } = this.props;
72
73
 
73
- const tabs = []
74
- for (const [index, value] of hosts.entries()) {
74
+ const tabs = [];
75
+ // for (const [index, value] of hosts.entries()) {
76
+ hosts.forEach((value, index) => {
75
77
  tabs.push(
76
78
  <VerticalTabs.Tab
77
79
  id={index}
78
- key={"vt_tab_"+index}
79
- title={ value.name }
80
- wrapStyle='nowrap'
80
+ key={`vt_tab_${index}`}
81
+ title={value.name}
82
+ wrapStyle="nowrap"
81
83
  onActivate={() => setActiveHost(index)}
82
84
  active={this.isActive(index)}
83
85
  />
84
86
  );
85
- }
87
+ });
86
88
 
87
89
  return tabs;
88
90
  }
89
91
 
92
+ // eslint-disable-next-line class-methods-use-this
90
93
  lastReportStatus(host) {
91
- if (!host['id']) {
94
+ if (!host.id) {
92
95
  return (
93
96
  <div>
94
- <span>Host: { host['name'] }</span>
97
+ <span>Host: {host.name}</span>
95
98
  <span>&nbsp;|&nbsp;</span>
96
- <span>State: { __('not build') }</span>
99
+ <span>State: {__('not build')}</span>
97
100
  <span>&nbsp;|&nbsp;</span>
98
- <span>Power Status: { __('unknown') }</span>
101
+ <span>Power Status: {__('unknown')}</span>
99
102
  </div>
100
- )
101
- } else {
102
- const already_deployed_msg = __("Already existing host which was added to the application instance");
103
- return (
104
- <div>
105
- <span>Host: <a href={ host['hostUrl'] }>{ host['name'] }</a></span>
106
- <span>&nbsp;|&nbsp;</span>
107
- <span>State: { host['build'] == true ? "in Build" : "Deployed" }</span>
108
- <span>&nbsp;|&nbsp;</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>)}
116
- </div>
117
- )
103
+ );
118
104
  }
105
+ const alreadyDeployedMsg = __(
106
+ 'Already existing host which was added to the application instance'
107
+ );
108
+ return (
109
+ <div>
110
+ <span>
111
+ Host: <a href={host.hostUrl}>{host.name}</a>
112
+ </span>
113
+ <span>&nbsp;|&nbsp;</span>
114
+ <span>State: {host.build === true ? 'in Build' : 'Deployed'}</span>
115
+ <span>&nbsp;|&nbsp;</span>
116
+ <span>
117
+ Power Status:{' '}
118
+ <PowerStatus
119
+ key={`power_status_${host.id}`}
120
+ id={host.id}
121
+ url={host.powerStatusUrl}
122
+ data={{ id: host.id, url: host.powerStatusUrl }}
123
+ />
124
+ </span>
125
+ {host.isExistingHost ? (
126
+ <span>
127
+ &nbsp;|&nbsp; Existing host &nbsp;
128
+ <Icon
129
+ style={{ marginRight: 8, marginLeft: 2 }}
130
+ type="pf"
131
+ name="info"
132
+ title={alreadyDeployedMsg}
133
+ />
134
+ </span>
135
+ ) : (
136
+ <span />
137
+ )}
138
+ </div>
139
+ );
119
140
  }
120
141
 
121
142
  render() {
122
143
  const {
123
- data: { appInstanceId, appInstanceName, deployTaskUrl, configureJobUrl, reportDataUrl },
124
- activeHostId, hosts,
144
+ data: { deployTaskUrl, configureJobUrl },
145
+ activeHostId,
125
146
  deploymentState,
126
- initialConfigureState, initialConfigureJobUrl, showInitialConfigureJob,
127
- loadReportData,
147
+ hosts,
148
+ initialConfigureJobUrl,
149
+ initialConfigureState,
150
+ loading,
151
+ showInitialConfigureJob,
128
152
  } = this.props;
129
153
 
130
- let tabs = [];
131
- let reportStatus = undefined;
132
- let report = undefined;
154
+ let report;
133
155
 
134
156
  // 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>);
157
+ if (hosts.length === 0) {
158
+ return <span>No host</span>;
137
159
  }
138
160
 
139
- tabs = this.collectLastReportData(hosts);
140
- reportStatus = this.lastReportStatus(hosts[activeHostId]);
161
+ const tabs = this.collectLastReportData(hosts);
162
+ const reportStatus = this.lastReportStatus(hosts[activeHostId]);
141
163
 
142
- if (hosts[activeHostId]['progress_report']) {
143
- report = hosts[activeHostId]['progress_report'];
164
+ if (hosts[activeHostId].progress_report) {
165
+ report = hosts[activeHostId].progress_report;
144
166
  }
145
167
 
146
168
  return (
@@ -149,75 +171,110 @@ class ApplicationInstanceReport extends React.Component {
149
171
  <div>
150
172
  <div className="deploy_status_head">Host deployment state</div>
151
173
  <div className="deploy_status_content">
152
- { (deploymentState != 'new' && deploymentState != 'finished' && deploymentState != 'failed') ? (<span><Spinner loading size='sm' /> &nbsp;</span>) : (<span></span>) }
153
- { deploymentState }
174
+ {loading ||
175
+ (deploymentState !== 'new' &&
176
+ deploymentState !== 'finished' &&
177
+ deploymentState !== 'failed') ? (
178
+ <span>
179
+ <Spinner loading size="sm" /> &nbsp;
180
+ </span>
181
+ ) : (
182
+ <span />
183
+ )}
184
+ {deploymentState}
154
185
  </div>
155
186
  </div>
156
187
  <div>
157
188
  <div className="deploy_status_head">Deployment task</div>
158
- <div className="deploy_status_content"><a href={ deployTaskUrl } >Last deployment task</a></div>
159
- </div>
160
- { (showInitialConfigureJob == true) ? (
161
- <div>
162
- <div className="deploy_status_head">Configuration job</div>
163
189
  <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>) }
190
+ <a href={deployTaskUrl}>Last deployment task</a>
167
191
  </div>
168
192
  </div>
193
+ {showInitialConfigureJob === true ? (
194
+ <div>
195
+ <div className="deploy_status_head">Configuration job</div>
196
+ <div className="deploy_status_content">
197
+ {initialConfigureState === 'scheduled' ||
198
+ initialConfigureState === 'pending' ? (
199
+ <span>
200
+ <Spinner loading size="sm" /> &nbsp;
201
+ </span>
202
+ ) : (
203
+ <span />
204
+ )}
205
+ {initialConfigureState !== 'unconfigured' &&
206
+ initialConfigureState !== 'scheduled' ? (
207
+ <a href={initialConfigureJobUrl}>Configuration job</a>
208
+ ) : (
209
+ <span />
210
+ )}
211
+ {initialConfigureState !== 'unconfigured' ? (
212
+ <span>&nbsp; State: {initialConfigureState}</span>
213
+ ) : (
214
+ <span />
215
+ )}
216
+ </div>
217
+ </div>
169
218
  ) : (
170
- <div>
171
- <div className="deploy_status_head">Configuration job</div>
172
- <div className="deploy_status_content"><a href={ configureJobUrl }>Configuration jobs</a></div>
173
- </div>
174
- ) }
219
+ <div>
220
+ <div className="deploy_status_head">Configuration job</div>
221
+ <div className="deploy_status_content">
222
+ <a href={configureJobUrl}>Configuration jobs</a>
223
+ </div>
224
+ </div>
225
+ )}
175
226
  </div>
176
227
  <div className="deploy_report_hosts">
177
228
  Hosts
178
- <VerticalTabs id="vertical_tabs">
179
- {tabs}
180
- </VerticalTabs>
181
- </div>
182
- <div className="deploy_report_status">
183
- {reportStatus}
229
+ <VerticalTabs id="vertical_tabs">{tabs}</VerticalTabs>
184
230
  </div>
231
+ <div className="deploy_report_status">{reportStatus}</div>
185
232
  <div className="deploy_report_tasks">
186
233
  <ReportViewer report={report} />
187
234
  </div>
188
235
  </span>
189
- )};
236
+ );
237
+ }
190
238
  }
191
239
 
192
240
  ApplicationInstanceReport.defaultProps = {
193
- error: {},
194
- appInstanceName: '',
195
- deployTaskUrl: '',
196
- configureJobUrl: '',
197
- hosts: [],
198
- report: [],
241
+ data: {
242
+ initialConfigureJobUrl: undefined,
243
+ },
199
244
  activeHostId: 0,
245
+ configureJobUrl: '',
200
246
  deploymentState: 'unknown',
201
- initialConfigureState: 'unknown',
247
+ deployTaskUrl: '',
248
+ hosts: [],
202
249
  initialConfigureJobUrl: '',
250
+ initialConfigureState: 'unknown',
251
+ loading: false,
203
252
  showInitialConfigureJob: false,
204
- }
253
+ };
205
254
 
206
255
  ApplicationInstanceReport.propTypes = {
207
- initApplicationInstanceReport: PropTypes.func,
208
- appInstanceName: PropTypes.string,
209
- deployTaskUrl: PropTypes.string,
256
+ data: PropTypes.shape({
257
+ hosts: PropTypes.array.isRequired,
258
+ deploymentState: PropTypes.string.isRequired,
259
+ appInstanceId: PropTypes.number.isRequired,
260
+ reportDataUrl: PropTypes.string.isRequired,
261
+ deployTaskUrl: PropTypes.string.isRequired,
262
+ configureJobUrl: PropTypes.string.isRequired,
263
+ initialConfigureState: PropTypes.string.isRequired,
264
+ initialConfigureJobUrl: PropTypes.string,
265
+ }),
266
+ activeHostId: PropTypes.number,
210
267
  configureJobUrl: PropTypes.string,
211
268
  deploymentState: PropTypes.string,
212
- initialConfigureState: PropTypes.string,
269
+ deployTaskUrl: PropTypes.string,
270
+ hosts: PropTypes.array,
213
271
  initialConfigureJobUrl: PropTypes.string,
272
+ initialConfigureState: PropTypes.string,
273
+ loading: PropTypes.bool,
214
274
  showInitialConfigureJob: PropTypes.bool,
215
- hosts: PropTypes.array,
216
- deploymentState: PropTypes.string,
217
- report: PropTypes.array,
218
- setActiveHost: PropTypes.func,
219
- loadReportData: PropTypes.func,
220
- activeHostId: PropTypes.number,
275
+ initApplicationInstanceReport: PropTypes.func.isRequired,
276
+ loadReportData: PropTypes.func.isRequired,
277
+ setActiveHost: PropTypes.func.isRequired,
221
278
  };
222
279
 
223
280
  export default ApplicationInstanceReport;
@@ -1,15 +1,5 @@
1
- import React from 'react';
2
1
  import api from 'foremanReact/API';
3
2
 
4
- import {
5
- actionHeaderCellFormatter,
6
- } from 'patternfly-react';
7
-
8
- import {
9
- propsToSnakeCase,
10
- propsToCamelCase,
11
- } from 'foremanReact/common/helpers';
12
-
13
3
  import {
14
4
  APPLICATION_INSTANCE_REPORT_INIT,
15
5
  APPLICATION_INSTANCE_REPORT_SET_ACTIVE_HOST,
@@ -19,7 +9,10 @@ import {
19
9
  } from './ApplicationInstanceReportConstants';
20
10
 
21
11
  export const initApplicationInstanceReport = (
22
- hosts, deploymentState, initialConfigureState, initialConfigureJobUrl,
12
+ hosts,
13
+ deploymentState,
14
+ initialConfigureState,
15
+ initialConfigureJobUrl
23
16
  ) => dispatch => {
24
17
  const initialState = {};
25
18
 
@@ -30,7 +23,7 @@ export const initApplicationInstanceReport = (
30
23
 
31
24
  // Decide if it should show only the initial Configure job state + URL or
32
25
  // the URL to all configuration jobs
33
- if (initialConfigureState == 'unconfigured') {
26
+ if (initialConfigureState === 'unconfigured') {
34
27
  initialState.showInitialConfigureJob = true;
35
28
  } else {
36
29
  initialState.showInitialConfigureJob = false;
@@ -44,22 +37,24 @@ export const initApplicationInstanceReport = (
44
37
 
45
38
  export const loadReportData = (
46
39
  reportDataUrl,
47
- appInstanceId,
48
- ) => dispatch => {
40
+ appInstanceId
41
+ ) => async dispatch => {
49
42
  dispatch({ type: APPLICATION_INSTANCE_REPORT_LOAD_REPORT_REQUEST });
50
43
 
51
44
  const baseUrl = reportDataUrl;
52
- const realUrl = baseUrl.replace("__id__", appInstanceId);
45
+ const realUrl = baseUrl.replace('__id__', appInstanceId);
53
46
 
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)));
47
+ try {
48
+ const { data } = await api.get(realUrl, {}, {});
49
+ dispatch({
50
+ type: APPLICATION_INSTANCE_REPORT_LOAD_REPORT_SUCCESS,
51
+ payload: { ...data },
52
+ });
53
+ } catch (error) {
54
+ dispatch(
55
+ errorHandler(APPLICATION_INSTANCE_REPORT_LOAD_REPORT_FAILURE, error)
56
+ );
57
+ }
63
58
  };
64
59
 
65
60
  const errorHandler = (msg, err) => {
@@ -70,7 +65,7 @@ const errorHandler = (msg, err) => {
70
65
  return { type: msg, payload: { error } };
71
66
  };
72
67
 
73
- export const setActiveHost = (id) => ({
68
+ export const setActiveHost = id => ({
74
69
  type: APPLICATION_INSTANCE_REPORT_SET_ACTIVE_HOST,
75
70
  payload: { activeHostId: id },
76
71
  });
@@ -1,5 +1,10 @@
1
- export const APPLICATION_INSTANCE_REPORT_INIT = 'APPLICATION_INSTANCE_REPORT_INIT';
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';
1
+ export const APPLICATION_INSTANCE_REPORT_INIT =
2
+ 'APPLICATION_INSTANCE_REPORT_INIT';
3
+ export const APPLICATION_INSTANCE_REPORT_SET_ACTIVE_HOST =
4
+ 'APPLICATION_INSTANCE_REPORT_SET_ACTIVE_HOST';
5
+ export const APPLICATION_INSTANCE_REPORT_LOAD_REPORT_REQUEST =
6
+ 'APPLICATION_INSTANCE_REPORT_LOAD_REPORT_REQUEST';
7
+ export const APPLICATION_INSTANCE_REPORT_LOAD_REPORT_SUCCESS =
8
+ 'APPLICATION_INSTANCE_REPORT_LOAD_REPORT_SUCCESS';
9
+ export const APPLICATION_INSTANCE_REPORT_LOAD_REPORT_FAILURE =
10
+ 'APPLICATION_INSTANCE_REPORT_LOAD_REPORT_FAILURE';