Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

Refactor OAuth connection handling in APICall and oAuthSettings components to pass current value directly to handleOAuthConnectionAction method, improving clarity and reducing redundancy.

Muhammad Hamza Khand110d6de1f21
diff --git a/packages/app/src/builder-ui/components/APICall.class.ts b/packages/app/src/builder-ui/components/APICall.class.ts
index 85fa4d89..efcc3ebc 100644
--- a/packages/app/src/builder-ui/components/APICall.class.ts
+++ b/packages/app/src/builder-ui/components/APICall.class.ts
@@ -209,8 +209,7 @@ export class APICall extends Component {
visible: () => true, // Always visible
events: {
click: () => {
- this.data.oauth_con_id = 'None';
- this.handleOAuthConnectionAction();
+ this.handleOAuthConnectionAction('None');
},
},
},
@@ -222,7 +221,7 @@ export class APICall extends Component {
cls: 'mt-[7px] !mr-[24px] !pt-[10px]',
visible: () => this.data.oauth_con_id && this.data.oauth_con_id !== 'None',
events: {
- click: () => this.handleOAuthConnectionAction(),
+ click: () => this.handleOAuthConnectionAction(this.data.oauth_con_id),
},
},
],
@@ -1598,10 +1597,9 @@ export class APICall extends Component {
this.updateOAuthActionButton();
}
- private async handleOAuthConnectionAction() {
- const currentValue = this.data.oauth_con_id;
+ private async handleOAuthConnectionAction(currentValue: string) {
const isNone = !currentValue || currentValue === 'None';
- // console.log('[OAuth Edit] Action started. Current Value:', currentValue, 'Is None:', isNone);
+
// Fetch existing OAuth connections ONLY when editing to avoid modal delay on "Add New"
if (!isNone) {
try {
diff --git a/packages/app/src/builder-ui/helpers/oauth/oauth-settings.helper.ts b/packages/app/src/builder-ui/helpers/oauth/oauth-settings.helper.ts
index 355d1bcb..8e268335 100644
--- a/packages/app/src/builder-ui/helpers/oauth/oauth-settings.helper.ts
+++ b/packages/app/src/builder-ui/helpers/oauth/oauth-settings.helper.ts
@@ -106,8 +106,7 @@ export class oAuthSettings {
visible: () => true,
events: {
click: () => {
- this.component.data.oauth_con_id = 'None';
- this.handleOAuthConnectionAction();
+ this.handleOAuthConnectionAction('None');
},
},
},
@@ -119,7 +118,7 @@ export class oAuthSettings {
visible: () =>
this.component.data.oauth_con_id && this.component.data.oauth_con_id !== 'None',
events: {
- click: () => this.handleOAuthConnectionAction(),
+ click: () => this.handleOAuthConnectionAction(this.component.data.oauth_con_id),
},
},
],
@@ -291,14 +290,12 @@ export class oAuthSettings {
/**
* Handles OAuth connection creation/editing
*/
- private async handleOAuthConnectionAction(): Promise<void> {
+ private async handleOAuthConnectionAction(currentValue: string): Promise<void> {
if (!this.oauthService || !this.uiHelper) {
errorToast('OAuth service not initialized', 'Error', 'alert');
return;
}
- const currentValue = this.component.data.oauth_con_id;
-
try {
const connections = await this.oauthService.loadConnections();