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.

Add checkSettings method for Gmail OAuth integration

samme-abdul2e43ff384eea
diff --git a/packages/app/src/builder-ui/components/Triggers/GmailTrigger.class.ts b/packages/app/src/builder-ui/components/Triggers/GmailTrigger.class.ts
index b8988af7..a434b511 100644
--- a/packages/app/src/builder-ui/components/Triggers/GmailTrigger.class.ts
+++ b/packages/app/src/builder-ui/components/Triggers/GmailTrigger.class.ts
@@ -47,6 +47,10 @@ export class GmailTrigger extends Trigger {
this.drawSettings.color = '#ff00f2';
}
+ public async checkSettings(): Promise<void> {
+ await this.oauth?.checkSettings();
+ }
+
/**
* Clean up event listeners and resources
*/
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 d597c8f6..664aff9f 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
@@ -24,6 +24,45 @@ export class oAuthSettings {
this.boundHandleAuthMessage = this.handleAuthMessage.bind(this);
}
+ /**
+ * Public: Add component-level Authenticate button if not authenticated.
+ * Minimal integration so other components can just call oauth.checkSettings().
+ */
+ public async checkSettings(): Promise<void> {
+ const connectionId: string | undefined = this.component?.data?.oauth_con_id;
+ const existingBtn = this.component?.domElement?.querySelector('button.oauthButton') as HTMLButtonElement || null;
+
+ // If no connection chosen, remove component-level button (if any) and exit
+ if (!connectionId || connectionId === 'None') {
+ if (existingBtn) this.component.clearComponentMessages();
+ return;
+ }
+
+ // Show temporary checking status while verifying auth
+ this.component.clearComponentMessages();
+ this.component.addComponentMessage('Checking Auth Info...', 'info text-center');
+
+ // If authenticated, ensure no redundant component-level button remains
+ const authed = await this.checkAuthentication();
+
+ // Clear the temporary message
+ this.component.clearComponentMessages();
+
+ if (authed) {
+ return;
+ }
+
+ // Show component-level Authenticate button only if not already present
+ if (existingBtn) return;
+
+ this.component.addComponentButton(
+ '<div class="fa-solid fa-user-shield"></div><p class="">Authenticate</p>',
+ 'warning',
+ { class: 'oauthButton' },
+ this.collectAndConsoleOAuthValues.bind(this),
+ );
+ }
+
/**
* Initialize OAuth services and load connections
*/