From f5ef52c6a98a23656db56483d975d106b6160e57 Mon Sep 17 00:00:00 2001 From: doubleface Date: Tue, 7 Jun 2022 16:42:58 +0200 Subject: [PATCH 1/4] feat: Add BI webview reconnection A "reconnect" button is now visible when trying to update credentials of a bi webview connector or any oauth connector. An addition in io-cozy-account_types secrets is neededed : the reconnect_endpoint as documented in https://docs.cozy.io/en/cozy-stack/konnectors-workflow/#reconnect --- .../src/components/EditAccountModal.jsx | 2 + .../src/components/OAuthForm.jsx | 11 +- .../src/components/OAuthForm.spec.js | 5 +- .../src/components/OAuthWindow.jsx | 6 +- .../src/components/TriggerManager.jsx | 4 +- .../__snapshots__/OAuthForm.spec.js.snap | 13 ++ .../cozy-harvest-lib/src/helpers/oauth.js | 21 ++- .../src/helpers/oauth.spec.js | 15 ++ packages/cozy-harvest-lib/src/locales/en.json | 3 + packages/cozy-harvest-lib/src/locales/fr.json | 3 + .../src/services/biWebView.js | 34 +++- .../src/services/biWebView.spec.js | 151 +++++++++++++++++- .../src/services/budget-insight.js | 4 +- 13 files changed, 253 insertions(+), 19 deletions(-) diff --git a/packages/cozy-harvest-lib/src/components/EditAccountModal.jsx b/packages/cozy-harvest-lib/src/components/EditAccountModal.jsx index 3c9dde842b..c0e40c4101 100644 --- a/packages/cozy-harvest-lib/src/components/EditAccountModal.jsx +++ b/packages/cozy-harvest-lib/src/components/EditAccountModal.jsx @@ -95,8 +95,10 @@ const DumbEditAccountModal = withRouter( showError={true} onVaultDismiss={redirectToAccount} fieldOptions={fieldOptions} + reconnect={fromReconnect} /> )} +
) diff --git a/packages/cozy-harvest-lib/src/components/OAuthForm.jsx b/packages/cozy-harvest-lib/src/components/OAuthForm.jsx index db1f36f661..b1dbddcaa9 100644 --- a/packages/cozy-harvest-lib/src/components/OAuthForm.jsx +++ b/packages/cozy-harvest-lib/src/components/OAuthForm.jsx @@ -72,30 +72,31 @@ export class OAuthForm extends PureComponent { } render() { - const { konnector, t, flowState } = this.props - const { initialValues, showOAuthWindow, needExtraParams, extraParams } = - this.state + const { konnector, t, flowState, reconnect, account } = this.props + const { showOAuthWindow, needExtraParams, extraParams } = this.state const isBusy = showOAuthWindow === true || flowState.running || (needExtraParams && !extraParams) - return initialValues ? null : ( + return ( <>