cozy-harvest-lib 6.14.6 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +64 -0
- package/dist/cli/cli.js +4 -2
- package/dist/components/AccountForm/__snapshots__/index.spec.jsx.snap +1 -1
- package/dist/components/OAuthForm.js +2 -1
- package/dist/components/infos/TriggerErrorInfo.js +82 -6
- package/dist/components/infos/TriggerErrorInfo.spec.js +22 -1
- package/dist/helpers/konnectors.js +51 -11
- package/dist/locales/en.json +2 -2
- package/dist/locales/fr.json +2 -2
- package/dist/models/ConnectionFlow.js +2 -1
- package/package.json +4 -4
- package/src/cli/cli.js +2 -0
- package/src/components/AccountForm/__snapshots__/index.spec.jsx.snap +1 -1
- package/src/components/OAuthForm.jsx +1 -0
- package/src/components/infos/TriggerErrorInfo.jsx +28 -7
- package/src/components/infos/TriggerErrorInfo.spec.js +16 -1
- package/src/helpers/konnectors.js +35 -5
- package/src/locales/en.json +2 -2
- package/src/locales/fr.json +2 -2
- package/src/models/ConnectionFlow.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,70 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [7.0.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@6.15.2...cozy-harvest-lib@7.0.0) (2022-01-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **eslint:** Propose Eslint plugin promise ([1fded18](https://github.com/cozy/cozy-libs/commit/1fded18))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
* **eslint:** Most errors are not auto fixable,
|
|
17
|
+
if needed, use // disable-next-line
|
|
18
|
+
|
|
19
|
+
Or insert in .eslintrc:
|
|
20
|
+
{
|
|
21
|
+
"rules": {
|
|
22
|
+
"promise/always-return": "warn",
|
|
23
|
+
"promise/no-return-wrap": "warn",
|
|
24
|
+
"promise/param-names": "warn",
|
|
25
|
+
"promise/catch-or-return": "warn",
|
|
26
|
+
"promise/no-native": "warn",
|
|
27
|
+
"promise/no-nesting": "warn",
|
|
28
|
+
"promise/no-promise-in-callback": "warn",
|
|
29
|
+
"promise/no-callback-in-promise": "warn",
|
|
30
|
+
"promise/avoid-new": "warn",
|
|
31
|
+
"promise/no-new-statics": "warn",
|
|
32
|
+
"promise/no-return-in-finally": "warn",
|
|
33
|
+
"promise/valid-params": "warn"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## [6.15.2](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@6.15.1...cozy-harvest-lib@6.15.2) (2022-01-06)
|
|
42
|
+
|
|
43
|
+
**Note:** Version bump only for package cozy-harvest-lib
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## [6.15.1](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@6.15.0...cozy-harvest-lib@6.15.1) (2021-12-28)
|
|
50
|
+
|
|
51
|
+
**Note:** Version bump only for package cozy-harvest-lib
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# [6.15.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@6.14.6...cozy-harvest-lib@6.15.0) (2021-12-20)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
### Features
|
|
61
|
+
|
|
62
|
+
* Also use supportMail for TERMS_VERSION_MISMATCH error ([986cd33](https://github.com/cozy/cozy-libs/commit/986cd33))
|
|
63
|
+
* Use configured support address in UNKNOWN_ERROR message ([1470f03](https://github.com/cozy/cozy-libs/commit/1470f03))
|
|
64
|
+
* Use fetchQueryAndGetFromState ([bd4c497](https://github.com/cozy/cozy-libs/commit/bd4c497))
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
6
70
|
## [6.14.6](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@6.14.5...cozy-harvest-lib@6.14.6) (2021-12-20)
|
|
7
71
|
|
|
8
72
|
**Note:** Version bump only for package cozy-harvest-lib
|
package/dist/cli/cli.js
CHANGED
|
@@ -334,11 +334,13 @@ var main = /*#__PURE__*/function () {
|
|
|
334
334
|
return function main() {
|
|
335
335
|
return _ref5.apply(this, arguments);
|
|
336
336
|
};
|
|
337
|
-
}();
|
|
337
|
+
}(); // eslint-disable-next-line promise/catch-or-return
|
|
338
|
+
|
|
338
339
|
|
|
339
340
|
main().catch(function (e) {
|
|
340
341
|
logger.error(e);
|
|
341
342
|
process.exit(1);
|
|
342
|
-
})
|
|
343
|
+
}) // eslint-disable-next-line promise/always-return
|
|
344
|
+
.then(function () {
|
|
343
345
|
process.exit(0);
|
|
344
346
|
});
|
|
@@ -80,7 +80,7 @@ exports[`AccountForm should render error 1`] = `
|
|
|
80
80
|
onFocusCapture={[Function]}
|
|
81
81
|
onKeyUp={[Function]}
|
|
82
82
|
>
|
|
83
|
-
<withI18n(withKonnectorLocales(TriggerErrorInfo)
|
|
83
|
+
<withI18n(withClient(withKonnectorLocales(TriggerErrorInfo))
|
|
84
84
|
className="u-mb-1"
|
|
85
85
|
error={[Error: Test error]}
|
|
86
86
|
konnector={
|
|
@@ -60,7 +60,8 @@ export var OAuthForm = /*#__PURE__*/function (_PureComponent) {
|
|
|
60
60
|
if (konnectorPolicy.fetchExtraOAuthUrlParams) {
|
|
61
61
|
this.setState({
|
|
62
62
|
needExtraParams: true
|
|
63
|
-
});
|
|
63
|
+
}); // eslint-disable-next-line promise/catch-or-return
|
|
64
|
+
|
|
64
65
|
konnectorPolicy.fetchExtraOAuthUrlParams({
|
|
65
66
|
flow: flow,
|
|
66
67
|
account: account,
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
3
5
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
10
|
|
|
7
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
12
|
|
|
@@ -13,7 +17,8 @@ import PropTypes from 'prop-types';
|
|
|
13
17
|
import { translate } from 'cozy-ui/transpiled/react/I18n';
|
|
14
18
|
import Infos from 'cozy-ui/transpiled/react/Infos';
|
|
15
19
|
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
16
|
-
import {
|
|
20
|
+
import { withClient } from 'cozy-client';
|
|
21
|
+
import { getErrorLocale, fetchSupportMail } from '../../helpers/konnectors';
|
|
17
22
|
import withKonnectorLocales from '../hoc/withKonnectorLocales';
|
|
18
23
|
import Markdown from '../Markdown';
|
|
19
24
|
/**
|
|
@@ -31,12 +36,82 @@ export var TriggerErrorInfo = /*#__PURE__*/function (_PureComponent) {
|
|
|
31
36
|
var _super = _createSuper(TriggerErrorInfo);
|
|
32
37
|
|
|
33
38
|
function TriggerErrorInfo() {
|
|
39
|
+
var _this;
|
|
40
|
+
|
|
34
41
|
_classCallCheck(this, TriggerErrorInfo);
|
|
35
42
|
|
|
36
|
-
|
|
43
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
44
|
+
args[_key] = arguments[_key];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
48
|
+
|
|
49
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
50
|
+
supportMail: null
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return _this;
|
|
37
54
|
}
|
|
38
55
|
|
|
39
56
|
_createClass(TriggerErrorInfo, [{
|
|
57
|
+
key: "componentDidMount",
|
|
58
|
+
value: function () {
|
|
59
|
+
var _componentDidMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
60
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
61
|
+
while (1) {
|
|
62
|
+
switch (_context.prev = _context.next) {
|
|
63
|
+
case 0:
|
|
64
|
+
_context.next = 2;
|
|
65
|
+
return this.loadSupportMail();
|
|
66
|
+
|
|
67
|
+
case 2:
|
|
68
|
+
case "end":
|
|
69
|
+
return _context.stop();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}, _callee, this);
|
|
73
|
+
}));
|
|
74
|
+
|
|
75
|
+
function componentDidMount() {
|
|
76
|
+
return _componentDidMount.apply(this, arguments);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return componentDidMount;
|
|
80
|
+
}()
|
|
81
|
+
}, {
|
|
82
|
+
key: "loadSupportMail",
|
|
83
|
+
value: function () {
|
|
84
|
+
var _loadSupportMail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
85
|
+
var client, supportMail;
|
|
86
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
87
|
+
while (1) {
|
|
88
|
+
switch (_context2.prev = _context2.next) {
|
|
89
|
+
case 0:
|
|
90
|
+
client = this.props.client;
|
|
91
|
+
_context2.next = 3;
|
|
92
|
+
return fetchSupportMail(client);
|
|
93
|
+
|
|
94
|
+
case 3:
|
|
95
|
+
supportMail = _context2.sent;
|
|
96
|
+
this.setState({
|
|
97
|
+
supportMail: supportMail
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
case 5:
|
|
101
|
+
case "end":
|
|
102
|
+
return _context2.stop();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}, _callee2, this);
|
|
106
|
+
}));
|
|
107
|
+
|
|
108
|
+
function loadSupportMail() {
|
|
109
|
+
return _loadSupportMail.apply(this, arguments);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return loadSupportMail;
|
|
113
|
+
}()
|
|
114
|
+
}, {
|
|
40
115
|
key: "render",
|
|
41
116
|
value: function render() {
|
|
42
117
|
var _this$props = this.props,
|
|
@@ -45,6 +120,7 @@ export var TriggerErrorInfo = /*#__PURE__*/function (_PureComponent) {
|
|
|
45
120
|
konnector = _this$props.konnector,
|
|
46
121
|
t = _this$props.t,
|
|
47
122
|
action = _this$props.action;
|
|
123
|
+
var supportMail = this.state.supportMail;
|
|
48
124
|
return /*#__PURE__*/React.createElement(Infos, {
|
|
49
125
|
className: className,
|
|
50
126
|
theme: "danger",
|
|
@@ -53,12 +129,12 @@ export var TriggerErrorInfo = /*#__PURE__*/function (_PureComponent) {
|
|
|
53
129
|
className: "u-error",
|
|
54
130
|
variant: "h6",
|
|
55
131
|
gutterBottom: true
|
|
56
|
-
}, getErrorLocale(error, konnector, t, 'title')), /*#__PURE__*/React.createElement(Typography, {
|
|
132
|
+
}, getErrorLocale(error, konnector, t, 'title')), supportMail ? /*#__PURE__*/React.createElement(Typography, {
|
|
57
133
|
variant: "body1",
|
|
58
134
|
component: "div"
|
|
59
135
|
}, /*#__PURE__*/React.createElement(Markdown, {
|
|
60
|
-
source: getErrorLocale(error, konnector, t, 'description')
|
|
61
|
-
})))
|
|
136
|
+
source: getErrorLocale(error, konnector, t, 'description', supportMail)
|
|
137
|
+
})) : null)
|
|
62
138
|
});
|
|
63
139
|
}
|
|
64
140
|
}]);
|
|
@@ -70,4 +146,4 @@ TriggerErrorInfo.proptTypes = {
|
|
|
70
146
|
konnector: PropTypes.object.isRequired,
|
|
71
147
|
t: PropTypes.func.isRequired
|
|
72
148
|
};
|
|
73
|
-
export default translate()(withKonnectorLocales(TriggerErrorInfo));
|
|
149
|
+
export default translate()(withClient(withKonnectorLocales(TriggerErrorInfo)));
|
|
@@ -15,6 +15,7 @@ var tMock = jest.fn().mockImplementation(function (key) {
|
|
|
15
15
|
return key;
|
|
16
16
|
});
|
|
17
17
|
describe('TriggerErrorInfo', function () {
|
|
18
|
+
var fakeClient;
|
|
18
19
|
beforeAll(function () {
|
|
19
20
|
jest.spyOn(console, 'error').mockImplementation(function () {});
|
|
20
21
|
});
|
|
@@ -31,7 +32,9 @@ describe('TriggerErrorInfo', function () {
|
|
|
31
32
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
32
33
|
optionProps = _ref.props;
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
fakeClient = {
|
|
36
|
+
fetchQueryAndGetFromState: jest.fn()
|
|
37
|
+
};
|
|
35
38
|
var root = render( /*#__PURE__*/React.createElement(AppLike, {
|
|
36
39
|
client: fakeClient
|
|
37
40
|
}, /*#__PURE__*/React.createElement(TriggerErrorInfo, _extends({}, props, optionProps))));
|
|
@@ -56,4 +59,22 @@ describe('TriggerErrorInfo', function () {
|
|
|
56
59
|
|
|
57
60
|
expect(root.findByText('An unknown error has occurred.')).toBeTruthy();
|
|
58
61
|
});
|
|
62
|
+
it('should render unknown error with configured mail support if any', function () {
|
|
63
|
+
fakeClient.fetchQueryAndGetFromState.mockResolvedValue({
|
|
64
|
+
data: [{
|
|
65
|
+
attributes: {
|
|
66
|
+
support_address: 'test@address'
|
|
67
|
+
}
|
|
68
|
+
}]
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
var _setup3 = setup({
|
|
72
|
+
props: {
|
|
73
|
+
error: new Error('Something is undefined')
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
root = _setup3.root;
|
|
77
|
+
|
|
78
|
+
expect(root.findByText('test@address')).toBeTruthy();
|
|
79
|
+
});
|
|
59
80
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
4
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
@@ -6,6 +7,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
7
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
8
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
9
|
import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
|
|
10
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
9
11
|
|
|
10
12
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
11
13
|
|
|
@@ -19,7 +21,9 @@ import get from 'lodash/get';
|
|
|
19
21
|
import has from 'lodash/has';
|
|
20
22
|
import trim from 'lodash/trim';
|
|
21
23
|
import { getBoundT } from '../locales';
|
|
22
|
-
import
|
|
24
|
+
import { Q, fetchPolicies } from 'cozy-client';
|
|
25
|
+
import * as accounts from './accounts';
|
|
26
|
+
var DEFAULT_SUPPORT_MAIL = 'claude@cozycloud.cc'; // Default name for base directory
|
|
23
27
|
|
|
24
28
|
var DEFAULT_LOCALIZED_BASE_DIR = 'Administrative'; // Type of errors returned by konnector
|
|
25
29
|
|
|
@@ -143,10 +147,12 @@ export var KonnectorJobError = /*#__PURE__*/function (_Error) {
|
|
|
143
147
|
*/
|
|
144
148
|
|
|
145
149
|
export var getErrorLocale = function getErrorLocale(error, konnector, t, suffixKey) {
|
|
150
|
+
var supportMail = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : DEFAULT_SUPPORT_MAIL;
|
|
146
151
|
var defaultKey = 'error.job.UNKNOWN_ERROR';
|
|
147
152
|
var translationVariables = {
|
|
148
153
|
name: konnector.name || '',
|
|
149
|
-
link: konnector.vendor_link || ''
|
|
154
|
+
link: konnector.vendor_link || '',
|
|
155
|
+
supportMail: supportMail
|
|
150
156
|
}; // not handled errors
|
|
151
157
|
|
|
152
158
|
if (!(error instanceof KonnectorJobError)) {
|
|
@@ -165,9 +171,41 @@ export var getErrorLocale = function getErrorLocale(error, konnector, t, suffixK
|
|
|
165
171
|
}))
|
|
166
172
|
}));
|
|
167
173
|
};
|
|
168
|
-
export var
|
|
174
|
+
export var fetchSupportMail = /*#__PURE__*/function () {
|
|
175
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(client) {
|
|
176
|
+
var result;
|
|
177
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
178
|
+
while (1) {
|
|
179
|
+
switch (_context.prev = _context.next) {
|
|
180
|
+
case 0:
|
|
181
|
+
_context.next = 2;
|
|
182
|
+
return client.fetchQueryAndGetFromState({
|
|
183
|
+
definition: Q('io.cozy.settings').getById('context'),
|
|
184
|
+
options: {
|
|
185
|
+
as: 'contextSupportMail',
|
|
186
|
+
fetchPolicy: fetchPolicies.olderThan(60 * 60 * 1000)
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
case 2:
|
|
191
|
+
result = _context.sent;
|
|
192
|
+
return _context.abrupt("return", get(result, 'data[0].attributes.support_address', DEFAULT_SUPPORT_MAIL));
|
|
193
|
+
|
|
194
|
+
case 4:
|
|
195
|
+
case "end":
|
|
196
|
+
return _context.stop();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}, _callee);
|
|
200
|
+
}));
|
|
201
|
+
|
|
202
|
+
return function fetchSupportMail(_x) {
|
|
203
|
+
return _ref.apply(this, arguments);
|
|
204
|
+
};
|
|
205
|
+
}();
|
|
206
|
+
export var getErrorLocaleBound = function getErrorLocaleBound(error, konnector, lang, suffixKey, supportMail) {
|
|
169
207
|
var t = getBoundT(lang);
|
|
170
|
-
return getErrorLocale(error, konnector, t, suffixKey);
|
|
208
|
+
return getErrorLocale(error, konnector, t, suffixKey, supportMail);
|
|
171
209
|
};
|
|
172
210
|
/**
|
|
173
211
|
* Returns the account type. Based on the information from the oauth attribute,
|
|
@@ -353,8 +391,8 @@ export var buildFolderPermission = function buildFolderPermission(folder) {
|
|
|
353
391
|
* @returns {Object}
|
|
354
392
|
*/
|
|
355
393
|
|
|
356
|
-
export var getLauncher = function getLauncher(
|
|
357
|
-
var win =
|
|
394
|
+
export var getLauncher = function getLauncher(_ref2) {
|
|
395
|
+
var win = _ref2.win;
|
|
358
396
|
return get(win, 'cozy.ClientConnectorLauncher', null);
|
|
359
397
|
};
|
|
360
398
|
/**
|
|
@@ -365,10 +403,10 @@ export var getLauncher = function getLauncher(_ref) {
|
|
|
365
403
|
* @returns {Boolean}
|
|
366
404
|
*/
|
|
367
405
|
|
|
368
|
-
export var isRunnable = function isRunnable(
|
|
369
|
-
var win =
|
|
370
|
-
|
|
371
|
-
konnector =
|
|
406
|
+
export var isRunnable = function isRunnable(_ref3) {
|
|
407
|
+
var win = _ref3.win,
|
|
408
|
+
_ref3$konnector = _ref3.konnector,
|
|
409
|
+
konnector = _ref3$konnector === void 0 ? {} : _ref3$konnector;
|
|
372
410
|
return Boolean(!konnector.clientSide || getLauncher({
|
|
373
411
|
win: win
|
|
374
412
|
}));
|
|
@@ -381,5 +419,7 @@ export default {
|
|
|
381
419
|
getLauncher: getLauncher,
|
|
382
420
|
isRunnable: isRunnable,
|
|
383
421
|
hasNewVersionAvailable: hasNewVersionAvailable,
|
|
384
|
-
needsFolder: needsFolder
|
|
422
|
+
needsFolder: needsFolder,
|
|
423
|
+
fetchSupportMail: fetchSupportMail,
|
|
424
|
+
DEFAULT_SUPPORT_MAIL: DEFAULT_SUPPORT_MAIL
|
|
385
425
|
};
|
package/dist/locales/en.json
CHANGED
|
@@ -151,11 +151,11 @@
|
|
|
151
151
|
},
|
|
152
152
|
"TERMS_VERSION_MISMATCH": {
|
|
153
153
|
"title": "Latest Terms of Service non accepted",
|
|
154
|
-
"description": "%{name} seems to have updated its Terms Of Service. Please check that the service is up to date. It this error still occurs, please contact us at [
|
|
154
|
+
"description": "%{name} seems to have updated its Terms Of Service. Please check that the service is up to date. It this error still occurs, please contact us at [%{supportMail}](mailto:%{supportMail})."
|
|
155
155
|
},
|
|
156
156
|
"UNKNOWN_ERROR": {
|
|
157
157
|
"title": "Connection error",
|
|
158
|
-
"description": "An unknown error has occurred. You can try to update your data. If the problem persists, please contact us at [
|
|
158
|
+
"description": "An unknown error has occurred. You can try to update your data. If the problem persists, please contact us at [%{supportMail}](mailto:%{supportMail})."
|
|
159
159
|
},
|
|
160
160
|
"USER_ACTION_NEEDED": {
|
|
161
161
|
"title": "Action needed on the provider's website",
|
package/dist/locales/fr.json
CHANGED
|
@@ -151,11 +151,11 @@
|
|
|
151
151
|
},
|
|
152
152
|
"TERMS_VERSION_MISMATCH": {
|
|
153
153
|
"title": "Nouvelles CGUs à accepter",
|
|
154
|
-
"description": "Il semblerait que %{name} ait mis à jour ses Conditions Générales d'Utilisation. Merci de vérifier que le service est à jour. Si l'erreur persiste, contacter nous via [
|
|
154
|
+
"description": "Il semblerait que %{name} ait mis à jour ses Conditions Générales d'Utilisation. Merci de vérifier que le service est à jour. Si l'erreur persiste, contacter nous via [%{supportMail}](mailto:%{supportMail})."
|
|
155
155
|
},
|
|
156
156
|
"UNKNOWN_ERROR": {
|
|
157
157
|
"title": "Erreur de Connexion",
|
|
158
|
-
"description": "Une erreur inconnue est survenue. Vous pouvez essayer de mettre à jour vos données. Si le problème persiste, n'hésitez pas à nous contacter via [
|
|
158
|
+
"description": "Une erreur inconnue est survenue. Vous pouvez essayer de mettre à jour vos données. Si le problème persiste, n'hésitez pas à nous contacter via [%{supportMail}](mailto:%{supportMail})."
|
|
159
159
|
},
|
|
160
160
|
"USER_ACTION_NEEDED": {
|
|
161
161
|
"title": "Action nécessaire chez le fournisseur",
|
|
@@ -319,7 +319,8 @@ export var ConnectionFlow = /*#__PURE__*/function () {
|
|
|
319
319
|
|
|
320
320
|
if (this.jobWatcher) {
|
|
321
321
|
this.jobWatcher.disableSuccessTimer();
|
|
322
|
-
}
|
|
322
|
+
} // eslint-disable-next-line promise/param-names
|
|
323
|
+
|
|
323
324
|
|
|
324
325
|
return new Promise(function (rawResolve) {
|
|
325
326
|
var accountId = _this.account._id;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-harvest-lib",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Provides logic, modules and components for Cozy's harvest applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Cozy",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"babel-plugin-inline-react-svg": "^1.1.0",
|
|
54
54
|
"babel-preset-cozy-app": "^2.0.1",
|
|
55
55
|
"cozy-client": "17.6.1",
|
|
56
|
-
"cozy-device-helper": "^1.
|
|
56
|
+
"cozy-device-helper": "^1.15.0",
|
|
57
57
|
"cozy-flags": "^2.8.3",
|
|
58
58
|
"cozy-keys-lib": "3.8.0",
|
|
59
|
-
"cozy-realtime": "^
|
|
59
|
+
"cozy-realtime": "^4.0.0",
|
|
60
60
|
"cozy-ui": "^57.6.0",
|
|
61
61
|
"enzyme": "3.11.0",
|
|
62
62
|
"enzyme-adapter-react-16": "1.15.6",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"react-router-dom": "^5.0.1"
|
|
86
86
|
},
|
|
87
87
|
"sideEffects": false,
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "d0157461fc7919473be52fa994fed99c23b24ec2"
|
|
89
89
|
}
|
package/src/cli/cli.js
CHANGED
|
@@ -201,11 +201,13 @@ const main = async () => {
|
|
|
201
201
|
await args.handler(args, client)
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
// eslint-disable-next-line promise/catch-or-return
|
|
204
205
|
main()
|
|
205
206
|
.catch(e => {
|
|
206
207
|
logger.error(e)
|
|
207
208
|
process.exit(1)
|
|
208
209
|
})
|
|
210
|
+
// eslint-disable-next-line promise/always-return
|
|
209
211
|
.then(() => {
|
|
210
212
|
process.exit(0)
|
|
211
213
|
})
|
|
@@ -80,7 +80,7 @@ exports[`AccountForm should render error 1`] = `
|
|
|
80
80
|
onFocusCapture={[Function]}
|
|
81
81
|
onKeyUp={[Function]}
|
|
82
82
|
>
|
|
83
|
-
<withI18n(withKonnectorLocales(TriggerErrorInfo)
|
|
83
|
+
<withI18n(withClient(withKonnectorLocales(TriggerErrorInfo))
|
|
84
84
|
className="u-mb-1"
|
|
85
85
|
error={[Error: Test error]}
|
|
86
86
|
konnector={
|
|
@@ -4,8 +4,9 @@ import PropTypes from 'prop-types'
|
|
|
4
4
|
import { translate } from 'cozy-ui/transpiled/react/I18n'
|
|
5
5
|
import Infos from 'cozy-ui/transpiled/react/Infos'
|
|
6
6
|
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
7
|
+
import { withClient } from 'cozy-client'
|
|
7
8
|
|
|
8
|
-
import { getErrorLocale } from '../../helpers/konnectors'
|
|
9
|
+
import { getErrorLocale, fetchSupportMail } from '../../helpers/konnectors'
|
|
9
10
|
import withKonnectorLocales from '../hoc/withKonnectorLocales'
|
|
10
11
|
import Markdown from '../Markdown'
|
|
11
12
|
|
|
@@ -18,8 +19,20 @@ import Markdown from '../Markdown'
|
|
|
18
19
|
* deals mainly with translation concerns.
|
|
19
20
|
*/
|
|
20
21
|
export class TriggerErrorInfo extends PureComponent {
|
|
22
|
+
state = {
|
|
23
|
+
supportMail: null
|
|
24
|
+
}
|
|
25
|
+
async componentDidMount() {
|
|
26
|
+
await this.loadSupportMail()
|
|
27
|
+
}
|
|
28
|
+
async loadSupportMail() {
|
|
29
|
+
const { client } = this.props
|
|
30
|
+
const supportMail = await fetchSupportMail(client)
|
|
31
|
+
this.setState({ supportMail })
|
|
32
|
+
}
|
|
21
33
|
render() {
|
|
22
34
|
const { className, error, konnector, t, action } = this.props
|
|
35
|
+
const { supportMail } = this.state
|
|
23
36
|
return (
|
|
24
37
|
<Infos
|
|
25
38
|
className={className}
|
|
@@ -30,11 +43,19 @@ export class TriggerErrorInfo extends PureComponent {
|
|
|
30
43
|
<Typography className="u-error" variant="h6" gutterBottom>
|
|
31
44
|
{getErrorLocale(error, konnector, t, 'title')}
|
|
32
45
|
</Typography>
|
|
33
|
-
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
46
|
+
{supportMail ? (
|
|
47
|
+
<Typography variant="body1" component="div">
|
|
48
|
+
<Markdown
|
|
49
|
+
source={getErrorLocale(
|
|
50
|
+
error,
|
|
51
|
+
konnector,
|
|
52
|
+
t,
|
|
53
|
+
'description',
|
|
54
|
+
supportMail
|
|
55
|
+
)}
|
|
56
|
+
/>
|
|
57
|
+
</Typography>
|
|
58
|
+
) : null}
|
|
38
59
|
</>
|
|
39
60
|
}
|
|
40
61
|
/>
|
|
@@ -48,4 +69,4 @@ TriggerErrorInfo.proptTypes = {
|
|
|
48
69
|
t: PropTypes.func.isRequired
|
|
49
70
|
}
|
|
50
71
|
|
|
51
|
-
export default translate()(withKonnectorLocales(TriggerErrorInfo))
|
|
72
|
+
export default translate()(withClient(withKonnectorLocales(TriggerErrorInfo)))
|
|
@@ -16,6 +16,7 @@ const fixtures = {
|
|
|
16
16
|
const tMock = jest.fn().mockImplementation(key => key)
|
|
17
17
|
|
|
18
18
|
describe('TriggerErrorInfo', () => {
|
|
19
|
+
let fakeClient
|
|
19
20
|
beforeAll(() => {
|
|
20
21
|
jest.spyOn(console, 'error').mockImplementation(() => {})
|
|
21
22
|
})
|
|
@@ -31,7 +32,9 @@ describe('TriggerErrorInfo', () => {
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
const setup = ({ props: optionProps } = {}) => {
|
|
34
|
-
|
|
35
|
+
fakeClient = {
|
|
36
|
+
fetchQueryAndGetFromState: jest.fn()
|
|
37
|
+
}
|
|
35
38
|
const root = render(
|
|
36
39
|
<AppLike client={fakeClient}>
|
|
37
40
|
<TriggerErrorInfo {...props} {...optionProps} />
|
|
@@ -53,4 +56,16 @@ describe('TriggerErrorInfo', () => {
|
|
|
53
56
|
})
|
|
54
57
|
expect(root.findByText('An unknown error has occurred.')).toBeTruthy()
|
|
55
58
|
})
|
|
59
|
+
|
|
60
|
+
it('should render unknown error with configured mail support if any', () => {
|
|
61
|
+
fakeClient.fetchQueryAndGetFromState.mockResolvedValue({
|
|
62
|
+
data: [{ attributes: { support_address: 'test@address' } }]
|
|
63
|
+
})
|
|
64
|
+
const { root } = setup({
|
|
65
|
+
props: {
|
|
66
|
+
error: new Error('Something is undefined')
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
expect(root.findByText('test@address')).toBeTruthy()
|
|
70
|
+
})
|
|
56
71
|
})
|
|
@@ -3,8 +3,12 @@ import has from 'lodash/has'
|
|
|
3
3
|
import trim from 'lodash/trim'
|
|
4
4
|
import { getBoundT } from '../locales'
|
|
5
5
|
|
|
6
|
+
import { Q, fetchPolicies } from 'cozy-client'
|
|
7
|
+
|
|
6
8
|
import * as accounts from './accounts'
|
|
7
9
|
|
|
10
|
+
const DEFAULT_SUPPORT_MAIL = 'claude@cozycloud.cc'
|
|
11
|
+
|
|
8
12
|
// Default name for base directory
|
|
9
13
|
const DEFAULT_LOCALIZED_BASE_DIR = 'Administrative'
|
|
10
14
|
|
|
@@ -130,11 +134,18 @@ export class KonnectorJobError extends Error {
|
|
|
130
134
|
* @param {Func} suffixKey What part of the error message should be returned, title or description
|
|
131
135
|
* @return {String} The error locale
|
|
132
136
|
*/
|
|
133
|
-
export const getErrorLocale = (
|
|
137
|
+
export const getErrorLocale = (
|
|
138
|
+
error,
|
|
139
|
+
konnector,
|
|
140
|
+
t,
|
|
141
|
+
suffixKey,
|
|
142
|
+
supportMail = DEFAULT_SUPPORT_MAIL
|
|
143
|
+
) => {
|
|
134
144
|
const defaultKey = 'error.job.UNKNOWN_ERROR'
|
|
135
145
|
const translationVariables = {
|
|
136
146
|
name: konnector.name || '',
|
|
137
|
-
link: konnector.vendor_link || ''
|
|
147
|
+
link: konnector.vendor_link || '',
|
|
148
|
+
supportMail
|
|
138
149
|
}
|
|
139
150
|
|
|
140
151
|
// not handled errors
|
|
@@ -156,9 +167,26 @@ export const getErrorLocale = (error, konnector, t, suffixKey) => {
|
|
|
156
167
|
})
|
|
157
168
|
}
|
|
158
169
|
|
|
159
|
-
export const
|
|
170
|
+
export const fetchSupportMail = async client => {
|
|
171
|
+
const result = await client.fetchQueryAndGetFromState({
|
|
172
|
+
definition: Q('io.cozy.settings').getById('context'),
|
|
173
|
+
options: {
|
|
174
|
+
as: 'contextSupportMail',
|
|
175
|
+
fetchPolicy: fetchPolicies.olderThan(60 * 60 * 1000)
|
|
176
|
+
}
|
|
177
|
+
})
|
|
178
|
+
return get(result, 'data[0].attributes.support_address', DEFAULT_SUPPORT_MAIL)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export const getErrorLocaleBound = (
|
|
182
|
+
error,
|
|
183
|
+
konnector,
|
|
184
|
+
lang,
|
|
185
|
+
suffixKey,
|
|
186
|
+
supportMail
|
|
187
|
+
) => {
|
|
160
188
|
const t = getBoundT(lang)
|
|
161
|
-
return getErrorLocale(error, konnector, t, suffixKey)
|
|
189
|
+
return getErrorLocale(error, konnector, t, suffixKey, supportMail)
|
|
162
190
|
}
|
|
163
191
|
|
|
164
192
|
/**
|
|
@@ -364,5 +392,7 @@ export default {
|
|
|
364
392
|
getLauncher,
|
|
365
393
|
isRunnable,
|
|
366
394
|
hasNewVersionAvailable,
|
|
367
|
-
needsFolder
|
|
395
|
+
needsFolder,
|
|
396
|
+
fetchSupportMail,
|
|
397
|
+
DEFAULT_SUPPORT_MAIL
|
|
368
398
|
}
|
package/src/locales/en.json
CHANGED
|
@@ -151,11 +151,11 @@
|
|
|
151
151
|
},
|
|
152
152
|
"TERMS_VERSION_MISMATCH": {
|
|
153
153
|
"title": "Latest Terms of Service non accepted",
|
|
154
|
-
"description": "%{name} seems to have updated its Terms Of Service. Please check that the service is up to date. It this error still occurs, please contact us at [
|
|
154
|
+
"description": "%{name} seems to have updated its Terms Of Service. Please check that the service is up to date. It this error still occurs, please contact us at [%{supportMail}](mailto:%{supportMail})."
|
|
155
155
|
},
|
|
156
156
|
"UNKNOWN_ERROR": {
|
|
157
157
|
"title": "Connection error",
|
|
158
|
-
"description": "An unknown error has occurred. You can try to update your data. If the problem persists, please contact us at [
|
|
158
|
+
"description": "An unknown error has occurred. You can try to update your data. If the problem persists, please contact us at [%{supportMail}](mailto:%{supportMail})."
|
|
159
159
|
},
|
|
160
160
|
"USER_ACTION_NEEDED": {
|
|
161
161
|
"title": "Action needed on the provider's website",
|
package/src/locales/fr.json
CHANGED
|
@@ -151,11 +151,11 @@
|
|
|
151
151
|
},
|
|
152
152
|
"TERMS_VERSION_MISMATCH": {
|
|
153
153
|
"title": "Nouvelles CGUs à accepter",
|
|
154
|
-
"description": "Il semblerait que %{name} ait mis à jour ses Conditions Générales d'Utilisation. Merci de vérifier que le service est à jour. Si l'erreur persiste, contacter nous via [
|
|
154
|
+
"description": "Il semblerait que %{name} ait mis à jour ses Conditions Générales d'Utilisation. Merci de vérifier que le service est à jour. Si l'erreur persiste, contacter nous via [%{supportMail}](mailto:%{supportMail})."
|
|
155
155
|
},
|
|
156
156
|
"UNKNOWN_ERROR": {
|
|
157
157
|
"title": "Erreur de Connexion",
|
|
158
|
-
"description": "Une erreur inconnue est survenue. Vous pouvez essayer de mettre à jour vos données. Si le problème persiste, n'hésitez pas à nous contacter via [
|
|
158
|
+
"description": "Une erreur inconnue est survenue. Vous pouvez essayer de mettre à jour vos données. Si le problème persiste, n'hésitez pas à nous contacter via [%{supportMail}](mailto:%{supportMail})."
|
|
159
159
|
},
|
|
160
160
|
"USER_ACTION_NEEDED": {
|
|
161
161
|
"title": "Action nécessaire chez le fournisseur",
|
|
@@ -255,6 +255,7 @@ export class ConnectionFlow {
|
|
|
255
255
|
this.jobWatcher.disableSuccessTimer()
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
+
// eslint-disable-next-line promise/param-names
|
|
258
259
|
return new Promise(rawResolve => {
|
|
259
260
|
const accountId = this.account._id
|
|
260
261
|
assert(accountId, 'Cannot wait for two fa on account without id')
|