foreman_acd 0.9.5 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -2
- data/lib/foreman_acd/version.rb +1 -1
- data/package.json +5 -3
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +210 -121
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +79 -91
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +30 -15
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +15 -15
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +96 -63
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +22 -11
- data/webpack/components/ApplicationDefinition/__fixtures__/{applicationDefinitionConfData_1.fixtures.js → applicationDefinitionConfData1.fixtures.js} +77 -105
- data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +49 -29
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +4 -4
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionHelper.test.js +16 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +0 -5
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +25 -25
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +9 -1
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +11 -11
- data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +30 -25
- data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +3 -3
- data/webpack/components/ApplicationDefinition/index.js +0 -1
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +91 -105
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +59 -84
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +12 -6
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +21 -27
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +14 -7
- data/webpack/components/ApplicationDefinitionImport/__fixtures__/{applicationDefinitionImportConfData_1.fixtures.js → applicationDefinitionImportConfData1.fixtures.js} +32 -40
- data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +14 -16
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +38 -8
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +0 -2
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +9 -9
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +116 -2
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +3 -3
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +344 -193
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +92 -105
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +34 -17
- data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +4 -7
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +114 -74
- data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +18 -9
- data/webpack/components/ApplicationInstance/__fixtures__/{applicationInstanceConfData_1.fixtures.js → applicationInstanceConfData1.fixtures.js} +68 -86
- data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +24 -32
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +75 -10
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +0 -8
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +27 -27
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +606 -2
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +12 -12
- data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +32 -25
- data/webpack/components/ApplicationInstance/components/Service.js +7 -18
- data/webpack/components/ApplicationInstance/components/ServiceCounter.js +25 -18
- data/webpack/components/ApplicationInstance/index.js +0 -1
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +167 -110
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +20 -25
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +10 -5
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +9 -12
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +12 -6
- data/webpack/components/ApplicationInstanceReport/__fixtures__/{applicationInstanceReportData_1.fixtures.js → applicationInstanceReportData1.fixtures.js} +154 -101
- data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +3 -10
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +28 -22
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +5 -7
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +0 -1
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +2 -2
- data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +9 -5
- data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +1 -3
- data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +35 -56
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +21 -28
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +6 -3
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +16 -19
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -4
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData1.fixtures.js +187 -0
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +13 -24
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +3 -2
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +11 -14
- data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +5 -5
- data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +31 -25
- data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +3 -9
- data/webpack/components/ParameterSelection/ParameterSelection.js +258 -174
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +110 -100
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +22 -11
- data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +13 -11
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +63 -49
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +10 -5
- data/webpack/components/ParameterSelection/__fixtures__/{parameterSelectionData_1.fixtures.js → parameterSelectionData1.fixtures.js} +67 -104
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +22 -26
- data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +50 -36
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionHelper.test.js +76 -0
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +0 -2
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +23 -25
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +100 -0
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +99 -112
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +18 -19
- data/webpack/components/ParameterSelection/index.js +1 -4
- data/webpack/components/SyncGitRepo/SyncGitRepo.js +124 -117
- data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +64 -74
- data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +17 -17
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData1.fixtures.js +7 -0
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +10 -18
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +80 -6
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +9 -11
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +192 -1
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +4 -4
- data/webpack/components/SyncGitRepo/components/FormTextInput.js +26 -21
- data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +29 -24
- data/webpack/components/SyncGitRepo/index.js +2 -5
- data/webpack/components/common/AddTableEntry.js +3 -10
- data/webpack/components/common/DeleteTableEntry.js +7 -15
- data/webpack/components/common/EditTableEntry.js +7 -7
- data/webpack/components/common/ExtSelect.js +12 -8
- data/webpack/components/common/ExtTextInput.js +12 -7
- data/webpack/components/common/LockTableEntry.js +6 -6
- data/webpack/components/common/RailsData.js +6 -16
- data/webpack/components/common/__tests__/ExtSelect.test.js +2 -2
- data/webpack/components/common/__tests__/RailsData.test.js +0 -2
- data/webpack/global_test_setup.js +11 -0
- data/webpack/helper.js +10 -21
- data/webpack/helper.test.js +17 -29
- data/webpack/index.js +25 -7
- data/webpack/js-yaml.js +1563 -1135
- data/webpack/reducer.js +52 -27
- metadata +13 -11
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +0 -191
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +0 -153
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +0 -7
@@ -1,69 +1,52 @@
|
|
1
|
-
import 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
|
-
|
20
|
-
|
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 ===
|
15
|
+
if (this.props.path === '' && this.props.scmType === 'directory') {
|
33
16
|
result = false;
|
34
17
|
|
35
|
-
if (msg
|
36
|
-
msg += __(
|
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 += __(
|
27
|
+
if (msg === '') {
|
28
|
+
msg += __('Git URL cannot be blank');
|
46
29
|
}
|
47
30
|
}
|
48
31
|
}
|
49
32
|
|
50
|
-
if (this.props.scmType !==
|
33
|
+
if (this.props.scmType !== 'git' && this.props.scmType !== 'directory') {
|
51
34
|
result = false;
|
52
35
|
|
53
|
-
if (msg
|
54
|
-
msg += __(
|
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
|
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(
|
63
|
+
handleGitRepoSync(
|
64
|
+
this.props.scmType,
|
65
|
+
this.props.path,
|
66
|
+
this.props.gitCommit
|
67
|
+
);
|
81
68
|
}
|
82
69
|
|
83
|
-
initSyncGitRepo(
|
84
|
-
|
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: {
|
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
|
-
|
87
|
+
const urlValidator = /^(ftp|http|https):\/\/[^ "]+$/;
|
106
88
|
|
107
|
-
|
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(
|
93
|
+
$('input[type="submit"][name="commit"]').attr('disabled', true);
|
111
94
|
} else {
|
112
|
-
$('input[type="submit"][name="commit"]').attr(
|
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={
|
121
|
-
editable={
|
122
|
-
viewText={
|
123
|
-
options={
|
124
|
-
onChange={
|
125
|
-
selectValue={
|
104
|
+
hidden={false}
|
105
|
+
editable={appDefinitions.length === 0}
|
106
|
+
viewText={scmTypes[scmType]}
|
107
|
+
options={scmTypes}
|
108
|
+
onChange={loadScmType}
|
109
|
+
selectValue={scmType}
|
126
110
|
/>
|
127
|
-
{
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
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"
|
152
|
-
<div className="col-md-4"
|
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
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
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
|
-
|
174
|
-
|
171
|
+
) : null}
|
175
172
|
</div>
|
176
|
-
|
177
|
-
|
173
|
+
</span>
|
174
|
+
);
|
175
|
+
}
|
178
176
|
}
|
179
177
|
|
180
178
|
SyncGitRepo.defaultProps = {
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
}
|
179
|
+
scmType: '',
|
180
|
+
path: '',
|
181
|
+
gitCommit: '',
|
182
|
+
gitUrl: '',
|
183
|
+
};
|
188
184
|
|
189
185
|
SyncGitRepo.propTypes = {
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
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
|
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,
|
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
|
-
|
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
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
)
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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
|
98
|
-
|
99
|
-
|
100
|
-
|
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 =
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
})
|
116
|
-
};
|
105
|
+
export const loadGitCommit = gitCommit => ({
|
106
|
+
type: SYNC_GIT_REPO_LOAD_GIT_COMMIT,
|
107
|
+
gitCommit,
|
108
|
+
});
|
117
109
|
|
118
|
-
export const loadGitUrl =
|
119
|
-
|
120
|
-
|
121
|
-
|
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
|
27
|
+
const { scmType } = action;
|
28
28
|
|
29
29
|
newState = {
|
30
|
-
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
|
37
|
+
const { path } = action;
|
38
38
|
|
39
39
|
newState = {
|
40
|
-
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
|
47
|
+
const { gitCommit } = action;
|
48
48
|
|
49
49
|
newState = {
|
50
|
-
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
|
57
|
+
const { gitUrl } = action;
|
58
58
|
|
59
59
|
newState = {
|
60
|
-
gitUrl
|
60
|
+
gitUrl,
|
61
61
|
};
|
62
62
|
|
63
63
|
return state.merge(newState);
|
64
64
|
}
|
65
65
|
case SYNC_GIT_REPO_FAILURE: {
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
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
|
}
|
@@ -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(
|
5
|
+
export const successState = Immutable(syncGitRepoConfData1);
|
13
6
|
|
14
7
|
// Payload Data
|
15
|
-
export const initSyncGitRepoPayload =
|
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:
|
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:
|
35
|
+
error: 'Something really bad happend',
|
44
36
|
};
|