cozy-harvest-lib 9.15.2 → 9.16.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 CHANGED
@@ -3,6 +3,45 @@
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.16.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.15.4...cozy-harvest-lib@9.16.0) (2022-06-30)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Lint ([c47501c](https://github.com/cozy/cozy-libs/commit/c47501c22dd080f75232acea66e47e4c3376fb82))
12
+
13
+
14
+ ### Features
15
+
16
+ * Allow EditAccountModal to have intentsApi ([43c5910](https://github.com/cozy/cozy-libs/commit/43c5910aba989fa09534cdfab8933512da606b2e))
17
+ * Now open the BI manage webview to the correct connection id ([2f3da74](https://github.com/cozy/cozy-libs/commit/2f3da74213710a06ad8877dd350bcd04b86d5e64))
18
+
19
+
20
+
21
+
22
+
23
+ ## [9.15.4](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.15.3...cozy-harvest-lib@9.15.4) (2022-06-28)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * **cozy-harvest-lib:** Revert RedirectToAccountFormButton label & size ([b942dce](https://github.com/cozy/cozy-libs/commit/b942dcef733a295e2334c8fdd3906f2f66318e70))
29
+
30
+
31
+
32
+
33
+
34
+ ## [9.15.3](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.15.2...cozy-harvest-lib@9.15.3) (2022-06-28)
35
+
36
+
37
+ ### Bug Fixes
38
+
39
+ * **deps:** update dependency jsdom to v16.5.0 [security] ([d9f1689](https://github.com/cozy/cozy-libs/commit/d9f16896f2c071c87bb6e04f2c029affd7d513e9))
40
+
41
+
42
+
43
+
44
+
6
45
  ## [9.15.2](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.15.1...cozy-harvest-lib@9.15.2) (2022-06-24)
7
46
 
8
47
  **Note:** Version bump only for package cozy-harvest-lib
@@ -157,7 +157,7 @@ export var AccountField = /*#__PURE__*/function (_PureComponent) {
157
157
 
158
158
  case 'dropdown':
159
159
  return /*#__PURE__*/React.createElement(Field, _extends({}, sanitizeSelectProps(fieldProps), {
160
- menuPosition: 'fixed'
160
+ menuPosition: "fixed"
161
161
  }));
162
162
 
163
163
  case 'password':
@@ -14,8 +14,8 @@ var CreateAccount = translate()(function (_ref) {
14
14
  t = _ref.t;
15
15
  return /*#__PURE__*/React.createElement(Button, {
16
16
  subtle: true,
17
- size: 'small',
18
- className: 'u-m-half',
17
+ size: "small",
18
+ className: "u-m-half",
19
19
  onClick: createAction,
20
20
  onTouchEnd: createAction,
21
21
  label: t('modal.addAccount.button')
@@ -32,6 +32,7 @@ import logger from '../logger';
32
32
  import { withTracker } from './hoc/tracking';
33
33
  import useTimeout from './hooks/useTimeout';
34
34
  import { withRouter } from 'react-router';
35
+ import { intentsApiProptype } from '../helpers/proptypes';
35
36
  var showStyle = {
36
37
  opacity: 1,
37
38
  transition: 'opacity 0.3s ease'
@@ -47,7 +48,8 @@ var DumbEditAccountModal = withRouter(function (_ref) {
47
48
  fetching = _ref.fetching,
48
49
  redirectToAccount = _ref.redirectToAccount,
49
50
  location = _ref.location,
50
- reconnect = _ref.reconnect;
51
+ reconnect = _ref.reconnect,
52
+ intentsApi = _ref.intentsApi;
51
53
 
52
54
  var _useCozyDialog = useCozyDialog({
53
55
  open: true,
@@ -103,7 +105,8 @@ var DumbEditAccountModal = withRouter(function (_ref) {
103
105
  showError: true,
104
106
  onVaultDismiss: redirectToAccount,
105
107
  fieldOptions: fieldOptions,
106
- reconnect: fromReconnect
108
+ reconnect: fromReconnect,
109
+ intentsApi: intentsApi
107
110
  }), /*#__PURE__*/React.createElement("div", {
108
111
  className: "u-mb-2"
109
112
  })));
@@ -256,6 +259,7 @@ EditAccountModal.propTypes = {
256
259
  konnector: PropTypes.object.isRequired,
257
260
  accountId: PropTypes.string.isRequired,
258
261
  accounts: PropTypes.array.isRequired,
259
- reconnect: PropTypes.bool
262
+ reconnect: PropTypes.bool,
263
+ intentsApi: intentsApiProptype
260
264
  };
261
265
  export default flow(withClient, withMountPointHistory, withTracker)(EditAccountModal);
@@ -84,13 +84,13 @@ var DumbKonnectorDialog = function DumbKonnectorDialog(_ref) {
84
84
  })), /*#__PURE__*/React.createElement(Button, {
85
85
  icon: /*#__PURE__*/React.createElement(Icon, {
86
86
  icon: CrossIcon,
87
- size: '24'
87
+ size: "24"
88
88
  }),
89
89
  onClick: onClose,
90
90
  iconOnly: true,
91
91
  label: t('close'),
92
92
  subtle: true,
93
- theme: 'secondary'
93
+ theme: "secondary"
94
94
  }))), /*#__PURE__*/React.createElement(DialogContent, null, content));
95
95
  };
96
96
 
@@ -22,8 +22,7 @@ var RedirectToAccountFormButton = function RedirectToAccountFormButton(_ref) {
22
22
  className: "u-ml-0",
23
23
  theme: "secondary",
24
24
  label: t('error.reconnect-via-form'),
25
- onClick: handleClick,
26
- extension: "full"
25
+ onClick: handleClick
27
26
  });
28
27
  };
29
28
 
@@ -19,7 +19,7 @@ describe('redirect to account form button', function () {
19
19
  }, /*#__PURE__*/React.createElement(RedirectToAccountFormButton, {
20
20
  trigger: trigger
21
21
  }))));
22
- fireEvent.click(root.getByText('Set the connection'));
22
+ fireEvent.click(root.getByText('Reconnect'));
23
23
  expect(replaceHistory).toHaveBeenCalledWith('/accounts/account-id-1337/edit?reconnect');
24
24
  });
25
25
  });
@@ -124,7 +124,7 @@
124
124
  "baseDir": "/Administrative"
125
125
  },
126
126
  "error": {
127
- "reconnect-via-form": "Set the connection",
127
+ "reconnect-via-form": "Reconnect",
128
128
  "job": {
129
129
  "DISK_QUOTA_EXCEEDED": {
130
130
  "title": "Storage full",
@@ -124,7 +124,7 @@
124
124
  "baseDir": "/Administratif"
125
125
  },
126
126
  "error": {
127
- "reconnect-via-form": "Régler la connexion",
127
+ "reconnect-via-form": "Se reconnecter",
128
128
  "job": {
129
129
  "DISK_QUOTA_EXCEEDED": {
130
130
  "title": "Espace Disque plein",
@@ -116,7 +116,7 @@ export var checkBIConnection = /*#__PURE__*/function () {
116
116
  }();
117
117
  export var fetchContractSynchronizationUrl = /*#__PURE__*/function () {
118
118
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
119
- var account, client, konnector, _yield$createTemporar, code, url, clientId;
119
+ var account, client, konnector, _yield$createTemporar, code, url, clientId, connId;
120
120
 
121
121
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
122
122
  while (1) {
@@ -135,9 +135,10 @@ export var fetchContractSynchronizationUrl = /*#__PURE__*/function () {
135
135
  code = _yield$createTemporar.code;
136
136
  url = _yield$createTemporar.url;
137
137
  clientId = _yield$createTemporar.clientId;
138
- return _context2.abrupt("return", "".concat(url, "/auth/webview/manage?client_id=").concat(clientId, "&code=").concat(code));
138
+ connId = getBIConnectionIdFromAccount(account);
139
+ return _context2.abrupt("return", "".concat(url, "/auth/webview/manage?client_id=").concat(clientId, "&code=").concat(code, "&connection_id=").concat(connId));
139
140
 
140
- case 8:
141
+ case 9:
141
142
  case "end":
142
143
  return _context2.stop();
143
144
  }
@@ -356,14 +356,22 @@ describe('fetchContractSynchronizationUrl', function () {
356
356
  });
357
357
  _context8.next = 5;
358
358
  return fetchContractSynchronizationUrl({
359
- account: account,
359
+ account: _objectSpread(_objectSpread({}, account), {}, {
360
+ data: {
361
+ auth: {
362
+ bi: {
363
+ connId: 1337
364
+ }
365
+ }
366
+ }
367
+ }),
360
368
  client: client,
361
369
  konnector: konnector
362
370
  });
363
371
 
364
372
  case 5:
365
373
  url = _context8.sent;
366
- expect(url).toEqual('https://cozy.biapi.pro/2.0/auth/webview/manage?client_id=test-client-id&code=bi-temporary-access-token-145613');
374
+ expect(url).toEqual('https://cozy.biapi.pro/2.0/auth/webview/manage?client_id=test-client-id&code=bi-temporary-access-token-145613&connection_id=1337');
367
375
 
368
376
  case 7:
369
377
  case "end":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-harvest-lib",
3
- "version": "9.15.2",
3
+ "version": "9.16.0",
4
4
  "description": "Provides logic, modules and components for Cozy's harvest applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -66,7 +66,7 @@
66
66
  "jest": "26.6.3",
67
67
  "jest-environment-jsdom-sixteen": "1.0.3",
68
68
  "jest-resolve-cached": "1.0.0",
69
- "jsdom": "16.4.0",
69
+ "jsdom": "16.5.0",
70
70
  "leaflet": "1.8.0",
71
71
  "prop-types": "15.7.2",
72
72
  "react": "16.12.0",
@@ -87,5 +87,5 @@
87
87
  "react-router-dom": "^5.0.1"
88
88
  },
89
89
  "sideEffects": false,
90
- "gitHead": "d4236ee62f017def90a5684b754b1632cfa05676"
90
+ "gitHead": "4f6aefaf76dfdadf5d9df433b954951feac5c0af"
91
91
  }
@@ -132,7 +132,7 @@ export class AccountField extends PureComponent {
132
132
  )
133
133
  case 'dropdown':
134
134
  return (
135
- <Field {...sanitizeSelectProps(fieldProps)} menuPosition={'fixed'} />
135
+ <Field {...sanitizeSelectProps(fieldProps)} menuPosition="fixed" />
136
136
  )
137
137
  case 'password':
138
138
  return (
@@ -66,9 +66,16 @@ export class AccountModal extends Component {
66
66
  'trigger'
67
67
  )
68
68
 
69
- const hasTriggerStatusChanged = matchingTrigger && this.state.trigger && matchingTrigger.current_state.status !== this.state.trigger.current_state.status
70
-
71
- if (this.props.accountId !== prevProps.accountId || hasTriggerStatusChanged) {
69
+ const hasTriggerStatusChanged =
70
+ matchingTrigger &&
71
+ this.state.trigger &&
72
+ matchingTrigger.current_state.status !==
73
+ this.state.trigger.current_state.status
74
+
75
+ if (
76
+ this.props.accountId !== prevProps.accountId ||
77
+ hasTriggerStatusChanged
78
+ ) {
72
79
  return await this.loadSelectedAccountId()
73
80
  }
74
81
  }
@@ -13,8 +13,8 @@ const CreateAccount = translate()(({ createAction, t }) => {
13
13
  return (
14
14
  <Button
15
15
  subtle
16
- size={'small'}
17
- className={'u-m-half'}
16
+ size="small"
17
+ className="u-m-half"
18
18
  onClick={createAction}
19
19
  onTouchEnd={createAction}
20
20
  label={t('modal.addAccount.button')}
@@ -24,6 +24,7 @@ import logger from '../logger'
24
24
  import { withTracker } from './hoc/tracking'
25
25
  import useTimeout from './hooks/useTimeout'
26
26
  import { withRouter } from 'react-router'
27
+ import { intentsApiProptype } from '../helpers/proptypes'
27
28
 
28
29
  const showStyle = { opacity: 1, transition: 'opacity 0.3s ease' }
29
30
  const hideStyle = { opacity: 0, transition: 'opacity 0.3s ease' }
@@ -36,7 +37,8 @@ const DumbEditAccountModal = withRouter(
36
37
  fetching,
37
38
  redirectToAccount,
38
39
  location,
39
- reconnect
40
+ reconnect,
41
+ intentsApi
40
42
  }) => {
41
43
  const { dialogProps, dialogTitleProps } = useCozyDialog({
42
44
  open: true,
@@ -96,6 +98,7 @@ const DumbEditAccountModal = withRouter(
96
98
  onVaultDismiss={redirectToAccount}
97
99
  fieldOptions={fieldOptions}
98
100
  reconnect={fromReconnect}
101
+ intentsApi={intentsApi}
99
102
  />
100
103
  )}
101
104
  <div className="u-mb-2" />
@@ -200,7 +203,8 @@ EditAccountModal.propTypes = {
200
203
  konnector: PropTypes.object.isRequired,
201
204
  accountId: PropTypes.string.isRequired,
202
205
  accounts: PropTypes.array.isRequired,
203
- reconnect: PropTypes.bool
206
+ reconnect: PropTypes.bool,
207
+ intentsApi: intentsApiProptype
204
208
  }
205
209
 
206
210
  export default flow(
@@ -69,12 +69,12 @@ const DumbKonnectorDialog = ({
69
69
  )}
70
70
  </div>
71
71
  <Button
72
- icon={<Icon icon={CrossIcon} size={'24'} />}
72
+ icon={<Icon icon={CrossIcon} size="24" />}
73
73
  onClick={onClose}
74
74
  iconOnly
75
75
  label={t('close')}
76
76
  subtle
77
- theme={'secondary'}
77
+ theme="secondary"
78
78
  />
79
79
  </div>
80
80
  </DialogTitle>
@@ -17,7 +17,6 @@ const RedirectToAccountFormButton = ({ trigger }) => {
17
17
  theme="secondary"
18
18
  label={t('error.reconnect-via-form')}
19
19
  onClick={handleClick}
20
- extension="full"
21
20
  />
22
21
  )
23
22
  }
@@ -22,7 +22,7 @@ describe('redirect to account form button', () => {
22
22
  </MountPointContext.Provider>
23
23
  </AppLike>
24
24
  )
25
- fireEvent.click(root.getByText('Set the connection'))
25
+ fireEvent.click(root.getByText('Reconnect'))
26
26
  expect(replaceHistory).toHaveBeenCalledWith(
27
27
  '/accounts/account-id-1337/edit?reconnect'
28
28
  )
@@ -124,7 +124,7 @@
124
124
  "baseDir": "/Administrative"
125
125
  },
126
126
  "error": {
127
- "reconnect-via-form": "Set the connection",
127
+ "reconnect-via-form": "Reconnect",
128
128
  "job": {
129
129
  "DISK_QUOTA_EXCEEDED": {
130
130
  "title": "Storage full",
@@ -124,7 +124,7 @@
124
124
  "baseDir": "/Administratif"
125
125
  },
126
126
  "error": {
127
- "reconnect-via-form": "Régler la connexion",
127
+ "reconnect-via-form": "Se reconnecter",
128
128
  "job": {
129
129
  "DISK_QUOTA_EXCEEDED": {
130
130
  "title": "Espace Disque plein",
@@ -91,7 +91,8 @@ export const fetchContractSynchronizationUrl = async ({
91
91
  konnector,
92
92
  account
93
93
  })
94
- return `${url}/auth/webview/manage?client_id=${clientId}&code=${code}`
94
+ const connId = getBIConnectionIdFromAccount(account)
95
+ return `${url}/auth/webview/manage?client_id=${clientId}&code=${code}&connection_id=${connId}`
95
96
  }
96
97
 
97
98
  /**
@@ -216,12 +216,12 @@ describe('fetchContractSynchronizationUrl', () => {
216
216
  })
217
217
 
218
218
  const url = await fetchContractSynchronizationUrl({
219
- account,
219
+ account: { ...account, data: { auth: { bi: { connId: 1337 } } } },
220
220
  client,
221
221
  konnector
222
222
  })
223
223
  expect(url).toEqual(
224
- 'https://cozy.biapi.pro/2.0/auth/webview/manage?client_id=test-client-id&code=bi-temporary-access-token-145613'
224
+ 'https://cozy.biapi.pro/2.0/auth/webview/manage?client_id=test-client-id&code=bi-temporary-access-token-145613&connection_id=1337'
225
225
  )
226
226
  })
227
227
  })