cozy-harvest-lib 30.8.2 → 31.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.
Files changed (96) hide show
  1. package/.storybook/main.ts +1 -0
  2. package/.storybook/preview.tsx +4 -1
  3. package/CHANGELOG.md +34 -0
  4. package/dist/components/AccountForm/index.js +1 -2
  5. package/dist/components/AccountModal.js +16 -5
  6. package/dist/components/AccountModal.spec.js +2 -4
  7. package/dist/components/AccountModalWithoutTabs/AccountModalHeader.js +25 -22
  8. package/dist/components/AccountModalWithoutTabs/AccountModalHeader.stories.js +35 -0
  9. package/dist/components/AccountSelectBox/AccountSelectorHeader.js +20 -12
  10. package/dist/components/AccountSelectBox/AccountSelectorHeader.stories.js +0 -8
  11. package/dist/components/AccountsListModal.js +7 -9
  12. package/dist/components/EditAccountModal.js +26 -8
  13. package/dist/components/HarvestModalRoot.js +10 -9
  14. package/dist/components/{Routes.js → HarvestRoutes.js} +5 -11
  15. package/dist/components/HarvestWrapper.js +3 -7
  16. package/dist/components/{Routes/RoutesV6.js → InternalRoutes.js} +10 -10
  17. package/dist/components/KonnectorAccounts.js +11 -2
  18. package/dist/components/KonnectorConfiguration/ConfigurationTab/index.js +4 -7
  19. package/dist/components/KonnectorConfiguration/ConfigurationTab/index.spec.js +6 -4
  20. package/dist/components/KonnectorConfiguration/KonnectorAccountWrapper.spec.js +1 -4
  21. package/dist/components/KonnectorSuccess.js +1 -2
  22. package/dist/components/NewAccountModal.js +7 -5
  23. package/dist/components/NewAccountModal.spec.js +30 -22
  24. package/dist/components/OAuthForm.js +7 -7
  25. package/dist/components/OAuthForm.spec.js +11 -13
  26. package/dist/components/RedirectToAccountFormButton.js +7 -8
  27. package/dist/components/RedirectToAccountFormButton.spec.js +20 -11
  28. package/dist/components/TriggerManager.spec.js +24 -34
  29. package/dist/components/__snapshots__/AccountModal.spec.jsx.snap +3 -3
  30. package/dist/components/cards/ErrorAlert.js +3 -5
  31. package/dist/components/cards/ErrorAlert.stories.js +0 -1
  32. package/dist/components/cards/LaunchButton.js +3 -2
  33. package/dist/components/cards/LaunchTriggerAlert.js +1 -5
  34. package/dist/components/cards/LaunchTriggerAlert.spec.js +17 -6
  35. package/dist/components/cards/MaintenanceAlert.js +3 -4
  36. package/dist/components/cards/RunnableAlert.js +3 -5
  37. package/dist/components/cards/RunnableAlert.stories.js +0 -1
  38. package/dist/components/cards/TriggerAlert.js +0 -4
  39. package/dist/components/cards/TriggerAlert.stories.js +0 -1
  40. package/dist/components/cards/actions/configureAction.js +4 -2
  41. package/dist/components/cards/actions/connectAction.js +2 -2
  42. package/dist/components/cards/actions/launchAction.js +4 -2
  43. package/dist/datacards/FileDataCard.js +4 -6
  44. package/dist/datacards/ViewerModal.js +7 -9
  45. package/dist/index.js +2 -2
  46. package/package.json +7 -7
  47. package/src/components/AccountForm/index.jsx +0 -2
  48. package/src/components/AccountModal.jsx +13 -6
  49. package/src/components/AccountModal.spec.jsx +2 -4
  50. package/src/components/AccountModalWithoutTabs/AccountModalHeader.jsx +17 -17
  51. package/src/components/AccountModalWithoutTabs/AccountModalHeader.stories.js +40 -0
  52. package/src/components/AccountSelectBox/AccountSelectorHeader.stories.ts +0 -4
  53. package/src/components/AccountSelectBox/AccountSelectorHeader.tsx +18 -14
  54. package/src/components/AccountsListModal.jsx +9 -5
  55. package/src/components/EditAccountModal.jsx +74 -68
  56. package/src/components/HarvestModalRoot.jsx +4 -7
  57. package/src/components/{Routes.jsx → HarvestRoutes.jsx} +5 -10
  58. package/src/components/HarvestWrapper.jsx +12 -19
  59. package/src/components/{Routes/RoutesV6.jsx → InternalRoutes.jsx} +10 -10
  60. package/src/components/KonnectorAccounts.jsx +8 -6
  61. package/src/components/KonnectorConfiguration/ConfigurationTab/index.jsx +4 -5
  62. package/src/components/KonnectorConfiguration/ConfigurationTab/index.spec.jsx +17 -15
  63. package/src/components/KonnectorConfiguration/KonnectorAccountWrapper.spec.jsx +14 -17
  64. package/src/components/KonnectorSuccess.jsx +1 -2
  65. package/src/components/NewAccountModal.jsx +5 -4
  66. package/src/components/NewAccountModal.spec.jsx +34 -24
  67. package/src/components/OAuthForm.jsx +5 -5
  68. package/src/components/OAuthForm.spec.js +11 -14
  69. package/src/components/RedirectToAccountFormButton.jsx +8 -6
  70. package/src/components/RedirectToAccountFormButton.spec.jsx +14 -11
  71. package/src/components/TriggerManager.spec.jsx +10 -19
  72. package/src/components/__snapshots__/AccountModal.spec.jsx.snap +3 -3
  73. package/src/components/cards/ErrorAlert.jsx +3 -5
  74. package/src/components/cards/ErrorAlert.stories.jsx +0 -1
  75. package/src/components/cards/LaunchButton.jsx +4 -4
  76. package/src/components/cards/LaunchTriggerAlert.jsx +1 -5
  77. package/src/components/cards/LaunchTriggerAlert.spec.jsx +14 -10
  78. package/src/components/cards/MaintenanceAlert.jsx +4 -4
  79. package/src/components/cards/RunnableAlert.jsx +3 -5
  80. package/src/components/cards/RunnableAlert.stories.jsx +0 -1
  81. package/src/components/cards/TriggerAlert.jsx +0 -4
  82. package/src/components/cards/TriggerAlert.stories.jsx +0 -1
  83. package/src/components/cards/actions/configureAction.js +6 -4
  84. package/src/components/cards/actions/connectAction.js +2 -2
  85. package/src/components/cards/actions/launchAction.js +6 -4
  86. package/src/datacards/FileDataCard.jsx +5 -5
  87. package/src/datacards/ViewerModal.jsx +7 -6
  88. package/src/index.js +2 -2
  89. package/dist/components/MountPointContext.js +0 -81
  90. package/dist/components/Routes/RoutesV4.js +0 -84
  91. package/dist/components/hoc/withRouter.js +0 -75
  92. package/dist/components/hoc/withRouter.spec.js +0 -85
  93. package/src/components/MountPointContext.jsx +0 -67
  94. package/src/components/Routes/RoutesV4.jsx +0 -90
  95. package/src/components/hoc/withRouter.jsx +0 -83
  96. package/src/components/hoc/withRouter.spec.jsx +0 -56
@@ -6,6 +6,7 @@ const config: StorybookConfig = {
6
6
  "@storybook/addon-links",
7
7
  "@storybook/addon-essentials",
8
8
  "@storybook/addon-interactions",
9
+ "storybook-addon-remix-react-router"
9
10
  ],
10
11
  framework: {
11
12
  name: "@storybook/react-webpack5",
@@ -5,6 +5,8 @@ import 'cozy-ui/dist/cozy-ui.utils.min.css'
5
5
  import 'cozy-ui/transpiled/react/stylesheet.css'
6
6
  import React from "react";
7
7
  import { StoryContainer } from "./StoryContainer";
8
+ import { withRouter } from 'storybook-addon-remix-react-router';
9
+
8
10
 
9
11
  const preview: Preview = {
10
12
  decorators: [
@@ -15,6 +17,7 @@ const preview: Preview = {
15
17
  </div>
16
18
  </StoryContainer>
17
19
  ),
20
+ withRouter
18
21
  ],
19
22
  parameters: {
20
23
  actions: { argTypesRegex: "^on[A-Z].*" },
@@ -23,7 +26,7 @@ const preview: Preview = {
23
26
  color: /(background|color)$/i,
24
27
  date: /Date$/,
25
28
  },
26
- },
29
+ }
27
30
  },
28
31
  };
29
32
 
package/CHANGELOG.md CHANGED
@@ -3,6 +3,40 @@
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
+ # [31.0.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@30.8.3...cozy-harvest-lib@31.0.0) (2024-11-28)
7
+
8
+
9
+ ### Code Refactoring
10
+
11
+ * Rename Routes to HarvestRoutes ([760608a](https://github.com/cozy/cozy-libs/commit/760608a4d8c4f42d5a5a1150d8bbbc89e08c3cd1))
12
+
13
+
14
+ ### Features
15
+
16
+ * **AccountModalHeader:** Add a story to test the component ([dbe8d8a](https://github.com/cozy/cozy-libs/commit/dbe8d8a90649636572e8edf4f49519c98cf30b01))
17
+ * Add react-router to work with storybook ([549ceab](https://github.com/cozy/cozy-libs/commit/549ceab2113faf041d110b953d255c49fd087192))
18
+ * Remove adaptive router ([9db7559](https://github.com/cozy/cozy-libs/commit/9db755987117b455c6c2bb0cde9046c51ad7c2fa))
19
+ * Remove react-router v3 package ([392c5c2](https://github.com/cozy/cozy-libs/commit/392c5c25affc2e78872ceb4d6f65831f8c3c816a))
20
+ * Remove RoutesV4 to only use RouteV6 ([6205897](https://github.com/cozy/cozy-libs/commit/620589750d2afc1716aae2ac1ef38a4a16cfcbf1))
21
+
22
+
23
+ ### BREAKING CHANGES
24
+
25
+ * You must have `react-router-dom >= 6.14.2`
26
+ * `Routes` has been renamed `HarvestRoutes`. You should changed the import `import { Routes } from 'cozy-harvest-lib'` to `import { HarvestRoutes } from 'cozy-harvest-lib'`
27
+
28
+
29
+
30
+
31
+
32
+ ## [30.8.3](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@30.8.2...cozy-harvest-lib@30.8.3) (2024-11-28)
33
+
34
+ **Note:** Version bump only for package cozy-harvest-lib
35
+
36
+
37
+
38
+
39
+
6
40
  ## [30.8.2](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@30.8.1...cozy-harvest-lib@30.8.2) (2024-11-27)
7
41
 
8
42
  **Note:** Version bump only for package cozy-harvest-lib
@@ -39,7 +39,6 @@ import withConnectionFlow from '../../models/withConnectionFlow';
39
39
  import { ConnectCard } from '../cards/ConnectCard';
40
40
  import withKonnectorLocales from '../hoc/withKonnectorLocales';
41
41
  import withLocales from '../hoc/withLocales';
42
- import withAdaptiveRouter from '../hoc/withRouter';
43
42
  import TriggerErrorInfo from '../infos/TriggerErrorInfo';
44
43
  var VALIDATION_ERROR_REQUIRED_FIELD = 'VALIDATION_ERROR_REQUIRED_FIELD';
45
44
  /**
@@ -461,4 +460,4 @@ AccountForm.defaultProps = {
461
460
  showError: true,
462
461
  fieldOptions: {}
463
462
  };
464
- export default compose(withAdaptiveRouter, withConnectionFlow(), withLocales, withKonnectorLocales)(AccountForm);
463
+ export default compose(withConnectionFlow(), withLocales, withKonnectorLocales)(AccountForm);
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
3
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
4
  import _createClass from "@babel/runtime/helpers/createClass";
@@ -16,6 +17,7 @@ import flow from 'lodash/flow';
16
17
  import get from 'lodash/get';
17
18
  import PropTypes from 'prop-types';
18
19
  import React, { Component } from 'react';
20
+ import { useNavigate } from 'react-router-dom';
19
21
  import { withClient } from 'cozy-client';
20
22
  import { triggers as triggersModel } from 'cozy-client/dist/models/trigger';
21
23
  import Button from 'cozy-ui/transpiled/react/Buttons';
@@ -25,7 +27,6 @@ import Infos from 'cozy-ui/transpiled/react/deprecated/Infos';
25
27
  import withBreakpoints from 'cozy-ui/transpiled/react/helpers/withBreakpoints';
26
28
  import AccountModalHeader from './AccountModalWithoutTabs/AccountModalHeader';
27
29
  import KonnectorAccountWrapper from './KonnectorConfiguration/KonnectorAccountWrapper';
28
- import { withMountPointProps } from './MountPointContext';
29
30
  import withLocales from './hoc/withLocales';
30
31
  import { fetchAccount as _fetchAccount } from '../connections/accounts';
31
32
  import { intentsApiProptype, innerAccountModalOverridesProptype } from '../helpers/proptypes';
@@ -246,7 +247,7 @@ export var AccountModal = /*#__PURE__*/function (_Component) {
246
247
  onDismiss = _this$props2.onDismiss,
247
248
  accountsAndTriggers = _this$props2.accountsAndTriggers,
248
249
  t = _this$props2.t,
249
- replaceHistory = _this$props2.replaceHistory,
250
+ navigate = _this$props2.navigate,
250
251
  initialActiveTab = _this$props2.initialActiveTab,
251
252
  isMobile = _this$props2.breakpoints.isMobile,
252
253
  showAccountSelection = _this$props2.showAccountSelection,
@@ -292,7 +293,9 @@ export var AccountModal = /*#__PURE__*/function (_Component) {
292
293
  account: account,
293
294
  onAccountDeleted: onDismiss,
294
295
  addAccount: function addAccount() {
295
- return replaceHistory('/new');
296
+ navigate('new', {
297
+ replace: true
298
+ });
296
299
  },
297
300
  showNewAccountButton: showNewAccountButton,
298
301
  intentsApi: intentsApi,
@@ -326,7 +329,7 @@ AccountModal.propTypes = {
326
329
  trigger: PropTypes.object.isRequired
327
330
  })).isRequired,
328
331
  t: PropTypes.func.isRequired,
329
- replaceHistory: PropTypes.func.isRequired,
332
+ navigate: PropTypes.func.isRequired,
330
333
  accountId: PropTypes.string.isRequired,
331
334
 
332
335
  /** @type {string} Can be set to force the initial active tab */
@@ -341,4 +344,12 @@ AccountModal.propTypes = {
341
344
  innerAccountModalOverrides: innerAccountModalOverridesProptype,
342
345
  Component: PropTypes.func
343
346
  };
344
- export default flow(withClient, withLocales, withMountPointProps, withBreakpoints())(AccountModal);
347
+
348
+ var AccountModalWrapper = function AccountModalWrapper(props) {
349
+ var navigate = useNavigate();
350
+ return /*#__PURE__*/React.createElement(AccountModal, _extends({}, props, {
351
+ navigate: navigate
352
+ }));
353
+ };
354
+
355
+ export default flow(withClient, withLocales, withBreakpoints())(AccountModalWrapper);
@@ -37,7 +37,6 @@ var accountsAndTriggersMock = [{
37
37
  var accountIdMock = '123';
38
38
  describe('AccountModal', function () {
39
39
  var setup = function setup() {
40
- var mockHistoryReplace = jest.fn();
41
40
  var component = shallow( /*#__PURE__*/React.createElement(AccountModal, {
42
41
  konnector: {},
43
42
  t: function t(x) {
@@ -45,15 +44,14 @@ describe('AccountModal', function () {
45
44
  },
46
45
  accountId: accountIdMock,
47
46
  accountsAndTriggers: accountsAndTriggersMock,
48
- replaceHistory: mockHistoryReplace,
47
+ navigate: function navigate() {},
49
48
  breakpoints: {
50
49
  isMobile: true
51
50
  },
52
51
  onDismiss: jest.fn()
53
52
  }));
54
53
  return {
55
- component: component,
56
- mockHistoryReplace: mockHistoryReplace
54
+ component: component
57
55
  };
58
56
  };
59
57
 
@@ -1,40 +1,44 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import { useMatch } from 'react-router-dom';
3
+ import { useMatch, useNavigate } from 'react-router-dom';
4
4
  import { models } from 'cozy-client';
5
5
  import Typography from 'cozy-ui/transpiled/react/Typography';
6
6
  import AccountSelectBox from '../AccountSelectBox/AccountSelectBox';
7
7
  import { AccountSelectorHeader } from '../AccountSelectBox/AccountSelectorHeader';
8
8
  import KonnectorModalHeader from '../KonnectorModalHeader';
9
- import { withMountPointProps } from '../MountPointContext';
10
9
  export var AccountModalHeader = function AccountModalHeader(_ref) {
11
10
  var konnector = _ref.konnector,
12
11
  account = _ref.account,
13
12
  accountsAndTriggers = _ref.accountsAndTriggers,
14
- showAccountSelection = _ref.showAccountSelection,
15
- pushHistory = _ref.pushHistory,
16
- replaceHistory = _ref.replaceHistory;
13
+ showAccountSelection = _ref.showAccountSelection;
17
14
  var isConfig = useMatch("/connected/".concat(konnector.slug, "/accounts/:accountId/config"));
18
- if (isConfig) return /*#__PURE__*/React.createElement(AccountSelectorHeader, {
19
- konnector: konnector,
20
- account: account,
21
- accountsAndTriggers: accountsAndTriggers,
22
- pushHistory: pushHistory,
23
- replaceHistory: replaceHistory,
24
- showAccountSelection: showAccountSelection
25
- });
15
+ var navigate = useNavigate();
16
+
17
+ if (isConfig) {
18
+ return /*#__PURE__*/React.createElement(AccountSelectorHeader, {
19
+ konnector: konnector,
20
+ account: account,
21
+ accountsAndTriggers: accountsAndTriggers,
22
+ showAccountSelection: showAccountSelection
23
+ });
24
+ }
25
+
26
+ var handleChange = function handleChange(option) {
27
+ navigate("../accounts/".concat(option.account._id));
28
+ };
29
+
30
+ var handleCreate = function handleCreate() {
31
+ navigate('../new');
32
+ };
33
+
26
34
  return /*#__PURE__*/React.createElement(KonnectorModalHeader, {
27
35
  konnector: konnector
28
36
  }, showAccountSelection ? /*#__PURE__*/React.createElement(AccountSelectBox, {
29
37
  loading: !account,
30
38
  selectedAccount: account,
31
39
  accountsAndTriggers: accountsAndTriggers,
32
- onChange: function onChange(option) {
33
- pushHistory("/accounts/".concat(option.account._id));
34
- },
35
- onCreate: function onCreate() {
36
- pushHistory('/new');
37
- }
40
+ onChange: handleChange,
41
+ onCreate: handleCreate
38
42
  }) : /*#__PURE__*/React.createElement(Typography, null, models.account.getAccountName(account)));
39
43
  };
40
44
  AccountModalHeader.defaultProps = {
@@ -44,7 +48,6 @@ AccountModalHeader.propTypes = {
44
48
  konnector: PropTypes.object.isRequired,
45
49
  account: PropTypes.object,
46
50
  accountsAndTriggers: PropTypes.array.isRequired,
47
- showAccountSelection: PropTypes.bool.isRequired,
48
- pushHistory: PropTypes.func.isRequired
51
+ showAccountSelection: PropTypes.bool.isRequired
49
52
  };
50
- export default withMountPointProps(AccountModalHeader);
53
+ export default AccountModalHeader;
@@ -0,0 +1,35 @@
1
+ import { reactRouterParameters } from 'storybook-addon-remix-react-router';
2
+ import { AccountModalHeader } from './AccountModalHeader';
3
+ import { AccountSelectorHeaderFixtures } from '../../../.storybook/fixtures/AccountSelectorHeader.fixtures';
4
+ var meta = {
5
+ component: AccountModalHeader,
6
+ args: {
7
+ account: AccountSelectorHeaderFixtures.account,
8
+ accountsAndTriggers: AccountSelectorHeaderFixtures.accountsAndTriggers,
9
+ konnector: AccountSelectorHeaderFixtures.konnector
10
+ }
11
+ };
12
+ export default meta;
13
+ export var Default = {
14
+ name: 'Default',
15
+ args: {
16
+ showAccountSelection: true
17
+ }
18
+ };
19
+ export var InsideConfig = {
20
+ name: 'Inside config',
21
+ parameters: {
22
+ reactRouter: reactRouterParameters({
23
+ location: {
24
+ path: '/connected/stub/accounts/:accountId/config',
25
+ pathParams: {
26
+ accountId: '1337'
27
+ }
28
+ },
29
+ routing: {
30
+ path: '/connected/stub/accounts/1337/config',
31
+ handle: 'Config'
32
+ }
33
+ })
34
+ }
35
+ };
@@ -3,6 +3,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
3
3
  var _excluded = ["className"];
4
4
  import cx from 'classnames';
5
5
  import React from 'react';
6
+ import { useNavigate } from 'react-router-dom';
6
7
  import { models } from 'cozy-client';
7
8
  import DialogBackButton from 'cozy-ui/transpiled/react/CozyDialogs/DialogBackButton';
8
9
  import DialogTitle from 'cozy-ui/transpiled/react/Dialog/DialogTitle';
@@ -12,22 +13,33 @@ import { useDialogContext } from '../DialogContext';
12
13
  export var AccountSelectorHeader = function AccountSelectorHeader(_ref) {
13
14
  var account = _ref.account,
14
15
  accountsAndTriggers = _ref.accountsAndTriggers,
15
- pushHistory = _ref.pushHistory,
16
- replaceHistory = _ref.replaceHistory,
17
16
  showAccountSelection = _ref.showAccountSelection;
18
17
 
19
18
  // @ts-expect-error IDK
20
19
  var _useDialogContext = useDialogContext(),
21
- dialogTitleProps = _useDialogContext.dialogTitleProps; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
20
+ dialogTitleProps = _useDialogContext.dialogTitleProps;
22
21
 
22
+ var navigate = useNavigate(); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
23
23
 
24
24
  var dialogTitlePropsClassName = dialogTitleProps.className,
25
25
  rest = _objectWithoutProperties(dialogTitleProps, _excluded);
26
26
 
27
+ var handleDismiss = function handleDismiss() {
28
+ navigate('..', {
29
+ replace: true
30
+ });
31
+ };
32
+
33
+ var handleChange = function handleChange(option) {
34
+ navigate("../accounts/".concat(option.account._id));
35
+ };
36
+
37
+ var handleCreate = function handleCreate() {
38
+ navigate("../new");
39
+ };
40
+
27
41
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DialogBackButton, {
28
- onClick: function onClick() {
29
- return replaceHistory("/accounts/".concat(String(account._id)));
30
- }
42
+ onClick: handleDismiss
31
43
  }), /*#__PURE__*/React.createElement(DialogTitle, _extends({}, rest, {
32
44
  className: cx('dialogTitleWithBack dialogTitleWithClose', // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
33
45
  dialogTitlePropsClassName),
@@ -36,12 +48,8 @@ export var AccountSelectorHeader = function AccountSelectorHeader(_ref) {
36
48
  loading: !account,
37
49
  selectedAccount: account,
38
50
  accountsAndTriggers: accountsAndTriggers,
39
- onChange: function onChange(option) {
40
- pushHistory("/accounts/".concat(option.account._id));
41
- },
42
- onCreate: function onCreate() {
43
- pushHistory('/new');
44
- },
51
+ onChange: handleChange,
52
+ onCreate: handleCreate,
45
53
  variant: "big"
46
54
  }) : /*#__PURE__*/React.createElement(Typography, null, models.account.getAccountName(account))));
47
55
  };
@@ -2,14 +2,6 @@ import { AccountSelectorHeader } from './AccountSelectorHeader';
2
2
  import { AccountSelectorHeaderFixtures } from '../../../.storybook/fixtures/AccountSelectorHeader.fixtures';
3
3
  var meta = {
4
4
  component: AccountSelectorHeader,
5
- argTypes: {
6
- replaceHistory: {
7
- action: 'replaceHistory'
8
- },
9
- pushHistory: {
10
- action: 'pushHistory'
11
- }
12
- },
13
5
  args: {
14
6
  account: AccountSelectorHeaderFixtures.account,
15
7
  accountsAndTriggers: AccountSelectorHeaderFixtures.accountsAndTriggers,
@@ -1,22 +1,18 @@
1
1
  import PropTypes from 'prop-types';
2
- import React, { useContext } from 'react';
2
+ import React from 'react';
3
+ import { useNavigate } from 'react-router-dom';
3
4
  import DialogTitle from 'cozy-ui/transpiled/react/Dialog/DialogTitle';
4
5
  import DialogContent from 'cozy-ui/transpiled/react/DialogContent';
5
6
  import Typography from 'cozy-ui/transpiled/react/Typography';
6
7
  import { translate } from 'cozy-ui/transpiled/react/providers/I18n';
7
8
  import AccountsList from './AccountsList/AccountsList';
8
9
  import KonnectorIcon from './KonnectorIcon';
9
- import { MountPointContext } from './MountPointContext';
10
10
 
11
11
  var AccountsListModal = function AccountsListModal(_ref) {
12
12
  var konnector = _ref.konnector,
13
13
  accounts = _ref.accounts,
14
14
  t = _ref.t;
15
-
16
- var _useContext = useContext(MountPointContext),
17
- pushHistory = _useContext.pushHistory,
18
- replaceHistory = _useContext.replaceHistory;
19
-
15
+ var navigate = useNavigate();
20
16
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DialogTitle, {
21
17
  disableTypography: true,
22
18
  className: "u-pt-3 u-pt-2-s"
@@ -33,10 +29,12 @@ var AccountsListModal = function AccountsListModal(_ref) {
33
29
  accounts: accounts,
34
30
  konnector: konnector,
35
31
  onPick: function onPick(option) {
36
- return replaceHistory("/accounts/".concat(option.account._id));
32
+ return navigate("accounts/".concat(option.account._id), {
33
+ replace: true
34
+ });
37
35
  },
38
36
  addAccount: function addAccount() {
39
- return pushHistory('/new');
37
+ return navigate('new');
40
38
  }
41
39
  })));
42
40
  };
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
3
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
4
  import _createClass from "@babel/runtime/helpers/createClass";
@@ -15,11 +16,11 @@ import flow from 'lodash/flow';
15
16
  import get from 'lodash/get';
16
17
  import PropTypes from 'prop-types';
17
18
  import React, { Component } from 'react';
19
+ import { useLocation, useNavigate } from 'react-router-dom';
18
20
  import { withClient } from 'cozy-client';
19
21
  import { triggers as triggersModel } from 'cozy-client/dist/models/trigger';
20
22
  import { Dialog } from 'cozy-ui/transpiled/react/CozyDialogs';
21
23
  import Spinner from 'cozy-ui/transpiled/react/Spinner';
22
- import { withMountPointProps } from './MountPointContext';
23
24
  import LegacyTriggerManager from './TriggerManager';
24
25
  import { withTracker } from './hoc/tracking';
25
26
  import useTimeout from './hooks/useTimeout';
@@ -34,16 +35,18 @@ var hideStyle = {
34
35
  opacity: 0,
35
36
  transition: 'opacity 0.3s ease'
36
37
  };
37
- var DumbEditAccountModal = withMountPointProps(function (_ref) {
38
+
39
+ var DumbEditAccountModal = function DumbEditAccountModal(_ref) {
38
40
  var konnector = _ref.konnector,
39
41
  account = _ref.account,
40
42
  trigger = _ref.trigger,
41
43
  fetching = _ref.fetching,
42
44
  redirectToAccount = _ref.redirectToAccount,
43
- location = _ref.location,
44
45
  reconnect = _ref.reconnect,
45
46
  intentsApi = _ref.intentsApi;
46
47
 
48
+ var _useLocation = useLocation(),
49
+ search = _useLocation.search;
47
50
  /**
48
51
  * The TriggerManager can open the vault if necessary when it is mounted.
49
52
  * If the vault is opened, the EditAccountModal will be closed and will reappear
@@ -51,10 +54,12 @@ var DumbEditAccountModal = withMountPointProps(function (_ref) {
51
54
  * To prevent any jarring effect (open edit modal -> close edit modal -> open
52
55
  * vault modal), we delay a bit the appearing of the edit modal via CSS.
53
56
  */
57
+
58
+
54
59
  var shouldShow = useTimeout(500); // TODO Avoid passing reconnect in props,
55
60
  // prefer to use location instead.
56
61
 
57
- var fromReconnect = reconnect || location.search.endsWith('reconnect'); // If we come from the reconnect button so focus on secret field
62
+ var fromReconnect = reconnect || search.endsWith('reconnect'); // If we come from the reconnect button so focus on secret field
58
63
 
59
64
  var fieldOptions = {
60
65
  displaySecretPlaceholder: true,
@@ -85,7 +90,8 @@ var DumbEditAccountModal = withMountPointProps(function (_ref) {
85
90
  style: shouldShow ? showStyle : hideStyle,
86
91
  title: konnector.name
87
92
  });
88
- });
93
+ };
94
+
89
95
  export var EditAccountModal = /*#__PURE__*/function (_Component) {
90
96
  _inherits(EditAccountModal, _Component);
91
97
 
@@ -194,9 +200,13 @@ export var EditAccountModal = /*#__PURE__*/function (_Component) {
194
200
  var account = this.state.account;
195
201
 
196
202
  if (account) {
197
- this.props.replaceHistory("/accounts/".concat(account._id, "/config"));
203
+ this.props.navigate('../config', {
204
+ replace: true,
205
+ relative: 'path'
206
+ });
198
207
  } else {
199
- this.props.pushHistory("/accounts");
208
+ // If we don't have a account, we go back to the root
209
+ this.props.navigate('..');
200
210
  }
201
211
  }
202
212
  }, {
@@ -239,4 +249,12 @@ EditAccountModal.propTypes = {
239
249
  reconnect: PropTypes.bool,
240
250
  intentsApi: intentsApiProptype
241
251
  };
242
- export default flow(withClient, withMountPointProps, withTracker)(EditAccountModal);
252
+
253
+ var EditAccountModalWrapper = function EditAccountModalWrapper(props) {
254
+ var navigate = useNavigate();
255
+ return /*#__PURE__*/React.createElement(EditAccountModal, _extends({}, props, {
256
+ navigate: navigate
257
+ }));
258
+ };
259
+
260
+ export default flow(withClient, withTracker)(EditAccountModalWrapper);
@@ -1,21 +1,22 @@
1
1
  import PropTypes from 'prop-types';
2
- import React, { useContext } from 'react';
2
+ import React from 'react';
3
+ import { Navigate } from 'react-router-dom';
3
4
  import AccountsListModal from './AccountsListModal';
4
- import { MountPointContext } from './MountPointContext';
5
5
 
6
6
  var HarvestModalRoot = function HarvestModalRoot(_ref) {
7
7
  var accounts = _ref.accounts,
8
8
  konnector = _ref.konnector;
9
9
 
10
- var _useContext = useContext(MountPointContext),
11
- replaceHistory = _useContext.replaceHistory;
12
-
13
10
  if (accounts.length === 0) {
14
- replaceHistory('/new');
15
- return null;
11
+ return /*#__PURE__*/React.createElement(Navigate, {
12
+ to: "new",
13
+ replace: true
14
+ });
16
15
  } else if (accounts.length === 1) {
17
- replaceHistory("/accounts/".concat(accounts[0].account._id));
18
- return null;
16
+ return /*#__PURE__*/React.createElement(Navigate, {
17
+ to: "accounts/".concat(accounts[0].account._id),
18
+ replace: true
19
+ });
19
20
  } else {
20
21
  return /*#__PURE__*/React.createElement(AccountsListModal, {
21
22
  konnector: konnector,
@@ -10,10 +10,8 @@ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
10
10
  import { DatacardOptions } from './Datacards/DatacardOptionsContext';
11
11
  import DialogContext from './DialogContext';
12
12
  import HarvestWrapper from './HarvestWrapper';
13
+ import { InternalRoutes } from './InternalRoutes';
13
14
  import KonnectorAccounts from './KonnectorAccounts';
14
- import RoutesV4 from './Routes/RoutesV4';
15
- import RoutesV6 from './Routes/RoutesV6';
16
- import { isRouterV6 } from './hoc/withRouter';
17
15
  import { useKonnectorWithTriggers } from '../helpers/useKonnectorWithTriggers';
18
16
 
19
17
  var HarvestDialog = function HarvestDialog(props) {
@@ -29,7 +27,7 @@ var HarvestDialog = function HarvestDialog(props) {
29
27
  }, props));
30
28
  };
31
29
 
32
- var Routes = function Routes(_ref) {
30
+ var HarvestRoutes = function HarvestRoutes(_ref) {
33
31
  var konnectorRoot = _ref.konnectorRoot,
34
32
  konnector = _ref.konnector,
35
33
  konnectorSlug = _ref.konnectorSlug,
@@ -40,7 +38,6 @@ var Routes = function Routes(_ref) {
40
38
  closable = _ref.closable,
41
39
  intentData = _ref.intentData,
42
40
  intentId = _ref.intentId;
43
- var RoutesV4orV6 = isRouterV6 ? RoutesV6 : RoutesV4;
44
41
 
45
42
  var _useI18n = useI18n(),
46
43
  t = _useI18n.t;
@@ -72,9 +69,6 @@ var Routes = function Routes(_ref) {
72
69
  return /*#__PURE__*/React.createElement(DatacardOptions, {
73
70
  options: datacardOptions
74
71
  }, /*#__PURE__*/React.createElement(HarvestWrapper, {
75
- mountPointProviderProps: {
76
- baseRoute: konnectorRoot
77
- },
78
72
  componentsPropsProviderProps: {
79
73
  ComponentsProps: ComponentsProps
80
74
  },
@@ -93,7 +87,7 @@ var Routes = function Routes(_ref) {
93
87
  })) : /*#__PURE__*/React.createElement(KonnectorAccounts, {
94
88
  konnector: konnectorWithTriggers
95
89
  }, function (accountsAndTriggers) {
96
- return /*#__PURE__*/React.createElement(RoutesV4orV6, {
90
+ return /*#__PURE__*/React.createElement(InternalRoutes, {
97
91
  konnectorRoot: konnectorRoot,
98
92
  konnectorWithTriggers: konnectorWithTriggers,
99
93
  accountsAndTriggers: accountsAndTriggers,
@@ -103,7 +97,7 @@ var Routes = function Routes(_ref) {
103
97
  }))), /*#__PURE__*/React.createElement(VaultUnlockPlaceholder, null)));
104
98
  };
105
99
 
106
- Routes.propTypes = {
100
+ HarvestRoutes.propTypes = {
107
101
  /** The root URL of the konnector */
108
102
  konnectorRoot: PropTypes.string,
109
103
 
@@ -131,4 +125,4 @@ Routes.propTypes = {
131
125
  /** Id of the intent if called from an intent */
132
126
  intentId: PropTypes.string
133
127
  };
134
- export default Routes;
128
+ export default HarvestRoutes;
@@ -1,13 +1,11 @@
1
1
  // @ts-check
2
2
  import React from 'react';
3
3
  import HarvestVaultProvider from './HarvestVaultProvider';
4
- import { MountPointProvider } from './MountPointContext';
5
4
  import ComponentsPropsProvider from './Providers/ComponentsPropsProvider';
6
5
  import { IntentProvider } from './Providers/IntentProvider';
7
6
  import VaultUnlockProvider from './VaultUnlockProvider';
8
7
  /**
9
8
  * @param {{
10
- * mountPointProviderProps?: { baseRoute: string; };
11
9
  * componentsPropsProviderProps?: {
12
10
  * ComponentsProps: import("./Providers/ComponentsPropsProvider").ComponentsProps;
13
11
  * };
@@ -17,14 +15,12 @@ import VaultUnlockProvider from './VaultUnlockProvider';
17
15
  */
18
16
 
19
17
  export default function HarvestWrapper(props) {
20
- var _props$mountPointProv, _props$componentsProp;
18
+ var _props$componentsProp;
21
19
 
22
- return /*#__PURE__*/React.createElement(MountPointProvider, {
23
- baseRoute: props === null || props === void 0 ? void 0 : (_props$mountPointProv = props.mountPointProviderProps) === null || _props$mountPointProv === void 0 ? void 0 : _props$mountPointProv.baseRoute
24
- }, /*#__PURE__*/React.createElement(HarvestVaultProvider, null, /*#__PURE__*/React.createElement(VaultUnlockProvider, null, /*#__PURE__*/React.createElement(IntentProvider, {
20
+ return /*#__PURE__*/React.createElement(HarvestVaultProvider, null, /*#__PURE__*/React.createElement(VaultUnlockProvider, null, /*#__PURE__*/React.createElement(IntentProvider, {
25
21
  intentData: props.intentData,
26
22
  intentId: props.intentId
27
23
  }, /*#__PURE__*/React.createElement(ComponentsPropsProvider, {
28
24
  ComponentsProps: props === null || props === void 0 ? void 0 : (_props$componentsProp = props.componentsPropsProviderProps) === null || _props$componentsProp === void 0 ? void 0 : _props$componentsProp.ComponentsProps
29
- }, props.children)))));
25
+ }, props.children))));
30
26
  }