From a1a2d97639fb2c8c6f4066add6bfbcc1e47d8592 Mon Sep 17 00:00:00 2001 From: Antonin Cezard Date: Wed, 22 Feb 2023 11:02:52 +0100 Subject: [PATCH] feat(cozy-harvest): Implement new account modal --- .../__snapshots__/index.spec.jsx.snap | 20 ++- .../src/components/AccountForm/index.jsx | 74 ++++++--- .../KonnectorConfiguration/DataTab/index.jsx | 4 +- .../src/components/KonnectorModalHeader.jsx | 8 +- .../src/components/NewAccountModal.jsx | 47 ++++-- .../src/components/OAuthForm.jsx | 23 +-- .../__snapshots__/OAuthForm.spec.js.snap | 150 +++++++++++++----- .../src/components/cards/ConnectCard.tsx | 29 ++++ .../src/components/cards/InformationsCard.tsx | 74 +++++++++ .../src/components/cards/WebsiteLinkCard.jsx | 63 -------- .../components/cards/WebsiteLinkCard.spec.jsx | 28 ---- .../src/helpers/getErrorMessage.ts | 28 ++++ packages/cozy-harvest-lib/src/jest.setup.js | 9 ++ packages/cozy-harvest-lib/tsconfig.json | 26 +-- 14 files changed, 366 insertions(+), 217 deletions(-) create mode 100644 packages/cozy-harvest-lib/src/components/cards/ConnectCard.tsx create mode 100644 packages/cozy-harvest-lib/src/components/cards/InformationsCard.tsx delete mode 100644 packages/cozy-harvest-lib/src/components/cards/WebsiteLinkCard.jsx delete mode 100644 packages/cozy-harvest-lib/src/components/cards/WebsiteLinkCard.spec.jsx create mode 100644 packages/cozy-harvest-lib/src/helpers/getErrorMessage.ts diff --git a/packages/cozy-harvest-lib/src/components/AccountForm/__snapshots__/index.spec.jsx.snap b/packages/cozy-harvest-lib/src/components/AccountForm/__snapshots__/index.spec.jsx.snap index dbeafb733d..bd84532108 100644 --- a/packages/cozy-harvest-lib/src/components/AccountForm/__snapshots__/index.spec.jsx.snap +++ b/packages/cozy-harvest-lib/src/components/AccountForm/__snapshots__/index.spec.jsx.snap @@ -147,14 +147,18 @@ exports[`AccountForm should render normally when client side konnector with laun inputRefByName={[Function]} t={[Function]} /> - diff --git a/packages/cozy-harvest-lib/src/components/AccountForm/index.jsx b/packages/cozy-harvest-lib/src/components/AccountForm/index.jsx index f343eeab50..8e98624681 100644 --- a/packages/cozy-harvest-lib/src/components/AccountForm/index.jsx +++ b/packages/cozy-harvest-lib/src/components/AccountForm/index.jsx @@ -14,22 +14,23 @@ import { Media, Img, Bd } from 'cozy-ui/transpiled/react/Media' import Typography from 'cozy-ui/transpiled/react/Typography' import { Dialog } from 'cozy-ui/transpiled/react/CozyDialogs' -import withAdaptiveRouter from '../hoc/withRouter' -import withLocales from '../hoc/withLocales' import AccountFields from './AccountFields' +import CannotConnectModal from './CannotConnectModal' +import ConnectionBackdrop from './ConnectionBackdrop' import ReadOnlyIdentifier from './ReadOnlyIdentifier' import TriggerErrorInfo from '../infos/TriggerErrorInfo' +import manifest from '../../helpers/manifest' +import withAdaptiveRouter from '../hoc/withRouter' +import withConnectionFlow from '../../models/withConnectionFlow' +import withKonnectorLocales from '../hoc/withKonnectorLocales' +import withLocales from '../hoc/withLocales' +import { ConnectCard } from '../cards/ConnectCard' +import { KonnectorJobError } from '../../helpers/konnectors' +import { findKonnectorPolicy } from '../../konnector-policies' import fieldHelpers, { getEncryptedFieldName, SECRET } from '../../helpers/fields' -import { KonnectorJobError } from '../../helpers/konnectors' -import { findKonnectorPolicy } from '../../konnector-policies' -import manifest from '../../helpers/manifest' -import withKonnectorLocales from '../hoc/withKonnectorLocales' -import withConnectionFlow from '../../models/withConnectionFlow' -import CannotConnectModal from './CannotConnectModal' -import ConnectionBackdrop from './ConnectionBackdrop' const VALIDATION_ERROR_REQUIRED_FIELD = 'VALIDATION_ERROR_REQUIRED_FIELD' @@ -314,18 +315,49 @@ export class AccountForm extends PureComponent { {t('accountForm.cannotConnectLink')} )} - + + `; @@ -100,30 +122,74 @@ exports[`OAuthForm should handle oauth cancelation 2`] = ` - + + `; exports[`OAuthForm should render 1`] = `
- + +
`; diff --git a/packages/cozy-harvest-lib/src/components/cards/ConnectCard.tsx b/packages/cozy-harvest-lib/src/components/cards/ConnectCard.tsx new file mode 100644 index 0000000000..35b6f88e1e --- /dev/null +++ b/packages/cozy-harvest-lib/src/components/cards/ConnectCard.tsx @@ -0,0 +1,29 @@ +import React from 'react' + +import Button from 'cozy-ui/transpiled/react/Button' +import Card from 'cozy-ui/transpiled/react/Card' +import Empty from 'cozy-ui/transpiled/react/Empty' +import CloudSync2 from 'cozy-ui/transpiled/react/Icons/CloudSync2' + +interface ConnectCardProps { + description: string + title: string + buttonProps: { + busy: boolean + disabled: boolean + label: string + onClick: () => void + } +} + +export const ConnectCard = ({ + buttonProps, + description, + title +}: ConnectCardProps): JSX.Element => ( + + + +