diff --git a/etc/plugin-config-ui-lib.api.md b/etc/plugin-config-ui-lib.api.md index 6c96f0e..fb3d2b2 100644 --- a/etc/plugin-config-ui-lib.api.md +++ b/etc/plugin-config-ui-lib.api.md @@ -185,10 +185,11 @@ export interface ControlNumberFieldProps { } // @public -export function ControlOAuthField({ getConnectPayloadSpec, getFinishPayloadSpec, }: ControlOAuthFieldProps): JSX_2.Element; +export function ControlOAuthField({ shouldAuthenticate, getConnectPayloadSpec, getFinishPayloadSpec, }: ControlOAuthFieldProps): JSX_2.Element; // @public (undocumented) export type ControlOAuthFieldProps = { + shouldAuthenticate?: () => Promise; getConnectPayloadSpec?: (formValues: any) => Promise>; getFinishPayloadSpec?: (formValues: any) => Promise>; }; diff --git a/package-lock.json b/package-lock.json index 14a7ab9..444fc8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@cloudquery/plugin-config-ui-lib", - "version": "4.2.2", + "version": "4.2.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@cloudquery/plugin-config-ui-lib", - "version": "4.2.2", + "version": "4.2.3", "license": "MPL-2.0", "dependencies": { "@babel/runtime": "^7.25.6", diff --git a/package.json b/package.json index d35f866..3f6f416 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@cloudquery/plugin-config-ui-lib", "description": "Plugin configuration UI library for CloudQuery Cloud App", - "version": "4.2.2", + "version": "4.2.3", "private": false, "main": "dist/index.cjs.js", "module": "dist/index.esm.js", @@ -21,6 +21,7 @@ "require": "./dist/components/devWrapper.cjs.js" }, "./e2e-utils": { + "types": "./dist/e2e-utils/index.d.ts", "import": "./dist/e2e-utils/index.esm.js", "require": "./dist/e2e-utils/index.cjs.js" }, diff --git a/src/components/form/controls/controlOAuthField.tsx b/src/components/form/controls/controlOAuthField.tsx index e668d63..f23cf3e 100644 --- a/src/components/form/controls/controlOAuthField.tsx +++ b/src/components/form/controls/controlOAuthField.tsx @@ -20,6 +20,7 @@ import { cloudQueryOauthConnectorUrl } from '../../../utils'; * @public */ export type ControlOAuthFieldProps = { + shouldAuthenticate?: () => Promise; getConnectPayloadSpec?: (formValues: any) => Promise>; getFinishPayloadSpec?: (formValues: any) => Promise>; }; @@ -30,6 +31,7 @@ export type ControlOAuthFieldProps = { * @public */ export function ControlOAuthField({ + shouldAuthenticate, getConnectPayloadSpec, getFinishPayloadSpec, }: ControlOAuthFieldProps) { @@ -55,6 +57,16 @@ export function ControlOAuthField({ getFinishPayloadSpec: async () => await getFinishPayloadSpec?.(getValues()), }); + const handleAuthenticate = async () => { + let proceed = true; + if (shouldAuthenticate) { + proceed = await shouldAuthenticate(); + } + if (proceed) { + authenticate(); + } + }; + useEffect(() => { if (authConnectorResult && connectorId) { setValue('connectorId', connectorId); @@ -86,7 +98,7 @@ export function ControlOAuthField({ To reconnect CloudQuery via {config.label}{' '} {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */} - + click here