cozy-harvest-lib 9.27.2 → 9.29.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/components/FlowProvider.js +3 -1
  3. package/dist/components/FlowProvider.spec.js +3 -0
  4. package/dist/components/KonnectorConfiguration/ConfigurationTab/BIContractActivationWindow.spec.js +143 -20
  5. package/dist/components/KonnectorConfiguration/ConfigurationTab/BiContractActivationWindow.js +68 -12
  6. package/dist/components/KonnectorConfiguration/ConfigurationTab/Contracts.js +11 -4
  7. package/dist/components/KonnectorConfiguration/ConfigurationTab/index.js +15 -22
  8. package/dist/components/KonnectorConfiguration/ConfigurationTab/index.spec.js +13 -33
  9. package/dist/components/KonnectorConfiguration/DataTab/index.js +1 -11
  10. package/dist/components/KonnectorConfiguration/DataTab.spec.js +0 -21
  11. package/dist/components/KonnectorConfiguration/KonnectorAccountTabs.js +66 -1
  12. package/dist/components/KonnectorConfiguration/KonnectorAccountTabs.spec.js +276 -2
  13. package/dist/components/OAuthForm.js +110 -173
  14. package/dist/components/OAuthForm.spec.js +186 -60
  15. package/dist/components/OAuthWindow.js +69 -26
  16. package/dist/components/TriggerManager.js +4 -4
  17. package/dist/components/TriggerManager.spec.js +1 -1
  18. package/dist/components/TwoFAModal.spec.js +8 -2
  19. package/dist/components/__snapshots__/OAuthForm.spec.js.snap +121 -30
  20. package/dist/components/cards/LaunchTriggerCard.js +6 -5
  21. package/dist/components/cards/LaunchTriggerCard.spec.js +77 -4
  22. package/dist/components/hooks/useOAuthExtraParams.js +82 -0
  23. package/dist/helpers/oauth.js +57 -35
  24. package/dist/helpers/oauth.spec.js +3 -1
  25. package/dist/konnector-policies.js +10 -1
  26. package/dist/locales/en.json +4 -0
  27. package/dist/locales/fr.json +4 -0
  28. package/dist/models/ConnectionFlow.js +66 -26
  29. package/dist/models/ConnectionFlow.spec.js +278 -60
  30. package/dist/models/flowEvents.js +1 -0
  31. package/dist/models/withConnectionFlow.spec.js +10 -1
  32. package/dist/services/biWebView.js +30 -17
  33. package/dist/services/biWebView.spec.js +19 -10
  34. package/dist/services/budget-insight.js +2 -2
  35. package/dist/services/jobUtils.js +7 -4
  36. package/dist/types.js +12 -0
  37. package/package.json +4 -3
  38. package/src/components/FlowProvider.jsx +1 -1
  39. package/src/components/FlowProvider.spec.jsx +3 -0
  40. package/src/components/KonnectorConfiguration/ConfigurationTab/BIContractActivationWindow.spec.jsx +60 -8
  41. package/src/components/KonnectorConfiguration/ConfigurationTab/BiContractActivationWindow.jsx +64 -7
  42. package/src/components/KonnectorConfiguration/ConfigurationTab/Contracts.jsx +8 -2
  43. package/src/components/KonnectorConfiguration/ConfigurationTab/index.jsx +8 -24
  44. package/src/components/KonnectorConfiguration/ConfigurationTab/index.spec.jsx +0 -19
  45. package/src/components/KonnectorConfiguration/DataTab/index.jsx +1 -18
  46. package/src/components/KonnectorConfiguration/DataTab.spec.jsx +0 -16
  47. package/src/components/KonnectorConfiguration/KonnectorAccountTabs.jsx +72 -0
  48. package/src/components/KonnectorConfiguration/KonnectorAccountTabs.spec.jsx +114 -2
  49. package/src/components/OAuthForm.jsx +105 -121
  50. package/src/components/OAuthForm.spec.js +71 -52
  51. package/src/components/OAuthWindow.jsx +55 -27
  52. package/src/components/TriggerManager.jsx +3 -3
  53. package/src/components/TriggerManager.spec.jsx +1 -1
  54. package/src/components/TwoFAModal.spec.jsx +8 -2
  55. package/src/components/__snapshots__/OAuthForm.spec.js.snap +121 -30
  56. package/src/components/cards/LaunchTriggerCard.jsx +3 -5
  57. package/src/components/cards/LaunchTriggerCard.spec.jsx +70 -8
  58. package/src/components/hooks/useOAuthExtraParams.js +43 -0
  59. package/src/helpers/oauth.js +48 -36
  60. package/src/helpers/oauth.spec.js +4 -1
  61. package/src/konnector-policies.js +9 -1
  62. package/src/locales/en.json +4 -0
  63. package/src/locales/fr.json +4 -0
  64. package/src/models/ConnectionFlow.js +47 -11
  65. package/src/models/ConnectionFlow.spec.js +162 -20
  66. package/src/models/flowEvents.js +1 -0
  67. package/src/models/withConnectionFlow.spec.jsx +11 -1
  68. package/src/services/biWebView.js +21 -8
  69. package/src/services/biWebView.spec.js +11 -7
  70. package/src/services/budget-insight.js +2 -2
  71. package/src/services/jobUtils.js +6 -3
  72. package/src/types.js +12 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,37 @@
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
+ # [9.29.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.28.0...cozy-harvest-lib@9.29.0) (2022-10-28)
7
+
8
+
9
+ ### Features
10
+
11
+ * Close Harvest when BI connection is removed in webview ([45d9e20](https://github.com/cozy/cozy-libs/commit/45d9e20042923b8cab14b8371ea9a596c9e4dea8))
12
+
13
+
14
+
15
+
16
+
17
+ # [9.28.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.27.2...cozy-harvest-lib@9.28.0) (2022-10-24)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * Add useEffect dependencies to useOAuthExtraParams hook ([fb046e4](https://github.com/cozy/cozy-libs/commit/fb046e4034754075a65f5dd4ffd184ba6e180941))
23
+ * Do not depend only on konnector.slug for useEffect dependencies ([65869cf](https://github.com/cozy/cozy-libs/commit/65869cfd154a8e925c6b1ef6ee084883e4484cdf))
24
+
25
+
26
+ ### Features
27
+
28
+ * Do not create trigger with full webhooks flag ([8ce5e78](https://github.com/cozy/cozy-libs/commit/8ce5e786e30e48fa46e0d31a912560740c5206a3))
29
+ * Reconnection with BI webviews & webhooks ([591047b](https://github.com/cozy/cozy-libs/commit/591047b0143dab480952d67787451ffeddb57632))
30
+ * Send realtime notifications when expecting a trigger ([b76da3d](https://github.com/cozy/cozy-libs/commit/b76da3d5ec184c6dcc4c2555f92aec6aa523b294))
31
+ * Use BI manage url to update contract synchronization ([fad2994](https://github.com/cozy/cozy-libs/commit/fad2994458e3c0c1f4ee1833855b60ea590fab49))
32
+
33
+
34
+
35
+
36
+
6
37
  ## [9.27.2](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.27.1...cozy-harvest-lib@9.27.2) (2022-10-19)
7
38
 
8
39
 
@@ -161,6 +161,8 @@ export var FlowProvider = /*#__PURE__*/function (_Component) {
161
161
  }, {
162
162
  key: "handleLoginSuccess",
163
163
  value: function handleLoginSuccess() {
164
+ var _flow$account;
165
+
164
166
  logger.info('FlowProvider: Handle success');
165
167
 
166
168
  if (this.state.showTwoFAModal) {
@@ -176,7 +178,7 @@ export var FlowProvider = /*#__PURE__*/function (_Component) {
176
178
 
177
179
  var triggerLike = _objectSpread({
178
180
  message: {
179
- account: flow.account._id
181
+ account: flow === null || flow === void 0 ? void 0 : (_flow$account = flow.account) === null || _flow$account === void 0 ? void 0 : _flow$account._id
180
182
  }
181
183
  }, flow.trigger);
182
184
 
@@ -14,6 +14,9 @@ var client = {
14
14
  on: jest.fn(),
15
15
  stackClient: {
16
16
  uri: 'https://cozy.tools:8080'
17
+ },
18
+ plugins: {
19
+ realtime: jest.fn()
17
20
  }
18
21
  };
19
22
  var trigger = {
@@ -12,38 +12,48 @@ jest.mock('../../../konnector-policies', function () {
12
12
  };
13
13
  });
14
14
  jest.mock('../../Popup', function () {
15
- return jest.fn().mockImplementation(function (_ref) {
16
- var onClose = _ref.onClose;
17
- setTimeout(onClose, 1);
18
- return null;
19
- });
15
+ return jest.fn();
20
16
  });
21
17
  jest.mock('../../InAppBrowser', function () {
22
- return jest.fn().mockImplementation(function (_ref2) {
23
- var onClose = _ref2.onClose;
18
+ return jest.fn().mockImplementation(function (_ref) {
19
+ var onClose = _ref.onClose;
24
20
  setTimeout(onClose, 1);
25
21
  return null;
26
22
  });
27
23
  });
28
24
  jest.mock('../../../helpers/oauth');
29
- jest.mock('cozy-realtime');
30
25
  jest.mock('cozy-device-helper');
31
26
  import BIContractActivationWindow from './BiContractActivationWindow';
32
27
  import { findKonnectorPolicy } from '../../../konnector-policies';
33
28
  import Popup from '../../Popup';
34
29
  import InAppBrowser from '../../InAppBrowser';
35
30
  import { isFlagshipApp } from 'cozy-device-helper';
36
- import { prepareOAuth } from '../../../helpers/oauth';
31
+ import { prepareOAuth, checkOAuthData } from '../../../helpers/oauth';
32
+ import CozyRealtime from 'cozy-realtime';
37
33
  findKonnectorPolicy.mockImplementation(function () {
38
34
  return {
39
35
  fetchExtraOAuthUrlParams: fetchExtraOAuthUrlParams,
40
36
  refreshContracts: refreshContracts
41
37
  };
42
38
  });
39
+ jest.mock('cozy-realtime', function () {
40
+ var result = function Realtime() {};
41
+
42
+ result.prototype.subscribe = jest.fn();
43
+ result.prototype.unsubscribeAll = jest.fn();
44
+ return result;
45
+ });
43
46
  var mockKonnector = {
44
47
  slug: 'mockkonnector'
45
48
  };
46
49
  var mockAccount = {};
50
+ var sendMessageFn = null;
51
+
52
+ CozyRealtime.prototype.subscribe = function (notified, doctype, channel, callback) {
53
+ sendMessageFn = callback;
54
+ };
55
+
56
+ var onAccountDeleted = jest.fn();
47
57
 
48
58
  var setup = function setup() {
49
59
  var client = new CozyClient({});
@@ -51,7 +61,8 @@ var setup = function setup() {
51
61
  client: client
52
62
  }, /*#__PURE__*/React.createElement(BIContractActivationWindow, {
53
63
  konnector: mockKonnector,
54
- account: mockAccount
64
+ account: mockAccount,
65
+ onAccountDeleted: onAccountDeleted
55
66
  })));
56
67
  };
57
68
 
@@ -69,6 +80,11 @@ describe('BIContractActivationWindow', function () {
69
80
  while (1) {
70
81
  switch (_context3.prev = _context3.next) {
71
82
  case 0:
83
+ Popup.mockImplementation(function (_ref3) {
84
+ var onClose = _ref3.onClose;
85
+ setTimeout(onClose, 1);
86
+ return null;
87
+ });
72
88
  prepareOAuth.mockImplementation(function () {
73
89
  return {
74
90
  oAuthUrl: 'https://test.url'
@@ -79,7 +95,7 @@ describe('BIContractActivationWindow', function () {
79
95
  });
80
96
  fetchExtraOAuthUrlParams.mockResolvedValue({});
81
97
  _setup = setup(), getByRole = _setup.getByRole;
82
- _context3.next = 6;
98
+ _context3.next = 7;
83
99
  return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
84
100
  return _regeneratorRuntime.wrap(function _callee$(_context) {
85
101
  while (1) {
@@ -98,8 +114,8 @@ describe('BIContractActivationWindow', function () {
98
114
  }, _callee);
99
115
  })));
100
116
 
101
- case 6:
102
- _context3.next = 8;
117
+ case 7:
118
+ _context3.next = 9;
103
119
  return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
104
120
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
105
121
  while (1) {
@@ -119,14 +135,14 @@ describe('BIContractActivationWindow', function () {
119
135
  }, _callee2);
120
136
  })));
121
137
 
122
- case 8:
138
+ case 9:
123
139
  expect(fetchExtraOAuthUrlParams).toHaveBeenCalled();
124
140
  expect(refreshContracts).toHaveBeenCalledTimes(1);
125
141
  expect(Popup).toHaveBeenCalledWith(expect.objectContaining({
126
142
  url: 'https://test.url'
127
143
  }), {});
128
144
 
129
- case 11:
145
+ case 12:
130
146
  case "end":
131
147
  return _context3.stop();
132
148
  }
@@ -140,6 +156,11 @@ describe('BIContractActivationWindow', function () {
140
156
  while (1) {
141
157
  switch (_context6.prev = _context6.next) {
142
158
  case 0:
159
+ Popup.mockImplementation(function (_ref7) {
160
+ var onClose = _ref7.onClose;
161
+ setTimeout(onClose, 1);
162
+ return null;
163
+ });
143
164
  isFlagshipApp.mockImplementation(function () {
144
165
  return true;
145
166
  });
@@ -150,7 +171,7 @@ describe('BIContractActivationWindow', function () {
150
171
  });
151
172
  fetchExtraOAuthUrlParams.mockResolvedValue({});
152
173
  _setup2 = setup(), getByRole = _setup2.getByRole;
153
- _context6.next = 6;
174
+ _context6.next = 7;
154
175
  return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
155
176
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
156
177
  while (1) {
@@ -169,8 +190,8 @@ describe('BIContractActivationWindow', function () {
169
190
  }, _callee4);
170
191
  })));
171
192
 
172
- case 6:
173
- _context6.next = 8;
193
+ case 7:
194
+ _context6.next = 9;
174
195
  return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
175
196
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
176
197
  while (1) {
@@ -190,18 +211,120 @@ describe('BIContractActivationWindow', function () {
190
211
  }, _callee5);
191
212
  })));
192
213
 
193
- case 8:
214
+ case 9:
194
215
  expect(fetchExtraOAuthUrlParams).toHaveBeenCalled();
195
216
  expect(refreshContracts).toHaveBeenCalledTimes(1);
196
217
  expect(InAppBrowser).toHaveBeenCalledWith(expect.objectContaining({
197
218
  url: 'https://testiab.url'
198
219
  }), expect.anything());
199
220
 
200
- case 11:
221
+ case 12:
201
222
  case "end":
202
223
  return _context6.stop();
203
224
  }
204
225
  }
205
226
  }, _callee6);
206
227
  })));
228
+ it('should show account delete dialog after BI connection removed and close harvest', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
229
+ var _setup3, getByRole;
230
+
231
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
232
+ while (1) {
233
+ switch (_context10.prev = _context10.next) {
234
+ case 0:
235
+ Popup.mockImplementation(function () {
236
+ return null;
237
+ });
238
+ prepareOAuth.mockImplementation(function () {
239
+ return {
240
+ oAuthUrl: 'https://test.url'
241
+ };
242
+ });
243
+ isFlagshipApp.mockImplementation(function () {
244
+ return false;
245
+ });
246
+ fetchExtraOAuthUrlParams.mockResolvedValue({});
247
+ _setup3 = setup(), getByRole = _setup3.getByRole;
248
+ _context10.next = 7;
249
+ return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
250
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
251
+ while (1) {
252
+ switch (_context7.prev = _context7.next) {
253
+ case 0:
254
+ _context7.next = 2;
255
+ return waitFor(function () {
256
+ return expect(getByRole('button').getAttribute('class')).not.toContain('Mui-disabled');
257
+ });
258
+
259
+ case 2:
260
+ case "end":
261
+ return _context7.stop();
262
+ }
263
+ }
264
+ }, _callee7);
265
+ })));
266
+
267
+ case 7:
268
+ _context10.next = 9;
269
+ return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
270
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
271
+ while (1) {
272
+ switch (_context8.prev = _context8.next) {
273
+ case 0:
274
+ fireEvent.click(getByRole('button'));
275
+
276
+ case 1:
277
+ case "end":
278
+ return _context8.stop();
279
+ }
280
+ }
281
+ }, _callee8);
282
+ })));
283
+
284
+ case 9:
285
+ checkOAuthData.mockImplementation(function () {
286
+ return true;
287
+ });
288
+ _context10.next = 12;
289
+ return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
290
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
291
+ while (1) {
292
+ switch (_context9.prev = _context9.next) {
293
+ case 0:
294
+ sendMessageFn({
295
+ data: {
296
+ oAuthStateKey: 'statekey',
297
+ finalLocation: 'connection_deleted=true'
298
+ }
299
+ });
300
+ _context9.next = 3;
301
+ return waitFor(function () {
302
+ return expect(getByRole('button', {
303
+ name: 'Close dialog'
304
+ })).toBeInTheDocument();
305
+ });
306
+
307
+ case 3:
308
+ fireEvent.click(getByRole('button', {
309
+ name: 'Close dialog'
310
+ }));
311
+
312
+ case 4:
313
+ case "end":
314
+ return _context9.stop();
315
+ }
316
+ }
317
+ }, _callee9);
318
+ })));
319
+
320
+ case 12:
321
+ expect(onAccountDeleted).toHaveBeenCalled();
322
+
323
+ case 13:
324
+ case "end":
325
+ return _context10.stop();
326
+ }
327
+ }
328
+ }, _callee10);
329
+ })));
207
330
  });
@@ -1,22 +1,26 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ // @ts-check
4
5
  import React, { useState, useEffect } from 'react';
5
6
  import PropTypes from 'prop-types';
6
7
  import { useClient } from 'cozy-client';
7
8
  import Button from 'cozy-ui/transpiled/react/MuiCozyTheme/Buttons';
8
9
  import ListItem from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItem';
10
+ import { Dialog } from 'cozy-ui/transpiled/react/CozyDialogs';
9
11
  import { findKonnectorPolicy } from '../../../konnector-policies';
10
12
  import OAuthWindow from '../../OAuthWindow';
11
13
  import withLocales from '../../hoc/withLocales';
12
14
  import { intentsApiProptype, innerAccountModalOverridesProptype } from '../../../helpers/proptypes';
15
+ import isEqual from 'lodash/isEqual';
13
16
 
14
17
  var BIContractActivationWindow = function BIContractActivationWindow(_ref) {
15
18
  var konnector = _ref.konnector,
16
19
  account = _ref.account,
17
20
  t = _ref.t,
18
21
  intentsApi = _ref.intentsApi,
19
- innerAccountModalOverrides = _ref.innerAccountModalOverrides;
22
+ innerAccountModalOverrides = _ref.innerAccountModalOverrides,
23
+ onAccountDeleted = _ref.onAccountDeleted;
20
24
 
21
25
  var _useState = useState(null),
22
26
  _useState2 = _slicedToArray(_useState, 2),
@@ -30,15 +34,49 @@ var BIContractActivationWindow = function BIContractActivationWindow(_ref) {
30
34
 
31
35
  var _useState5 = useState(false),
32
36
  _useState6 = _slicedToArray(_useState5, 2),
33
- shouldRefreshContracts = _useState6[0],
34
- setShouldRefreshContracts = _useState6[1];
37
+ isDeleteConnectionDialogVisible = _useState6[0],
38
+ setDeleteConnectionDialogVisible = _useState6[1];
39
+
40
+ var _useState7 = useState(false),
41
+ _useState8 = _slicedToArray(_useState7, 2),
42
+ shouldRefreshContracts = _useState8[0],
43
+ setShouldRefreshContracts = _useState8[1];
35
44
 
36
45
  var konnectorPolicy = findKonnectorPolicy(konnector);
37
46
  var client = useClient();
47
+ /**
48
+ * Detects if a BI connection has been removed
49
+ *
50
+ * @param {String} [finalLocation] - url search param string from the final oauth location
51
+ * @returns {Boolean}
52
+ */
53
+
54
+ var isBIConnectionRemoved = function isBIConnectionRemoved(finalLocation) {
55
+ var queryParams = new URLSearchParams(finalLocation);
56
+ return queryParams.get('connection_deleted') === 'true';
57
+ };
58
+ /**
59
+ * @typedef FinalOAuthRealtimeMessage
60
+ * @property {String} finalLocation - url search param string from the final oauth location
61
+ * @property {String|null} err - OAuth error message
62
+ * @property {String} oAuthStateKey - OAuth key
63
+ */
64
+
65
+ /**
66
+ *
67
+ * @param {String} key - OAuth key
68
+ * @param {FinalOAuthRealtimeMessage} [oauthData]
69
+ */
70
+
38
71
 
39
- var onPopupClosed = function onPopupClosed() {
72
+ var onPopupClosed = function onPopupClosed(key, oauthData) {
40
73
  setWindowVisible(false);
41
- setShouldRefreshContracts(true);
74
+
75
+ if (oauthData && isBIConnectionRemoved(oauthData.finalLocation)) {
76
+ setDeleteConnectionDialogVisible(true);
77
+ } else {
78
+ setShouldRefreshContracts(true);
79
+ }
42
80
  };
43
81
 
44
82
  useEffect(function () {
@@ -67,7 +105,8 @@ var BIContractActivationWindow = function BIContractActivationWindow(_ref) {
67
105
  return konnectorPolicy.fetchExtraOAuthUrlParams({
68
106
  client: client,
69
107
  account: account,
70
- konnector: konnector
108
+ konnector: konnector,
109
+ manage: true
71
110
  });
72
111
 
73
112
  case 2:
@@ -87,7 +126,7 @@ var BIContractActivationWindow = function BIContractActivationWindow(_ref) {
87
126
  if (konnectorPolicy.fetchExtraOAuthUrlParams) {
88
127
  handleLinkFetch();
89
128
  }
90
- }, [konnector.slug, account, client, konnectorPolicy]);
129
+ }, [konnector, account, client, konnectorPolicy]);
91
130
  if (!konnectorPolicy.fetchExtraOAuthUrlParams) return null;
92
131
  var ButtonWrapper = innerAccountModalOverrides !== null && innerAccountModalOverrides !== void 0 && innerAccountModalOverrides.SyncButtonWrapperComp ? innerAccountModalOverrides.SyncButtonWrapperComp : React.Fragment;
93
132
  return /*#__PURE__*/React.createElement(ListItem, null, /*#__PURE__*/React.createElement(ButtonWrapper, null, /*#__PURE__*/React.createElement(Button, {
@@ -97,13 +136,25 @@ var BIContractActivationWindow = function BIContractActivationWindow(_ref) {
97
136
  onClick: function onClick() {
98
137
  return setWindowVisible(true);
99
138
  }
100
- }, t('contracts.handle-synchronization'))), isWindowVisible && /*#__PURE__*/React.createElement(OAuthWindow, {
139
+ }, t('contracts.handle-synchronization'))), /*#__PURE__*/React.createElement(Dialog, {
140
+ open: isDeleteConnectionDialogVisible,
141
+ title: t('modal.deleteBIConnection.title'),
142
+ content: t('modal.deleteAccount.description'),
143
+ onClose: onAccountDeleted,
144
+ actions: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
145
+ variant: "text",
146
+ color: "primary",
147
+ "aria-label": "Close dialog",
148
+ onClick: onAccountDeleted
149
+ }, t('close')))
150
+ }), isWindowVisible && /*#__PURE__*/React.createElement(OAuthWindow, {
101
151
  extraParams: extraParams,
102
152
  konnector: konnector,
103
153
  account: account,
104
154
  intentsApi: intentsApi,
105
155
  onSuccess: onPopupClosed,
106
- onCancel: onPopupClosed
156
+ onCancel: onPopupClosed,
157
+ manage: true
107
158
  }));
108
159
  };
109
160
 
@@ -111,6 +162,11 @@ BIContractActivationWindow.propTypes = {
111
162
  t: PropTypes.func,
112
163
  account: PropTypes.object,
113
164
  intentsApi: intentsApiProptype,
114
- innerAccountModalOverrides: innerAccountModalOverridesProptype
115
- };
116
- export default withLocales(BIContractActivationWindow);
165
+ innerAccountModalOverrides: innerAccountModalOverridesProptype,
166
+
167
+ /** What to do when the current account is deleted */
168
+ onAccountDeleted: PropTypes.func
169
+ }; // use isEqual to avoid an infinite rerender since the konnector object is a new one on each render
170
+ // when used in the home application
171
+
172
+ export default /*#__PURE__*/React.memo(withLocales(BIContractActivationWindow), isEqual);
@@ -1,3 +1,4 @@
1
+ // @ts-check
1
2
  import React from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
  import compose from 'lodash/flowRight';
@@ -34,7 +35,8 @@ var DumbContracts = function DumbContracts(_ref2) {
34
35
  account = _ref2.account,
35
36
  konnector = _ref2.konnector,
36
37
  intentsApi = _ref2.intentsApi,
37
- innerAccountModalOverrides = _ref2.innerAccountModalOverrides;
38
+ innerAccountModalOverrides = _ref2.innerAccountModalOverrides,
39
+ onAccountDeleted = _ref2.onAccountDeleted;
38
40
 
39
41
  var _useI18n = useI18n(),
40
42
  t = _useI18n.t;
@@ -57,7 +59,8 @@ var DumbContracts = function DumbContracts(_ref2) {
57
59
  konnector: konnector,
58
60
  account: account,
59
61
  intentsApi: intentsApi,
60
- innerAccountModalOverrides: innerAccountModalOverrides
62
+ innerAccountModalOverrides: innerAccountModalOverrides,
63
+ onAccountDeleted: onAccountDeleted
61
64
  }))));
62
65
  };
63
66
 
@@ -74,9 +77,13 @@ DumbContracts.propTypes = {
74
77
  /** Can be present if showing contracts still linked to an account/konnector/trigger */
75
78
  konnector: PropTypes.object,
76
79
  intentsApi: intentsApiProptype,
77
- innerAccountModalOverrides: innerAccountModalOverridesProptype
80
+ innerAccountModalOverrides: innerAccountModalOverridesProptype,
81
+
82
+ /** What to do when the current account is deleted */
83
+ onAccountDeleted: PropTypes.func
78
84
  };
79
- export var ContractsForAccount = compose(withLocales, queryConnect({
85
+ export var ContractsForAccount = compose(withLocales, // @ts-ignore Aucune surcharge ne correspond à cet appel
86
+ queryConnect({
80
87
  contracts: makeContractsConn
81
88
  }))(DumbContracts);
82
89
  export var Contracts = withLocales(DumbContracts);
@@ -1,12 +1,12 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ // @ts-check
4
5
  import React, { useContext, useState } from 'react';
5
6
  import PropTypes from 'prop-types';
6
7
  import cx from 'classnames';
7
8
  import { useClient } from 'cozy-client';
8
9
  import { Account } from 'cozy-doctypes';
9
- import { useVaultClient, CozyUtils } from 'cozy-keys-lib';
10
10
  import Button from 'cozy-ui/transpiled/react/Button';
11
11
  import Spinner from 'cozy-ui/transpiled/react/Spinner';
12
12
  import palette from 'cozy-ui/transpiled/react/palette';
@@ -22,16 +22,15 @@ import RightIcon from 'cozy-ui/transpiled/react/Icons/Right';
22
22
  import UnlinkIcon from 'cozy-ui/transpiled/react/Icons/Unlink';
23
23
  import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
24
24
  import ListItemSecondaryAction from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItemSecondaryAction';
25
- import Alerter from 'cozy-ui/transpiled/react/Alerter';
26
- import { useVaultUnlockContext } from 'cozy-keys-lib';
25
+ import Alerter from 'cozy-ui/transpiled/react/Alerter'; // @ts-ignore peerDep
26
+
27
+ import { useVaultClient, CozyUtils, useVaultUnlockContext } from 'cozy-keys-lib';
27
28
  import { deleteAccount } from '../../../connections/accounts';
28
29
  import { unshareCipher } from '../../../models/cipherUtils';
29
30
  import { findKonnectorPolicy } from '../../../konnector-policies';
30
31
  import useSafeState from '../../useSafeState';
31
- import TriggerErrorInfo from '../../infos/TriggerErrorInfo';
32
32
  import { MountPointContext } from '../../MountPointContext';
33
33
  import { useTrackPage, useTracker } from '../../hoc/tracking';
34
- import RedirectToAccountFormButton from '../../RedirectToAccountFormButton';
35
34
  import { ContractsForAccount } from './Contracts';
36
35
  import { intentsApiProptype, innerAccountModalOverridesProptype } from '../../../helpers/proptypes';
37
36
  var tabMobileNavListStyle = {
@@ -95,9 +94,9 @@ var ConfigurationTab = function ConfigurationTab(_ref2) {
95
94
  setRequestDeletion = _useState2[1];
96
95
 
97
96
  var tracker = useTracker();
98
- var flowState = flow.getState();
99
- var error = flowState.error,
100
- running = flowState.running;
97
+
98
+ var _flow$getState = flow.getState(),
99
+ running = _flow$getState.running;
101
100
 
102
101
  var _useVaultUnlockContex = useVaultUnlockContext(),
103
102
  showUnlockForm = _useVaultUnlockContex.showUnlockForm;
@@ -159,7 +158,9 @@ var ConfigurationTab = function ConfigurationTab(_ref2) {
159
158
  return deleteAccount(client, account);
160
159
 
161
160
  case 5:
162
- Alerter.success(t('modal.updateAccount.delete-account-success'));
161
+ // @ts-ignore La propriété 'success' n'existe pas sur le type '(...args: any[]) => any'.
162
+ Alerter.success(t('modal.updateAccount.delete-account-success')); // @ts-ignore 0 arguments attendus, mais 1 reçus.
163
+
163
164
  tracker.trackEvent({
164
165
  name: 'compte_bancaire_supprime',
165
166
  connectorSlug: account.account_type
@@ -171,7 +172,8 @@ var ConfigurationTab = function ConfigurationTab(_ref2) {
171
172
  _context2.prev = 9;
172
173
  _context2.t0 = _context2["catch"](1);
173
174
  // eslint-disable-next-line no-console
174
- console.warn('Error while deleting account', _context2.t0);
175
+ console.warn('Error while deleting account', _context2.t0); // @ts-ignore La propriété 'error' n'existe pas sur le type '(...args: any[]) => any'.
176
+
175
177
  Alerter.error(t('modal.updateAccount.delete-account-error'));
176
178
 
177
179
  case 13:
@@ -229,17 +231,7 @@ var ConfigurationTab = function ConfigurationTab(_ref2) {
229
231
  var konnectorPolicy = findKonnectorPolicy(konnector);
230
232
  return /*#__PURE__*/React.createElement("div", {
231
233
  className: isMobile ? '' : 'u-pt-1 u-pb-1-half'
232
- }, error && /*#__PURE__*/React.createElement("div", {
233
- className: isMobile ? 'u-p-1' : 'u-pb-2'
234
- }, /*#__PURE__*/React.createElement(TriggerErrorInfo, {
235
- error: error,
236
- konnector: konnector,
237
- trigger: flow.trigger,
238
- action: error.isSolvableViaReconnect() ? /*#__PURE__*/React.createElement(RedirectToAccountFormButton, {
239
- konnector: konnector,
240
- trigger: flow.trigger
241
- }) : null
242
- })), /*#__PURE__*/React.createElement(NavigationList, {
234
+ }, /*#__PURE__*/React.createElement(NavigationList, {
243
235
  style: isMobile ? tabMobileNavListStyle : null
244
236
  }, /*#__PURE__*/React.createElement(NavigationListHeader, null, t('modal.updateAccount.general-subheader')), /*#__PURE__*/React.createElement(NavigationListSection, null, konnector.oauth || konnectorPolicy.isBIWebView ? null : /*#__PURE__*/React.createElement(ListItem, {
245
237
  button: true,
@@ -274,7 +266,8 @@ var ConfigurationTab = function ConfigurationTab(_ref2) {
274
266
  konnector: konnector,
275
267
  account: account,
276
268
  intentsApi: intentsApi,
277
- innerAccountModalOverrides: innerAccountModalOverrides
269
+ innerAccountModalOverrides: innerAccountModalOverrides,
270
+ onAccountDeleted: onAccountDeleted
278
271
  })), showNewAccountButton ? /*#__PURE__*/React.createElement("div", {
279
272
  className: cx('u-ta-right u-mt-1', isMobile ? 'u-ph-1 u-pb-1' : null)
280
273
  }, /*#__PURE__*/React.createElement(Button, {