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,58 +1,35 @@
1
- import React, { useState } from 'react';
2
- import {
3
- cloneDeep,
4
- } from 'lodash';
1
+ import React from 'react';
5
2
  import PropTypes from 'prop-types';
6
3
  import {
7
4
  Icon,
8
5
  Button,
9
6
  MessageDialog,
7
+ Table,
8
+ inlineEditFormatterFactory,
10
9
  } from 'patternfly-react';
11
10
  import * as resolve from 'table-resolver';
11
+ import { translate as __ } from 'foremanReact/common/I18n';
12
12
  import Select from 'foremanReact/components/common/forms/Select';
13
13
  import CommonForm from 'foremanReact/components/common/forms/CommonForm';
14
- import AddTableEntry from '../common/AddTableEntry';
15
- import DeleteTableEntry from '../common/DeleteTableEntry';
16
14
  import RailsData from '../common/RailsData';
17
15
  import { EasyHeaderFormatter } from '../../helper';
18
- import { translate as __ } from 'foremanReact/common/I18n';
19
-
20
- import {
21
- Table,
22
- FormControl,
23
- inlineEditFormatterFactory,
24
- } from 'patternfly-react';
25
16
 
26
17
  class ApplicationDefinitionImport extends React.Component {
27
-
28
- constructor(props) {
29
- super(props);
30
- }
31
-
32
18
  onFileChange = event => {
33
19
  // Update the state
34
20
  this.setState({ selectedFile: event.target.files[0] });
35
-
36
21
  };
37
22
 
38
- isEditing({rowData}) {
39
- return (rowData.backup !== undefined);
40
- }
41
-
42
- setAnsiblePlaybookServices() {
43
- this.setState({ansiblePlaybookServices: this.props.ansiblePlaybookServices});
23
+ static isEditing({ rowData }) {
24
+ return rowData.backup !== undefined;
44
25
  }
45
26
 
46
27
  componentDidMount() {
47
- const {
48
- mode,
49
- ansiblePlaybookServices,
50
- hostgroups, } = this.props;
28
+ const { ansiblePlaybookServices, hostgroups } = this.props;
51
29
 
52
30
  const {
53
31
  initApplicationDefinitionImport,
54
32
  changeEditApplicationDefinitionImportService,
55
- handleImportAnsiblePlaybook,
56
33
  } = this.props;
57
34
 
58
35
  this.headerFormatter = EasyHeaderFormatter;
@@ -67,50 +44,56 @@ class ApplicationDefinitionImport extends React.Component {
67
44
  <td className="editing">
68
45
  <Select
69
46
  value={value.toString()}
70
- onChange={e => changeEditApplicationDefinitionImportService(e.target.value, additionalData) }
47
+ onChange={e =>
48
+ changeEditApplicationDefinitionImportService(
49
+ e.target.value,
50
+ additionalData
51
+ )
52
+ }
71
53
  options={options}
72
54
  allowClear
73
55
  key="key"
74
56
  />
75
57
  </td>
76
- )
58
+ ),
77
59
  };
78
60
 
79
61
  const inlineEditFormatter = inlineEditFormatterFactory({
80
- isEditing: additionalData => this.isEditing(additionalData),
62
+ isEditing: additionalData => this.constructor.isEditing(additionalData),
81
63
  renderValue: (value, additionalData) => {
82
64
  let prettyValue = value;
83
- if (additionalData.property == 'hostgroup') {
65
+ if (additionalData.property === 'hostgroup') {
84
66
  prettyValue = hostgroups[value];
85
67
  }
86
- return inlineEditFormatterImpl.renderValue(prettyValue, additionalData)
68
+ return inlineEditFormatterImpl.renderValue(prettyValue, additionalData);
87
69
  },
88
70
  renderEdit: (value, additionalData) => {
89
- if (additionalData.property == 'hostgroup') {
71
+ if (additionalData.property === 'hostgroup') {
90
72
  if (additionalData.rowData) {
91
- return inlineEditFormatterImpl.renderEditSelect(value, additionalData, hostgroups);
73
+ return inlineEditFormatterImpl.renderEditSelect(
74
+ value,
75
+ additionalData,
76
+ hostgroups
77
+ );
92
78
  }
93
- return inlineEditFormatterImpl.renderValue(hostgroups[value], additionalData)
79
+ return inlineEditFormatterImpl.renderValue(
80
+ hostgroups[value],
81
+ additionalData
82
+ );
94
83
  }
95
84
  return inlineEditFormatterImpl.renderValue(value, additionalData);
96
- }
85
+ },
97
86
  });
98
87
  this.inlineEditFormatter = inlineEditFormatter;
99
88
 
100
89
  initApplicationDefinitionImport(
101
90
  ansiblePlaybookServices,
102
91
  this.headerFormatter,
103
- this.inlineEditFormatter,
92
+ this.inlineEditFormatter
104
93
  );
105
- };
94
+ }
106
95
 
107
96
  render() {
108
- const {
109
- organization,
110
- location,
111
- foremanDataUrl,
112
- mode,} = this.props;
113
-
114
97
  const {
115
98
  showAlertModal,
116
99
  alertModalText,
@@ -120,95 +103,98 @@ class ApplicationDefinitionImport extends React.Component {
120
103
  columns,
121
104
  handleImportAnsiblePlaybook,
122
105
  } = this.props;
123
- let ansibleServices;
124
106
 
125
107
  return (
126
108
  <span>
127
- {ansibleServices = this.setAnsiblePlaybookServices}
128
- {ansibleServices}
129
- <MessageDialog
109
+ <MessageDialog
130
110
  show={showAlertModal}
131
111
  onHide={closeAlertModal}
132
112
  primaryAction={closeAlertModal}
133
113
  primaryActionButtonContent={__('OK')}
134
- primaryActionButtonBsStyle={"danger"}
114
+ primaryActionButtonBsStyle="danger"
135
115
  icon={<Icon type="pf" name="error-circle-o" />}
136
116
  title={alertModalTitle}
137
117
  primaryContent={alertModalText}
138
118
  />
139
- <div>
140
- <CommonForm label="Application Definition file" className="custom-file-upload">
141
- <input
142
- type="file"
143
- onChange={this.onFileChange}
144
- />
145
- </CommonForm>
146
- <CommonForm>
147
- <Button
148
- bsStyle="default"
149
- onClick={e => handleImportAnsiblePlaybook(this.state.selectedFile, e)}
119
+ <div>
120
+ <CommonForm
121
+ label="Application Definition file"
122
+ className="custom-file-upload"
150
123
  >
151
- {__('Import')} </Button>
152
- </CommonForm>
124
+ <input type="file" onChange={this.onFileChange} />
125
+ </CommonForm>
126
+ <CommonForm>
127
+ <Button
128
+ bsStyle="default"
129
+ onClick={e =>
130
+ handleImportAnsiblePlaybook(this.state.selectedFile, e)
131
+ }
132
+ >
133
+ {__('Import')}{' '}
134
+ </Button>
135
+ </CommonForm>
153
136
  </div>
154
137
 
155
- {(Object.keys(this.props.ansiblePlaybookServices).length > 0) ? (
138
+ {ansiblePlaybookServices.length > 0 ? (
156
139
  <div className="form-group">
157
- <Table.PfProvider
158
- striped
159
- bordered
160
- hover
161
- dataTable
162
- columns={columns}
163
- components={{
164
- body: {
165
- cell: cellProps => cellProps.children
166
- }
167
- }}
168
- >
169
- <Table.Header headerRows={resolve.headerRows({ columns })} />
170
- <Table.Body
171
- rows={this.props.ansiblePlaybookServices}
172
- rowKey="id"
173
- onRow={(rowData, { rowIndex }) => ({
174
- role: 'row',
175
- isEditing: () => this.isEditing({ rowData }),
176
- last: rowIndex === this.props.ansiblePlaybookServices.length - 1
177
- })}
178
- />
179
- </Table.PfProvider>
180
- </div>) : null }
140
+ <Table.PfProvider
141
+ striped
142
+ bordered
143
+ hover
144
+ dataTable
145
+ columns={columns}
146
+ components={{
147
+ body: {
148
+ cell: cellProps => cellProps.children,
149
+ },
150
+ }}
151
+ >
152
+ <Table.Header headerRows={resolve.headerRows({ columns })} />
153
+ <Table.Body
154
+ rows={ansiblePlaybookServices}
155
+ rowKey="id"
156
+ onRow={(rowData, { rowIndex }) => ({
157
+ role: 'row',
158
+ isEditable: () => this.isEditing({ rowData }),
159
+ last: ansiblePlaybookServices.length - 1,
160
+ })}
161
+ />
162
+ </Table.PfProvider>
163
+ </div>
164
+ ) : null}
181
165
  <RailsData
182
- key='applications_definition_import'
183
- view='app_definition_import'
184
- parameter='services'
185
- value={JSON.stringify(this.props.ansiblePlaybookServices)}
166
+ key="applications_definition_import"
167
+ view="app_definition_import"
168
+ parameter="services"
169
+ value={JSON.stringify(ansiblePlaybookServices)}
186
170
  />
187
171
  </span>
188
- )};
172
+ );
173
+ }
189
174
  }
190
175
 
191
176
  ApplicationDefinitionImport.defaultProps = {
192
- error: {},
177
+ // error: {},
193
178
  showAlertModal: false,
194
179
  alertModalText: '',
195
180
  alertModalTitle: '',
196
- editMode: false,
197
181
  columns: [],
198
- ansiblePlaybookServices: {},
199
- editParamsOfRowId: null,
200
- }
182
+ ansiblePlaybookServices: [],
183
+ };
201
184
 
202
185
  ApplicationDefinitionImport.propTypes = {
203
- initApplicationDefinitionImport: PropTypes.func,
204
- editMode: PropTypes.bool.isRequired,
186
+ hostgroups: PropTypes.object.isRequired,
187
+ // error: PropTypes.object,
188
+ ansiblePlaybookServices: PropTypes.array,
189
+ // editMode: PropTypes.bool.isRequired,
205
190
  columns: PropTypes.array,
206
191
  showAlertModal: PropTypes.bool,
207
192
  alertModalText: PropTypes.string,
208
193
  alertModalTitle: PropTypes.string,
209
- closeAlertModal: PropTypes.func,
210
- handleImportAnsiblePlaybook: PropTypes.func,
211
- changeEditApplicationDefinitionImportService: PropTypes.func,
194
+ changeEditApplicationDefinitionImportService: PropTypes.func.isRequired,
195
+ closeAlertModal: PropTypes.func.isRequired,
196
+ handleImportAnsiblePlaybook: PropTypes.func.isRequired,
197
+ initApplicationDefinitionImport: PropTypes.func.isRequired,
212
198
  };
213
199
 
214
200
  export default ApplicationDefinitionImport;
@@ -1,23 +1,7 @@
1
- import React from 'react';
2
- import { API, actionTypeGenerator } from 'foremanReact/redux/API';
1
+ import { API } from 'foremanReact/redux/API';
3
2
  import { addToast } from 'foremanReact/components/ToastsList';
4
3
  import { sprintf, translate as __ } from 'foremanReact/common/I18n';
5
4
 
6
-
7
- import {
8
- setModalOpen,
9
- setModalClosed,
10
- } from 'foremanReact/components/ForemanModal/ForemanModalActions';
11
-
12
- import {
13
- actionHeaderCellFormatter,
14
- } from 'patternfly-react';
15
-
16
- import {
17
- propsToSnakeCase,
18
- propsToCamelCase,
19
- } from 'foremanReact/common/helpers';
20
-
21
5
  import {
22
6
  APPLICATION_DEFINITION_IMPORT_INIT,
23
7
  APPLICATION_DEFINITION_IMPORT_CLOSE_ALERT_MODAL,
@@ -27,11 +11,10 @@ import {
27
11
  APPLICATION_DEFINITION_IMPORT_FILE_FAILURE,
28
12
  } from './ApplicationDefinitionImportConstants';
29
13
 
30
-
31
14
  export const initApplicationDefinitionImport = (
32
15
  ansiblePlaybookServices,
33
16
  headerFormatter,
34
- inlineEditFormatter,
17
+ inlineEditFormatter
35
18
  ) => dispatch => {
36
19
  const initialState = {};
37
20
 
@@ -44,16 +27,16 @@ export const initApplicationDefinitionImport = (
44
27
  props: {
45
28
  index: 0,
46
29
  style: {
47
- width: '20%'
48
- }
30
+ width: '20%',
31
+ },
49
32
  },
50
33
  },
51
34
  cell: {
52
35
  props: {
53
- index: 0,
54
- },
55
- formatters: [inlineEditFormatter]
56
- }
36
+ index: 0,
37
+ },
38
+ formatters: [inlineEditFormatter],
39
+ },
57
40
  },
58
41
  {
59
42
  property: 'hostgroup',
@@ -63,17 +46,17 @@ export const initApplicationDefinitionImport = (
63
46
  props: {
64
47
  index: 1,
65
48
  style: {
66
- width: '20%'
67
- }
49
+ width: '20%',
50
+ },
68
51
  },
69
52
  },
70
53
  cell: {
71
54
  props: {
72
- index: 1,
73
- },
74
- formatters: [inlineEditFormatter]
75
- }
76
- }
55
+ index: 1,
56
+ },
57
+ formatters: [inlineEditFormatter],
58
+ },
59
+ },
77
60
  ];
78
61
 
79
62
  initialState.ansiblePlaybookServices = ansiblePlaybookServices;
@@ -84,21 +67,15 @@ export const initApplicationDefinitionImport = (
84
67
  });
85
68
  };
86
69
 
87
-
88
- const errorHandler = (msg, err) => {
89
- const error = {
90
- errorMsg: __('Failed to fetch data from server.'),
91
- statusText: err,
92
- };
93
- return { type: msg, payload: { error } };
94
- };
95
-
96
70
  export const closeAlertModal = () => ({
97
71
  type: APPLICATION_DEFINITION_IMPORT_CLOSE_ALERT_MODAL,
98
- payload: {}
72
+ payload: {},
99
73
  });
100
74
 
101
- export const changeEditApplicationDefinitionImportService = (value, additionalData) => ({
75
+ export const changeEditApplicationDefinitionImportService = (
76
+ value,
77
+ additionalData
78
+ ) => ({
102
79
  type: APPLICATION_DEFINITION_IMPORT_SERVICE_EDIT_CHANGE,
103
80
  payload: {
104
81
  value,
@@ -106,56 +83,54 @@ export const changeEditApplicationDefinitionImportService = (value, additionalDa
106
83
  },
107
84
  });
108
85
 
109
-
110
- export const handleImportAnsiblePlaybook = (
111
- file, e,) => async dispatch => {
86
+ export const handleImportAnsiblePlaybook = (file, e) => async dispatch => {
112
87
  e.preventDefault();
113
88
  dispatch({
114
89
  type: APPLICATION_DEFINITION_IMPORT_FILE_REQUEST,
115
90
  payload: {
116
91
  app_definition_file: file,
117
- }});
92
+ },
93
+ });
118
94
  try {
119
95
  const formData = new FormData();
120
96
 
121
97
  // Update the formData object
122
- formData.append(
123
- "app_definition_file",
124
- file,
125
- file.name
126
- );
98
+ formData.append('app_definition_file', file, file.name);
127
99
  const { data } = await API.post(
128
- '/acd/app_definitions/handle_file_upload', formData);
100
+ '/acd/app_definitions/handle_file_upload',
101
+ formData
102
+ );
129
103
  dispatch(
130
- addToast({
131
- type: 'success',
132
- message: sprintf(
133
- __('Sucessfully synced imported app template')
134
- ),
135
- key: APPLICATION_DEFINITION_IMPORT_FILE_SUCCESS,
136
- })
137
- );
138
- return dispatch({
139
- type: APPLICATION_DEFINITION_IMPORT_FILE_SUCCESS,
140
- payload: {
141
- ansiblePlaybookServices: data,
142
- },
143
- response: data,
144
- });
145
- } catch (error) {
146
- dispatch(
147
- addToast({
148
- type: 'error',
149
- message: sprintf(__('Error occurred while importing app template: %s'), error.response.data.message),
150
- key: APPLICATION_DEFINITION_IMPORT_FILE_FAILURE,
151
- })
152
- );
153
- return dispatch({
154
- type: APPLICATION_DEFINITION_IMPORT_FILE_FAILURE,
155
- payload: {
156
- error: error,
157
- },
158
- response: error,
159
- });
160
- }
104
+ addToast({
105
+ type: 'success',
106
+ message: sprintf(__('Sucessfully synced imported app template')),
107
+ key: APPLICATION_DEFINITION_IMPORT_FILE_SUCCESS,
108
+ })
109
+ );
110
+ return dispatch({
111
+ type: APPLICATION_DEFINITION_IMPORT_FILE_SUCCESS,
112
+ payload: {
113
+ ansiblePlaybookServices: data,
114
+ },
115
+ response: data,
116
+ });
117
+ } catch (error) {
118
+ dispatch(
119
+ addToast({
120
+ type: 'error',
121
+ message: sprintf(
122
+ __('Error occurred while importing app template: %s'),
123
+ error.response.data.message
124
+ ),
125
+ key: APPLICATION_DEFINITION_IMPORT_FILE_FAILURE,
126
+ })
127
+ );
128
+ return dispatch({
129
+ type: APPLICATION_DEFINITION_IMPORT_FILE_FAILURE,
130
+ payload: {
131
+ error,
132
+ },
133
+ response: error,
134
+ });
135
+ }
161
136
  };
@@ -1,6 +1,12 @@
1
- export const APPLICATION_DEFINITION_IMPORT_INIT = 'INIT_APPLICATION_DEFINITION_IMPORT_INIT';
2
- export const APPLICATION_DEFINITION_IMPORT_SERVICE_EDIT_CHANGE = 'APPLICATION_DEFINITION_IMPORT_SERVICE_EDIT_CHANGE';
3
- export const APPLICATION_DEFINITION_IMPORT_FILE_FAILURE = 'APPLICATION_DEFINITION_IMPORT_FILE_FAILURE';
4
- export const APPLICATION_DEFINITION_IMPORT_FILE_REQUEST = 'APPLICATION_DEFINITION_IMPORT_FILE_REQUEST';
5
- export const APPLICATION_DEFINITION_IMPORT_FILE_SUCCESS = 'APPLICATION_DEFINITION_IMPORT_FILE_SUCCESS';
6
- export const APPLICATION_DEFINITION_IMPORT_CLOSE_ALERT_MODAL = 'APPLICATION_DEFINITION_IMPORT_CLOSE_ALERT_MODAL';
1
+ export const APPLICATION_DEFINITION_IMPORT_INIT =
2
+ 'INIT_APPLICATION_DEFINITION_IMPORT_INIT';
3
+ export const APPLICATION_DEFINITION_IMPORT_SERVICE_EDIT_CHANGE =
4
+ 'APPLICATION_DEFINITION_IMPORT_SERVICE_EDIT_CHANGE';
5
+ export const APPLICATION_DEFINITION_IMPORT_FILE_FAILURE =
6
+ 'APPLICATION_DEFINITION_IMPORT_FILE_FAILURE';
7
+ export const APPLICATION_DEFINITION_IMPORT_FILE_REQUEST =
8
+ 'APPLICATION_DEFINITION_IMPORT_FILE_REQUEST';
9
+ export const APPLICATION_DEFINITION_IMPORT_FILE_SUCCESS =
10
+ 'APPLICATION_DEFINITION_IMPORT_FILE_SUCCESS';
11
+ export const APPLICATION_DEFINITION_IMPORT_CLOSE_ALERT_MODAL =
12
+ 'APPLICATION_DEFINITION_IMPORT_CLOSE_ALERT_MODAL';
@@ -1,12 +1,6 @@
1
1
  import Immutable from 'seamless-immutable';
2
2
 
3
- import {
4
- cloneDeep,
5
- findIndex,
6
- findLastIndex,
7
- } from 'lodash';
8
-
9
- import { translate as __ } from 'foremanReact/common/I18n';
3
+ import { cloneDeep, findIndex } from 'lodash';
10
4
 
11
5
  import {
12
6
  APPLICATION_DEFINITION_IMPORT_INIT,
@@ -48,29 +42,29 @@ const applicationDefinitionImportConf = (state = initialState, action) => {
48
42
  }
49
43
 
50
44
  case APPLICATION_DEFINITION_IMPORT_FILE_FAILURE: {
51
- return state.merge({ error: payload.error, loading: false });
52
- }
53
- case APPLICATION_DEFINITION_IMPORT_FILE_REQUEST: {
54
- return state.set('loading', true);
55
- }
56
- case APPLICATION_DEFINITION_IMPORT_FILE_SUCCESS: {
57
- let newState = {};
58
- let ansibleServices = [];
59
- const ansiblePlaybookServices = payload.ansiblePlaybookServices['ansible_services'];
45
+ return state.merge({ error: payload.error, loading: false });
46
+ }
47
+ case APPLICATION_DEFINITION_IMPORT_FILE_REQUEST: {
48
+ return state.set('loading', true);
49
+ }
50
+ case APPLICATION_DEFINITION_IMPORT_FILE_SUCCESS: {
51
+ let newState = {};
52
+ const ansibleServices = [];
53
+ const ansiblePlaybookServices =
54
+ payload.ansiblePlaybookServices.ansible_services;
60
55
 
61
- for (var ind in ansiblePlaybookServices) {
62
- const value = ansiblePlaybookServices[ind];
63
- const newRow = { id: value['id'], name: value['value'], hostgroup: '' };
64
- newRow.backup = cloneDeep(newRow);
65
- ansibleServices.push(newRow);
66
- }
56
+ ansiblePlaybookServices.forEach(value => {
57
+ const newRow = { id: value.id, name: value.value, hostgroup: '' };
58
+ newRow.backup = cloneDeep(newRow);
59
+ ansibleServices.push(newRow);
60
+ });
67
61
 
68
- newState = {
69
- ansiblePlaybookServices: ansibleServices,
70
- };
62
+ newState = {
63
+ ansiblePlaybookServices: ansibleServices,
64
+ };
71
65
 
72
- return state.merge(newState);
73
- }
66
+ return state.merge(newState);
67
+ }
74
68
  default:
75
69
  return state;
76
70
  }
@@ -1,8 +1,15 @@
1
- const applicationDefinitionImportConf = state => state.foremanAcd.applicationDefinitionImportConf;
1
+ const applicationDefinitionImportConf = state =>
2
+ state.foremanAcd.applicationDefinitionImportConf;
2
3
 
3
- export const selectEditMode = state => applicationDefinitionImportConf(state).editMode;
4
- export const selectColumns = state => applicationDefinitionImportConf(state).columns;
5
- export const selectAnsiblePlaybookServices = state => applicationDefinitionImportConf(state).ansiblePlaybookServices;
6
- export const selectShowAlertModal = state => applicationDefinitionImportConf(state).showAlertModal;
7
- export const selectAlertModalText = state => applicationDefinitionImportConf(state).alertModalText;
8
- export const selectAlertModalTitle = state => applicationDefinitionImportConf(state).alertModalTitle;
4
+ export const selectEditMode = state =>
5
+ applicationDefinitionImportConf(state).editMode;
6
+ export const selectColumns = state =>
7
+ applicationDefinitionImportConf(state).columns;
8
+ export const selectAnsiblePlaybookServices = state =>
9
+ applicationDefinitionImportConf(state).ansiblePlaybookServices;
10
+ export const selectShowAlertModal = state =>
11
+ applicationDefinitionImportConf(state).showAlertModal;
12
+ export const selectAlertModalText = state =>
13
+ applicationDefinitionImportConf(state).alertModalText;
14
+ export const selectAlertModalTitle = state =>
15
+ applicationDefinitionImportConf(state).alertModalTitle;