cozy-harvest-lib 8.0.0 → 8.2.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 +40 -0
- package/dist/components/AccountModal.js +5 -4
- package/dist/components/AccountModal.spec.js +4 -1
- package/dist/components/AccountsListModal.js +3 -2
- package/dist/components/EditAccountModal.js +3 -3
- package/dist/components/HarvestModalRoot.js +3 -3
- package/dist/components/KonnectorConfiguration/ConfigurationTab/index.js +2 -2
- package/dist/components/MountPointContext.js +24 -10
- package/dist/components/MountPointContext.spec.js +17 -17
- package/dist/components/NewAccountModal.js +3 -3
- package/dist/components/NewAccountModal.spec.js +6 -6
- package/dist/components/RedirectToAccountFormButton.js +3 -3
- package/dist/components/RedirectToAccountFormButton.spec.js +4 -4
- package/dist/components/cards/AppLinkCard.js +2 -1
- package/dist/models/ConnectionFlow.js +63 -40
- package/dist/models/ConnectionFlow.spec.js +43 -4
- package/dist/models/konnector/KonnectorJobWatcher.js +6 -0
- package/package.json +2 -2
- package/src/components/AccountModal.jsx +5 -4
- package/src/components/AccountModal.spec.jsx +7 -2
- package/src/components/AccountsListModal.jsx +2 -2
- package/src/components/EditAccountModal.jsx +3 -3
- package/src/components/HarvestModalRoot.jsx +3 -3
- package/src/components/KonnectorConfiguration/ConfigurationTab/index.jsx +2 -2
- package/src/components/MountPointContext.jsx +29 -12
- package/src/components/MountPointContext.spec.jsx +17 -17
- package/src/components/NewAccountModal.jsx +3 -3
- package/src/components/NewAccountModal.spec.jsx +6 -6
- package/src/components/RedirectToAccountFormButton.jsx +3 -3
- package/src/components/RedirectToAccountFormButton.spec.jsx +4 -4
- package/src/components/cards/AppLinkCard.jsx +2 -1
- package/src/models/ConnectionFlow.js +23 -5
- package/src/models/ConnectionFlow.spec.js +30 -5
- package/src/models/konnector/KonnectorJobWatcher.js +5 -0
- package/test/fixtures.js +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,46 @@
|
|
|
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
|
+
# [8.2.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@8.1.1...cozy-harvest-lib@8.2.0) (2022-04-13)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Fix back navigation ([89283ab](https://github.com/cozy/cozy-libs/commit/89283ab1beb06fa15625a7f108abbddf37216397))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [8.1.1](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@8.1.0...cozy-harvest-lib@8.1.1) (2022-04-11)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **cozy-harvest-lib:** Correctly handle onClick on AppLinkCard ([c9068c5](https://github.com/cozy/cozy-libs/commit/c9068c53a1ec2e1f6b9b7636f6b25aadec69900f))
|
|
23
|
+
* **cozy-harvest-lib:** Disable AppLink button until fallback is resolved ([bedc90d](https://github.com/cozy/cozy-libs/commit/bedc90d80c899bb93a2be70d6963d62742fb600b))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# [8.1.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@8.0.0...cozy-harvest-lib@8.1.0) (2022-04-08)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Bug Fixes
|
|
33
|
+
|
|
34
|
+
* Remove unused restoreAllMocks ([6dd376a](https://github.com/cozy/cozy-libs/commit/6dd376a2a7f4393a9446375383d6b77510f87d95))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Features
|
|
38
|
+
|
|
39
|
+
* Do not mark a job as succeeded on login success ([39e6d01](https://github.com/cozy/cozy-libs/commit/39e6d0161839a6d00ef0dcf24eb6aa0ddeff5f78))
|
|
40
|
+
* Watch job changes when the trigger is already running ([ca01663](https://github.com/cozy/cozy-libs/commit/ca01663eb41bbbcfed5d1f146c9cd68956faa9df))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
6
46
|
# [8.0.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@7.3.7...cozy-harvest-lib@8.0.0) (2022-04-04)
|
|
7
47
|
|
|
8
48
|
|
|
@@ -26,7 +26,7 @@ import * as triggersModel from '../helpers/triggers';
|
|
|
26
26
|
import KonnectorAccountTabs from './KonnectorConfiguration/KonnectorAccountTabs';
|
|
27
27
|
import AccountSelectBox from './AccountSelectBox/AccountSelectBox';
|
|
28
28
|
import KonnectorModalHeader from './KonnectorModalHeader';
|
|
29
|
-
import {
|
|
29
|
+
import { withMountPointHistory } from './MountPointContext';
|
|
30
30
|
import withLocales from './hoc/withLocales';
|
|
31
31
|
import DialogContent from '@material-ui/core/DialogContent';
|
|
32
32
|
/**
|
|
@@ -247,6 +247,7 @@ export var AccountModal = /*#__PURE__*/function (_Component) {
|
|
|
247
247
|
accountsAndTriggers = _this$props2.accountsAndTriggers,
|
|
248
248
|
t = _this$props2.t,
|
|
249
249
|
pushHistory = _this$props2.pushHistory,
|
|
250
|
+
replaceHistory = _this$props2.replaceHistory,
|
|
250
251
|
initialActiveTab = _this$props2.initialActiveTab,
|
|
251
252
|
isMobile = _this$props2.breakpoints.isMobile,
|
|
252
253
|
showAccountSelection = _this$props2.showAccountSelection,
|
|
@@ -293,7 +294,7 @@ export var AccountModal = /*#__PURE__*/function (_Component) {
|
|
|
293
294
|
account: account,
|
|
294
295
|
onAccountDeleted: onDismiss,
|
|
295
296
|
addAccount: function addAccount() {
|
|
296
|
-
return
|
|
297
|
+
return replaceHistory('/new');
|
|
297
298
|
},
|
|
298
299
|
showNewAccountButton: showNewAccountButton
|
|
299
300
|
})));
|
|
@@ -324,7 +325,7 @@ AccountModal.propTypes = {
|
|
|
324
325
|
trigger: PropTypes.object.isRequired
|
|
325
326
|
})).isRequired,
|
|
326
327
|
t: PropTypes.func.isRequired,
|
|
327
|
-
|
|
328
|
+
replaceHistory: PropTypes.func.isRequired,
|
|
328
329
|
accountId: PropTypes.string.isRequired,
|
|
329
330
|
|
|
330
331
|
/** @type {string} Can be set to force the initial active tab */
|
|
@@ -336,4 +337,4 @@ AccountModal.propTypes = {
|
|
|
336
337
|
/** @type {Boolean} Whether to show the button to add a new account */
|
|
337
338
|
showNewAccountButton: PropTypes.bool
|
|
338
339
|
};
|
|
339
|
-
export default flow(withClient, withLocales,
|
|
340
|
+
export default flow(withClient, withLocales, withMountPointHistory, withBreakpoints())(AccountModal);
|
|
@@ -38,6 +38,7 @@ var accountIdMock = '123';
|
|
|
38
38
|
describe('AccountModal', function () {
|
|
39
39
|
var setup = function setup() {
|
|
40
40
|
var mockHistoryPush = jest.fn();
|
|
41
|
+
var mockHistoryReplace = jest.fn();
|
|
41
42
|
var component = shallow( /*#__PURE__*/React.createElement(AccountModal, {
|
|
42
43
|
konnector: {},
|
|
43
44
|
t: function t(x) {
|
|
@@ -46,6 +47,7 @@ describe('AccountModal', function () {
|
|
|
46
47
|
accountId: accountIdMock,
|
|
47
48
|
accountsAndTriggers: accountsAndTriggersMock,
|
|
48
49
|
pushHistory: mockHistoryPush,
|
|
50
|
+
replaceHistory: mockHistoryReplace,
|
|
49
51
|
breakpoints: {
|
|
50
52
|
isMobile: true
|
|
51
53
|
},
|
|
@@ -53,7 +55,8 @@ describe('AccountModal', function () {
|
|
|
53
55
|
}));
|
|
54
56
|
return {
|
|
55
57
|
component: component,
|
|
56
|
-
mockHistoryPush: mockHistoryPush
|
|
58
|
+
mockHistoryPush: mockHistoryPush,
|
|
59
|
+
mockHistoryReplace: mockHistoryReplace
|
|
57
60
|
};
|
|
58
61
|
};
|
|
59
62
|
|
|
@@ -13,7 +13,8 @@ var AccountsListModal = function AccountsListModal(_ref) {
|
|
|
13
13
|
t = _ref.t;
|
|
14
14
|
|
|
15
15
|
var _useContext = useContext(MountPointContext),
|
|
16
|
-
pushHistory = _useContext.pushHistory
|
|
16
|
+
pushHistory = _useContext.pushHistory,
|
|
17
|
+
replaceHistory = _useContext.replaceHistory;
|
|
17
18
|
|
|
18
19
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DialogContent, null, /*#__PURE__*/React.createElement(Stack, {
|
|
19
20
|
className: "u-mb-3"
|
|
@@ -29,7 +30,7 @@ var AccountsListModal = function AccountsListModal(_ref) {
|
|
|
29
30
|
accounts: accounts,
|
|
30
31
|
konnector: konnector,
|
|
31
32
|
onPick: function onPick(option) {
|
|
32
|
-
return
|
|
33
|
+
return replaceHistory("/accounts/".concat(option.account._id));
|
|
33
34
|
},
|
|
34
35
|
addAccount: function addAccount() {
|
|
35
36
|
return pushHistory('/new');
|
|
@@ -27,7 +27,7 @@ import { DialogCloseButton, useCozyDialog } from 'cozy-ui/transpiled/react/CozyD
|
|
|
27
27
|
import { fetchAccount as _fetchAccount } from '../connections/accounts';
|
|
28
28
|
import * as triggersModel from '../helpers/triggers';
|
|
29
29
|
import TriggerManager from './TriggerManager';
|
|
30
|
-
import {
|
|
30
|
+
import { withMountPointHistory } from './MountPointContext';
|
|
31
31
|
import logger from '../logger';
|
|
32
32
|
import { withTracker } from './hoc/tracking';
|
|
33
33
|
import useTimeout from './hooks/useTimeout';
|
|
@@ -213,7 +213,7 @@ export var EditAccountModal = /*#__PURE__*/function (_Component) {
|
|
|
213
213
|
var account = this.state.account;
|
|
214
214
|
|
|
215
215
|
if (account) {
|
|
216
|
-
this.props.
|
|
216
|
+
this.props.replaceHistory("/accounts/".concat(account._id));
|
|
217
217
|
} else {
|
|
218
218
|
this.props.pushHistory("/accounts");
|
|
219
219
|
}
|
|
@@ -255,4 +255,4 @@ EditAccountModal.propTypes = {
|
|
|
255
255
|
accounts: PropTypes.array.isRequired,
|
|
256
256
|
reconnect: PropTypes.bool
|
|
257
257
|
};
|
|
258
|
-
export default flow(withClient,
|
|
258
|
+
export default flow(withClient, withMountPointHistory, withTracker)(EditAccountModal);
|
|
@@ -8,13 +8,13 @@ var HarvestModalRoot = function HarvestModalRoot(_ref) {
|
|
|
8
8
|
konnector = _ref.konnector;
|
|
9
9
|
|
|
10
10
|
var _useContext = useContext(MountPointContext),
|
|
11
|
-
|
|
11
|
+
replaceHistory = _useContext.replaceHistory;
|
|
12
12
|
|
|
13
13
|
if (accounts.length === 0) {
|
|
14
|
-
|
|
14
|
+
replaceHistory('/new');
|
|
15
15
|
return null;
|
|
16
16
|
} else if (accounts.length === 1) {
|
|
17
|
-
|
|
17
|
+
replaceHistory("/accounts/".concat(accounts[0].account._id));
|
|
18
18
|
return null;
|
|
19
19
|
} else {
|
|
20
20
|
return /*#__PURE__*/React.createElement(AccountsListModal, {
|
|
@@ -76,7 +76,7 @@ var ConfigurationTab = function ConfigurationTab(_ref2) {
|
|
|
76
76
|
isMobile = _useBreakpoints.isMobile;
|
|
77
77
|
|
|
78
78
|
var _useContext = useContext(MountPointContext),
|
|
79
|
-
|
|
79
|
+
replaceHistory = _useContext.replaceHistory;
|
|
80
80
|
|
|
81
81
|
var client = useClient();
|
|
82
82
|
var vaultClient = useVaultClient();
|
|
@@ -238,7 +238,7 @@ var ConfigurationTab = function ConfigurationTab(_ref2) {
|
|
|
238
238
|
button: true,
|
|
239
239
|
divider: true,
|
|
240
240
|
onClick: function onClick() {
|
|
241
|
-
return
|
|
241
|
+
return replaceHistory("/accounts/".concat(account._id, "/edit"));
|
|
242
242
|
}
|
|
243
243
|
}, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
244
244
|
icon: KeyIcon,
|
|
@@ -26,20 +26,32 @@ export var RawMountPointProvider = /*#__PURE__*/function (_React$Component) {
|
|
|
26
26
|
|
|
27
27
|
_this = _super.call(this, props);
|
|
28
28
|
_this.pushHistory = _this.pushHistory.bind(_assertThisInitialized(_this));
|
|
29
|
+
_this.replaceHistory = _this.replaceHistory.bind(_assertThisInitialized(_this));
|
|
29
30
|
_this.state = {
|
|
30
31
|
baseRoute: props.baseRoute || '/',
|
|
31
|
-
pushHistory: _this.pushHistory
|
|
32
|
+
pushHistory: _this.pushHistory,
|
|
33
|
+
replaceHistory: _this.replaceHistory
|
|
32
34
|
};
|
|
33
35
|
return _this;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
_createClass(RawMountPointProvider, [{
|
|
37
|
-
key: "
|
|
38
|
-
value: function
|
|
39
|
+
key: "historyAction",
|
|
40
|
+
value: function historyAction(route, method) {
|
|
39
41
|
var history = this.props.history;
|
|
40
42
|
var baseRoute = this.state.baseRoute;
|
|
41
|
-
var segments = baseRoute.split('/').concat(route.split('/')).filter(Boolean);
|
|
42
|
-
history
|
|
43
|
+
var segments = '/'.concat(baseRoute.split('/').concat(route.split('/')).filter(Boolean).join('/'));
|
|
44
|
+
history[method](segments);
|
|
45
|
+
}
|
|
46
|
+
}, {
|
|
47
|
+
key: "pushHistory",
|
|
48
|
+
value: function pushHistory(route) {
|
|
49
|
+
this.historyAction(route, 'push');
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
key: "replaceHistory",
|
|
53
|
+
value: function replaceHistory(route) {
|
|
54
|
+
this.historyAction(route, 'replace');
|
|
43
55
|
}
|
|
44
56
|
}, {
|
|
45
57
|
key: "render",
|
|
@@ -57,19 +69,21 @@ RawMountPointProvider.propTypes = {
|
|
|
57
69
|
history: PropTypes.object
|
|
58
70
|
};
|
|
59
71
|
|
|
60
|
-
var
|
|
72
|
+
var withMountPointHistory = function withMountPointHistory(BaseComponent) {
|
|
61
73
|
var Component = function Component(props) {
|
|
62
74
|
var _useContext = useContext(MountPointContext),
|
|
63
|
-
pushHistory = _useContext.pushHistory
|
|
75
|
+
pushHistory = _useContext.pushHistory,
|
|
76
|
+
replaceHistory = _useContext.replaceHistory;
|
|
64
77
|
|
|
65
78
|
return /*#__PURE__*/React.createElement(BaseComponent, _extends({
|
|
66
|
-
pushHistory: pushHistory
|
|
79
|
+
pushHistory: pushHistory,
|
|
80
|
+
replaceHistory: replaceHistory
|
|
67
81
|
}, props));
|
|
68
82
|
};
|
|
69
83
|
|
|
70
|
-
Component.displayName = "
|
|
84
|
+
Component.displayName = "withMountPointHistory(".concat(BaseComponent.displayName || BaseComponent.name, ")");
|
|
71
85
|
return Component;
|
|
72
86
|
};
|
|
73
87
|
|
|
74
88
|
var MountPointProvider = withRouter(RawMountPointProvider);
|
|
75
|
-
export { MountPointContext, MountPointProvider,
|
|
89
|
+
export { MountPointContext, MountPointProvider, withMountPointHistory };
|
|
@@ -3,7 +3,7 @@ import { shallow } from 'enzyme';
|
|
|
3
3
|
import { RawMountPointProvider } from 'components/MountPointContext';
|
|
4
4
|
describe('MountPointProvider', function () {
|
|
5
5
|
var historyMock = {
|
|
6
|
-
|
|
6
|
+
replace: jest.fn()
|
|
7
7
|
};
|
|
8
8
|
beforeEach(function () {
|
|
9
9
|
jest.resetAllMocks();
|
|
@@ -13,33 +13,33 @@ describe('MountPointProvider', function () {
|
|
|
13
13
|
baseRoute: "/root",
|
|
14
14
|
history: historyMock
|
|
15
15
|
}));
|
|
16
|
-
component.instance().
|
|
17
|
-
expect(historyMock.
|
|
18
|
-
component.instance().
|
|
19
|
-
expect(historyMock.
|
|
20
|
-
component.instance().
|
|
21
|
-
expect(historyMock.
|
|
22
|
-
component.instance().
|
|
23
|
-
expect(historyMock.
|
|
16
|
+
component.instance().replaceHistory('/one');
|
|
17
|
+
expect(historyMock.replace).toHaveBeenCalledWith('/root/one');
|
|
18
|
+
component.instance().replaceHistory('/one/two');
|
|
19
|
+
expect(historyMock.replace).toHaveBeenCalledWith('/root/one/two');
|
|
20
|
+
component.instance().replaceHistory('no/slash');
|
|
21
|
+
expect(historyMock.replace).toHaveBeenCalledWith('/root/no/slash');
|
|
22
|
+
component.instance().replaceHistory('too/many///slashes');
|
|
23
|
+
expect(historyMock.replace).toHaveBeenCalledWith('/root/too/many/slashes');
|
|
24
24
|
});
|
|
25
25
|
it('should handle a trailing slash in the base route', function () {
|
|
26
26
|
var component = shallow( /*#__PURE__*/React.createElement(RawMountPointProvider, {
|
|
27
27
|
baseRoute: "/root/",
|
|
28
28
|
history: historyMock
|
|
29
29
|
}));
|
|
30
|
-
component.instance().
|
|
31
|
-
expect(historyMock.
|
|
32
|
-
component.instance().
|
|
33
|
-
expect(historyMock.
|
|
30
|
+
component.instance().replaceHistory('/one');
|
|
31
|
+
expect(historyMock.replace).toHaveBeenCalledWith('/root/one');
|
|
32
|
+
component.instance().replaceHistory('no/slash');
|
|
33
|
+
expect(historyMock.replace).toHaveBeenCalledWith('/root/no/slash');
|
|
34
34
|
});
|
|
35
35
|
it('should handle a base route with multiple segments', function () {
|
|
36
36
|
var component = shallow( /*#__PURE__*/React.createElement(RawMountPointProvider, {
|
|
37
37
|
baseRoute: "/base/route/",
|
|
38
38
|
history: historyMock
|
|
39
39
|
}));
|
|
40
|
-
component.instance().
|
|
41
|
-
expect(historyMock.
|
|
42
|
-
component.instance().
|
|
43
|
-
expect(historyMock.
|
|
40
|
+
component.instance().replaceHistory('/one');
|
|
41
|
+
expect(historyMock.replace).toHaveBeenCalledWith('/base/route/one');
|
|
42
|
+
component.instance().replaceHistory('/one/two');
|
|
43
|
+
expect(historyMock.replace).toHaveBeenCalledWith('/base/route/one/two');
|
|
44
44
|
});
|
|
45
45
|
});
|
|
@@ -32,7 +32,7 @@ var NewAccountModal = function NewAccountModal(_ref) {
|
|
|
32
32
|
var client = useClient();
|
|
33
33
|
|
|
34
34
|
var _useContext = useContext(MountPointContext),
|
|
35
|
-
|
|
35
|
+
replaceHistory = _useContext.replaceHistory;
|
|
36
36
|
|
|
37
37
|
var _useMaintenanceStatus = useMaintenanceStatus(client, konnector),
|
|
38
38
|
fetchStatus = _useMaintenanceStatus.fetchStatus,
|
|
@@ -78,7 +78,7 @@ var NewAccountModal = function NewAccountModal(_ref) {
|
|
|
78
78
|
path += '/success';
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
replaceHistory(path);
|
|
82
82
|
},
|
|
83
83
|
onSuccess: function onSuccess(trigger) {
|
|
84
84
|
var accountId = triggersModel.getAccountId(trigger);
|
|
@@ -88,7 +88,7 @@ var NewAccountModal = function NewAccountModal(_ref) {
|
|
|
88
88
|
path += '/success';
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
replaceHistory(path);
|
|
92
92
|
},
|
|
93
93
|
onVaultDismiss: onDismiss,
|
|
94
94
|
fieldOptions: fieldOptions
|
|
@@ -27,9 +27,9 @@ jest.mock('./DialogContext', function () {
|
|
|
27
27
|
};
|
|
28
28
|
});
|
|
29
29
|
describe('NewAccountModal', function () {
|
|
30
|
-
var
|
|
30
|
+
var replaceHistory = jest.fn();
|
|
31
31
|
var mountPointContextValue = {
|
|
32
|
-
|
|
32
|
+
replaceHistory: replaceHistory
|
|
33
33
|
};
|
|
34
34
|
var konnectorTrigger = {
|
|
35
35
|
worker: 'konnector',
|
|
@@ -58,7 +58,7 @@ describe('NewAccountModal', function () {
|
|
|
58
58
|
}
|
|
59
59
|
}))));
|
|
60
60
|
onLoginSuccessFn(konnectorTrigger);
|
|
61
|
-
expect(
|
|
61
|
+
expect(replaceHistory).toHaveBeenCalledWith('/accounts/accountNumber/success');
|
|
62
62
|
});
|
|
63
63
|
it('should redirect to route without success on login success for client triggers', function () {
|
|
64
64
|
render( /*#__PURE__*/React.createElement(AppLike, {
|
|
@@ -72,7 +72,7 @@ describe('NewAccountModal', function () {
|
|
|
72
72
|
}
|
|
73
73
|
}))));
|
|
74
74
|
onLoginSuccessFn(clientTrigger);
|
|
75
|
-
expect(
|
|
75
|
+
expect(replaceHistory).toHaveBeenCalledWith('/accounts/accountNumberClient');
|
|
76
76
|
});
|
|
77
77
|
it('should redirect to success route on success for non client triggers', function () {
|
|
78
78
|
render( /*#__PURE__*/React.createElement(AppLike, {
|
|
@@ -86,7 +86,7 @@ describe('NewAccountModal', function () {
|
|
|
86
86
|
}
|
|
87
87
|
}))));
|
|
88
88
|
onSuccessFn(konnectorTrigger);
|
|
89
|
-
expect(
|
|
89
|
+
expect(replaceHistory).toHaveBeenCalledWith('/accounts/accountNumber/success');
|
|
90
90
|
});
|
|
91
91
|
it('should redirect to route without success on success for client triggers', function () {
|
|
92
92
|
render( /*#__PURE__*/React.createElement(AppLike, {
|
|
@@ -100,6 +100,6 @@ describe('NewAccountModal', function () {
|
|
|
100
100
|
}
|
|
101
101
|
}))));
|
|
102
102
|
onSuccessFn(clientTrigger);
|
|
103
|
-
expect(
|
|
103
|
+
expect(replaceHistory).toHaveBeenCalledWith('/accounts/accountNumberClient');
|
|
104
104
|
});
|
|
105
105
|
});
|
|
@@ -13,11 +13,11 @@ var RedirectToAccountFormButton = function RedirectToAccountFormButton(_ref) {
|
|
|
13
13
|
var accountId = getAccountId(trigger);
|
|
14
14
|
|
|
15
15
|
var _useContext = useContext(MountPointContext),
|
|
16
|
-
|
|
16
|
+
replaceHistory = _useContext.replaceHistory;
|
|
17
17
|
|
|
18
18
|
var handleClick = useCallback(function () {
|
|
19
|
-
|
|
20
|
-
}, [accountId,
|
|
19
|
+
replaceHistory("/accounts/".concat(accountId, "/edit?reconnect"));
|
|
20
|
+
}, [accountId, replaceHistory]);
|
|
21
21
|
return /*#__PURE__*/React.createElement(Button, {
|
|
22
22
|
className: "u-ml-0",
|
|
23
23
|
theme: "secondary",
|
|
@@ -4,10 +4,10 @@ import { MountPointContext } from './MountPointContext';
|
|
|
4
4
|
import RedirectToAccountFormButton from './RedirectToAccountFormButton';
|
|
5
5
|
import AppLike from '../../test/AppLike';
|
|
6
6
|
describe('redirect to account form button', function () {
|
|
7
|
-
it('should use
|
|
8
|
-
var
|
|
7
|
+
it('should use replaceHistory to navigate', function () {
|
|
8
|
+
var replaceHistory = jest.fn();
|
|
9
9
|
var mountPointContextValue = {
|
|
10
|
-
|
|
10
|
+
replaceHistory: replaceHistory
|
|
11
11
|
};
|
|
12
12
|
var trigger = {
|
|
13
13
|
message: {
|
|
@@ -20,6 +20,6 @@ describe('redirect to account form button', function () {
|
|
|
20
20
|
trigger: trigger
|
|
21
21
|
}))));
|
|
22
22
|
fireEvent.click(root.getByText('Reconnect'));
|
|
23
|
-
expect(
|
|
23
|
+
expect(replaceHistory).toHaveBeenCalledWith('/accounts/account-id-1337/edit?reconnect');
|
|
24
24
|
});
|
|
25
25
|
});
|
|
@@ -41,7 +41,8 @@ export var AppLinkButton = function AppLinkButton(_ref) {
|
|
|
41
41
|
var onClick = _ref2.onClick,
|
|
42
42
|
href = _ref2.href;
|
|
43
43
|
return /*#__PURE__*/React.createElement(ButtonLink, {
|
|
44
|
-
|
|
44
|
+
disabled: fetchStatus !== 'loaded',
|
|
45
|
+
onClick: fetchStatus === 'loaded' ? onClick : null,
|
|
45
46
|
href: href,
|
|
46
47
|
icon: isInstalled ? /*#__PURE__*/React.createElement(AppIcon, {
|
|
47
48
|
app: slug,
|
|
@@ -184,6 +184,7 @@ export var ConnectionFlow = /*#__PURE__*/function () {
|
|
|
184
184
|
this.realtime = new Realtime({
|
|
185
185
|
client: client
|
|
186
186
|
});
|
|
187
|
+
this.watchCurrentJobIfTriggerIsAlreadyRunning();
|
|
187
188
|
}
|
|
188
189
|
|
|
189
190
|
_createClass(ConnectionFlow, [{
|
|
@@ -500,7 +501,8 @@ export var ConnectionFlow = /*#__PURE__*/function () {
|
|
|
500
501
|
}, {
|
|
501
502
|
key: "handleLoginSuccess",
|
|
502
503
|
value: function handleLoginSuccess() {
|
|
503
|
-
this.jobWatcher.
|
|
504
|
+
this.jobWatcher.handleLoginSuccess();
|
|
505
|
+
this.triggerEvent(LOGIN_SUCCESS_EVENT);
|
|
504
506
|
}
|
|
505
507
|
}, {
|
|
506
508
|
key: "handleLoginSuccessHandled",
|
|
@@ -848,16 +850,11 @@ export var ConnectionFlow = /*#__PURE__*/function () {
|
|
|
848
850
|
key: "launch",
|
|
849
851
|
value: function () {
|
|
850
852
|
var _launch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
851
|
-
var _this2 = this;
|
|
852
|
-
|
|
853
853
|
var _ref5,
|
|
854
854
|
_ref5$autoSuccessTime,
|
|
855
855
|
autoSuccessTimer,
|
|
856
856
|
computedAutoSuccessTimer,
|
|
857
857
|
launcher,
|
|
858
|
-
_iterator2,
|
|
859
|
-
_step2,
|
|
860
|
-
_loop,
|
|
861
858
|
_args11 = arguments;
|
|
862
859
|
|
|
863
860
|
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
@@ -908,42 +905,11 @@ export var ConnectionFlow = /*#__PURE__*/function () {
|
|
|
908
905
|
}
|
|
909
906
|
}
|
|
910
907
|
|
|
911
|
-
this.
|
|
912
|
-
this.jobWatcher = watchKonnectorJob(this.client, this.job, {
|
|
908
|
+
this.watchJob({
|
|
913
909
|
autoSuccessTimer: computedAutoSuccessTimer
|
|
914
910
|
});
|
|
915
|
-
logger.info("ConnectionFlow: Subscribed to ".concat(JOBS_DOCTYPE, ":").concat(this.job._id));
|
|
916
|
-
_iterator2 = _createForOfIteratorHelper(JOB_EVENTS);
|
|
917
|
-
|
|
918
|
-
try {
|
|
919
|
-
_loop = function _loop() {
|
|
920
|
-
var ev = _step2.value;
|
|
921
|
-
|
|
922
|
-
_this2.jobWatcher.on(ev, function () {
|
|
923
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
924
|
-
args[_key2] = arguments[_key2];
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
return _this2.triggerEvent.apply(_this2, [ev].concat(args));
|
|
928
|
-
});
|
|
929
|
-
};
|
|
930
|
-
|
|
931
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
932
|
-
_loop();
|
|
933
|
-
}
|
|
934
|
-
} catch (err) {
|
|
935
|
-
_iterator2.e(err);
|
|
936
|
-
} finally {
|
|
937
|
-
_iterator2.f();
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
this.unsubscribeAllRealtime = function () {
|
|
941
|
-
_this2.jobWatcher.unsubscribeAll();
|
|
942
|
-
|
|
943
|
-
_this2.realtime.unsubscribeAll();
|
|
944
|
-
};
|
|
945
911
|
|
|
946
|
-
case
|
|
912
|
+
case 14:
|
|
947
913
|
case "end":
|
|
948
914
|
return _context11.stop();
|
|
949
915
|
}
|
|
@@ -957,6 +923,63 @@ export var ConnectionFlow = /*#__PURE__*/function () {
|
|
|
957
923
|
|
|
958
924
|
return launch;
|
|
959
925
|
}()
|
|
926
|
+
/**
|
|
927
|
+
* If the trigger we display is already running, subscribe to the associated job
|
|
928
|
+
*/
|
|
929
|
+
|
|
930
|
+
}, {
|
|
931
|
+
key: "watchCurrentJobIfTriggerIsAlreadyRunning",
|
|
932
|
+
value: function watchCurrentJobIfTriggerIsAlreadyRunning() {
|
|
933
|
+
if (get(this, 'trigger.current_state.status') === 'running') {
|
|
934
|
+
this.job = {
|
|
935
|
+
_id: get(this, 'trigger.current_state.last_executed_job_id')
|
|
936
|
+
};
|
|
937
|
+
this.watchJob();
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
}, {
|
|
941
|
+
key: "watchJob",
|
|
942
|
+
value: function watchJob() {
|
|
943
|
+
var _this2 = this;
|
|
944
|
+
|
|
945
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
946
|
+
autoSuccessTimer: false
|
|
947
|
+
};
|
|
948
|
+
this.realtime.subscribe('updated', JOBS_DOCTYPE, this.job._id, this.handleJobUpdated.bind(this));
|
|
949
|
+
this.jobWatcher = watchKonnectorJob(this.client, this.job, options);
|
|
950
|
+
logger.info("ConnectionFlow: Subscribed to ".concat(JOBS_DOCTYPE, ":").concat(this.job._id));
|
|
951
|
+
|
|
952
|
+
var _iterator2 = _createForOfIteratorHelper(JOB_EVENTS),
|
|
953
|
+
_step2;
|
|
954
|
+
|
|
955
|
+
try {
|
|
956
|
+
var _loop = function _loop() {
|
|
957
|
+
var ev = _step2.value;
|
|
958
|
+
|
|
959
|
+
_this2.jobWatcher.on(ev, function () {
|
|
960
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
961
|
+
args[_key2] = arguments[_key2];
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
return _this2.triggerEvent.apply(_this2, [ev].concat(args));
|
|
965
|
+
});
|
|
966
|
+
};
|
|
967
|
+
|
|
968
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
969
|
+
_loop();
|
|
970
|
+
}
|
|
971
|
+
} catch (err) {
|
|
972
|
+
_iterator2.e(err);
|
|
973
|
+
} finally {
|
|
974
|
+
_iterator2.f();
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
this.unsubscribeAllRealtime = function () {
|
|
978
|
+
_this2.jobWatcher.unsubscribeAll();
|
|
979
|
+
|
|
980
|
+
_this2.realtime.unsubscribeAll();
|
|
981
|
+
};
|
|
982
|
+
}
|
|
960
983
|
}, {
|
|
961
984
|
key: "unwatch",
|
|
962
985
|
value: function unwatch() {
|
|
@@ -985,7 +1008,7 @@ export var ConnectionFlow = /*#__PURE__*/function () {
|
|
|
985
1008
|
accountError = _this$state.accountError;
|
|
986
1009
|
var triggerError = triggersModel.getKonnectorJobError(trigger);
|
|
987
1010
|
return {
|
|
988
|
-
running: ![ERRORED, IDLE, SUCCESS].includes(status),
|
|
1011
|
+
running: get(trigger, 'current_state.status') === 'running' || ![ERRORED, IDLE, SUCCESS].includes(status),
|
|
989
1012
|
twoFARunning: status === RUNNING_TWOFA,
|
|
990
1013
|
twoFARetry: status == TWO_FA_MISMATCH,
|
|
991
1014
|
triggerError: triggerError,
|