cozy-harvest-lib 9.29.0 → 9.29.2
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 +24 -0
- package/dist/components/KonnectorConfiguration/ConfigurationTab/BiContractActivationWindow.js +1 -1
- package/dist/components/KonnectorConfiguration/ConfigurationTab/index.js +2 -5
- package/dist/components/KonnectorConfiguration/ConfigurationTab/index.spec.js +25 -28
- package/dist/components/Routes.js +2 -1
- package/dist/components/TriggerManager.js +5 -7
- package/dist/components/VaultUnlockProvider/index.js +23 -0
- package/package.json +2 -2
- package/src/components/KonnectorConfiguration/ConfigurationTab/BiContractActivationWindow.jsx +1 -1
- package/src/components/KonnectorConfiguration/ConfigurationTab/index.jsx +2 -3
- package/src/components/KonnectorConfiguration/ConfigurationTab/index.spec.jsx +15 -16
- package/src/components/Routes.jsx +2 -5
- package/src/components/TriggerManager.jsx +4 -8
- package/src/components/VaultUnlockProvider/index.jsx +25 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [9.29.2](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.29.1...cozy-harvest-lib@9.29.2) (2022-11-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **cozy-harvest-lib:** Correctly instantiate `VaultUnlockProvider` ([f92da60](https://github.com/cozy/cozy-libs/commit/f92da602578142b5fdd4a072031010d1b2c8e015))
|
|
12
|
+
* **cozy-harvest-lib:** Re-enable skipped `ConfigurationTab` unit test ([b815eab](https://github.com/cozy/cozy-libs/commit/b815eabd692abc3d83eb0d558ae1afcfe2cb4b95))
|
|
13
|
+
* **cozy-harvest-lib:** Remove addCheckShouldUnlock from showUnlockForm ([691d47b](https://github.com/cozy/cozy-libs/commit/691d47b360ef83c50fdb576a9ef1b6bf916db009))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## [9.29.1](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.29.0...cozy-harvest-lib@9.29.1) (2022-11-03)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* Wrong locale on BI connection removal ([ed2f352](https://github.com/cozy/cozy-libs/commit/ed2f352467da5f36ef1753de5578f156bb2a1ffb))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
6
30
|
# [9.29.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.28.0...cozy-harvest-lib@9.29.0) (2022-10-28)
|
|
7
31
|
|
|
8
32
|
|
package/dist/components/KonnectorConfiguration/ConfigurationTab/BiContractActivationWindow.js
CHANGED
|
@@ -139,7 +139,7 @@ var BIContractActivationWindow = function BIContractActivationWindow(_ref) {
|
|
|
139
139
|
}, t('contracts.handle-synchronization'))), /*#__PURE__*/React.createElement(Dialog, {
|
|
140
140
|
open: isDeleteConnectionDialogVisible,
|
|
141
141
|
title: t('modal.deleteBIConnection.title'),
|
|
142
|
-
content: t('modal.
|
|
142
|
+
content: t('modal.deleteBIConnection.description'),
|
|
143
143
|
onClose: onAccountDeleted,
|
|
144
144
|
actions: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
145
145
|
variant: "text",
|
|
@@ -24,7 +24,7 @@ import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
|
|
|
24
24
|
import ListItemSecondaryAction from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItemSecondaryAction';
|
|
25
25
|
import Alerter from 'cozy-ui/transpiled/react/Alerter'; // @ts-ignore peerDep
|
|
26
26
|
|
|
27
|
-
import { useVaultClient,
|
|
27
|
+
import { useVaultClient, useVaultUnlockContext } from 'cozy-keys-lib';
|
|
28
28
|
import { deleteAccount } from '../../../connections/accounts';
|
|
29
29
|
import { unshareCipher } from '../../../models/cipherUtils';
|
|
30
30
|
import { findKonnectorPolicy } from '../../../konnector-policies';
|
|
@@ -120,10 +120,7 @@ var ConfigurationTab = function ConfigurationTab(_ref2) {
|
|
|
120
120
|
|
|
121
121
|
showUnlockForm({
|
|
122
122
|
closable: true,
|
|
123
|
-
onUnlock: handleUnlockForDeletion
|
|
124
|
-
addCheckShouldUnlock: function addCheckShouldUnlock() {
|
|
125
|
-
return CozyUtils.checkHasInstalledExtension(client);
|
|
126
|
-
}
|
|
123
|
+
onUnlock: handleUnlockForDeletion
|
|
127
124
|
});
|
|
128
125
|
_context.next = 8;
|
|
129
126
|
break;
|
|
@@ -14,7 +14,8 @@ import { MountPointProvider } from '../../../components/MountPointContext';
|
|
|
14
14
|
import { createMockClient } from 'cozy-client/dist/mock';
|
|
15
15
|
import { deleteAccount } from '../../../connections/accounts';
|
|
16
16
|
import AppLike from '../../../../test/AppLike';
|
|
17
|
-
import { VaultProvider, VaultUnlockPlaceholder,
|
|
17
|
+
import { VaultProvider, VaultUnlockPlaceholder, useVaultClient, CozyUtils } from 'cozy-keys-lib';
|
|
18
|
+
import VaultUnlockProvider from '../../VaultUnlockProvider';
|
|
18
19
|
import { findKonnectorPolicy } from '../../../konnector-policies';
|
|
19
20
|
jest.mock('../../../konnector-policies', function () {
|
|
20
21
|
return {
|
|
@@ -42,7 +43,10 @@ var SimpleVaultUnlocker = function SimpleVaultUnlocker(_ref) {
|
|
|
42
43
|
jest.mock('cozy-keys-lib', function () {
|
|
43
44
|
var actual = jest.requireActual('cozy-keys-lib');
|
|
44
45
|
return _objectSpread(_objectSpread({}, actual), {}, {
|
|
45
|
-
useVaultClient: jest.fn()
|
|
46
|
+
useVaultClient: jest.fn(),
|
|
47
|
+
CozyUtils: {
|
|
48
|
+
checkHasInstalledExtension: jest.fn()
|
|
49
|
+
}
|
|
46
50
|
});
|
|
47
51
|
});
|
|
48
52
|
describe('ConfigurationTab', function () {
|
|
@@ -75,7 +79,6 @@ describe('ConfigurationTab', function () {
|
|
|
75
79
|
konnector = _ref2$konnector === void 0 ? {} : _ref2$konnector,
|
|
76
80
|
_ref2$trigger = _ref2.trigger,
|
|
77
81
|
trigger = _ref2$trigger === void 0 ? {} : _ref2$trigger,
|
|
78
|
-
checkShouldUnlock = _ref2.checkShouldUnlock,
|
|
79
82
|
_ref2$flowState = _ref2.flowState,
|
|
80
83
|
flowState = _ref2$flowState === void 0 ? DEFAULT_FLOW_STATE : _ref2$flowState;
|
|
81
84
|
|
|
@@ -93,7 +96,6 @@ describe('ConfigurationTab', function () {
|
|
|
93
96
|
rows: []
|
|
94
97
|
});
|
|
95
98
|
var unlockFormProps = {
|
|
96
|
-
checkShouldUnlock: checkShouldUnlock,
|
|
97
99
|
UnlockForm: SimpleVaultUnlocker
|
|
98
100
|
};
|
|
99
101
|
var root = render( /*#__PURE__*/React.createElement(AppLike, {
|
|
@@ -102,9 +104,7 @@ describe('ConfigurationTab', function () {
|
|
|
102
104
|
baseRoute: "/"
|
|
103
105
|
}, /*#__PURE__*/React.createElement(VaultProvider, {
|
|
104
106
|
instance: "http://cozy.tools:8080"
|
|
105
|
-
}, /*#__PURE__*/React.createElement(VaultUnlockProvider, {
|
|
106
|
-
checkShouldUnlock: checkShouldUnlock
|
|
107
|
-
}, /*#__PURE__*/React.createElement(ConfigurationTab, {
|
|
107
|
+
}, /*#__PURE__*/React.createElement(VaultUnlockProvider, null, /*#__PURE__*/React.createElement(ConfigurationTab, {
|
|
108
108
|
konnector: konnector,
|
|
109
109
|
account: account,
|
|
110
110
|
addAccount: addAccount,
|
|
@@ -135,9 +135,8 @@ describe('ConfigurationTab', function () {
|
|
|
135
135
|
while (1) {
|
|
136
136
|
switch (_context2.prev = _context2.next) {
|
|
137
137
|
case 0:
|
|
138
|
-
_setup2 = setup(
|
|
139
|
-
|
|
140
|
-
}), root = _setup2.root;
|
|
138
|
+
_setup2 = setup(), root = _setup2.root;
|
|
139
|
+
CozyUtils.checkHasInstalledExtension.mockResolvedValueOnce(false);
|
|
141
140
|
useVaultClient.mockReturnValue({
|
|
142
141
|
isLocked: jest.fn().mockResolvedValue(false)
|
|
143
142
|
});
|
|
@@ -151,7 +150,7 @@ describe('ConfigurationTab', function () {
|
|
|
151
150
|
expect(root.getByText(modalText));
|
|
152
151
|
expect(deleteAccount).not.toHaveBeenCalled();
|
|
153
152
|
confirmBtn = root.getByText('Disconnect');
|
|
154
|
-
_context2.next =
|
|
153
|
+
_context2.next = 13;
|
|
155
154
|
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
156
155
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
157
156
|
while (1) {
|
|
@@ -167,10 +166,10 @@ describe('ConfigurationTab', function () {
|
|
|
167
166
|
}, _callee);
|
|
168
167
|
})));
|
|
169
168
|
|
|
170
|
-
case
|
|
169
|
+
case 13:
|
|
171
170
|
expect(deleteAccount).toHaveBeenCalled();
|
|
172
171
|
|
|
173
|
-
case
|
|
172
|
+
case 14:
|
|
174
173
|
case "end":
|
|
175
174
|
return _context2.stop();
|
|
176
175
|
}
|
|
@@ -189,16 +188,15 @@ describe('ConfigurationTab', function () {
|
|
|
189
188
|
saveInVault: false
|
|
190
189
|
};
|
|
191
190
|
});
|
|
192
|
-
_setup3 = setup(
|
|
193
|
-
|
|
194
|
-
}), root = _setup3.root;
|
|
191
|
+
_setup3 = setup(), root = _setup3.root;
|
|
192
|
+
CozyUtils.checkHasInstalledExtension.mockResolvedValueOnce(true);
|
|
195
193
|
btn = root.getByText('Disconnect this account');
|
|
196
194
|
expect(root.queryByText('Your account will be disconnected, but already imported data will be kept.')).toBeFalsy();
|
|
197
195
|
fireEvent.click(btn);
|
|
198
196
|
expect(root.getByText('Your account will be disconnected, but already imported data will be kept.'));
|
|
199
197
|
expect(deleteAccount).not.toHaveBeenCalled();
|
|
200
198
|
confirmBtn = root.getByText('Disconnect');
|
|
201
|
-
_context4.next =
|
|
199
|
+
_context4.next = 11;
|
|
202
200
|
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
203
201
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
204
202
|
while (1) {
|
|
@@ -214,17 +212,17 @@ describe('ConfigurationTab', function () {
|
|
|
214
212
|
}, _callee3);
|
|
215
213
|
})));
|
|
216
214
|
|
|
217
|
-
case
|
|
215
|
+
case 11:
|
|
218
216
|
expect(deleteAccount).toHaveBeenCalled();
|
|
219
217
|
|
|
220
|
-
case
|
|
218
|
+
case 12:
|
|
221
219
|
case "end":
|
|
222
220
|
return _context4.stop();
|
|
223
221
|
}
|
|
224
222
|
}
|
|
225
223
|
}, _callee4);
|
|
226
224
|
})));
|
|
227
|
-
|
|
225
|
+
it('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() {
|
|
228
226
|
var _setup4, root, btn, confirmBtn;
|
|
229
227
|
|
|
230
228
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
@@ -237,16 +235,15 @@ describe('ConfigurationTab', function () {
|
|
|
237
235
|
useVaultClient.mockReturnValue({
|
|
238
236
|
isLocked: jest.fn().mockResolvedValue(true)
|
|
239
237
|
});
|
|
240
|
-
_setup4 = setup(
|
|
241
|
-
|
|
242
|
-
}), root = _setup4.root;
|
|
238
|
+
_setup4 = setup(), root = _setup4.root;
|
|
239
|
+
CozyUtils.checkHasInstalledExtension.mockResolvedValueOnce(true);
|
|
243
240
|
btn = root.getByText('Disconnect this account');
|
|
244
241
|
expect(root.queryByText('Your account will be disconnected, but already imported data will be kept.')).toBeFalsy();
|
|
245
242
|
fireEvent.click(btn);
|
|
246
243
|
expect(root.getByText('Your account will be disconnected, but already imported data will be kept.'));
|
|
247
244
|
expect(deleteAccount).not.toHaveBeenCalled();
|
|
248
245
|
confirmBtn = root.getByText('Disconnect');
|
|
249
|
-
_context7.next =
|
|
246
|
+
_context7.next = 12;
|
|
250
247
|
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
251
248
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
252
249
|
while (1) {
|
|
@@ -262,11 +259,11 @@ describe('ConfigurationTab', function () {
|
|
|
262
259
|
}, _callee5);
|
|
263
260
|
})));
|
|
264
261
|
|
|
265
|
-
case
|
|
262
|
+
case 12:
|
|
266
263
|
expect(deleteAccount).not.toHaveBeenCalled(); // Since the konnector saves the cipher in the vault, we need to unlock the
|
|
267
264
|
// vault, for the cipher to be correctly unshared from the vault
|
|
268
265
|
|
|
269
|
-
_context7.next =
|
|
266
|
+
_context7.next = 15;
|
|
270
267
|
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
271
268
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
272
269
|
while (1) {
|
|
@@ -282,10 +279,10 @@ describe('ConfigurationTab', function () {
|
|
|
282
279
|
}, _callee6);
|
|
283
280
|
})));
|
|
284
281
|
|
|
285
|
-
case
|
|
282
|
+
case 15:
|
|
286
283
|
expect(deleteAccount).toHaveBeenCalled();
|
|
287
284
|
|
|
288
|
-
case
|
|
285
|
+
case 16:
|
|
289
286
|
case "end":
|
|
290
287
|
return _context7.stop();
|
|
291
288
|
}
|
|
@@ -7,7 +7,7 @@ import Dialog from 'cozy-ui/transpiled/react/Dialog';
|
|
|
7
7
|
import { DialogCloseButton, useCozyDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
|
|
8
8
|
import { useI18n } from 'cozy-ui/transpiled/react/I18n';
|
|
9
9
|
import Spinner from 'cozy-ui/transpiled/react/Spinner';
|
|
10
|
-
import { useVaultUnlockContext,
|
|
10
|
+
import { useVaultUnlockContext, VaultUnlockPlaceholder } from 'cozy-keys-lib';
|
|
11
11
|
import KonnectorAccounts from './KonnectorAccounts';
|
|
12
12
|
import AccountModal from './AccountModal';
|
|
13
13
|
import NewAccountModal from './NewAccountModal';
|
|
@@ -15,6 +15,7 @@ import EditAccountModal from './EditAccountModal';
|
|
|
15
15
|
import KonnectorSuccess from './KonnectorSuccess';
|
|
16
16
|
import HarvestModalRoot from './HarvestModalRoot';
|
|
17
17
|
import HarvestVaultProvider from './HarvestVaultProvider';
|
|
18
|
+
import VaultUnlockProvider from './VaultUnlockProvider';
|
|
18
19
|
import { MountPointProvider } from './MountPointContext';
|
|
19
20
|
import DialogContext from './DialogContext';
|
|
20
21
|
import { DatacardOptions } from './Datacards/DatacardOptionsContext';
|
|
@@ -25,7 +25,7 @@ import { useVaultClient } from 'cozy-keys-lib';
|
|
|
25
25
|
import { translate } from 'cozy-ui/transpiled/react/I18n';
|
|
26
26
|
import Spinner from 'cozy-ui/transpiled/react/Spinner';
|
|
27
27
|
import { ModalBackButton } from 'cozy-ui/transpiled/react/Modal';
|
|
28
|
-
import { CipherType, withVaultUnlockContext, VaultUnlockPlaceholder
|
|
28
|
+
import { CipherType, withVaultUnlockContext, VaultUnlockPlaceholder } from 'cozy-keys-lib';
|
|
29
29
|
import AccountForm from './AccountForm';
|
|
30
30
|
import OAuthForm from './OAuthForm';
|
|
31
31
|
import { fetchAccount } from '../connections/accounts';
|
|
@@ -36,6 +36,7 @@ import logger from '../logger';
|
|
|
36
36
|
import { findKonnectorPolicy } from '../konnector-policies';
|
|
37
37
|
import withConnectionFlow from '../models/withConnectionFlow';
|
|
38
38
|
import HarvestVaultProvider from './HarvestVaultProvider';
|
|
39
|
+
import VaultUnlockProvider from './VaultUnlockProvider';
|
|
39
40
|
import { intentsApiProptype } from '../helpers/proptypes';
|
|
40
41
|
var IDLE = 'IDLE';
|
|
41
42
|
var RUNNING = 'RUNNING';
|
|
@@ -317,13 +318,13 @@ export var DumbTriggerManager = /*#__PURE__*/function (_Component) {
|
|
|
317
318
|
key: "componentDidMount",
|
|
318
319
|
value: function () {
|
|
319
320
|
var _componentDidMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
320
|
-
var _this$props3, konnector, showUnlockForm, onVaultDismiss, vaultClosable, vaultClient,
|
|
321
|
+
var _this$props3, konnector, showUnlockForm, onVaultDismiss, vaultClosable, vaultClient, konnectorPolicy, isVaultLocked;
|
|
321
322
|
|
|
322
323
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
323
324
|
while (1) {
|
|
324
325
|
switch (_context3.prev = _context3.next) {
|
|
325
326
|
case 0:
|
|
326
|
-
_this$props3 = this.props, konnector = _this$props3.konnector, showUnlockForm = _this$props3.showUnlockForm, onVaultDismiss = _this$props3.onVaultDismiss, vaultClosable = _this$props3.vaultClosable, vaultClient = _this$props3.vaultClient
|
|
327
|
+
_this$props3 = this.props, konnector = _this$props3.konnector, showUnlockForm = _this$props3.showUnlockForm, onVaultDismiss = _this$props3.onVaultDismiss, vaultClosable = _this$props3.vaultClosable, vaultClient = _this$props3.vaultClient;
|
|
327
328
|
konnectorPolicy = findKonnectorPolicy(konnector);
|
|
328
329
|
|
|
329
330
|
if (!konnectorPolicy.saveInVault) {
|
|
@@ -349,10 +350,7 @@ export var DumbTriggerManager = /*#__PURE__*/function (_Component) {
|
|
|
349
350
|
showUnlockForm({
|
|
350
351
|
onDismiss: onVaultDismiss,
|
|
351
352
|
closable: vaultClosable,
|
|
352
|
-
onUnlock: this.handleVaultUnlock
|
|
353
|
-
addCheckShouldUnlock: function addCheckShouldUnlock() {
|
|
354
|
-
return CozyUtils.checkHasInstalledExtension(client);
|
|
355
|
-
}
|
|
353
|
+
onUnlock: this.handleVaultUnlock
|
|
356
354
|
});
|
|
357
355
|
} else {
|
|
358
356
|
this.handleVaultUnlock();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["children"];
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { useClient } from 'cozy-client';
|
|
6
|
+
import { VaultUnlockProvider as WrappedVaultUnlockProvider, CozyUtils } from 'cozy-keys-lib';
|
|
7
|
+
|
|
8
|
+
var VaultUnlockProvider = function VaultUnlockProvider(_ref) {
|
|
9
|
+
var children = _ref.children,
|
|
10
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
11
|
+
|
|
12
|
+
var client = useClient();
|
|
13
|
+
|
|
14
|
+
var addCheckShouldUnlock = function addCheckShouldUnlock() {
|
|
15
|
+
return CozyUtils.checkHasInstalledExtension(client);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return /*#__PURE__*/React.createElement(WrappedVaultUnlockProvider, _extends({}, props, {
|
|
19
|
+
addCheckShouldUnlock: addCheckShouldUnlock
|
|
20
|
+
}), children);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default /*#__PURE__*/React.memo(VaultUnlockProvider);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-harvest-lib",
|
|
3
|
-
"version": "9.29.
|
|
3
|
+
"version": "9.29.2",
|
|
4
4
|
"description": "Provides logic, modules and components for Cozy's harvest applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Cozy",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"react-router-dom": "^5.0.1"
|
|
92
92
|
},
|
|
93
93
|
"sideEffects": false,
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "404afa42827560b63af1973421a00395db5e9c1d"
|
|
95
95
|
}
|
package/src/components/KonnectorConfiguration/ConfigurationTab/BiContractActivationWindow.jsx
CHANGED
|
@@ -106,7 +106,7 @@ const BIContractActivationWindow = ({
|
|
|
106
106
|
<Dialog
|
|
107
107
|
open={isDeleteConnectionDialogVisible}
|
|
108
108
|
title={t('modal.deleteBIConnection.title')}
|
|
109
|
-
content={t('modal.
|
|
109
|
+
content={t('modal.deleteBIConnection.description')}
|
|
110
110
|
onClose={onAccountDeleted}
|
|
111
111
|
actions={
|
|
112
112
|
<>
|
|
@@ -26,7 +26,7 @@ import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
|
|
|
26
26
|
import ListItemSecondaryAction from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItemSecondaryAction'
|
|
27
27
|
import Alerter from 'cozy-ui/transpiled/react/Alerter'
|
|
28
28
|
// @ts-ignore peerDep
|
|
29
|
-
import { useVaultClient,
|
|
29
|
+
import { useVaultClient, useVaultUnlockContext } from 'cozy-keys-lib'
|
|
30
30
|
|
|
31
31
|
import { deleteAccount } from '../../../connections/accounts'
|
|
32
32
|
import { unshareCipher } from '../../../models/cipherUtils'
|
|
@@ -99,8 +99,7 @@ const ConfigurationTab = ({
|
|
|
99
99
|
if (konnectorPolicy.saveInVault) {
|
|
100
100
|
showUnlockForm({
|
|
101
101
|
closable: true,
|
|
102
|
-
onUnlock: handleUnlockForDeletion
|
|
103
|
-
addCheckShouldUnlock: () => CozyUtils.checkHasInstalledExtension(client)
|
|
102
|
+
onUnlock: handleUnlockForDeletion
|
|
104
103
|
})
|
|
105
104
|
} else {
|
|
106
105
|
await handleDeleteAccount()
|
|
@@ -10,9 +10,10 @@ import AppLike from '../../../../test/AppLike'
|
|
|
10
10
|
import {
|
|
11
11
|
VaultProvider,
|
|
12
12
|
VaultUnlockPlaceholder,
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
useVaultClient,
|
|
14
|
+
CozyUtils
|
|
15
15
|
} from 'cozy-keys-lib'
|
|
16
|
+
import VaultUnlockProvider from '../../VaultUnlockProvider'
|
|
16
17
|
|
|
17
18
|
import { findKonnectorPolicy } from '../../../konnector-policies'
|
|
18
19
|
jest.mock('../../../konnector-policies', () => ({
|
|
@@ -35,7 +36,10 @@ jest.mock('cozy-keys-lib', () => {
|
|
|
35
36
|
const actual = jest.requireActual('cozy-keys-lib')
|
|
36
37
|
return {
|
|
37
38
|
...actual,
|
|
38
|
-
useVaultClient: jest.fn()
|
|
39
|
+
useVaultClient: jest.fn(),
|
|
40
|
+
CozyUtils: {
|
|
41
|
+
checkHasInstalledExtension: jest.fn()
|
|
42
|
+
}
|
|
39
43
|
}
|
|
40
44
|
})
|
|
41
45
|
|
|
@@ -64,7 +68,6 @@ describe('ConfigurationTab', () => {
|
|
|
64
68
|
function setup({
|
|
65
69
|
konnector = {},
|
|
66
70
|
trigger = {},
|
|
67
|
-
checkShouldUnlock,
|
|
68
71
|
flowState = DEFAULT_FLOW_STATE
|
|
69
72
|
} = {}) {
|
|
70
73
|
const account = {}
|
|
@@ -77,14 +80,13 @@ describe('ConfigurationTab', () => {
|
|
|
77
80
|
const mockClient = createMockClient({ queries: {} })
|
|
78
81
|
mockClient.stackClient.fetchJSON.mockResolvedValue({ rows: [] })
|
|
79
82
|
const unlockFormProps = {
|
|
80
|
-
checkShouldUnlock,
|
|
81
83
|
UnlockForm: SimpleVaultUnlocker
|
|
82
84
|
}
|
|
83
85
|
const root = render(
|
|
84
86
|
<AppLike client={mockClient}>
|
|
85
87
|
<MountPointProvider baseRoute="/">
|
|
86
88
|
<VaultProvider instance="http://cozy.tools:8080">
|
|
87
|
-
<VaultUnlockProvider
|
|
89
|
+
<VaultUnlockProvider>
|
|
88
90
|
<ConfigurationTab
|
|
89
91
|
konnector={konnector}
|
|
90
92
|
account={account}
|
|
@@ -112,9 +114,8 @@ describe('ConfigurationTab', () => {
|
|
|
112
114
|
|
|
113
115
|
describe('deletion modal', () => {
|
|
114
116
|
it('should display deletion modal when clicking on disconnect this account (vault does not need to be unlocked)', async () => {
|
|
115
|
-
const { root } = setup(
|
|
116
|
-
|
|
117
|
-
})
|
|
117
|
+
const { root } = setup()
|
|
118
|
+
CozyUtils.checkHasInstalledExtension.mockResolvedValueOnce(false)
|
|
118
119
|
useVaultClient.mockReturnValue({
|
|
119
120
|
isLocked: jest.fn().mockResolvedValue(false)
|
|
120
121
|
})
|
|
@@ -135,9 +136,8 @@ describe('ConfigurationTab', () => {
|
|
|
135
136
|
|
|
136
137
|
it('should display deletion modal when clicking on disconnect this account (vault needs to be unlocked, connector policy does not save in vault)', async () => {
|
|
137
138
|
findKonnectorPolicy.mockImplementation(() => ({ saveInVault: false }))
|
|
138
|
-
const { root } = setup(
|
|
139
|
-
|
|
140
|
-
})
|
|
139
|
+
const { root } = setup()
|
|
140
|
+
CozyUtils.checkHasInstalledExtension.mockResolvedValueOnce(true)
|
|
141
141
|
const btn = root.getByText('Disconnect this account')
|
|
142
142
|
expect(
|
|
143
143
|
root.queryByText(
|
|
@@ -158,14 +158,13 @@ describe('ConfigurationTab', () => {
|
|
|
158
158
|
expect(deleteAccount).toHaveBeenCalled()
|
|
159
159
|
})
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
it('should display deletion modal when clicking on disconnect this account (vault needs to be unlocked, connector policy saves in vault)', async () => {
|
|
162
162
|
findKonnectorPolicy.mockReturnValue({ saveInVault: true })
|
|
163
163
|
useVaultClient.mockReturnValue({
|
|
164
164
|
isLocked: jest.fn().mockResolvedValue(true)
|
|
165
165
|
})
|
|
166
|
-
const { root } = setup(
|
|
167
|
-
|
|
168
|
-
})
|
|
166
|
+
const { root } = setup()
|
|
167
|
+
CozyUtils.checkHasInstalledExtension.mockResolvedValueOnce(true)
|
|
169
168
|
const btn = root.getByText('Disconnect this account')
|
|
170
169
|
expect(
|
|
171
170
|
root.queryByText(
|
|
@@ -10,11 +10,7 @@ import {
|
|
|
10
10
|
} from 'cozy-ui/transpiled/react/CozyDialogs'
|
|
11
11
|
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
|
|
12
12
|
import Spinner from 'cozy-ui/transpiled/react/Spinner'
|
|
13
|
-
import {
|
|
14
|
-
useVaultUnlockContext,
|
|
15
|
-
VaultUnlockProvider,
|
|
16
|
-
VaultUnlockPlaceholder
|
|
17
|
-
} from 'cozy-keys-lib'
|
|
13
|
+
import { useVaultUnlockContext, VaultUnlockPlaceholder } from 'cozy-keys-lib'
|
|
18
14
|
|
|
19
15
|
import KonnectorAccounts from './KonnectorAccounts'
|
|
20
16
|
import AccountModal from './AccountModal'
|
|
@@ -23,6 +19,7 @@ import EditAccountModal from './EditAccountModal'
|
|
|
23
19
|
import KonnectorSuccess from './KonnectorSuccess'
|
|
24
20
|
import HarvestModalRoot from './HarvestModalRoot'
|
|
25
21
|
import HarvestVaultProvider from './HarvestVaultProvider'
|
|
22
|
+
import VaultUnlockProvider from './VaultUnlockProvider'
|
|
26
23
|
import { MountPointProvider } from './MountPointContext'
|
|
27
24
|
import DialogContext from './DialogContext'
|
|
28
25
|
import { DatacardOptions } from './Datacards/DatacardOptionsContext'
|
|
@@ -14,9 +14,7 @@ import { ModalBackButton } from 'cozy-ui/transpiled/react/Modal'
|
|
|
14
14
|
import {
|
|
15
15
|
CipherType,
|
|
16
16
|
withVaultUnlockContext,
|
|
17
|
-
VaultUnlockPlaceholder
|
|
18
|
-
VaultUnlockProvider,
|
|
19
|
-
CozyUtils
|
|
17
|
+
VaultUnlockPlaceholder
|
|
20
18
|
} from 'cozy-keys-lib'
|
|
21
19
|
|
|
22
20
|
import AccountForm from './AccountForm'
|
|
@@ -29,6 +27,7 @@ import logger from '../logger'
|
|
|
29
27
|
import { findKonnectorPolicy } from '../konnector-policies'
|
|
30
28
|
import withConnectionFlow from '../models/withConnectionFlow'
|
|
31
29
|
import HarvestVaultProvider from './HarvestVaultProvider'
|
|
30
|
+
import VaultUnlockProvider from './VaultUnlockProvider'
|
|
32
31
|
import { intentsApiProptype } from '../helpers/proptypes'
|
|
33
32
|
|
|
34
33
|
const IDLE = 'IDLE'
|
|
@@ -216,8 +215,7 @@ export class DumbTriggerManager extends Component {
|
|
|
216
215
|
showUnlockForm,
|
|
217
216
|
onVaultDismiss,
|
|
218
217
|
vaultClosable,
|
|
219
|
-
vaultClient
|
|
220
|
-
client
|
|
218
|
+
vaultClient
|
|
221
219
|
} = this.props
|
|
222
220
|
const konnectorPolicy = findKonnectorPolicy(konnector)
|
|
223
221
|
if (konnectorPolicy.saveInVault) {
|
|
@@ -231,9 +229,7 @@ export class DumbTriggerManager extends Component {
|
|
|
231
229
|
showUnlockForm({
|
|
232
230
|
onDismiss: onVaultDismiss,
|
|
233
231
|
closable: vaultClosable,
|
|
234
|
-
onUnlock: this.handleVaultUnlock
|
|
235
|
-
addCheckShouldUnlock: () =>
|
|
236
|
-
CozyUtils.checkHasInstalledExtension(client)
|
|
232
|
+
onUnlock: this.handleVaultUnlock
|
|
237
233
|
})
|
|
238
234
|
} else {
|
|
239
235
|
this.handleVaultUnlock()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { useClient } from 'cozy-client'
|
|
3
|
+
import {
|
|
4
|
+
VaultUnlockProvider as WrappedVaultUnlockProvider,
|
|
5
|
+
CozyUtils
|
|
6
|
+
} from 'cozy-keys-lib'
|
|
7
|
+
|
|
8
|
+
const VaultUnlockProvider = ({ children, ...props }) => {
|
|
9
|
+
const client = useClient()
|
|
10
|
+
|
|
11
|
+
const addCheckShouldUnlock = () => {
|
|
12
|
+
return CozyUtils.checkHasInstalledExtension(client)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<WrappedVaultUnlockProvider
|
|
17
|
+
{...props}
|
|
18
|
+
addCheckShouldUnlock={addCheckShouldUnlock}
|
|
19
|
+
>
|
|
20
|
+
{children}
|
|
21
|
+
</WrappedVaultUnlockProvider>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default React.memo(VaultUnlockProvider)
|