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,69 +1,52 @@
1
- import React, { useState } from 'react'
1
+ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import {
4
- Icon,
5
- Button,
6
- } from 'patternfly-react';
7
- import {
8
- sprintf,
9
- translate as __
10
- } from 'foremanReact/common/I18n';
11
- import {Select, TextInput} from 'foremanReact/components/common/forms/Select';
12
- import ScmTypeSelector from './components/ScmTypeSelector';
13
- import FormTextInput from './components/FormTextInput'
14
- import { arrayToObject } from '../../helper';
15
- import CommonForm from 'foremanReact/components/common/forms/CommonForm';
3
+ import { Button } from 'patternfly-react';
16
4
  import $ from 'jquery';
17
-
18
- import {
19
- FormControl,
20
- inlineEditFormatterFactory,
21
- } from 'patternfly-react';
5
+ import CommonForm from 'foremanReact/components/common/forms/CommonForm';
6
+ import { translate as __ } from 'foremanReact/common/I18n';
7
+ import ScmTypeSelector from './components/ScmTypeSelector';
8
+ import FormTextInput from './components/FormTextInput';
22
9
 
23
10
  class SyncGitRepo extends React.Component {
24
- constructor(props) {
25
- super(props);
26
- }
27
-
28
11
  validateParameters() {
29
12
  let result = true;
30
- let msg = "";
13
+ let msg = '';
31
14
 
32
- if (this.props.path === "" && this.props.scmType === 'directory') {
15
+ if (this.props.path === '' && this.props.scmType === 'directory') {
33
16
  result = false;
34
17
 
35
- if (msg == "") {
36
- msg += __("Directory path cannot be blank");
18
+ if (msg === '') {
19
+ msg += __('Directory path cannot be blank');
37
20
  }
38
21
  }
39
22
 
40
23
  if (this.props.scmType === 'git') {
41
- if (this.props.gitUrl === "") {
24
+ if (this.props.gitUrl === '') {
42
25
  result = false;
43
26
 
44
- if (msg == "") {
45
- msg += __("Git URL cannot be blank");
27
+ if (msg === '') {
28
+ msg += __('Git URL cannot be blank');
46
29
  }
47
30
  }
48
31
  }
49
32
 
50
- if (this.props.scmType !== "git" && this.props.scmType !== "directory" ) {
33
+ if (this.props.scmType !== 'git' && this.props.scmType !== 'directory') {
51
34
  result = false;
52
35
 
53
- if (msg == "") {
54
- msg += __("SCM Type cannot be blank");
36
+ if (msg === '') {
37
+ msg += __('SCM Type cannot be blank');
55
38
  }
56
39
  }
57
40
 
58
41
  return {
59
42
  validateResult: result,
60
- validateMsg: msg
61
- }
43
+ validateMsg: msg,
44
+ };
62
45
  }
63
46
 
64
47
  componentDidMount() {
65
48
  const {
66
- data: {mode, scmType, path, gitCommit, gitUrl, appDefinitions},
49
+ data: { mode, scmType, path, gitCommit, gitUrl },
67
50
  initSyncGitRepo,
68
51
  loadScmType,
69
52
  loadPath,
@@ -77,20 +60,19 @@ class SyncGitRepo extends React.Component {
77
60
  loadPath(path);
78
61
  loadGitCommit(gitCommit);
79
62
  loadGitUrl(gitUrl);
80
- handleGitRepoSync(this.props.scmType, this.props.path, this.props.gitCommit)
63
+ handleGitRepoSync(
64
+ this.props.scmType,
65
+ this.props.path,
66
+ this.props.gitCommit
67
+ );
81
68
  }
82
69
 
83
- initSyncGitRepo(
84
- scmType,
85
- path,
86
- gitCommit,
87
- gitUrl,
88
- );
89
- };
70
+ initSyncGitRepo(scmType, path, gitCommit, gitUrl);
71
+ }
90
72
 
91
73
  render() {
92
74
  const {
93
- data: {mode, scmTypes, organization, location, appDefinitions},
75
+ data: { scmTypes, appDefinitions },
94
76
  scmType,
95
77
  path,
96
78
  gitCommit,
@@ -102,101 +84,126 @@ class SyncGitRepo extends React.Component {
102
84
  handleGitRepoSync,
103
85
  } = this.props;
104
86
 
105
- var url_validator = /^(ftp|http|https):\/\/[^ "]+$/;
87
+ const urlValidator = /^(ftp|http|https):\/\/[^ "]+$/;
106
88
 
107
- let { validateResult, validateMsg } = this.validateParameters();
89
+ const { validateResult, validateMsg } = this.validateParameters();
108
90
 
91
+ /* eslint-disable jquery/no-attr */
109
92
  if (validateResult === false) {
110
- $('input[type="submit"][name="commit"]').attr("disabled", true);
93
+ $('input[type="submit"][name="commit"]').attr('disabled', true);
111
94
  } else {
112
- $('input[type="submit"][name="commit"]').attr("disabled", false);
95
+ $('input[type="submit"][name="commit"]').attr('disabled', false);
113
96
  }
97
+ /* eslint-enable jquery/no-attr */
114
98
 
115
99
  return (
116
100
  <span>
117
101
  <div>
118
102
  <ScmTypeSelector
119
103
  label="SCM Type *"
120
- hidden={ false }
121
- editable={ appDefinitions.length == 0 }
122
- viewText={ scmTypes[scmType] }
123
- options={ scmTypes }
124
- onChange={ loadScmType }
125
- selectValue={ scmType }
104
+ hidden={false}
105
+ editable={appDefinitions.length === 0}
106
+ viewText={scmTypes[scmType]}
107
+ options={scmTypes}
108
+ onChange={loadScmType}
109
+ selectValue={scmType}
126
110
  />
127
- {(scmType === 'directory') ? (
128
- <FormTextInput
129
- label= 'Directory Path *'
130
- editable= { appDefinitions.length == 0 }
131
- viewText={ path }
132
- onChange={ loadPath }
133
- parameter="path"
134
- /> ) : null }
135
- {(scmType === 'git') ? (
136
- <FormTextInput
137
- label= 'Git Url *'
138
- editable= { appDefinitions.length == 0 }
139
- viewText={ gitUrl }
140
- onChange={ loadGitUrl }
141
- parameter="git_url"
142
- /> ) : null }
143
- {(!url_validator.test(gitUrl) && gitUrl)? (
144
- <div className="form-group">
145
- <div className="col-md-2"></div>
146
- <div className="col-md-4"><pre>{ __("Git URL is wrong") }</pre></div>
147
- </div>
148
- ) : (<div></div>)}
149
- {validateResult == false ? (
111
+ {scmType === 'directory' ? (
112
+ <FormTextInput
113
+ label="Directory Path *"
114
+ editable={appDefinitions.length === 0}
115
+ viewText={path}
116
+ onChange={loadPath}
117
+ parameter="path"
118
+ />
119
+ ) : null}
120
+ {scmType === 'git' ? (
121
+ <FormTextInput
122
+ label="Git Url *"
123
+ editable={appDefinitions.length === 0}
124
+ viewText={gitUrl}
125
+ onChange={loadGitUrl}
126
+ parameter="git_url"
127
+ />
128
+ ) : null}
129
+ {!urlValidator.test(gitUrl) && gitUrl ? (
150
130
  <div className="form-group">
151
- <div className="col-md-2"></div>
152
- <div className="col-md-4"><pre>{validateMsg}</pre></div>
131
+ <div className="col-md-2" />
132
+ <div className="col-md-4">
133
+ <pre>{__('Git URL is wrong')}</pre>
134
+ </div>
153
135
  </div>
154
- ) : (<div></div>)}
155
- {(scmType === "git") ? (
156
- <FormTextInput
157
- label="Git Branch/Commit/Tag"
158
- editable= { appDefinitions.length == 0 }
159
- viewText={ gitCommit }
160
- onChange={ loadGitCommit }
161
- parameter="git_commit"
162
- /> ) : null }
163
- {(scmType === "git") ? (
164
- <CommonForm>
165
- <span className="help-block help-inline">
166
- <Button
167
- bsStyle="default"
168
- onClick={ (e) => handleGitRepoSync(gitUrl, gitCommit, scmType, e) }
169
- >
170
- {__('Sync Repository')} </Button>
171
- </span>
136
+ ) : (
137
+ <div />
138
+ )}
139
+ {validateResult === false ? (
140
+ <div className="form-group">
141
+ <div className="col-md-2" />
142
+ <div className="col-md-4">
143
+ <pre>{validateMsg}</pre>
144
+ </div>
145
+ </div>
146
+ ) : (
147
+ <div />
148
+ )}
149
+ {scmType === 'git' ? (
150
+ <FormTextInput
151
+ label="Git Branch/Commit/Tag"
152
+ editable={appDefinitions.length === 0}
153
+ viewText={gitCommit}
154
+ onChange={loadGitCommit}
155
+ parameter="git_commit"
156
+ />
157
+ ) : null}
158
+ {scmType === 'git' ? (
159
+ <CommonForm>
160
+ <span className="help-block help-inline">
161
+ <Button
162
+ bsStyle="default"
163
+ onClick={e =>
164
+ handleGitRepoSync(gitUrl, gitCommit, scmType, e)
165
+ }
166
+ >
167
+ {__('Sync Repository')}{' '}
168
+ </Button>
169
+ </span>
172
170
  </CommonForm>
173
- ) : null }
174
-
171
+ ) : null}
175
172
  </div>
176
- </span>
177
- )};
173
+ </span>
174
+ );
175
+ }
178
176
  }
179
177
 
180
178
  SyncGitRepo.defaultProps = {
181
- error: {},
182
- scmType: "",
183
- path: "",
184
- gitCommit: "",
185
- gitUrl: "",
186
-
187
- }
179
+ scmType: '',
180
+ path: '',
181
+ gitCommit: '',
182
+ gitUrl: '',
183
+ };
188
184
 
189
185
  SyncGitRepo.propTypes = {
190
- initSyncGitRepo: PropTypes.func,
191
- loadScmType: PropTypes.func,
192
- loadGitCommit: PropTypes.func,
193
- loadPath: PropTypes.func,
194
- loadGitUrl: PropTypes.func,
195
- handleGitRepoSync: PropTypes.func,
196
- scmType: PropTypes.string.isRequired,
197
- path: PropTypes.string.isRequired,
186
+ data: PropTypes.shape({
187
+ appDefinitions: PropTypes.array.isRequired,
188
+ gitCommit: PropTypes.string.isRequired,
189
+ gitUrl: PropTypes.string.isRequired,
190
+ location: PropTypes.string,
191
+ mode: PropTypes.string,
192
+ organization: PropTypes.string,
193
+ path: PropTypes.string.isRequired,
194
+ scmType: PropTypes.string.isRequired,
195
+ scmTypes: PropTypes.object.isRequired,
196
+ }).isRequired,
198
197
  gitCommit: PropTypes.string,
199
198
  gitUrl: PropTypes.string,
199
+ handleGitRepoSync: PropTypes.func.isRequired,
200
+ initSyncGitRepo: PropTypes.func.isRequired,
201
+ loadScmType: PropTypes.func.isRequired,
202
+ loadGitCommit: PropTypes.func.isRequired,
203
+ loadPath: PropTypes.func.isRequired,
204
+ loadGitUrl: PropTypes.func.isRequired,
205
+ path: PropTypes.string,
206
+ scmType: PropTypes.string,
200
207
  };
201
208
 
202
209
  export default SyncGitRepo;
@@ -1,5 +1,4 @@
1
- import React from 'react';
2
- import { API, actionTypeGenerator } from 'foremanReact/redux/API';
1
+ import { API } from 'foremanReact/redux/API';
3
2
  import { sprintf, translate as __ } from 'foremanReact/common/I18n';
4
3
  import { addToast } from 'foremanReact/components/ToastsList';
5
4
 
@@ -18,7 +17,7 @@ export const initSyncGitRepo = (
18
17
  scmType,
19
18
  path,
20
19
  gitCommit,
21
- gitUrl,
20
+ gitUrl
22
21
  ) => dispatch => {
23
22
  const initialState = {};
24
23
 
@@ -33,91 +32,82 @@ export const initSyncGitRepo = (
33
32
  });
34
33
  };
35
34
 
36
- const errorHandler = (msg, err) => {
37
- const error = {
38
- errorMsg: __('Failed to fetch data from server.'),
39
- statusText: err,
40
- };
41
- return { type: msg, payload: { error } };
42
- };
43
-
44
35
  export const handleGitRepoSync = (
45
- gitUrl, gitCommit, scmType, e,
36
+ gitUrl,
37
+ gitCommit,
38
+ scmType,
39
+ e
46
40
  ) => async dispatch => {
47
41
  e.preventDefault();
48
- //const { REQUEST, SUCCESS, FAILURE } = actionTypeGenerator(SYNC_GIT_REPOSITORY);
49
42
  dispatch({
50
43
  type: SYNC_GIT_REPO_REQUEST,
51
44
  payload: {
52
45
  git_commit: gitCommit,
53
46
  scm_type: scmType,
54
47
  git_url: gitUrl,
55
- }});
48
+ },
49
+ });
56
50
  try {
57
- const { data } = await API.post(
58
- '/acd/ansible_playbooks/sync_git_repo', {"ansible_playbook": {"git_commit":gitCommit, "scm_type":scmType, "git_url":gitUrl}}
51
+ const { data } = await API.post('/acd/ansible_playbooks/sync_git_repo', {
52
+ ansible_playbook: {
53
+ git_commit: gitCommit,
54
+ scm_type: scmType,
55
+ git_url: gitUrl,
56
+ },
57
+ });
58
+ dispatch(
59
+ addToast({
60
+ type: 'success',
61
+ message: sprintf(__('Sucessfully synced git repository ')),
62
+ key: SYNC_GIT_REPO_SUCCESS,
63
+ })
59
64
  );
65
+ return dispatch({
66
+ type: SYNC_GIT_REPO_SUCCESS,
67
+ payload: {
68
+ git_commit: gitCommit,
69
+ git_url: gitUrl,
70
+ scm_type: scmType,
71
+ },
72
+ response: data,
73
+ });
74
+ } catch (error) {
60
75
  dispatch(
61
- addToast({
62
- type: 'success',
63
- message: sprintf(
64
- __('Sucessfully synced git repository ')
65
- ),
66
- key: SYNC_GIT_REPO_SUCCESS,
67
- })
68
- );
69
- return dispatch({
70
- type: SYNC_GIT_REPO_SUCCESS,
71
- payload: {
72
- git_commit: gitCommit,
73
- git_url: gitUrl,
74
- scm_type: scmType,
75
- },
76
- response: data,
77
- });
78
- } catch (error) {
79
- dispatch(
80
- addToast({
81
- type: 'error',
82
- message: sprintf(__('Error occurred while syncing git repository: %s'), error.response.data.message),
83
- key: SYNC_GIT_REPO_FAILURE,
84
- })
85
- );
86
- return dispatch({
87
- type: SYNC_GIT_REPO_FAILURE,
88
- payload: {
89
- error: error,
90
- },
91
- response: error,
92
- });
93
- }
76
+ addToast({
77
+ type: 'error',
78
+ message: sprintf(
79
+ __('Error occurred while syncing git repository: %s'),
80
+ error.response.data.message
81
+ ),
82
+ key: SYNC_GIT_REPO_FAILURE,
83
+ })
84
+ );
85
+ return dispatch({
86
+ type: SYNC_GIT_REPO_FAILURE,
87
+ payload: {
88
+ error,
89
+ },
90
+ response: error,
91
+ });
92
+ }
94
93
  };
95
94
 
95
+ export const loadScmType = scmType => ({
96
+ type: SYNC_GIT_REPO_LOAD_SCM_TYPE,
97
+ scmType,
98
+ });
96
99
 
97
- export const loadScmType = (scmType) => {
98
- return ({
99
- type: SYNC_GIT_REPO_LOAD_SCM_TYPE,
100
- scmType: scmType,
101
- })
102
- };
103
-
104
- export const loadPath = (path) => {
105
- return ({
106
- type: SYNC_GIT_REPO_LOAD_PATH,
107
- path: path,
108
- })
109
- };
100
+ export const loadPath = path => ({
101
+ type: SYNC_GIT_REPO_LOAD_PATH,
102
+ path,
103
+ });
110
104
 
111
- export const loadGitCommit = (gitCommit) => {
112
- return ({
113
- type: SYNC_GIT_REPO_LOAD_GIT_COMMIT,
114
- gitCommit: gitCommit,
115
- })
116
- };
105
+ export const loadGitCommit = gitCommit => ({
106
+ type: SYNC_GIT_REPO_LOAD_GIT_COMMIT,
107
+ gitCommit,
108
+ });
117
109
 
118
- export const loadGitUrl = (gitUrl) => {
119
- return ({
120
- type: SYNC_GIT_REPO_LOAD_GIT_URL,
121
- gitUrl: gitUrl,
122
- })
123
- };
110
+ export const loadGitUrl = gitUrl => ({
111
+ type: SYNC_GIT_REPO_LOAD_GIT_URL,
112
+ gitUrl,
113
+ });
@@ -24,54 +24,54 @@ const syncGitRepoConf = (state = initialState, action) => {
24
24
  }
25
25
  case SYNC_GIT_REPO_LOAD_SCM_TYPE: {
26
26
  let newState = {};
27
- const scmType = action.scmType;
27
+ const { scmType } = action;
28
28
 
29
29
  newState = {
30
- scmType: scmType,
30
+ scmType,
31
31
  };
32
32
 
33
33
  return state.merge(newState);
34
34
  }
35
35
  case SYNC_GIT_REPO_LOAD_PATH: {
36
36
  let newState = {};
37
- const path = action.path;
37
+ const { path } = action;
38
38
 
39
39
  newState = {
40
- path: path,
40
+ path,
41
41
  };
42
42
 
43
43
  return state.merge(newState);
44
44
  }
45
45
  case SYNC_GIT_REPO_LOAD_GIT_COMMIT: {
46
46
  let newState = {};
47
- const gitCommit = action.gitCommit;
47
+ const { gitCommit } = action;
48
48
 
49
49
  newState = {
50
- gitCommit: gitCommit,
50
+ gitCommit,
51
51
  };
52
52
 
53
53
  return state.merge(newState);
54
54
  }
55
55
  case SYNC_GIT_REPO_LOAD_GIT_URL: {
56
56
  let newState = {};
57
- const gitUrl = action.gitUrl;
57
+ const { gitUrl } = action;
58
58
 
59
59
  newState = {
60
- gitUrl: gitUrl,
60
+ gitUrl,
61
61
  };
62
62
 
63
63
  return state.merge(newState);
64
64
  }
65
65
  case SYNC_GIT_REPO_FAILURE: {
66
- return state.merge({ error: payload.error, loading: false });
67
- }
68
- case SYNC_GIT_REPO_REQUEST: {
69
- return state.set('loading', true);
70
- }
71
- case SYNC_GIT_REPO_SUCCESS: {
72
- let newState = {};
73
- return state.merge(newState);
74
- }
66
+ return state.merge({ error: payload.error, loading: false });
67
+ }
68
+ case SYNC_GIT_REPO_REQUEST: {
69
+ return state.set('loading', true);
70
+ }
71
+ case SYNC_GIT_REPO_SUCCESS: {
72
+ const newState = {};
73
+ return state.merge(newState);
74
+ }
75
75
  default:
76
76
  return state;
77
77
  }
@@ -0,0 +1,7 @@
1
+ export const syncGitRepoConfData1 = {
2
+ path: 'https://example.com',
3
+ gitCommit: 'master',
4
+ scmType: { git: 'git' },
5
+ scmTypes: { git: 'git', directory: 'directory' },
6
+ gitUrl: 'https://github.com/alpha.git',
7
+ };
@@ -1,44 +1,36 @@
1
1
  import Immutable from 'seamless-immutable';
2
- import {
3
- cloneDeep,
4
- findIndex,
5
- findLastIndex,
6
- } from 'lodash';
7
2
 
8
- import {
9
- syncGitRepoConfData_1,
10
- } from '../__fixtures__/syncGitRepoConfData_1.fixtures';
3
+ import { syncGitRepoConfData1 } from '../__fixtures__/syncGitRepoConfData1.fixtures';
11
4
 
12
- export const successState = Immutable(syncGitRepoConfData_1);
5
+ export const successState = Immutable(syncGitRepoConfData1);
13
6
 
14
7
  // Payload Data
15
- export const initSyncGitRepoPayload = syncGitRepoConfData_1;
8
+ export const initSyncGitRepoPayload = syncGitRepoConfData1;
16
9
 
17
10
  export const loadPathPayload = {
18
- path: 'https://example.com'
11
+ path: 'https://example.com',
19
12
  };
20
13
 
21
14
  export const loadGitCommitPayload = {
22
- gitCommit: 'master'
15
+ gitCommit: 'master',
23
16
  };
24
17
 
25
18
  export const loadGitUrlPayload = {
26
- gitUrl: 'https://github.com/alpha.git'
19
+ gitUrl: 'https://github.com/alpha.git',
27
20
  };
28
21
 
29
22
  export const loadScmTypePayload = {
30
23
  scmType: {
31
- git: "git",
32
- }
24
+ git: 'git',
25
+ },
33
26
  };
34
27
 
35
28
  export const handleGitRepoSyncRequestPayload = {
36
29
  clearRows: false,
37
30
  };
38
31
 
39
- export const handleGitRepoSyncSuccessPayload = {
40
- };
32
+ export const handleGitRepoSyncSuccessPayload = {};
41
33
 
42
34
  export const handleGitRepoSyncFailurePayload = {
43
- error: "Something really bad happend",
35
+ error: 'Something really bad happend',
44
36
  };