cozy-harvest-lib 11.2.0 → 11.3.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 +11 -0
- package/dist/components/NewAccountModal.js +21 -23
- package/dist/components/Routes/RoutesV4.js +2 -0
- package/dist/components/Routes/RoutesV6.js +2 -0
- package/dist/components/Routes.js +2 -0
- package/package.json +2 -2
- package/src/components/NewAccountModal.jsx +22 -27
- package/src/components/Routes/RoutesV4.jsx +2 -0
- package/src/components/Routes/RoutesV6.jsx +2 -0
- package/src/components/Routes.jsx +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
# [11.3.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@11.2.0...cozy-harvest-lib@11.3.0) (2023-01-04)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **harvest:** Add onSuccess in Routes API ([5f41164](https://github.com/cozy/cozy-libs/commit/5f411642d0ac325375925cad157f66275e64db67))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [11.2.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@11.1.0...cozy-harvest-lib@11.2.0) (2023-01-02)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -2,19 +2,19 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import cx from 'classnames';
|
|
5
|
-
import
|
|
5
|
+
import DialogContent from '@material-ui/core/DialogContent';
|
|
6
6
|
import flag from 'cozy-flags';
|
|
7
|
+
import { useClient } from 'cozy-client';
|
|
7
8
|
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
8
9
|
import Spinner from 'cozy-ui/transpiled/react/Spinner';
|
|
9
10
|
import Typography from 'cozy-ui/transpiled/react/Typography';
|
|
11
|
+
import { DialogTitle } from 'cozy-ui/transpiled/react/Dialog';
|
|
10
12
|
import TriggerManager from './TriggerManager';
|
|
11
13
|
import KonnectorIcon from './KonnectorIcon';
|
|
12
14
|
import * as triggersModel from '../helpers/triggers';
|
|
13
15
|
import KonnectorMaintenance from './Maintenance';
|
|
14
16
|
import useMaintenanceStatus from './hooks/useMaintenanceStatus';
|
|
15
17
|
import { MountPointContext } from './MountPointContext';
|
|
16
|
-
import DialogContent from '@material-ui/core/DialogContent';
|
|
17
|
-
import { DialogTitle } from 'cozy-ui/transpiled/react/Dialog';
|
|
18
18
|
import { useDialogContext } from './DialogContext';
|
|
19
19
|
/**
|
|
20
20
|
* We need to deal with `onLoginSuccess` and `onSucess` because we
|
|
@@ -25,6 +25,7 @@ import { useDialogContext } from './DialogContext';
|
|
|
25
25
|
|
|
26
26
|
var NewAccountModal = function NewAccountModal(_ref) {
|
|
27
27
|
var konnector = _ref.konnector,
|
|
28
|
+
onSuccess = _ref.onSuccess,
|
|
28
29
|
onDismiss = _ref.onDismiss;
|
|
29
30
|
|
|
30
31
|
var _useI18n = useI18n(),
|
|
@@ -49,6 +50,21 @@ var NewAccountModal = function NewAccountModal(_ref) {
|
|
|
49
50
|
var fieldOptions = {
|
|
50
51
|
displaySecretPlaceholder: false
|
|
51
52
|
};
|
|
53
|
+
|
|
54
|
+
var handleSuccess = function handleSuccess(trigger) {
|
|
55
|
+
if (onSuccess) {
|
|
56
|
+
return onSuccess();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
var accountId = triggersModel.getAccountId(trigger);
|
|
60
|
+
|
|
61
|
+
if (!flag('harvest.inappconnectors.enabled') && trigger.worker !== 'client') {
|
|
62
|
+
replaceHistory("/accounts/".concat(accountId, "/success"));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
replaceHistory("/accounts/".concat(accountId));
|
|
66
|
+
};
|
|
67
|
+
|
|
52
68
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DialogTitle, _extends({}, dialogTitleProps, {
|
|
53
69
|
className: cx(dialogTitleProps.className, 'u-ta-center u-flex-column u-stack-m u-pb-1'),
|
|
54
70
|
disableTypography: true
|
|
@@ -71,26 +87,8 @@ var NewAccountModal = function NewAccountModal(_ref) {
|
|
|
71
87
|
className: "u-pt-0"
|
|
72
88
|
}, /*#__PURE__*/React.createElement(TriggerManager, {
|
|
73
89
|
konnector: konnector,
|
|
74
|
-
onLoginSuccess:
|
|
75
|
-
|
|
76
|
-
var path = "/accounts/".concat(accountId);
|
|
77
|
-
|
|
78
|
-
if (!flag('harvest.inappconnectors.enabled') && trigger.worker !== 'client') {
|
|
79
|
-
path += '/success';
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
replaceHistory(path);
|
|
83
|
-
},
|
|
84
|
-
onSuccess: function onSuccess(trigger) {
|
|
85
|
-
var accountId = triggersModel.getAccountId(trigger);
|
|
86
|
-
var path = "/accounts/".concat(accountId);
|
|
87
|
-
|
|
88
|
-
if (!flag('harvest.inappconnectors.enabled') && trigger.worker !== 'client') {
|
|
89
|
-
path += '/success';
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
replaceHistory(path);
|
|
93
|
-
},
|
|
90
|
+
onLoginSuccess: handleSuccess,
|
|
91
|
+
onSuccess: handleSuccess,
|
|
94
92
|
onVaultDismiss: onDismiss,
|
|
95
93
|
fieldOptions: fieldOptions
|
|
96
94
|
}), /*#__PURE__*/React.createElement("div", {
|
|
@@ -12,6 +12,7 @@ var RoutesV4 = function RoutesV4(_ref) {
|
|
|
12
12
|
var konnectorRoot = _ref.konnectorRoot,
|
|
13
13
|
konnectorWithTriggers = _ref.konnectorWithTriggers,
|
|
14
14
|
accountsAndTriggers = _ref.accountsAndTriggers,
|
|
15
|
+
onSuccess = _ref.onSuccess,
|
|
15
16
|
onDismiss = _ref.onDismiss;
|
|
16
17
|
return /*#__PURE__*/React.createElement(Switch, null, /*#__PURE__*/React.createElement(Route, {
|
|
17
18
|
path: "".concat(konnectorRoot, "/"),
|
|
@@ -59,6 +60,7 @@ var RoutesV4 = function RoutesV4(_ref) {
|
|
|
59
60
|
render: function render() {
|
|
60
61
|
return /*#__PURE__*/React.createElement(NewAccountModal, {
|
|
61
62
|
konnector: konnectorWithTriggers,
|
|
63
|
+
onSuccess: onSuccess,
|
|
62
64
|
onDismiss: onDismiss
|
|
63
65
|
});
|
|
64
66
|
}
|
|
@@ -16,6 +16,7 @@ var HarvestParamsWrapper = function HarvestParamsWrapper(props) {
|
|
|
16
16
|
var RoutesV6 = function RoutesV6(_ref) {
|
|
17
17
|
var konnectorWithTriggers = _ref.konnectorWithTriggers,
|
|
18
18
|
accountsAndTriggers = _ref.accountsAndTriggers,
|
|
19
|
+
onSuccess = _ref.onSuccess,
|
|
19
20
|
onDismiss = _ref.onDismiss;
|
|
20
21
|
return /*#__PURE__*/React.createElement(Routes, null, /*#__PURE__*/React.createElement(Route, {
|
|
21
22
|
path: "/",
|
|
@@ -27,6 +28,7 @@ var RoutesV6 = function RoutesV6(_ref) {
|
|
|
27
28
|
path: "new",
|
|
28
29
|
element: /*#__PURE__*/React.createElement(NewAccountModal, {
|
|
29
30
|
konnector: konnectorWithTriggers,
|
|
31
|
+
onSuccess: onSuccess,
|
|
30
32
|
onDismiss: onDismiss
|
|
31
33
|
})
|
|
32
34
|
}), /*#__PURE__*/React.createElement(Route, {
|
|
@@ -48,6 +48,7 @@ var Routes = function Routes(_ref) {
|
|
|
48
48
|
var konnectorRoot = _ref.konnectorRoot,
|
|
49
49
|
konnector = _ref.konnector,
|
|
50
50
|
konnectorSlug = _ref.konnectorSlug,
|
|
51
|
+
onSuccess = _ref.onSuccess,
|
|
51
52
|
onDismiss = _ref.onDismiss,
|
|
52
53
|
datacardOptions = _ref.datacardOptions,
|
|
53
54
|
ComponentsProps = _ref.ComponentsProps;
|
|
@@ -96,6 +97,7 @@ var Routes = function Routes(_ref) {
|
|
|
96
97
|
konnectorRoot: konnectorRoot,
|
|
97
98
|
konnectorWithTriggers: konnectorWithTriggers,
|
|
98
99
|
accountsAndTriggers: accountsAndTriggers,
|
|
100
|
+
onSuccess: onSuccess,
|
|
99
101
|
onDismiss: onDismiss
|
|
100
102
|
});
|
|
101
103
|
}))), /*#__PURE__*/React.createElement(VaultUnlockPlaceholder, null))))));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-harvest-lib",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.3.0",
|
|
4
4
|
"description": "Provides logic, modules and components for Cozy's harvest applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Cozy",
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"react-router-dom": ">=4.3.1"
|
|
91
91
|
},
|
|
92
92
|
"sideEffects": false,
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "b79c5ad02f0c8a765122146353959fb32f2f3b3e"
|
|
94
94
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React, { useContext } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import cx from 'classnames'
|
|
4
|
-
import
|
|
5
|
-
import flag from 'cozy-flags'
|
|
4
|
+
import DialogContent from '@material-ui/core/DialogContent'
|
|
6
5
|
|
|
6
|
+
import flag from 'cozy-flags'
|
|
7
|
+
import { useClient } from 'cozy-client'
|
|
7
8
|
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
|
|
8
9
|
import Spinner from 'cozy-ui/transpiled/react/Spinner'
|
|
9
10
|
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
11
|
+
import { DialogTitle } from 'cozy-ui/transpiled/react/Dialog'
|
|
10
12
|
|
|
11
13
|
import TriggerManager from './TriggerManager'
|
|
12
14
|
import KonnectorIcon from './KonnectorIcon'
|
|
@@ -14,8 +16,6 @@ import * as triggersModel from '../helpers/triggers'
|
|
|
14
16
|
import KonnectorMaintenance from './Maintenance'
|
|
15
17
|
import useMaintenanceStatus from './hooks/useMaintenanceStatus'
|
|
16
18
|
import { MountPointContext } from './MountPointContext'
|
|
17
|
-
import DialogContent from '@material-ui/core/DialogContent'
|
|
18
|
-
import { DialogTitle } from 'cozy-ui/transpiled/react/Dialog'
|
|
19
19
|
import { useDialogContext } from './DialogContext'
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -24,7 +24,7 @@ import { useDialogContext } from './DialogContext'
|
|
|
24
24
|
* few konnectors know if the login is success or not.
|
|
25
25
|
*
|
|
26
26
|
*/
|
|
27
|
-
const NewAccountModal = ({ konnector, onDismiss }) => {
|
|
27
|
+
const NewAccountModal = ({ konnector, onSuccess, onDismiss }) => {
|
|
28
28
|
const { t } = useI18n()
|
|
29
29
|
const client = useClient()
|
|
30
30
|
const { replaceHistory } = useContext(MountPointContext)
|
|
@@ -40,6 +40,21 @@ const NewAccountModal = ({ konnector, onDismiss }) => {
|
|
|
40
40
|
displaySecretPlaceholder: false
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
const handleSuccess = trigger => {
|
|
44
|
+
if (onSuccess) {
|
|
45
|
+
return onSuccess()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const accountId = triggersModel.getAccountId(trigger)
|
|
49
|
+
if (
|
|
50
|
+
!flag('harvest.inappconnectors.enabled') &&
|
|
51
|
+
trigger.worker !== 'client'
|
|
52
|
+
) {
|
|
53
|
+
replaceHistory(`/accounts/${accountId}/success`)
|
|
54
|
+
}
|
|
55
|
+
replaceHistory(`/accounts/${accountId}`)
|
|
56
|
+
}
|
|
57
|
+
|
|
43
58
|
return (
|
|
44
59
|
<>
|
|
45
60
|
<DialogTitle
|
|
@@ -69,28 +84,8 @@ const NewAccountModal = ({ konnector, onDismiss }) => {
|
|
|
69
84
|
<DialogContent className="u-pt-0">
|
|
70
85
|
<TriggerManager
|
|
71
86
|
konnector={konnector}
|
|
72
|
-
onLoginSuccess={
|
|
73
|
-
|
|
74
|
-
let path = `/accounts/${accountId}`
|
|
75
|
-
if (
|
|
76
|
-
!flag('harvest.inappconnectors.enabled') &&
|
|
77
|
-
trigger.worker !== 'client'
|
|
78
|
-
) {
|
|
79
|
-
path += '/success'
|
|
80
|
-
}
|
|
81
|
-
replaceHistory(path)
|
|
82
|
-
}}
|
|
83
|
-
onSuccess={trigger => {
|
|
84
|
-
const accountId = triggersModel.getAccountId(trigger)
|
|
85
|
-
let path = `/accounts/${accountId}`
|
|
86
|
-
if (
|
|
87
|
-
!flag('harvest.inappconnectors.enabled') &&
|
|
88
|
-
trigger.worker !== 'client'
|
|
89
|
-
) {
|
|
90
|
-
path += '/success'
|
|
91
|
-
}
|
|
92
|
-
replaceHistory(path)
|
|
93
|
-
}}
|
|
87
|
+
onLoginSuccess={handleSuccess}
|
|
88
|
+
onSuccess={handleSuccess}
|
|
94
89
|
onVaultDismiss={onDismiss}
|
|
95
90
|
fieldOptions={fieldOptions}
|
|
96
91
|
/>
|
|
@@ -14,6 +14,7 @@ const RoutesV4 = ({
|
|
|
14
14
|
konnectorRoot,
|
|
15
15
|
konnectorWithTriggers,
|
|
16
16
|
accountsAndTriggers,
|
|
17
|
+
onSuccess,
|
|
17
18
|
onDismiss
|
|
18
19
|
}) => {
|
|
19
20
|
return (
|
|
@@ -64,6 +65,7 @@ const RoutesV4 = ({
|
|
|
64
65
|
render={() => (
|
|
65
66
|
<NewAccountModal
|
|
66
67
|
konnector={konnectorWithTriggers}
|
|
68
|
+
onSuccess={onSuccess}
|
|
67
69
|
onDismiss={onDismiss}
|
|
68
70
|
/>
|
|
69
71
|
)}
|
|
@@ -18,6 +18,7 @@ const HarvestParamsWrapper = props => {
|
|
|
18
18
|
const RoutesV6 = ({
|
|
19
19
|
konnectorWithTriggers,
|
|
20
20
|
accountsAndTriggers,
|
|
21
|
+
onSuccess,
|
|
21
22
|
onDismiss
|
|
22
23
|
}) => {
|
|
23
24
|
return (
|
|
@@ -37,6 +38,7 @@ const RoutesV6 = ({
|
|
|
37
38
|
element={
|
|
38
39
|
<NewAccountModal
|
|
39
40
|
konnector={konnectorWithTriggers}
|
|
41
|
+
onSuccess={onSuccess}
|
|
40
42
|
onDismiss={onDismiss}
|
|
41
43
|
/>
|
|
42
44
|
}
|
|
@@ -49,6 +49,7 @@ const Routes = ({
|
|
|
49
49
|
konnectorRoot,
|
|
50
50
|
konnector,
|
|
51
51
|
konnectorSlug,
|
|
52
|
+
onSuccess,
|
|
52
53
|
onDismiss,
|
|
53
54
|
datacardOptions,
|
|
54
55
|
ComponentsProps
|
|
@@ -95,6 +96,7 @@ const Routes = ({
|
|
|
95
96
|
konnectorRoot={konnectorRoot}
|
|
96
97
|
konnectorWithTriggers={konnectorWithTriggers}
|
|
97
98
|
accountsAndTriggers={accountsAndTriggers}
|
|
99
|
+
onSuccess={onSuccess}
|
|
98
100
|
onDismiss={onDismiss}
|
|
99
101
|
/>
|
|
100
102
|
)}
|