Skip to content
This repository was archived by the owner on Jan 12, 2026. It is now read-only.

Commit 6e893b6

Browse files
Ehnance control oauth (#74)
1 parent f2d09eb commit 6e893b6

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

etc/plugin-config-ui-lib.api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,11 @@ export interface ControlNumberFieldProps {
185185
}
186186

187187
// @public
188-
export function ControlOAuthField({ getConnectPayloadSpec, getFinishPayloadSpec, }: ControlOAuthFieldProps): JSX_2.Element;
188+
export function ControlOAuthField({ shouldAuthenticate, getConnectPayloadSpec, getFinishPayloadSpec, }: ControlOAuthFieldProps): JSX_2.Element;
189189

190190
// @public (undocumented)
191191
export type ControlOAuthFieldProps = {
192+
shouldAuthenticate?: () => Promise<boolean>;
192193
getConnectPayloadSpec?: (formValues: any) => Promise<Record<string, any>>;
193194
getFinishPayloadSpec?: (formValues: any) => Promise<Record<string, any>>;
194195
};

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@cloudquery/plugin-config-ui-lib",
33
"description": "Plugin configuration UI library for CloudQuery Cloud App",
4-
"version": "4.2.2",
4+
"version": "4.2.3",
55
"private": false,
66
"main": "dist/index.cjs.js",
77
"module": "dist/index.esm.js",
@@ -21,6 +21,7 @@
2121
"require": "./dist/components/devWrapper.cjs.js"
2222
},
2323
"./e2e-utils": {
24+
"types": "./dist/e2e-utils/index.d.ts",
2425
"import": "./dist/e2e-utils/index.esm.js",
2526
"require": "./dist/e2e-utils/index.cjs.js"
2627
},

src/components/form/controls/controlOAuthField.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { cloudQueryOauthConnectorUrl } from '../../../utils';
2020
* @public
2121
*/
2222
export type ControlOAuthFieldProps = {
23+
shouldAuthenticate?: () => Promise<boolean>;
2324
getConnectPayloadSpec?: (formValues: any) => Promise<Record<string, any>>;
2425
getFinishPayloadSpec?: (formValues: any) => Promise<Record<string, any>>;
2526
};
@@ -30,6 +31,7 @@ export type ControlOAuthFieldProps = {
3031
* @public
3132
*/
3233
export function ControlOAuthField({
34+
shouldAuthenticate,
3335
getConnectPayloadSpec,
3436
getFinishPayloadSpec,
3537
}: ControlOAuthFieldProps) {
@@ -55,6 +57,16 @@ export function ControlOAuthField({
5557
getFinishPayloadSpec: async () => await getFinishPayloadSpec?.(getValues()),
5658
});
5759

60+
const handleAuthenticate = async () => {
61+
let proceed = true;
62+
if (shouldAuthenticate) {
63+
proceed = await shouldAuthenticate();
64+
}
65+
if (proceed) {
66+
authenticate();
67+
}
68+
};
69+
5870
useEffect(() => {
5971
if (authConnectorResult && connectorId) {
6072
setValue('connectorId', connectorId);
@@ -86,7 +98,7 @@ export function ControlOAuthField({
8698
<LoadingButton
8799
size="large"
88100
variant="contained"
89-
onClick={authenticate}
101+
onClick={handleAuthenticate}
90102
loading={isLoading}
91103
fullWidth={false}
92104
disabled={!!connectorIdValue}
@@ -106,7 +118,7 @@ export function ControlOAuthField({
106118
<Typography variant="body2" color="textSecondary">
107119
To reconnect CloudQuery via {config.label}{' '}
108120
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
109-
<Link underline="always" sx={{ cursor: 'pointer' }} onClick={authenticate}>
121+
<Link underline="always" sx={{ cursor: 'pointer' }} onClick={handleAuthenticate}>
110122
click here
111123
</Link>
112124
</Typography>

0 commit comments

Comments
 (0)