cozy-harvest-lib 13.3.0 → 13.5.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/components/AccountForm/CannotConnectModal.js +14 -8
  3. package/dist/components/AccountForm/__snapshots__/index.spec.jsx.snap +12 -8
  4. package/dist/components/AccountForm/index.js +28 -9
  5. package/dist/components/KonnectorConfiguration/DataTab/index.js +2 -2
  6. package/dist/components/KonnectorModalHeader.js +3 -2
  7. package/dist/components/Markdown.js +7 -3
  8. package/dist/components/NewAccountModal.js +11 -2
  9. package/dist/components/OAuthForm.js +13 -9
  10. package/dist/components/__snapshots__/OAuthForm.spec.js.snap +108 -42
  11. package/dist/components/cards/ConnectCard.js +20 -0
  12. package/dist/components/cards/InformationsCard.js +64 -0
  13. package/dist/cozy-ui.d.js +0 -0
  14. package/dist/helpers/getErrorMessage.js +19 -0
  15. package/dist/jest.setup.js +10 -1
  16. package/dist/locales/en.json +12 -3
  17. package/dist/locales/fr.json +12 -3
  18. package/dist/logger.d.js +1 -0
  19. package/dist/models/ConnectionFlow.js +22 -15
  20. package/dist/models/ConnectionFlow.spec.js +235 -176
  21. package/dist/policies/clisk.js +11 -5
  22. package/dist/policies/clisk.spec.js +66 -2
  23. package/jest.config.js +2 -2
  24. package/package.json +6 -4
  25. package/src/components/AccountForm/CannotConnectModal.jsx +15 -7
  26. package/src/components/AccountForm/__snapshots__/index.spec.jsx.snap +12 -8
  27. package/src/components/AccountForm/index.jsx +53 -21
  28. package/src/components/KonnectorConfiguration/DataTab/index.jsx +2 -2
  29. package/src/components/KonnectorModalHeader.jsx +6 -2
  30. package/src/components/Markdown.jsx +2 -1
  31. package/src/components/NewAccountModal.jsx +31 -16
  32. package/src/components/OAuthForm.jsx +13 -10
  33. package/src/components/__snapshots__/OAuthForm.spec.js.snap +108 -42
  34. package/src/components/cards/ConnectCard.tsx +29 -0
  35. package/src/components/cards/InformationsCard.tsx +74 -0
  36. package/src/cozy-ui.d.ts +14 -0
  37. package/src/helpers/getErrorMessage.ts +28 -0
  38. package/src/jest.setup.js +9 -0
  39. package/src/locales/en.json +12 -3
  40. package/src/locales/fr.json +12 -3
  41. package/src/logger.d.ts +2 -0
  42. package/src/models/ConnectionFlow.js +9 -7
  43. package/src/models/ConnectionFlow.spec.js +44 -2
  44. package/src/policies/clisk.js +9 -4
  45. package/src/policies/clisk.spec.js +55 -2
  46. package/tsconfig.json +11 -0
  47. package/dist/components/cards/WebsiteLinkCard.js +0 -59
  48. package/dist/components/cards/WebsiteLinkCard.spec.js +0 -32
  49. package/src/components/cards/WebsiteLinkCard.jsx +0 -63
  50. package/src/components/cards/WebsiteLinkCard.spec.jsx +0 -28
package/CHANGELOG.md CHANGED
@@ -3,6 +3,33 @@
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
+ # [13.5.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@13.4.0...cozy-harvest-lib@13.5.0) (2023-02-27)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add k konnector ([038a1f1](https://github.com/cozy/cozy-libs/commit/038a1f193057a2386b4c99ecc96f09bc00dfa1dc))
12
+ * **cozy-harvest:** Add locales for new account ([0476351](https://github.com/cozy/cozy-libs/commit/0476351a0220985cd5cd48483987158201c2a6db))
13
+ * **cozy-harvest:** Implement new account modal ([a1a2d97](https://github.com/cozy/cozy-libs/commit/a1a2d97639fb2c8c6f4066add6bfbcc1e47d8592))
14
+ * Enable TS on cozy-harvest ([0eb444b](https://github.com/cozy/cozy-libs/commit/0eb444b6265b27f88b057c1f79777b8cdc1fd86a))
15
+ * Send account and trigger to the launcher ([5d54d14](https://github.com/cozy/cozy-libs/commit/5d54d14aed91574f05de0a067bc93797cf841f99))
16
+
17
+
18
+
19
+
20
+
21
+ # [13.4.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@13.3.0...cozy-harvest-lib@13.4.0) (2023-02-21)
22
+
23
+
24
+ ### Features
25
+
26
+ * **harvest:** Add create account wording in CannotConnectModal ([1d78356](https://github.com/cozy/cozy-libs/commit/1d78356b441b70c4da0a0ad06df3250edfe5ae52))
27
+ * **harvest:** Add props propagation on Markdown component ([f76f9a6](https://github.com/cozy/cozy-libs/commit/f76f9a6a22c6bbe23169638973b68ecfb7842257))
28
+
29
+
30
+
31
+
32
+
6
33
  # [13.3.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@13.2.2...cozy-harvest-lib@13.3.0) (2023-02-16)
7
34
 
8
35
 
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Typography from 'cozy-ui/transpiled/react/Typography';
4
- import Link from 'cozy-ui/transpiled/react/Link';
5
4
  import { ConfirmDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
6
5
  import { useI18n } from 'cozy-ui/transpiled/react/I18n';
7
6
  import { useComponentsProps } from '../Providers/ComponentsPropsProvider';
7
+ import Markdown from '../Markdown';
8
8
 
9
9
  var CannotConnectModal = function CannotConnectModal(_ref) {
10
10
  var _ComponentsProps$Cann;
@@ -24,13 +24,19 @@ var CannotConnectModal = function CannotConnectModal(_ref) {
24
24
  content: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, {
25
25
  variant: "h4",
26
26
  className: "u-mb-1"
27
- }, t('accountForm.cannotConnectModal.title')), /*#__PURE__*/React.createElement(Typography, {
28
- className: "u-mb-1"
29
- }, t('accountForm.cannotConnectModal.content'), /*#__PURE__*/React.createElement(Link, {
30
- href: vendorLink,
31
- target: "_blank",
32
- rel: "noopener noreferrer"
33
- }, vendorName)), ComponentsProps === null || ComponentsProps === void 0 ? void 0 : (_ComponentsProps$Cann = ComponentsProps.CannotConnectModal) === null || _ComponentsProps$Cann === void 0 ? void 0 : _ComponentsProps$Cann.extraContent),
27
+ }, t('accountForm.cannotConnectModal.title')), /*#__PURE__*/React.createElement(Markdown, {
28
+ className: "u-mb-1",
29
+ source: t('accountForm.cannotConnectModal.content', {
30
+ vendorLink: vendorLink,
31
+ vendorName: vendorName
32
+ })
33
+ }), /*#__PURE__*/React.createElement(Markdown, {
34
+ className: "u-mb-1",
35
+ source: t('accountForm.cannotConnectModal.noAccount', {
36
+ vendorLink: vendorLink,
37
+ vendorName: vendorName
38
+ })
39
+ }), ComponentsProps === null || ComponentsProps === void 0 ? void 0 : (_ComponentsProps$Cann = ComponentsProps.CannotConnectModal) === null || _ComponentsProps$Cann === void 0 ? void 0 : _ComponentsProps$Cann.extraContent),
34
40
  onClose: onClose
35
41
  });
36
42
  };
@@ -147,14 +147,18 @@ exports[`AccountForm should render normally when client side konnector with laun
147
147
  inputRefByName={[Function]}
148
148
  t={[Function]}
149
149
  />
150
- <ForwardRef
151
- className="u-mt-2 u-mb-1-half"
152
- data-testid="submit-btn"
153
- disabled={false}
154
- fullWidth={true}
155
- label="Connect"
156
- onClick={[Function]}
157
- variant="primary"
150
+ <ConnectCard
151
+ buttonProps={
152
+ Object {
153
+ "busy": undefined,
154
+ "data-testid": "submit-btn",
155
+ "disabled": false,
156
+ "label": "Connect",
157
+ "onClick": [Function],
158
+ }
159
+ }
160
+ description="Connect testkonnector to your Cozy to synchronize your account and automatically retrieve all your data. "
161
+ title="Connect to your Cozy"
158
162
  />
159
163
  </React.Fragment>
160
164
  </div>
@@ -28,19 +28,20 @@ import Info from 'cozy-ui/transpiled/react/Icons/Info';
28
28
  import { Media, Img, Bd } from 'cozy-ui/transpiled/react/Media';
29
29
  import Typography from 'cozy-ui/transpiled/react/Typography';
30
30
  import { Dialog } from 'cozy-ui/transpiled/react/CozyDialogs';
31
- import withAdaptiveRouter from '../hoc/withRouter';
32
- import withLocales from '../hoc/withLocales';
33
31
  import AccountFields from './AccountFields';
32
+ import CannotConnectModal from './CannotConnectModal';
33
+ import ConnectionBackdrop from './ConnectionBackdrop';
34
34
  import ReadOnlyIdentifier from './ReadOnlyIdentifier';
35
35
  import TriggerErrorInfo from '../infos/TriggerErrorInfo';
36
- import fieldHelpers, { getEncryptedFieldName, SECRET } from '../../helpers/fields';
37
- import { KonnectorJobError } from '../../helpers/konnectors';
38
- import { findKonnectorPolicy } from '../../konnector-policies';
39
36
  import manifest from '../../helpers/manifest';
40
- import withKonnectorLocales from '../hoc/withKonnectorLocales';
37
+ import withAdaptiveRouter from '../hoc/withRouter';
41
38
  import withConnectionFlow from '../../models/withConnectionFlow';
42
- import CannotConnectModal from './CannotConnectModal';
43
- import ConnectionBackdrop from './ConnectionBackdrop';
39
+ import withKonnectorLocales from '../hoc/withKonnectorLocales';
40
+ import withLocales from '../hoc/withLocales';
41
+ import { ConnectCard } from '../cards/ConnectCard';
42
+ import { KonnectorJobError } from '../../helpers/konnectors';
43
+ import { findKonnectorPolicy } from '../../konnector-policies';
44
+ import fieldHelpers, { getEncryptedFieldName, SECRET } from '../../helpers/fields';
44
45
  var VALIDATION_ERROR_REQUIRED_FIELD = 'VALIDATION_ERROR_REQUIRED_FIELD';
45
46
  /**
46
47
  * AccountForm is reponsible of generating a form which will allow user to
@@ -357,7 +358,25 @@ export var AccountForm = /*#__PURE__*/function (_PureComponent) {
357
358
  variant: "body1",
358
359
  component: "button",
359
360
  onClick: _this3.showCannotConnectModal
360
- }, t('accountForm.cannotConnectLink')), /*#__PURE__*/React.createElement(Button, {
361
+ }, t('accountForm.cannotConnectLink')), konnector.clientSide ? /*#__PURE__*/React.createElement(ConnectCard, {
362
+ title: t('accountForm.clientSide.title'),
363
+ description: t('accountForm.clientSide.description', {
364
+ name: konnector.name
365
+ }),
366
+ buttonProps: _defineProperty({
367
+ busy: submitting && !flag('harvest.inappconnectors.enabled'),
368
+ disabled: submitting || !_this3.isSubmittable({
369
+ dirty: dirty,
370
+ error: error,
371
+ initialValues: initialValues,
372
+ valid: valid
373
+ }),
374
+ label: t('accountForm.clientSide.submit'),
375
+ onClick: function onClick() {
376
+ return _this3.handleSubmit(values, form);
377
+ }
378
+ }, 'data-testid', 'submit-btn')
379
+ }) : /*#__PURE__*/React.createElement(Button, {
361
380
  busy: submitting && !flag('harvest.inappconnectors.enabled'),
362
381
  className: "u-mt-2 u-mb-1-half",
363
382
  disabled: submitting || !_this3.isSubmittable({
@@ -13,7 +13,7 @@ import KonnectorUpdateInfos from '../../../components/infos/KonnectorUpdateInfos
13
13
  import LaunchTriggerCard from '../../../components/cards/LaunchTriggerCard';
14
14
  import KonnectorMaintenance from '../../../components/Maintenance';
15
15
  import AppLinkCard from '../../../components/cards/AppLinkCard';
16
- import WebsiteLinkCard from '../../../components/cards/WebsiteLinkCard';
16
+ import { InformationsCard } from '../../../components/cards/InformationsCard';
17
17
  import useMaintenanceStatus from '../../../components/hooks/useMaintenanceStatus';
18
18
  import getRelatedAppsSlugs from '../../../models/getRelatedAppsSlugs';
19
19
  import appLinksProps from '../../../components/KonnectorConfiguration/DataTab/appLinksProps';
@@ -86,7 +86,7 @@ export var DataTab = function DataTab(_ref) {
86
86
  account: account,
87
87
  trigger: trigger,
88
88
  konnector: konnector
89
- }), konnector.vendor_link && /*#__PURE__*/React.createElement(WebsiteLinkCard, {
89
+ }), konnector.vendor_link && /*#__PURE__*/React.createElement(InformationsCard, {
90
90
  link: konnector.vendor_link
91
91
  }))));
92
92
  };
@@ -15,13 +15,14 @@ var resetFontStyles = {
15
15
 
16
16
  var KonnectorModalHeader = function KonnectorModalHeader(_ref) {
17
17
  var konnector = _ref.konnector,
18
- children = _ref.children;
18
+ children = _ref.children,
19
+ className = _ref.className;
19
20
 
20
21
  var _useDialogContext = useDialogContext(),
21
22
  dialogTitleProps = _useDialogContext.dialogTitleProps;
22
23
 
23
24
  return /*#__PURE__*/React.createElement(DialogTitle, _extends({}, dialogTitleProps, {
24
- className: "u-pb-half",
25
+ className: cx('u-pb-half', className),
25
26
  disableTypography: true
26
27
  }), /*#__PURE__*/React.createElement(Media, null, /*#__PURE__*/React.createElement(Img, {
27
28
  className: cx('u-mr-1', _defineProperty({}, children === null ? 'u-w-2 u-h-2' : 'u-w-3 u-h-3', true))
@@ -1,4 +1,6 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
1
2
  import _extends from "@babel/runtime/helpers/extends";
3
+ var _excluded = ["source", "linkProps"];
2
4
  import React from 'react';
3
5
  import ReactMarkdown from 'react-markdown';
4
6
  import Link from 'cozy-ui/transpiled/react/Link';
@@ -24,13 +26,15 @@ var reactMarkdownRendererOptions = function reactMarkdownRendererOptions(_ref) {
24
26
 
25
27
  export var Markdown = function Markdown(_ref2) {
26
28
  var source = _ref2.source,
27
- linkProps = _ref2.linkProps;
28
- return /*#__PURE__*/React.createElement(ReactMarkdown, {
29
+ linkProps = _ref2.linkProps,
30
+ props = _objectWithoutProperties(_ref2, _excluded);
31
+
32
+ return /*#__PURE__*/React.createElement(ReactMarkdown, _extends({}, props, {
29
33
  source: source,
30
34
  linkTarget: "_blank",
31
35
  renderers: reactMarkdownRendererOptions({
32
36
  linkProps: linkProps
33
37
  })
34
- });
38
+ }));
35
39
  };
36
40
  export default Markdown;
@@ -16,6 +16,8 @@ import KonnectorMaintenance from './Maintenance';
16
16
  import useMaintenanceStatus from './hooks/useMaintenanceStatus';
17
17
  import { MountPointContext } from './MountPointContext';
18
18
  import { useDialogContext } from './DialogContext';
19
+ import { InformationsCard } from './cards/InformationsCard';
20
+ import KonnectorModalHeader from './KonnectorModalHeader';
19
21
  /**
20
22
  * We need to deal with `onLoginSuccess` and `onSucess` because we
21
23
  * can have a `onSuccess` without having a `onLoginSuccess` since only
@@ -43,6 +45,7 @@ var NewAccountModal = function NewAccountModal(_ref) {
43
45
  maintenanceMessages = _useMaintenanceStatus2.messages;
44
46
 
45
47
  var isMaintenanceLoaded = fetchStatus === 'loaded' || fetchStatus === 'failed';
48
+ var serverSideKonnector = !(konnector.oauth || konnector.clientSide);
46
49
 
47
50
  var _useDialogContext = useDialogContext(),
48
51
  dialogTitleProps = _useDialogContext.dialogTitleProps;
@@ -65,7 +68,7 @@ var NewAccountModal = function NewAccountModal(_ref) {
65
68
  replaceHistory("/accounts/".concat(accountId));
66
69
  };
67
70
 
68
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DialogTitle, _extends({}, dialogTitleProps, {
71
+ return /*#__PURE__*/React.createElement(React.Fragment, null, serverSideKonnector ? /*#__PURE__*/React.createElement(DialogTitle, _extends({}, dialogTitleProps, {
69
72
  className: cx(dialogTitleProps.className, 'u-ta-center u-flex-column u-stack-m u-pb-1'),
70
73
  disableTypography: true
71
74
  }), /*#__PURE__*/React.createElement(KonnectorIcon, {
@@ -75,7 +78,10 @@ var NewAccountModal = function NewAccountModal(_ref) {
75
78
  variant: "h5"
76
79
  }, t('modal.addAccount.title', {
77
80
  name: konnector.name
78
- })))), !isMaintenanceLoaded ? /*#__PURE__*/React.createElement(DialogContent, {
81
+ })))) : /*#__PURE__*/React.createElement(KonnectorModalHeader, {
82
+ className: "u-elevation-1 u-mb-1",
83
+ konnector: konnector
84
+ }), !isMaintenanceLoaded ? /*#__PURE__*/React.createElement(DialogContent, {
79
85
  className: "u-ta-center u-pt-1 u-pb-3"
80
86
  }, /*#__PURE__*/React.createElement(Spinner, {
81
87
  size: "xxlarge"
@@ -91,6 +97,9 @@ var NewAccountModal = function NewAccountModal(_ref) {
91
97
  onSuccess: handleSuccess,
92
98
  onVaultDismiss: onDismiss,
93
99
  fieldOptions: fieldOptions
100
+ }), !serverSideKonnector && /*#__PURE__*/React.createElement(InformationsCard, {
101
+ className: "u-mt-1",
102
+ link: konnector.vendor_link
94
103
  }), /*#__PURE__*/React.createElement("div", {
95
104
  className: "u-mb-2"
96
105
  })));
@@ -4,7 +4,6 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import React, { useCallback, useEffect, useState } from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import compose from 'lodash/flowRight';
7
- import Button from 'cozy-ui/transpiled/react/Button';
8
7
  import { useFlowState } from '../models/withConnectionFlow';
9
8
  import useOAuthExtraParams from './hooks/useOAuthExtraParams';
10
9
  import withLocales from './hoc/withLocales';
@@ -18,6 +17,7 @@ import isEqual from 'lodash/isEqual';
18
17
  import { useClient } from 'cozy-client';
19
18
  import { OAUTH_SERVICE_ERROR, OAUTH_SERVICE_OK, openOAuthWindow } from './OAuthService';
20
19
  import { useWebviewIntent } from 'cozy-intent';
20
+ import { ConnectCard } from './cards/ConnectCard';
21
21
  /**
22
22
  * The OAuth Form is responsible for displaying a form for OAuth konnectors. It
23
23
  * starts the OAuth process
@@ -130,18 +130,22 @@ export var OAuthForm = function OAuthForm(props) {
130
130
  var error = flowState.error;
131
131
  var isBusy = showOAuthWindow || flowState.running || needsExtraParams && !extraParams;
132
132
  var isBankingKonnector = (_konnector$categories = konnector.categories) === null || _konnector$categories === void 0 ? void 0 : _konnector$categories.includes('banking');
133
- var buttonLabel = reconnect ? isBankingKonnector ? 'oauth.banking.reconnect.label' : 'oauth.reconnect.label' : isBankingKonnector ? 'oauth.banking.connect.label' : 'oauth.connect.label';
133
+ var buttonLabel = reconnect ? isBankingKonnector ? 'oauth.banking.reconnect.label' : 'oauth.reconnect.label' : isBankingKonnector ? 'oauth.banking.connect.label' : 'oauth.connect.submit';
134
134
  return /*#__PURE__*/React.createElement(React.Fragment, null, error && /*#__PURE__*/React.createElement(TriggerErrorInfo, {
135
135
  className: "u-mb-1",
136
136
  error: error,
137
137
  konnector: konnector
138
- }), !reconnect && /*#__PURE__*/React.createElement(Button, {
139
- className: "u-mt-1",
140
- busy: isBusy,
141
- disabled: isBusy,
142
- extension: "full",
143
- label: t(buttonLabel),
144
- onClick: handleConnect
138
+ }), !reconnect && /*#__PURE__*/React.createElement(ConnectCard, {
139
+ title: t('oauth.connect.title'),
140
+ description: t('oauth.connect.description', {
141
+ name: konnector.name
142
+ }),
143
+ buttonProps: {
144
+ busy: isBusy,
145
+ disabled: isBusy,
146
+ label: t(buttonLabel),
147
+ onClick: handleConnect
148
+ }
145
149
  }));
146
150
  };
147
151
  OAuthForm.propTypes = {
@@ -34,37 +34,59 @@ exports[`OAuthForm should handle oauth cancelation 1`] = `
34
34
  </div>
35
35
  </div>
36
36
  </div>
37
- <button
38
- aria-busy="true"
39
- aria-disabled="true"
40
- class="styles__c-btn___-2Vnj styles__c-btn--full___2VmR1 styles__c-btn--center___16_Xh u-mt-1"
41
- disabled=""
42
- type="submit"
37
+ <div
38
+ class="styles__c-card___YgP7B u-flex u-flex-wrap"
43
39
  >
44
- <span>
40
+ <div
41
+ class="styles__c-empty___3w5oV"
42
+ >
43
+ CloudSync2
44
+ <h3
45
+ class="MuiTypography-root MuiTypography-h3 MuiTypography-colorTextPrimary MuiTypography-gutterBottom"
46
+ >
47
+ oauth.connect.title
48
+ </h3>
49
+ <p
50
+ class="MuiTypography-root MuiTypography-body1 MuiTypography-colorTextSecondary MuiTypography-gutterBottom"
51
+ >
52
+ oauth.connect.description
53
+ </p>
54
+ <div
55
+ class="styles__c-empty-text___3HnvR"
56
+ />
57
+ </div>
58
+ <button
59
+ aria-busy="true"
60
+ aria-disabled="true"
61
+ class="styles__c-btn___-2Vnj styles__c-btn--center___16_Xh u-mh-auto"
62
+ disabled=""
63
+ type="submit"
64
+ >
45
65
  <span>
46
- oauth.connect.label
66
+ <span>
67
+ oauth.connect.submit
68
+ </span>
69
+ <svg
70
+ aria-busy="true"
71
+ aria-hidden="true"
72
+ class="u-ml-half styles__icon___23x3R styles__icon--spin___ybfC1"
73
+ focusable="false"
74
+ height="16"
75
+ role="progressbar"
76
+ viewBox="0 0 32 32"
77
+ width="16"
78
+ >
79
+ <path
80
+ d="M16 0a16 16 0 000 32 16 16 0 000-32m0 4a12 12 0 010 24 12 12 0 010-24"
81
+ opacity="0.25"
82
+ />
83
+ <path
84
+ d="M16 0a16 16 0 0116 16h-4A12 12 0 0016 4z"
85
+ />
86
+ </svg>
47
87
  </span>
48
- <svg
49
- aria-busy="true"
50
- aria-hidden="true"
51
- class="u-ml-half styles__icon___23x3R styles__icon--spin___ybfC1"
52
- focusable="false"
53
- height="16"
54
- role="progressbar"
55
- viewBox="0 0 32 32"
56
- width="16"
57
- >
58
- <path
59
- d="M16 0a16 16 0 000 32 16 16 0 000-32m0 4a12 12 0 010 24 12 12 0 010-24"
60
- opacity="0.25"
61
- />
62
- <path
63
- d="M16 0a16 16 0 0116 16h-4A12 12 0 0016 4z"
64
- />
65
- </svg>
66
- </span>
67
- </button>
88
+ </button>
89
+ </div>
68
90
  </div>
69
91
  `;
70
92
 
@@ -100,30 +122,74 @@ exports[`OAuthForm should handle oauth cancelation 2`] = `
100
122
  </div>
101
123
  </div>
102
124
  </div>
103
- <button
104
- class="styles__c-btn___-2Vnj styles__c-btn--full___2VmR1 styles__c-btn--center___16_Xh u-mt-1"
105
- type="submit"
125
+ <div
126
+ class="styles__c-card___YgP7B u-flex u-flex-wrap"
106
127
  >
107
- <span>
128
+ <div
129
+ class="styles__c-empty___3w5oV"
130
+ >
131
+ CloudSync2
132
+ <h3
133
+ class="MuiTypography-root MuiTypography-h3 MuiTypography-colorTextPrimary MuiTypography-gutterBottom"
134
+ >
135
+ oauth.connect.title
136
+ </h3>
137
+ <p
138
+ class="MuiTypography-root MuiTypography-body1 MuiTypography-colorTextSecondary MuiTypography-gutterBottom"
139
+ >
140
+ oauth.connect.description
141
+ </p>
142
+ <div
143
+ class="styles__c-empty-text___3HnvR"
144
+ />
145
+ </div>
146
+ <button
147
+ class="styles__c-btn___-2Vnj styles__c-btn--center___16_Xh u-mh-auto"
148
+ type="submit"
149
+ >
108
150
  <span>
109
- oauth.connect.label
151
+ <span>
152
+ oauth.connect.submit
153
+ </span>
110
154
  </span>
111
- </span>
112
- </button>
155
+ </button>
156
+ </div>
113
157
  </div>
114
158
  `;
115
159
 
116
160
  exports[`OAuthForm should render 1`] = `
117
161
  <div>
118
- <button
119
- class="styles__c-btn___-2Vnj styles__c-btn--full___2VmR1 styles__c-btn--center___16_Xh u-mt-1"
120
- type="submit"
162
+ <div
163
+ class="styles__c-card___YgP7B u-flex u-flex-wrap"
121
164
  >
122
- <span>
165
+ <div
166
+ class="styles__c-empty___3w5oV"
167
+ >
168
+ CloudSync2
169
+ <h3
170
+ class="MuiTypography-root MuiTypography-h3 MuiTypography-colorTextPrimary MuiTypography-gutterBottom"
171
+ >
172
+ oauth.connect.title
173
+ </h3>
174
+ <p
175
+ class="MuiTypography-root MuiTypography-body1 MuiTypography-colorTextSecondary MuiTypography-gutterBottom"
176
+ >
177
+ oauth.connect.description
178
+ </p>
179
+ <div
180
+ class="styles__c-empty-text___3HnvR"
181
+ />
182
+ </div>
183
+ <button
184
+ class="styles__c-btn___-2Vnj styles__c-btn--center___16_Xh u-mh-auto"
185
+ type="submit"
186
+ >
123
187
  <span>
124
- oauth.connect.label
188
+ <span>
189
+ oauth.connect.submit
190
+ </span>
125
191
  </span>
126
- </span>
127
- </button>
192
+ </button>
193
+ </div>
128
194
  </div>
129
195
  `;
@@ -0,0 +1,20 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import Button from 'cozy-ui/transpiled/react/Button';
4
+ import Card from 'cozy-ui/transpiled/react/Card';
5
+ import Empty from 'cozy-ui/transpiled/react/Empty';
6
+ import CloudSync2 from 'cozy-ui/transpiled/react/Icons/CloudSync2';
7
+ export var ConnectCard = function ConnectCard(_ref) {
8
+ var buttonProps = _ref.buttonProps,
9
+ description = _ref.description,
10
+ title = _ref.title;
11
+ return /*#__PURE__*/React.createElement(Card, {
12
+ className: "u-flex u-flex-wrap"
13
+ }, /*#__PURE__*/React.createElement(Empty, {
14
+ icon: CloudSync2,
15
+ title: title,
16
+ text: description
17
+ }), /*#__PURE__*/React.createElement(Button, _extends({
18
+ className: "u-mh-auto"
19
+ }, buttonProps)));
20
+ };
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import cx from 'classnames';
3
+ import Card from 'cozy-ui/transpiled/react/Card';
4
+ import Divider from 'cozy-ui/transpiled/react/MuiCozyTheme/Divider';
5
+ import GlobeIcon from 'cozy-ui/transpiled/react/Icons/Globe';
6
+ import Icon from 'cozy-ui/transpiled/react/Icon';
7
+ import List from 'cozy-ui/transpiled/react/MuiCozyTheme/List';
8
+ import ListItem from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItem';
9
+ import ListItemIcon from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItemIcon';
10
+ import Typography from 'cozy-ui/transpiled/react/Typography';
11
+ import logger from '../../logger';
12
+ import { ListItemText } from '@material-ui/core';
13
+ import { getErrorMessage } from '../../helpers/getErrorMessage';
14
+ import { useI18n } from 'cozy-ui/transpiled/react/I18n';
15
+
16
+ var getLabel = function getLabel(link) {
17
+ if (!link) return null;
18
+
19
+ try {
20
+ var url = new URL(link);
21
+ return url.host;
22
+ } catch (error) {
23
+ logger('warn', getErrorMessage(error));
24
+ return null;
25
+ }
26
+ };
27
+
28
+ export var InformationsCard = function InformationsCard(_ref) {
29
+ var className = _ref.className,
30
+ link = _ref.link;
31
+
32
+ var _useI18n = useI18n(),
33
+ t = _useI18n.t;
34
+
35
+ var label = getLabel(link);
36
+ if (!label) return null;
37
+ return /*#__PURE__*/React.createElement(Card, {
38
+ className: cx('u-p-0', className)
39
+ }, /*#__PURE__*/React.createElement("div", {
40
+ className: "u-ph-1 u-flex u-flex-items-center",
41
+ style: {
42
+ minHeight: '64px'
43
+ }
44
+ }, /*#__PURE__*/React.createElement(Typography, {
45
+ variant: "h5"
46
+ }, t('card.websiteLink.title'))), /*#__PURE__*/React.createElement(Divider, {
47
+ className: "u-ml-0 u-maw-100 u-mb-half"
48
+ }), /*#__PURE__*/React.createElement(List, {
49
+ className: "u-p-0"
50
+ }, /*#__PURE__*/React.createElement(ListItem, {
51
+ button: true,
52
+ className: "u-mb-half",
53
+ component: "a",
54
+ href: link,
55
+ target: "_blank"
56
+ }, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
57
+ icon: GlobeIcon,
58
+ size: 16,
59
+ color: "textPrimary"
60
+ })), /*#__PURE__*/React.createElement(ListItemText, {
61
+ primary: t('card.websiteLink.description'),
62
+ secondary: label
63
+ }))));
64
+ };
File without changes
@@ -0,0 +1,19 @@
1
+ var isErrorWithMessage = function isErrorWithMessage(error) {
2
+ return typeof error === 'object' && error !== null && 'message' in error && typeof error.message === 'string';
3
+ };
4
+
5
+ var toErrorWithMessage = function toErrorWithMessage(maybeError) {
6
+ if (isErrorWithMessage(maybeError)) return maybeError;
7
+
8
+ try {
9
+ return new Error(JSON.stringify(maybeError));
10
+ } catch (_unused) {
11
+ // fallback in case there's an error stringifying the maybeError
12
+ // like with circular references for example.
13
+ return new Error(String(maybeError));
14
+ }
15
+ };
16
+
17
+ export var getErrorMessage = function getErrorMessage(error) {
18
+ return toErrorWithMessage(error).message;
19
+ };
@@ -41,4 +41,13 @@ console.warn = function (message, component) {
41
41
  console.error = function () {
42
42
  originalConsoleError.apply(this, arguments);
43
43
  throw new Error('console.error should not be called during tests');
44
- };
44
+ }; // Needed for now because `cozy-ui` can't be updated to the latest version in devDependencies
45
+
46
+
47
+ jest.mock('cozy-ui/transpiled/react/Icons/CloudSync2', function () {
48
+ return function () {
49
+ return 'CloudSync2';
50
+ };
51
+ }, {
52
+ virtual: true
53
+ });
@@ -23,10 +23,16 @@
23
23
  },
24
24
  "cannotConnectModal": {
25
25
  "title": "You can't connect?",
26
- "content": "You can check your login or reset your password on the website "
26
+ "content": "You can check your login or reset your password on the [%{vendorName}](%{vendorLink})'s website.",
27
+ "noAccount": "If you do not have an account you will need to create one on the [%{vendorName}](%{vendorLink})'s website."
27
28
  },
28
29
  "cannotConnectLink": "I can't connect",
29
- "notClientSide": "The %{name} application uses a brand-new and efficient system for retrieving your data from your Cozy. This action is only accessible from the Cozy mobile app."
30
+ "notClientSide": "The %{name} application uses a brand-new and efficient system for retrieving your data from your Cozy. This action is only accessible from the Cozy mobile app.",
31
+ "clientSide": {
32
+ "title": "Connect to your Cozy",
33
+ "submit": "Connect",
34
+ "description": "Connect %{name} to your Cozy to synchronize your account and automatically retrieve all your data. "
35
+ }
30
36
  },
31
37
  "contracts": {
32
38
  "headers": {
@@ -423,7 +429,10 @@
423
429
  "label": "Reconnect"
424
430
  },
425
431
  "connect": {
426
- "label": "Connect"
432
+ "description": "Connect %{slug} to your Cozy to synchronize your account and automatically retrieve all your data.",
433
+ "label": "Connect",
434
+ "submit": "Connect",
435
+ "title": "Connect to your Cozy"
427
436
  },
428
437
  "window": {
429
438
  "title": "OAuth"