cozy-harvest-lib 18.2.2 → 19.0.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,24 @@
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
+ # [19.0.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@18.2.2...cozy-harvest-lib@19.0.0) (2023-10-18)
7
+
8
+
9
+ ### Features
10
+
11
+ * **cozy-harvest-lib:** Update cozy-client from 41.0.0 to 41.8.1 ([351d981](https://github.com/cozy/cozy-libs/commit/351d98105c625a23a1fa98f6df8a1a0009c16d0b))
12
+ * Redirect users to where they can download the mobile application ([9d71ea6](https://github.com/cozy/cozy-libs/commit/9d71ea6d78b7b6a832a06bc013c6e9690d3f3d74))
13
+ * Small wording improvements linked to CCC ([e8dafde](https://github.com/cozy/cozy-libs/commit/e8dafdea275bfe32b40a350114a564a87ca17f90))
14
+
15
+
16
+ ### BREAKING CHANGES
17
+
18
+ * **cozy-harvest-lib:** You need cozy-client >= 41.8.1
19
+
20
+
21
+
22
+
23
+
6
24
  ## [18.2.2](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@18.2.1...cozy-harvest-lib@18.2.2) (2023-10-13)
7
25
 
8
26
 
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { getFlagshipDownloadLink } from 'cozy-client/dist/models/utils';
3
+ import Buttons from 'cozy-ui/transpiled/react/Buttons';
4
+ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
5
+
6
+ var InstallFlagshipButton = function InstallFlagshipButton(_ref) {
7
+ var className = _ref.className;
8
+
9
+ var _useI18n = useI18n(),
10
+ t = _useI18n.t,
11
+ lang = _useI18n.lang;
12
+
13
+ var handleClick = function handleClick() {
14
+ var downloadLink = getFlagshipDownloadLink(lang);
15
+ window.open(downloadLink, '_blank');
16
+ };
17
+
18
+ return /*#__PURE__*/React.createElement(Buttons, {
19
+ className: className,
20
+ fullWidth: true,
21
+ label: t('accountForm.installFlagship.label'),
22
+ onClick: handleClick
23
+ });
24
+ };
25
+
26
+ export { InstallFlagshipButton };
@@ -0,0 +1,74 @@
1
+ import { render, fireEvent, screen } from '@testing-library/react';
2
+ import React from 'react';
3
+ import { isAndroid, isIOS } from 'cozy-device-helper';
4
+ import flag from 'cozy-flags';
5
+ import { InstallFlagshipButton } from './InstallFlagshipButton';
6
+ jest.mock('cozy-device-helper', function () {
7
+ return {
8
+ isAndroid: jest.fn(),
9
+ isIOS: jest.fn()
10
+ };
11
+ });
12
+ jest.mock('cozy-flags');
13
+ jest.mock('cozy-ui/transpiled/react/providers/I18n', function () {
14
+ return {
15
+ useI18n: jest.fn(function () {
16
+ return {
17
+ t: function t(key) {
18
+ return key;
19
+ },
20
+ lang: 'en'
21
+ };
22
+ })
23
+ };
24
+ });
25
+ describe('InstallFlagshipButton', function () {
26
+ afterEach(function () {
27
+ jest.clearAllMocks();
28
+ });
29
+ it('should render correctly', function () {
30
+ render( /*#__PURE__*/React.createElement(InstallFlagshipButton, null));
31
+ expect(screen.getByText('accountForm.installFlagship.label')).toBeInTheDocument();
32
+ });
33
+ it('should open the download link in a new tab when clicked', function () {
34
+ var mockWindowOpen = jest.spyOn(window, 'open').mockImplementation(function () {});
35
+ render( /*#__PURE__*/React.createElement(InstallFlagshipButton, null));
36
+ fireEvent.click(screen.getByText('accountForm.installFlagship.label'));
37
+ expect(mockWindowOpen).toHaveBeenCalledTimes(1);
38
+ expect(mockWindowOpen).toHaveBeenCalledWith('https://cozy.io/en/download', '_blank');
39
+ });
40
+ it('should open the Play Store when clicked on an Android device', function () {
41
+ isAndroid.mockReturnValueOnce(true);
42
+ var mockWindowOpen = jest.spyOn(window, 'open').mockImplementation(function () {});
43
+ render( /*#__PURE__*/React.createElement(InstallFlagshipButton, null));
44
+ fireEvent.click(screen.getByText('accountForm.installFlagship.label'));
45
+ expect(mockWindowOpen).toHaveBeenCalledTimes(1);
46
+ expect(mockWindowOpen).toHaveBeenCalledWith('https://play.google.com/store/apps/details?id=io.cozy.flagship.mobile&hl=en', '_blank');
47
+ });
48
+ it('should open the Play Store when clicked on an Android device with a custom id', function () {
49
+ isAndroid.mockReturnValueOnce(true);
50
+ flag.mockReturnValueOnce('playstore_custom_id');
51
+ var mockWindowOpen = jest.spyOn(window, 'open').mockImplementation(function () {});
52
+ render( /*#__PURE__*/React.createElement(InstallFlagshipButton, null));
53
+ fireEvent.click(screen.getByText('accountForm.installFlagship.label'));
54
+ expect(mockWindowOpen).toHaveBeenCalledTimes(1);
55
+ expect(mockWindowOpen).toHaveBeenCalledWith('https://play.google.com/store/apps/details?id=playstore_custom_id&hl=en', '_blank');
56
+ });
57
+ it('should open the App Store when clicked on an iOS device', function () {
58
+ isIOS.mockReturnValueOnce(true);
59
+ var mockWindowOpen = jest.spyOn(window, 'open').mockImplementation(function () {});
60
+ render( /*#__PURE__*/React.createElement(InstallFlagshipButton, null));
61
+ fireEvent.click(screen.getByText('accountForm.installFlagship.label'));
62
+ expect(mockWindowOpen).toHaveBeenCalledTimes(1);
63
+ expect(mockWindowOpen).toHaveBeenCalledWith('https://apps.apple.com/en/app/id1600636174', '_blank');
64
+ });
65
+ it('should open the App Store when clicked on an iOS device with a custom id', function () {
66
+ isIOS.mockReturnValueOnce(true);
67
+ flag.mockReturnValueOnce('appstore_custom_id');
68
+ var mockWindowOpen = jest.spyOn(window, 'open').mockImplementation(function () {});
69
+ render( /*#__PURE__*/React.createElement(InstallFlagshipButton, null));
70
+ fireEvent.click(screen.getByText('accountForm.installFlagship.label'));
71
+ expect(mockWindowOpen).toHaveBeenCalledTimes(1);
72
+ expect(mockWindowOpen).toHaveBeenCalledWith('https://apps.apple.com/en/app/appstore_custom_id', '_blank');
73
+ });
74
+ });
@@ -157,7 +157,7 @@ exports[`AccountForm should render normally when client side konnector with laun
157
157
  "onClick": [Function],
158
158
  }
159
159
  }
160
- description="Connect testkonnector to your Cozy to synchronize your account and automatically retrieve all your data. "
160
+ description="Connect testkonnector to your Cozy to synchronize your account and retrieve all your data. "
161
161
  title="Connect to your Cozy"
162
162
  />
163
163
  </React.Fragment>
@@ -189,12 +189,8 @@ exports[`AccountForm should render with specific message when client side konnec
189
189
  </ForwardRef>
190
190
  </Bd>
191
191
  </Media>
192
- <ForwardRef
192
+ <InstallFlagshipButton
193
193
  className="u-mt-2 u-mb-1-half"
194
- fullWidth={true}
195
- label="Install Cozy on mobile"
196
- onClick={[Function]}
197
- variant="primary"
198
194
  />
199
195
  </React.Fragment>
200
196
  </div>
@@ -30,6 +30,7 @@ import Typography from 'cozy-ui/transpiled/react/Typography';
30
30
  import { Media, Img, Bd } from 'cozy-ui/transpiled/react/deprecated/Media';
31
31
  import AccountFields from './AccountFields';
32
32
  import CannotConnectModal from './CannotConnectModal';
33
+ import { InstallFlagshipButton } from './InstallFlagshipButton';
33
34
  import ReadOnlyIdentifier from './ReadOnlyIdentifier';
34
35
  import fieldHelpers, { getEncryptedFieldName, SECRET } from '../../helpers/fields';
35
36
  import { KonnectorJobError } from '../../helpers/konnectors';
@@ -294,7 +295,6 @@ export var AccountForm = /*#__PURE__*/function (_PureComponent) {
294
295
  showError = _this$props2.showError,
295
296
  t = _this$props2.t,
296
297
  fieldOptions = _this$props2.fieldOptions,
297
- historyAction = _this$props2.historyAction,
298
298
  flowState = _this$props2.flowState;
299
299
  var submitting = flowState.running;
300
300
  var error = flowState.error;
@@ -400,13 +400,8 @@ export var AccountForm = /*#__PURE__*/function (_PureComponent) {
400
400
  className: "u-m-1"
401
401
  }, /*#__PURE__*/React.createElement(Typography, null, t('accountForm.notClientSide', {
402
402
  name: name
403
- })))), /*#__PURE__*/React.createElement(Button, {
404
- className: "u-mt-2 u-mb-1-half",
405
- fullWidth: true,
406
- label: t('accountForm.installFlagship.label'),
407
- onClick: function onClick() {
408
- return historyAction('/', 'push');
409
- }
403
+ })))), /*#__PURE__*/React.createElement(InstallFlagshipButton, {
404
+ className: "u-mt-2 u-mb-1-half"
410
405
  })), _this3.state.showConfirmationModal && /*#__PURE__*/React.createElement(Dialog, {
411
406
  title: t('triggerManager.confirmationModal.title'),
412
407
  description: t('triggerManager.confirmationModal.description'),
@@ -31,7 +31,7 @@
31
31
  "clientSide": {
32
32
  "title": "Connect to your Cozy",
33
33
  "submit": "Connect",
34
- "description": "Connect %{name} to your Cozy to synchronize your account and automatically retrieve all your data. "
34
+ "description": "Connect %{name} to your Cozy to synchronize your account and retrieve all your data. "
35
35
  }
36
36
  },
37
37
  "contracts": {
@@ -545,7 +545,7 @@
545
545
  },
546
546
  "connectionBackdrop": {
547
547
  "connecting": "Connection in progress",
548
- "progress": "We are requesting %{name}, this can take up to 30 seconds..."
548
+ "progress": "Establishing a connection to %{name} can take up to 30 seconds..."
549
549
  },
550
550
  "disconnectedAccountModal": {
551
551
  "disconnected-help": "This account is disconnected. Your data has been kept. If you want to restart the synchronisation, please reconfigure your account with the \"Add a bank\" button."
@@ -31,7 +31,7 @@
31
31
  "clientSide": {
32
32
  "title": "Connecter à mon Cozy",
33
33
  "submit": "Connecter",
34
- "description": "Connectez %{name} à votre Cozy pour synchroniser votre compte et récupérer automatiquement vos données."
34
+ "description": "Connectez %{name} à votre Cozy pour synchroniser votre compte et récupérer vos données."
35
35
  }
36
36
  },
37
37
  "contracts": {
@@ -545,7 +545,7 @@
545
545
  },
546
546
  "connectionBackdrop": {
547
547
  "connecting": "Connexion en cours",
548
- "progress": "Nous interrogeons %{name}, cela peut prendre jusqu'à 30 secondes..."
548
+ "progress": "Établissement de la connexion à %{name}, cela peut prendre jusqu'à 30 secondes.."
549
549
  },
550
550
  "disconnectedAccountModal": {
551
551
  "disconnected-help": "Vous avez déconnecté votre compte. Vous conservez l'historique de vos données déjà importées. Si vous souhaitez reprendre la connexion, reconfigurez votre compte depuis le bouton \"Ajouter une banque\"."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-harvest-lib",
3
- "version": "18.2.2",
3
+ "version": "19.0.0",
4
4
  "description": "Provides logic, modules and components for Cozy's harvest applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -72,7 +72,7 @@
72
72
  "babel-jest": "26.6.3",
73
73
  "babel-plugin-inline-react-svg": "1.1.2",
74
74
  "babel-preset-cozy-app": "^2.1.0",
75
- "cozy-client": "^41.0.0",
75
+ "cozy-client": "^41.8.1",
76
76
  "cozy-device-helper": "^3.0.0",
77
77
  "cozy-flags": "^3.0.1",
78
78
  "cozy-intent": "^2.17.1",
@@ -100,7 +100,7 @@
100
100
  },
101
101
  "peerDependencies": {
102
102
  "@babel/runtime": ">=7.12.5",
103
- "cozy-client": ">=41.0.0",
103
+ "cozy-client": ">=41.8.1",
104
104
  "cozy-device-helper": ">=2.6.0",
105
105
  "cozy-flags": ">=2.3.5",
106
106
  "cozy-intent": ">=1.14.1",
@@ -112,5 +112,5 @@
112
112
  "react-router-dom": ">=4.3.1"
113
113
  },
114
114
  "sideEffects": false,
115
- "gitHead": "db1beed511c49a1083ff9e95cda069d04f850d6d"
115
+ "gitHead": "2bd960d39f21969432cd25c5fc6e54ea85969c4a"
116
116
  }
@@ -0,0 +1,25 @@
1
+ import React from 'react'
2
+
3
+ import { getFlagshipDownloadLink } from 'cozy-client/dist/models/utils'
4
+ import Buttons from 'cozy-ui/transpiled/react/Buttons'
5
+ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
6
+
7
+ const InstallFlagshipButton = ({ className }) => {
8
+ const { t, lang } = useI18n()
9
+
10
+ const handleClick = () => {
11
+ let downloadLink = getFlagshipDownloadLink(lang)
12
+ window.open(downloadLink, '_blank')
13
+ }
14
+
15
+ return (
16
+ <Buttons
17
+ className={className}
18
+ fullWidth
19
+ label={t('accountForm.installFlagship.label')}
20
+ onClick={handleClick}
21
+ />
22
+ )
23
+ }
24
+
25
+ export { InstallFlagshipButton }
@@ -0,0 +1,113 @@
1
+ import { render, fireEvent, screen } from '@testing-library/react'
2
+ import React from 'react'
3
+
4
+ import { isAndroid, isIOS } from 'cozy-device-helper'
5
+ import flag from 'cozy-flags'
6
+
7
+ import { InstallFlagshipButton } from './InstallFlagshipButton'
8
+
9
+ jest.mock('cozy-device-helper', () => ({
10
+ isAndroid: jest.fn(),
11
+ isIOS: jest.fn()
12
+ }))
13
+
14
+ jest.mock('cozy-flags')
15
+
16
+ jest.mock('cozy-ui/transpiled/react/providers/I18n', () => ({
17
+ useI18n: jest.fn(() => ({ t: key => key, lang: 'en' }))
18
+ }))
19
+
20
+ describe('InstallFlagshipButton', () => {
21
+ afterEach(() => {
22
+ jest.clearAllMocks()
23
+ })
24
+
25
+ it('should render correctly', () => {
26
+ render(<InstallFlagshipButton />)
27
+
28
+ expect(
29
+ screen.getByText('accountForm.installFlagship.label')
30
+ ).toBeInTheDocument()
31
+ })
32
+
33
+ it('should open the download link in a new tab when clicked', () => {
34
+ const mockWindowOpen = jest
35
+ .spyOn(window, 'open')
36
+ .mockImplementation(() => {})
37
+
38
+ render(<InstallFlagshipButton />)
39
+
40
+ fireEvent.click(screen.getByText('accountForm.installFlagship.label'))
41
+ expect(mockWindowOpen).toHaveBeenCalledTimes(1)
42
+ expect(mockWindowOpen).toHaveBeenCalledWith(
43
+ 'https://cozy.io/en/download',
44
+ '_blank'
45
+ )
46
+ })
47
+
48
+ it('should open the Play Store when clicked on an Android device', () => {
49
+ isAndroid.mockReturnValueOnce(true)
50
+ const mockWindowOpen = jest
51
+ .spyOn(window, 'open')
52
+ .mockImplementation(() => {})
53
+
54
+ render(<InstallFlagshipButton />)
55
+
56
+ fireEvent.click(screen.getByText('accountForm.installFlagship.label'))
57
+ expect(mockWindowOpen).toHaveBeenCalledTimes(1)
58
+ expect(mockWindowOpen).toHaveBeenCalledWith(
59
+ 'https://play.google.com/store/apps/details?id=io.cozy.flagship.mobile&hl=en',
60
+ '_blank'
61
+ )
62
+ })
63
+
64
+ it('should open the Play Store when clicked on an Android device with a custom id', () => {
65
+ isAndroid.mockReturnValueOnce(true)
66
+ flag.mockReturnValueOnce('playstore_custom_id')
67
+ const mockWindowOpen = jest
68
+ .spyOn(window, 'open')
69
+ .mockImplementation(() => {})
70
+
71
+ render(<InstallFlagshipButton />)
72
+
73
+ fireEvent.click(screen.getByText('accountForm.installFlagship.label'))
74
+ expect(mockWindowOpen).toHaveBeenCalledTimes(1)
75
+ expect(mockWindowOpen).toHaveBeenCalledWith(
76
+ 'https://play.google.com/store/apps/details?id=playstore_custom_id&hl=en',
77
+ '_blank'
78
+ )
79
+ })
80
+
81
+ it('should open the App Store when clicked on an iOS device', () => {
82
+ isIOS.mockReturnValueOnce(true)
83
+ const mockWindowOpen = jest
84
+ .spyOn(window, 'open')
85
+ .mockImplementation(() => {})
86
+
87
+ render(<InstallFlagshipButton />)
88
+
89
+ fireEvent.click(screen.getByText('accountForm.installFlagship.label'))
90
+ expect(mockWindowOpen).toHaveBeenCalledTimes(1)
91
+ expect(mockWindowOpen).toHaveBeenCalledWith(
92
+ 'https://apps.apple.com/en/app/id1600636174',
93
+ '_blank'
94
+ )
95
+ })
96
+
97
+ it('should open the App Store when clicked on an iOS device with a custom id', () => {
98
+ isIOS.mockReturnValueOnce(true)
99
+ flag.mockReturnValueOnce('appstore_custom_id')
100
+ const mockWindowOpen = jest
101
+ .spyOn(window, 'open')
102
+ .mockImplementation(() => {})
103
+
104
+ render(<InstallFlagshipButton />)
105
+
106
+ fireEvent.click(screen.getByText('accountForm.installFlagship.label'))
107
+ expect(mockWindowOpen).toHaveBeenCalledTimes(1)
108
+ expect(mockWindowOpen).toHaveBeenCalledWith(
109
+ 'https://apps.apple.com/en/app/appstore_custom_id',
110
+ '_blank'
111
+ )
112
+ })
113
+ })
@@ -157,7 +157,7 @@ exports[`AccountForm should render normally when client side konnector with laun
157
157
  "onClick": [Function],
158
158
  }
159
159
  }
160
- description="Connect testkonnector to your Cozy to synchronize your account and automatically retrieve all your data. "
160
+ description="Connect testkonnector to your Cozy to synchronize your account and retrieve all your data. "
161
161
  title="Connect to your Cozy"
162
162
  />
163
163
  </React.Fragment>
@@ -189,12 +189,8 @@ exports[`AccountForm should render with specific message when client side konnec
189
189
  </ForwardRef>
190
190
  </Bd>
191
191
  </Media>
192
- <ForwardRef
192
+ <InstallFlagshipButton
193
193
  className="u-mt-2 u-mb-1-half"
194
- fullWidth={true}
195
- label="Install Cozy on mobile"
196
- onClick={[Function]}
197
- variant="primary"
198
194
  />
199
195
  </React.Fragment>
200
196
  </div>
@@ -16,6 +16,7 @@ import { Media, Img, Bd } from 'cozy-ui/transpiled/react/deprecated/Media'
16
16
 
17
17
  import AccountFields from './AccountFields'
18
18
  import CannotConnectModal from './CannotConnectModal'
19
+ import { InstallFlagshipButton } from './InstallFlagshipButton'
19
20
  import ReadOnlyIdentifier from './ReadOnlyIdentifier'
20
21
  import fieldHelpers, {
21
22
  getEncryptedFieldName,
@@ -232,7 +233,6 @@ export class AccountForm extends PureComponent {
232
233
  showError,
233
234
  t,
234
235
  fieldOptions,
235
- historyAction,
236
236
  flowState
237
237
  } = this.props
238
238
  const submitting = flowState.running
@@ -371,12 +371,7 @@ export class AccountForm extends PureComponent {
371
371
  </Typography>
372
372
  </Bd>
373
373
  </Media>
374
- <Button
375
- className="u-mt-2 u-mb-1-half"
376
- fullWidth
377
- label={t('accountForm.installFlagship.label')}
378
- onClick={() => historyAction('/', 'push')}
379
- />
374
+ <InstallFlagshipButton className="u-mt-2 u-mb-1-half" />
380
375
  </>
381
376
  )}
382
377
  {this.state.showConfirmationModal && (
@@ -31,7 +31,7 @@
31
31
  "clientSide": {
32
32
  "title": "Connect to your Cozy",
33
33
  "submit": "Connect",
34
- "description": "Connect %{name} to your Cozy to synchronize your account and automatically retrieve all your data. "
34
+ "description": "Connect %{name} to your Cozy to synchronize your account and retrieve all your data. "
35
35
  }
36
36
  },
37
37
  "contracts": {
@@ -545,7 +545,7 @@
545
545
  },
546
546
  "connectionBackdrop": {
547
547
  "connecting": "Connection in progress",
548
- "progress": "We are requesting %{name}, this can take up to 30 seconds..."
548
+ "progress": "Establishing a connection to %{name} can take up to 30 seconds..."
549
549
  },
550
550
  "disconnectedAccountModal": {
551
551
  "disconnected-help": "This account is disconnected. Your data has been kept. If you want to restart the synchronisation, please reconfigure your account with the \"Add a bank\" button."
@@ -31,7 +31,7 @@
31
31
  "clientSide": {
32
32
  "title": "Connecter à mon Cozy",
33
33
  "submit": "Connecter",
34
- "description": "Connectez %{name} à votre Cozy pour synchroniser votre compte et récupérer automatiquement vos données."
34
+ "description": "Connectez %{name} à votre Cozy pour synchroniser votre compte et récupérer vos données."
35
35
  }
36
36
  },
37
37
  "contracts": {
@@ -545,7 +545,7 @@
545
545
  },
546
546
  "connectionBackdrop": {
547
547
  "connecting": "Connexion en cours",
548
- "progress": "Nous interrogeons %{name}, cela peut prendre jusqu'à 30 secondes..."
548
+ "progress": "Établissement de la connexion à %{name}, cela peut prendre jusqu'à 30 secondes.."
549
549
  },
550
550
  "disconnectedAccountModal": {
551
551
  "disconnected-help": "Vous avez déconnecté votre compte. Vous conservez l'historique de vos données déjà importées. Si vous souhaitez reprendre la connexion, reconfigurez votre compte depuis le bouton \"Ajouter une banque\"."