cozy-harvest-lib 9.29.2 → 9.29.4

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,25 @@
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.4](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.29.3...cozy-harvest-lib@9.29.4) (2022-11-15)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Dispatch account deletion after BI connection deletion ([2055a5e](https://github.com/cozy/cozy-libs/commit/2055a5e04e23594279eacd30979f54ad0b80a25c))
12
+
13
+
14
+
15
+
16
+
17
+ ## [9.29.3](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@9.29.2...cozy-harvest-lib@9.29.3) (2022-11-14)
18
+
19
+ **Note:** Version bump only for package cozy-harvest-lib
20
+
21
+
22
+
23
+
24
+
6
25
  ## [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
26
 
8
27
 
@@ -1,10 +1,16 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
4
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
+
6
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
+
8
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
+
4
10
  // @ts-check
5
- import React, { useState, useEffect } from 'react';
11
+ import React, { useState, useEffect, useCallback } from 'react';
6
12
  import PropTypes from 'prop-types';
7
- import { useClient } from 'cozy-client';
13
+ import { useClient, Mutations } from 'cozy-client';
8
14
  import Button from 'cozy-ui/transpiled/react/MuiCozyTheme/Buttons';
9
15
  import ListItem from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItem';
10
16
  import { Dialog } from 'cozy-ui/transpiled/react/CozyDialogs';
@@ -44,6 +50,32 @@ var BIContractActivationWindow = function BIContractActivationWindow(_ref) {
44
50
 
45
51
  var konnectorPolicy = findKonnectorPolicy(konnector);
46
52
  var client = useClient();
53
+ var onClose = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
54
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
55
+ while (1) {
56
+ switch (_context.prev = _context.next) {
57
+ case 0:
58
+ client.dispatch({
59
+ type: 'RECEIVE_MUTATION_RESULT',
60
+ mutationId: client.generateRandomId(),
61
+ response: {
62
+ data: _objectSpread(_objectSpread({}, account), {}, {
63
+ _deleted: true
64
+ })
65
+ },
66
+ definition: Mutations.deleteDocument(_objectSpread(_objectSpread({}, account), {}, {
67
+ _deleted: true
68
+ }))
69
+ });
70
+ onAccountDeleted();
71
+
72
+ case 2:
73
+ case "end":
74
+ return _context.stop();
75
+ }
76
+ }
77
+ }, _callee);
78
+ })), [onAccountDeleted, account, client]);
47
79
  /**
48
80
  * Detects if a BI connection has been removed
49
81
  *
@@ -95,13 +127,13 @@ var BIContractActivationWindow = function BIContractActivationWindow(_ref) {
95
127
  }
96
128
 
97
129
  function _handleLinkFetch() {
98
- _handleLinkFetch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
130
+ _handleLinkFetch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
99
131
  var result;
100
- return _regeneratorRuntime.wrap(function _callee$(_context) {
132
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
101
133
  while (1) {
102
- switch (_context.prev = _context.next) {
134
+ switch (_context2.prev = _context2.next) {
103
135
  case 0:
104
- _context.next = 2;
136
+ _context2.next = 2;
105
137
  return konnectorPolicy.fetchExtraOAuthUrlParams({
106
138
  client: client,
107
139
  account: account,
@@ -110,15 +142,15 @@ var BIContractActivationWindow = function BIContractActivationWindow(_ref) {
110
142
  });
111
143
 
112
144
  case 2:
113
- result = _context.sent;
145
+ result = _context2.sent;
114
146
  setExtraParams(result);
115
147
 
116
148
  case 4:
117
149
  case "end":
118
- return _context.stop();
150
+ return _context2.stop();
119
151
  }
120
152
  }
121
- }, _callee);
153
+ }, _callee2);
122
154
  }));
123
155
  return _handleLinkFetch.apply(this, arguments);
124
156
  }
@@ -140,12 +172,12 @@ var BIContractActivationWindow = function BIContractActivationWindow(_ref) {
140
172
  open: isDeleteConnectionDialogVisible,
141
173
  title: t('modal.deleteBIConnection.title'),
142
174
  content: t('modal.deleteBIConnection.description'),
143
- onClose: onAccountDeleted,
175
+ onClose: onClose,
144
176
  actions: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
145
177
  variant: "text",
146
178
  color: "primary",
147
179
  "aria-label": "Close dialog",
148
- onClick: onAccountDeleted
180
+ onClick: onClose
149
181
  }, t('close')))
150
182
  }), isWindowVisible && /*#__PURE__*/React.createElement(OAuthWindow, {
151
183
  extraParams: extraParams,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-harvest-lib",
3
- "version": "9.29.2",
3
+ "version": "9.29.4",
4
4
  "description": "Provides logic, modules and components for Cozy's harvest applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -54,11 +54,11 @@
54
54
  "babel-plugin-inline-react-svg": "1.1.2",
55
55
  "babel-preset-cozy-app": "^2.0.4",
56
56
  "cozy-client": "27.17.0",
57
- "cozy-device-helper": "^2.5.0",
57
+ "cozy-device-helper": "^2.6.0",
58
58
  "cozy-flags": "^2.10.2",
59
- "cozy-intent": "^2.6.0",
59
+ "cozy-intent": "^2.7.0",
60
60
  "cozy-keys-lib": "^4.1.9",
61
- "cozy-realtime": "^4.2.8",
61
+ "cozy-realtime": "^4.2.9",
62
62
  "cozy-ui": "60.6.0",
63
63
  "enzyme": "3.11.0",
64
64
  "enzyme-adapter-react-16": "1.15.6",
@@ -91,5 +91,5 @@
91
91
  "react-router-dom": "^5.0.1"
92
92
  },
93
93
  "sideEffects": false,
94
- "gitHead": "404afa42827560b63af1973421a00395db5e9c1d"
94
+ "gitHead": "e605f0d91eb7fa6e8ce7150dc0dfcad2cb8f0965"
95
95
  }
@@ -1,7 +1,7 @@
1
1
  // @ts-check
2
- import React, { useState, useEffect } from 'react'
2
+ import React, { useState, useEffect, useCallback } from 'react'
3
3
  import PropTypes from 'prop-types'
4
- import { useClient } from 'cozy-client'
4
+ import { useClient, Mutations } from 'cozy-client'
5
5
  import Button from 'cozy-ui/transpiled/react/MuiCozyTheme/Buttons'
6
6
  import ListItem from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItem'
7
7
  import { Dialog } from 'cozy-ui/transpiled/react/CozyDialogs'
@@ -31,6 +31,16 @@ const BIContractActivationWindow = ({
31
31
  const konnectorPolicy = findKonnectorPolicy(konnector)
32
32
  const client = useClient()
33
33
 
34
+ const onClose = useCallback(async () => {
35
+ client.dispatch({
36
+ type: 'RECEIVE_MUTATION_RESULT',
37
+ mutationId: client.generateRandomId(),
38
+ response: { data: { ...account, _deleted: true } },
39
+ definition: Mutations.deleteDocument({ ...account, _deleted: true })
40
+ })
41
+ onAccountDeleted()
42
+ }, [onAccountDeleted, account, client])
43
+
34
44
  /**
35
45
  * Detects if a BI connection has been removed
36
46
  *
@@ -107,14 +117,14 @@ const BIContractActivationWindow = ({
107
117
  open={isDeleteConnectionDialogVisible}
108
118
  title={t('modal.deleteBIConnection.title')}
109
119
  content={t('modal.deleteBIConnection.description')}
110
- onClose={onAccountDeleted}
120
+ onClose={onClose}
111
121
  actions={
112
122
  <>
113
123
  <Button
114
124
  variant="text"
115
125
  color="primary"
116
126
  aria-label="Close dialog"
117
- onClick={onAccountDeleted}
127
+ onClick={onClose}
118
128
  >
119
129
  {t('close')}
120
130
  </Button>