cozy-harvest-lib 9.27.2 → 9.28.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 (62) hide show
  1. package/CHANGELOG.md +20 -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.js +11 -5
  5. package/dist/components/KonnectorConfiguration/ConfigurationTab/index.js +4 -16
  6. package/dist/components/KonnectorConfiguration/ConfigurationTab/index.spec.js +13 -33
  7. package/dist/components/KonnectorConfiguration/DataTab/index.js +1 -11
  8. package/dist/components/KonnectorConfiguration/DataTab.spec.js +0 -21
  9. package/dist/components/KonnectorConfiguration/KonnectorAccountTabs.js +66 -1
  10. package/dist/components/KonnectorConfiguration/KonnectorAccountTabs.spec.js +276 -2
  11. package/dist/components/OAuthForm.js +110 -173
  12. package/dist/components/OAuthForm.spec.js +186 -60
  13. package/dist/components/OAuthWindow.js +8 -2
  14. package/dist/components/TriggerManager.js +4 -4
  15. package/dist/components/TriggerManager.spec.js +1 -1
  16. package/dist/components/TwoFAModal.spec.js +8 -2
  17. package/dist/components/__snapshots__/OAuthForm.spec.js.snap +121 -30
  18. package/dist/components/cards/LaunchTriggerCard.js +6 -5
  19. package/dist/components/cards/LaunchTriggerCard.spec.js +77 -4
  20. package/dist/components/hooks/useOAuthExtraParams.js +82 -0
  21. package/dist/helpers/oauth.js +16 -4
  22. package/dist/konnector-policies.js +10 -1
  23. package/dist/models/ConnectionFlow.js +66 -26
  24. package/dist/models/ConnectionFlow.spec.js +278 -60
  25. package/dist/models/flowEvents.js +1 -0
  26. package/dist/models/withConnectionFlow.spec.js +10 -1
  27. package/dist/services/biWebView.js +30 -17
  28. package/dist/services/biWebView.spec.js +19 -10
  29. package/dist/services/budget-insight.js +2 -2
  30. package/dist/services/jobUtils.js +7 -4
  31. package/dist/types.js +11 -0
  32. package/package.json +4 -3
  33. package/src/components/FlowProvider.jsx +1 -1
  34. package/src/components/FlowProvider.spec.jsx +3 -0
  35. package/src/components/KonnectorConfiguration/ConfigurationTab/BiContractActivationWindow.jsx +9 -3
  36. package/src/components/KonnectorConfiguration/ConfigurationTab/index.jsx +1 -22
  37. package/src/components/KonnectorConfiguration/ConfigurationTab/index.spec.jsx +0 -19
  38. package/src/components/KonnectorConfiguration/DataTab/index.jsx +1 -18
  39. package/src/components/KonnectorConfiguration/DataTab.spec.jsx +0 -16
  40. package/src/components/KonnectorConfiguration/KonnectorAccountTabs.jsx +72 -0
  41. package/src/components/KonnectorConfiguration/KonnectorAccountTabs.spec.jsx +114 -2
  42. package/src/components/OAuthForm.jsx +105 -121
  43. package/src/components/OAuthForm.spec.js +71 -52
  44. package/src/components/OAuthWindow.jsx +12 -2
  45. package/src/components/TriggerManager.jsx +3 -3
  46. package/src/components/TriggerManager.spec.jsx +1 -1
  47. package/src/components/TwoFAModal.spec.jsx +8 -2
  48. package/src/components/__snapshots__/OAuthForm.spec.js.snap +121 -30
  49. package/src/components/cards/LaunchTriggerCard.jsx +3 -5
  50. package/src/components/cards/LaunchTriggerCard.spec.jsx +70 -8
  51. package/src/components/hooks/useOAuthExtraParams.js +43 -0
  52. package/src/helpers/oauth.js +13 -3
  53. package/src/konnector-policies.js +9 -1
  54. package/src/models/ConnectionFlow.js +47 -11
  55. package/src/models/ConnectionFlow.spec.js +162 -20
  56. package/src/models/flowEvents.js +1 -0
  57. package/src/models/withConnectionFlow.spec.jsx +11 -1
  58. package/src/services/biWebView.js +21 -8
  59. package/src/services/biWebView.spec.js +11 -7
  60. package/src/services/budget-insight.js +2 -2
  61. package/src/services/jobUtils.js +6 -3
  62. package/src/types.js +11 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,26 @@
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.28.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.27.2...cozy-harvest-lib@9.28.0) (2022-10-24)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Add useEffect dependencies to useOAuthExtraParams hook ([fb046e4](https://github.com/cozy/cozy-libs/commit/fb046e4034754075a65f5dd4ffd184ba6e180941))
12
+ * Do not depend only on konnector.slug for useEffect dependencies ([65869cf](https://github.com/cozy/cozy-libs/commit/65869cfd154a8e925c6b1ef6ee084883e4484cdf))
13
+
14
+
15
+ ### Features
16
+
17
+ * Do not create trigger with full webhooks flag ([8ce5e78](https://github.com/cozy/cozy-libs/commit/8ce5e786e30e48fa46e0d31a912560740c5206a3))
18
+ * Reconnection with BI webviews & webhooks ([591047b](https://github.com/cozy/cozy-libs/commit/591047b0143dab480952d67787451ffeddb57632))
19
+ * Send realtime notifications when expecting a trigger ([b76da3d](https://github.com/cozy/cozy-libs/commit/b76da3d5ec184c6dcc4c2555f92aec6aa523b294))
20
+ * Use BI manage url to update contract synchronization ([fad2994](https://github.com/cozy/cozy-libs/commit/fad2994458e3c0c1f4ee1833855b60ea590fab49))
21
+
22
+
23
+
24
+
25
+
6
26
  ## [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
27
 
8
28
 
@@ -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 = {
@@ -1,6 +1,7 @@
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';
@@ -10,6 +11,7 @@ import { findKonnectorPolicy } from '../../../konnector-policies';
10
11
  import OAuthWindow from '../../OAuthWindow';
11
12
  import withLocales from '../../hoc/withLocales';
12
13
  import { intentsApiProptype, innerAccountModalOverridesProptype } from '../../../helpers/proptypes';
14
+ import isEqual from 'lodash/isEqual';
13
15
 
14
16
  var BIContractActivationWindow = function BIContractActivationWindow(_ref) {
15
17
  var konnector = _ref.konnector,
@@ -67,7 +69,8 @@ var BIContractActivationWindow = function BIContractActivationWindow(_ref) {
67
69
  return konnectorPolicy.fetchExtraOAuthUrlParams({
68
70
  client: client,
69
71
  account: account,
70
- konnector: konnector
72
+ konnector: konnector,
73
+ manage: true
71
74
  });
72
75
 
73
76
  case 2:
@@ -87,7 +90,7 @@ var BIContractActivationWindow = function BIContractActivationWindow(_ref) {
87
90
  if (konnectorPolicy.fetchExtraOAuthUrlParams) {
88
91
  handleLinkFetch();
89
92
  }
90
- }, [konnector.slug, account, client, konnectorPolicy]);
93
+ }, [konnector, account, client, konnectorPolicy]);
91
94
  if (!konnectorPolicy.fetchExtraOAuthUrlParams) return null;
92
95
  var ButtonWrapper = innerAccountModalOverrides !== null && innerAccountModalOverrides !== void 0 && innerAccountModalOverrides.SyncButtonWrapperComp ? innerAccountModalOverrides.SyncButtonWrapperComp : React.Fragment;
93
96
  return /*#__PURE__*/React.createElement(ListItem, null, /*#__PURE__*/React.createElement(ButtonWrapper, null, /*#__PURE__*/React.createElement(Button, {
@@ -103,7 +106,8 @@ var BIContractActivationWindow = function BIContractActivationWindow(_ref) {
103
106
  account: account,
104
107
  intentsApi: intentsApi,
105
108
  onSuccess: onPopupClosed,
106
- onCancel: onPopupClosed
109
+ onCancel: onPopupClosed,
110
+ manage: true
107
111
  }));
108
112
  };
109
113
 
@@ -112,5 +116,7 @@ BIContractActivationWindow.propTypes = {
112
116
  account: PropTypes.object,
113
117
  intentsApi: intentsApiProptype,
114
118
  innerAccountModalOverrides: innerAccountModalOverridesProptype
115
- };
116
- export default withLocales(BIContractActivationWindow);
119
+ }; // use isEqual to avoid an infinite rerender since the konnector object is a new one on each render
120
+ // when used in the home application
121
+
122
+ export default /*#__PURE__*/React.memo(withLocales(BIContractActivationWindow), isEqual);
@@ -28,10 +28,8 @@ import { deleteAccount } from '../../../connections/accounts';
28
28
  import { unshareCipher } from '../../../models/cipherUtils';
29
29
  import { findKonnectorPolicy } from '../../../konnector-policies';
30
30
  import useSafeState from '../../useSafeState';
31
- import TriggerErrorInfo from '../../infos/TriggerErrorInfo';
32
31
  import { MountPointContext } from '../../MountPointContext';
33
32
  import { useTrackPage, useTracker } from '../../hoc/tracking';
34
- import RedirectToAccountFormButton from '../../RedirectToAccountFormButton';
35
33
  import { ContractsForAccount } from './Contracts';
36
34
  import { intentsApiProptype, innerAccountModalOverridesProptype } from '../../../helpers/proptypes';
37
35
  var tabMobileNavListStyle = {
@@ -95,9 +93,9 @@ var ConfigurationTab = function ConfigurationTab(_ref2) {
95
93
  setRequestDeletion = _useState2[1];
96
94
 
97
95
  var tracker = useTracker();
98
- var flowState = flow.getState();
99
- var error = flowState.error,
100
- running = flowState.running;
96
+
97
+ var _flow$getState = flow.getState(),
98
+ running = _flow$getState.running;
101
99
 
102
100
  var _useVaultUnlockContex = useVaultUnlockContext(),
103
101
  showUnlockForm = _useVaultUnlockContex.showUnlockForm;
@@ -229,17 +227,7 @@ var ConfigurationTab = function ConfigurationTab(_ref2) {
229
227
  var konnectorPolicy = findKonnectorPolicy(konnector);
230
228
  return /*#__PURE__*/React.createElement("div", {
231
229
  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, {
230
+ }, /*#__PURE__*/React.createElement(NavigationList, {
243
231
  style: isMobile ? tabMobileNavListStyle : null
244
232
  }, /*#__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
233
  button: true,
@@ -13,7 +13,6 @@ import React from 'react';
13
13
  import { MountPointProvider } from '../../../components/MountPointContext';
14
14
  import { createMockClient } from 'cozy-client/dist/mock';
15
15
  import { deleteAccount } from '../../../connections/accounts';
16
- import { KonnectorJobError } from '../../../helpers/konnectors';
17
16
  import AppLike from '../../../../test/AppLike';
18
17
  import { VaultProvider, VaultUnlockPlaceholder, VaultUnlockProvider, useVaultClient } from 'cozy-keys-lib';
19
18
  import { findKonnectorPolicy } from '../../../konnector-policies';
@@ -128,36 +127,17 @@ describe('ConfigurationTab', function () {
128
127
 
129
128
  expect(root.getByText('Identifiers')).toBeTruthy();
130
129
  });
131
- describe('reconnect button', function () {
132
- it('should show a reconnect button if error is solvable by reconnecting through form', function () {
133
- var _setup2 = setup({
134
- checkShouldUnlock: jest.fn().mockResolvedValue(false),
135
- trigger: {
136
- message: {
137
- account: 'account-id-123',
138
- konnector: 'konnector-slug'
139
- }
140
- },
141
- flowState: {
142
- error: new KonnectorJobError('LOGIN_FAILED')
143
- }
144
- }),
145
- root = _setup2.root;
146
-
147
- expect(root.getByText('Reconnect')).toBeTruthy();
148
- });
149
- });
150
130
  describe('deletion modal', function () {
151
131
  it('should display deletion modal when clicking on disconnect this account (vault does not need to be unlocked)', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
152
- var _setup3, root, btn, modalText, confirmBtn;
132
+ var _setup2, root, btn, modalText, confirmBtn;
153
133
 
154
134
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
155
135
  while (1) {
156
136
  switch (_context2.prev = _context2.next) {
157
137
  case 0:
158
- _setup3 = setup({
138
+ _setup2 = setup({
159
139
  checkShouldUnlock: jest.fn().mockResolvedValue(false)
160
- }), root = _setup3.root;
140
+ }), root = _setup2.root;
161
141
  useVaultClient.mockReturnValue({
162
142
  isLocked: jest.fn().mockResolvedValue(false)
163
143
  });
@@ -198,7 +178,7 @@ describe('ConfigurationTab', function () {
198
178
  }, _callee2);
199
179
  })));
200
180
  it('should display deletion modal when clicking on disconnect this account (vault needs to be unlocked, connector policy does not save in vault)', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
201
- var _setup4, root, btn, confirmBtn;
181
+ var _setup3, root, btn, confirmBtn;
202
182
 
203
183
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
204
184
  while (1) {
@@ -209,9 +189,9 @@ describe('ConfigurationTab', function () {
209
189
  saveInVault: false
210
190
  };
211
191
  });
212
- _setup4 = setup({
192
+ _setup3 = setup({
213
193
  checkShouldUnlock: jest.fn().mockResolvedValue(true)
214
- }), root = _setup4.root;
194
+ }), root = _setup3.root;
215
195
  btn = root.getByText('Disconnect this account');
216
196
  expect(root.queryByText('Your account will be disconnected, but already imported data will be kept.')).toBeFalsy();
217
197
  fireEvent.click(btn);
@@ -245,7 +225,7 @@ describe('ConfigurationTab', function () {
245
225
  }, _callee4);
246
226
  })));
247
227
  xit('should display deletion modal when clicking on disconnect this account (vault needs to be unlocked, connector policy saves in vault)', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
248
- var _setup5, root, btn, confirmBtn;
228
+ var _setup4, root, btn, confirmBtn;
249
229
 
250
230
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
251
231
  while (1) {
@@ -257,9 +237,9 @@ describe('ConfigurationTab', function () {
257
237
  useVaultClient.mockReturnValue({
258
238
  isLocked: jest.fn().mockResolvedValue(true)
259
239
  });
260
- _setup5 = setup({
240
+ _setup4 = setup({
261
241
  checkShouldUnlock: jest.fn().mockResolvedValue(true)
262
- }), root = _setup5.root;
242
+ }), root = _setup4.root;
263
243
  btn = root.getByText('Disconnect this account');
264
244
  expect(root.queryByText('Your account will be disconnected, but already imported data will be kept.')).toBeFalsy();
265
245
  fireEvent.click(btn);
@@ -318,12 +298,12 @@ describe('ConfigurationTab', function () {
318
298
  isLocked: jest.fn().mockResolvedValue(false)
319
299
  });
320
300
 
321
- var _setup6 = setup({
301
+ var _setup5 = setup({
322
302
  konnector: {
323
303
  oauth: true
324
304
  }
325
305
  }),
326
- root = _setup6.root;
306
+ root = _setup5.root;
327
307
 
328
308
  expect(root.queryByText('Identifiers')).toBe(null);
329
309
  });
@@ -337,14 +317,14 @@ describe('ConfigurationTab', function () {
337
317
  isLocked: jest.fn().mockResolvedValue(false)
338
318
  });
339
319
 
340
- var _setup7 = setup({
320
+ var _setup6 = setup({
341
321
  konnector: {
342
322
  partnership: {
343
323
  domain: 'budget-insight.com'
344
324
  }
345
325
  }
346
326
  }),
347
- root = _setup7.root;
327
+ root = _setup6.root;
348
328
 
349
329
  expect(root.queryByText('Identifiers')).toBe(null);
350
330
  });
@@ -12,12 +12,10 @@ import LaunchTriggerCard from '../../../components/cards/LaunchTriggerCard';
12
12
  import KonnectorMaintenance from '../../../components/Maintenance';
13
13
  import AppLinkCard from '../../../components/cards/AppLinkCard';
14
14
  import WebsiteLinkCard from '../../../components/cards/WebsiteLinkCard';
15
- import TriggerErrorInfo from '../../../components/infos/TriggerErrorInfo';
16
15
  import useMaintenanceStatus from '../../../components/hooks/useMaintenanceStatus';
17
16
  import getRelatedAppsSlugs from '../../../models/getRelatedAppsSlugs';
18
17
  import appLinksProps from '../../../components/KonnectorConfiguration/DataTab/appLinksProps';
19
18
  import { useTrackPage } from '../../../components/hoc/tracking';
20
- import RedirectToAccountFormButton from '../../RedirectToAccountFormButton';
21
19
  import Datacards from '../../Datacards';
22
20
  export var DataTab = function DataTab(_ref) {
23
21
  var konnector = _ref.konnector,
@@ -31,9 +29,8 @@ export var DataTab = function DataTab(_ref) {
31
29
 
32
30
  var flowState = flow.getState();
33
31
  var error = flowState.error;
34
- var hasError = !!error;
35
32
  useTrackPage('donnees');
36
- var hasTermsVersionMismatchError = hasError && error.isTermsVersionMismatchError();
33
+ var hasTermsVersionMismatchError = !!error && error.isTermsVersionMismatchError();
37
34
  var appLinks = getRelatedAppsSlugs({
38
35
  konnectorManifest: konnector,
39
36
  trigger: trigger
@@ -59,13 +56,6 @@ export var DataTab = function DataTab(_ref) {
59
56
  })), konnectorsModel.hasNewVersionAvailable(konnector) && /*#__PURE__*/React.createElement(KonnectorUpdateInfos, {
60
57
  konnector: konnector,
61
58
  isBlocking: hasTermsVersionMismatchError
62
- }), hasError && !isInMaintenance && /*#__PURE__*/React.createElement(TriggerErrorInfo, {
63
- error: error,
64
- konnector: konnector,
65
- action: error.isSolvableViaReconnect() ? /*#__PURE__*/React.createElement(RedirectToAccountFormButton, {
66
- konnector: konnector,
67
- trigger: trigger
68
- }) : null
69
59
  }), /*#__PURE__*/React.createElement(LaunchTriggerCard, {
70
60
  flow: flow,
71
61
  disabled: isInMaintenance
@@ -9,7 +9,6 @@ import { shallow } from 'enzyme';
9
9
  import { DataTab } from 'components/KonnectorConfiguration/DataTab';
10
10
  import LaunchTriggerCard from 'components/cards/LaunchTriggerCard';
11
11
  import AppLinkCard from 'components/cards/AppLinkCard';
12
- import TriggerErrorInfo from 'components/infos/TriggerErrorInfo';
13
12
  import KonnectorMaintenance from 'components/Maintenance';
14
13
  import useMaintenanceStatus from 'components/hooks/useMaintenanceStatus';
15
14
  jest.mock('components/hooks/useMaintenanceStatus');
@@ -70,32 +69,12 @@ describe('DataTab', function () {
70
69
  var component = setup();
71
70
  expect(component.find(LaunchTriggerCard).length).toEqual(1);
72
71
  });
73
- it('should show error info', function () {
74
- var component = setup({}, {
75
- isError: true
76
- });
77
- expect(component.find(TriggerErrorInfo).length).toEqual(1);
78
- });
79
72
  it('should show maintenance info', function () {
80
73
  var component = setup({}, {
81
74
  isInMaintenance: true
82
75
  });
83
76
  expect(component.find(KonnectorMaintenance).length).toEqual(1);
84
77
  });
85
- it('should show error info if konnector is not in maintenance', function () {
86
- var component = setup({}, {
87
- isError: true,
88
- isInMaintenance: false
89
- });
90
- expect(component.find(TriggerErrorInfo).length).toEqual(1);
91
- });
92
- it('should not show error info if konnector is in maintenance', function () {
93
- var component = setup({}, {
94
- isError: true,
95
- isInMaintenance: true
96
- });
97
- expect(component.find(TriggerErrorInfo).length).toEqual(0);
98
- });
99
78
  describe('links to other apps', function () {
100
79
  it('should show the link to drive when the konnector saves files', function () {
101
80
  var withoutFolder = setup({
@@ -2,16 +2,25 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import React, { useState, useRef, useCallback } from 'react';
4
4
  import PropTypes from 'prop-types';
5
+ import { useClient } from 'cozy-client';
6
+ import flag from 'cozy-flags';
5
7
  import { makeStyles } from '@material-ui/core/styles';
6
8
  import { Tab as UITab, Tabs } from 'cozy-ui/transpiled/react/MuiTabs';
7
9
  import Divider from 'cozy-ui/transpiled/react/MuiCozyTheme/Divider';
8
10
  import { useI18n } from 'cozy-ui/transpiled/react/I18n';
9
11
  import useBreakpoints from 'cozy-ui/transpiled/react/hooks/useBreakpoints';
10
12
  import SwipeableViews from 'react-swipeable-views';
13
+ import Button from 'cozy-ui/transpiled/react/Buttons';
11
14
  import useDOMMutations from '../hooks/useDOMMutations';
12
15
  import FlowProvider from '../FlowProvider';
13
16
  import DataTab from './DataTab';
14
17
  import ConfigurationTab from './ConfigurationTab';
18
+ import TriggerErrorInfo from '../infos/TriggerErrorInfo';
19
+ import RedirectToAccountFormButton from '../RedirectToAccountFormButton';
20
+ import useOAuthExtraParams from '../hooks/useOAuthExtraParams';
21
+ import OAuthWindow from '../OAuthWindow';
22
+ import { findKonnectorPolicy } from '../../konnector-policies';
23
+ import useMaintenanceStatus from '../hooks/useMaintenanceStatus';
15
24
  import { intentsApiProptype, innerAccountModalOverridesProptype } from '../../helpers/proptypes';
16
25
  var tabIndexes = {
17
26
  data: 0,
@@ -62,6 +71,10 @@ var DumbKonnectorAccountTabs = function DumbKonnectorAccountTabs(props) {
62
71
  flow = props.flow,
63
72
  intentsApi = props.intentsApi,
64
73
  innerAccountModalOverrides = props.innerAccountModalOverrides;
74
+ var client = useClient();
75
+
76
+ var _useI18n2 = useI18n(),
77
+ t = _useI18n2.t;
65
78
 
66
79
  var _useBreakpoints = useBreakpoints(),
67
80
  isMobile = _useBreakpoints.isMobile;
@@ -71,6 +84,9 @@ var DumbKonnectorAccountTabs = function DumbKonnectorAccountTabs(props) {
71
84
  tab = _useState2[0],
72
85
  setTab = _useState2[1];
73
86
 
87
+ var _useMaintenanceStatus = useMaintenanceStatus(client, konnector),
88
+ isInMaintenance = _useMaintenanceStatus.data.isInMaintenance;
89
+
74
90
  var handleTabChange = function handleTabChange(ev, newTab) {
75
91
  return setTab(newTab);
76
92
  };
@@ -85,13 +101,62 @@ var DumbKonnectorAccountTabs = function DumbKonnectorAccountTabs(props) {
85
101
  return swipeableActions.current.updateHeight();
86
102
  }, [swipeableActions]);
87
103
  useDOMMutations(nodeRef.current, domMutationsConfig, updateSwiperHeight);
104
+ var konnectorPolicy = findKonnectorPolicy(konnector);
105
+
106
+ var _useOAuthExtraParams = useOAuthExtraParams({
107
+ account: account,
108
+ client: client,
109
+ konnector: konnector,
110
+ reconnect: true
111
+ }),
112
+ extraParams = _useOAuthExtraParams.extraParams;
113
+
114
+ var _useState3 = useState(false),
115
+ _useState4 = _slicedToArray(_useState3, 2),
116
+ showBIWebView = _useState4[0],
117
+ setShowBIWebView = _useState4[1];
118
+
119
+ var hideBIWebView = useCallback(function () {
120
+ setShowBIWebView(false);
121
+ }, []);
122
+ var handleClick = useCallback(function () {
123
+ setShowBIWebView(true);
124
+
125
+ if (flag('harvest.bi.fullwebhooks')) {
126
+ flow.expectTriggerLaunch();
127
+ }
128
+ }, [flow]);
129
+ var errorActionButton = konnectorPolicy.isBIWebView ? /*#__PURE__*/React.createElement(Button, {
130
+ className: "u-ml-0",
131
+ variant: "secondary",
132
+ label: t('error.reconnect-via-form'),
133
+ onClick: handleClick,
134
+ disabled: !extraParams,
135
+ busy: !extraParams
136
+ }) : /*#__PURE__*/React.createElement(RedirectToAccountFormButton, {
137
+ konnector: konnector,
138
+ trigger: initialTrigger
139
+ });
88
140
  return /*#__PURE__*/React.createElement("div", {
89
141
  ref: nodeRef
90
142
  }, /*#__PURE__*/React.createElement(KonnectorAccountTabsTabs, {
91
143
  tab: tab,
92
144
  onChange: handleTabChange,
93
145
  flowState: flowState
94
- }), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(SwipeableViews, {
146
+ }), /*#__PURE__*/React.createElement(Divider, null), error && !isInMaintenance && /*#__PURE__*/React.createElement(TriggerErrorInfo, {
147
+ error: error,
148
+ konnector: konnector,
149
+ action: error.isSolvableViaReconnect() ? errorActionButton : null,
150
+ className: "u-mt-1"
151
+ }), showBIWebView && /*#__PURE__*/React.createElement(OAuthWindow, {
152
+ extraParams: extraParams,
153
+ konnector: konnector,
154
+ reconnect: true,
155
+ onSuccess: hideBIWebView,
156
+ onCancel: hideBIWebView,
157
+ account: account,
158
+ intentsApi: intentsApi
159
+ }), /*#__PURE__*/React.createElement(SwipeableViews, {
95
160
  animateHeight: true,
96
161
  index: tab,
97
162
  disabled: true,