|
1 | 1 | 'use client' |
2 | 2 |
|
3 | 3 | import { useCallback, useEffect, useMemo, useState } from 'react' |
4 | | -import { Button, Combobox, type ComboboxOptionGroup } from '@sim/emcn' |
| 4 | +import { Chip, Combobox, type ComboboxOptionGroup } from '@sim/emcn' |
5 | 5 | import { Key, SquareArrowUpRight } from '@sim/emcn/icons' |
6 | 6 | import { useParams } from 'next/navigation' |
7 | 7 | import { consumeOAuthReturnContext, writeOAuthReturnContext } from '@/lib/credentials/client-state' |
@@ -211,7 +211,9 @@ export function CredentialSelector({ |
211 | 211 | const needsUpdate = |
212 | 212 | hasOAuthSelection && |
213 | 213 | !isServiceAccount && |
214 | | - (missingRequiredScopes.length > 0 || dataversePolicy.requiresSeparateCredential) && |
| 214 | + (missingRequiredScopes.length > 0 || |
| 215 | + dataversePolicy.requiresSeparateCredential || |
| 216 | + dataversePolicy.hasInvalidEnvironment) && |
215 | 217 | !effectiveDisabled && |
216 | 218 | !isPreview && |
217 | 219 | !credentialsLoading |
@@ -474,29 +476,31 @@ export function CredentialSelector({ |
474 | 476 | <span className='mr-1.5 inline-block size-[6px] rounded-xs bg-amber-500' /> |
475 | 477 | {dataversePolicy.message} |
476 | 478 | </div> |
477 | | - <Button |
478 | | - variant='active' |
479 | | - onClick={() => { |
480 | | - if (dataversePolicy.requiresSeparateCredential) { |
481 | | - setShowConnectModal(true) |
482 | | - return |
483 | | - } |
484 | | - writeOAuthReturnContext({ |
485 | | - origin: 'workflow', |
486 | | - workflowId: activeWorkflowId || '', |
487 | | - displayName: selectedCredential?.name ?? getProviderName(provider), |
488 | | - providerId: effectiveProviderId, |
489 | | - preCount: credentials.filter((c) => c.type !== 'service_account').length, |
490 | | - workspaceId, |
491 | | - reconnect: true, |
492 | | - requestedAt: Date.now(), |
493 | | - }) |
494 | | - setShowOAuthModal(true) |
495 | | - }} |
496 | | - className='w-full px-2 py-1 text-caption' |
497 | | - > |
498 | | - {dataversePolicy.actionLabel} |
499 | | - </Button> |
| 479 | + {!dataversePolicy.hasInvalidEnvironment && ( |
| 480 | + <Chip |
| 481 | + variant='primary' |
| 482 | + fullWidth |
| 483 | + onClick={() => { |
| 484 | + if (dataversePolicy.requiresSeparateCredential) { |
| 485 | + setShowConnectModal(true) |
| 486 | + return |
| 487 | + } |
| 488 | + writeOAuthReturnContext({ |
| 489 | + origin: 'workflow', |
| 490 | + workflowId: activeWorkflowId || '', |
| 491 | + displayName: selectedCredential?.name ?? getProviderName(provider), |
| 492 | + providerId: effectiveProviderId, |
| 493 | + preCount: credentials.filter((c) => c.type !== 'service_account').length, |
| 494 | + workspaceId, |
| 495 | + reconnect: true, |
| 496 | + requestedAt: Date.now(), |
| 497 | + }) |
| 498 | + setShowOAuthModal(true) |
| 499 | + }} |
| 500 | + > |
| 501 | + {dataversePolicy.actionLabel} |
| 502 | + </Chip> |
| 503 | + )} |
500 | 504 | </div> |
501 | 505 | )} |
502 | 506 |
|
|
0 commit comments