@@ -14,7 +14,6 @@ import {
1414} from '@/components/icons'
1515import { Button } from '@/components/ui/button'
1616import { createLogger } from '@/lib/logs/console/logger'
17- import { ToolCredentialSelector } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/tool-input/components/tool-credential-selector'
1817import { WebhookModal } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/webhook/components'
1918import { useSubBlockValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/hooks/use-sub-block-value'
2019import { useSubBlockStore } from '@/stores/workflows/subblock/store'
@@ -331,7 +330,6 @@ export function WebhookConfig({
331330 const params = useParams ( )
332331 const workflowId = params . workflowId as string
333332 const [ isLoading , setIsLoading ] = useState ( false )
334- const [ gmailCredentialId , setGmailCredentialId ] = useState < string > ( '' )
335333
336334 // No need to manage webhook status separately - it's determined by having provider + path
337335
@@ -341,6 +339,9 @@ export function WebhookConfig({
341339 // Store the webhook path
342340 const [ storeWebhookPath , setWebhookPath ] = useSubBlockValue ( blockId , 'webhookPath' )
343341
342+ // Store Gmail credential from the dedicated subblock
343+ const [ storeGmailCredential , setGmailCredential ] = useSubBlockValue ( blockId , 'gmailCredential' )
344+
344345 // Don't auto-generate webhook paths - only create them when user actually configures a webhook
345346 // This prevents the "Active Webhook" badge from showing on unconfigured blocks
346347
@@ -351,6 +352,7 @@ export function WebhookConfig({
351352 const webhookProvider = propValue ?. webhookProvider ?? storeWebhookProvider
352353 const webhookPath = propValue ?. webhookPath ?? storeWebhookPath
353354 const providerConfig = propValue ?. providerConfig ?? storeProviderConfig
355+ const gmailCredentialId = storeGmailCredential || ''
354356
355357 // Store the actual provider from the database
356358 const [ actualProvider , setActualProvider ] = useState < string | null > ( null )
@@ -444,7 +446,7 @@ export function WebhookConfig({
444446
445447 // Clear component state
446448 setError ( null )
447- setGmailCredentialId ( '' )
449+ setGmailCredential ( '' )
448450
449451 // Note: Store will be cleared AFTER successful database deletion
450452 // This ensures store and database stay perfectly in sync
@@ -695,31 +697,12 @@ export function WebhookConfig({
695697 // Check if the webhook is connected for the selected provider
696698 const isWebhookConnected = webhookId && webhookProvider === actualProvider
697699
698- const handleCredentialChange = ( credentialId : string ) => {
699- if ( isPreview || disabled ) return
700- setGmailCredentialId ( credentialId )
701- }
702-
703- // For Gmail, we need to show the credential selector
700+ // For Gmail, show configure button when credential is available and webhook not connected
704701 if ( webhookProvider === 'gmail' && ! isWebhookConnected ) {
705702 return (
706703 < div className = 'w-full' >
707704 { error && < div className = 'mb-2 text-red-500 text-sm dark:text-red-400' > { error } </ div > }
708705
709- < div className = 'mb-3' >
710- < ToolCredentialSelector
711- value = { gmailCredentialId }
712- onChange = { handleCredentialChange }
713- provider = 'google-email'
714- requiredScopes = { [
715- 'https://www.googleapis.com/auth/gmail.modify' ,
716- 'https://www.googleapis.com/auth/gmail.labels' ,
717- ] }
718- label = 'Select Gmail account'
719- disabled = { isConnecting || isSaving || isDeleting || isPreview || disabled }
720- />
721- </ div >
722-
723706 { gmailCredentialId && (
724707 < Button
725708 variant = 'outline'
0 commit comments