11'use client' ;
22
3- import { User , Users } from 'lucide-react' ;
3+ import { Info , User , Users } from 'lucide-react' ;
44import { useState } from 'react' ;
5+ import { Alert , AlertDescription } from '@/components/ui/alert' ;
56import { Button } from '@/components/ui/button' ;
67import {
78 Dialog ,
@@ -11,6 +12,7 @@ import {
1112 DialogHeader ,
1213 DialogTitle ,
1314} from '@/components/ui/dialog' ;
15+ import { useRuntimeConfig } from '@/contexts/runtime-config-context' ;
1416import { type CredentialScope , CredentialScopeEnum } from '../form/validation' ;
1517
1618interface ScopeSelectionDialogProps {
@@ -27,6 +29,10 @@ export function ScopeSelectionDialog({
2729 onConfirm,
2830} : ScopeSelectionDialogProps ) {
2931 const [ selectedScope , setSelectedScope ] = useState < CredentialScope > ( CredentialScopeEnum . project ) ;
32+ const { PUBLIC_DISABLE_AUTH } = useRuntimeConfig ( ) ;
33+
34+ const isAuthDisabled = PUBLIC_DISABLE_AUTH === 'true' ;
35+ const isUserScopeDisabled = isAuthDisabled ;
3036
3137 const handleConfirm = ( ) => {
3238 onConfirm ( selectedScope ) ;
@@ -53,7 +59,7 @@ export function ScopeSelectionDialog({
5359 : 'border-border hover:border-primary/50'
5460 } `}
5561 >
56- < Users className = "w-5 h-5 mt-0.5 text-muted-foreground" />
62+ < Users className = "h-4 w-4 mt-1 shrink-0 text-muted-foreground" />
5763 < div className = "flex-1" >
5864 < div className = "font-medium" > Project (Shared)</ div >
5965 < p className = "text-sm text-muted-foreground mt-1" >
@@ -64,21 +70,37 @@ export function ScopeSelectionDialog({
6470
6571 < button
6672 type = "button"
67- onClick = { ( ) => setSelectedScope ( CredentialScopeEnum . user ) }
73+ onClick = { ( ) => {
74+ if ( ! isUserScopeDisabled ) {
75+ setSelectedScope ( CredentialScopeEnum . user ) ;
76+ }
77+ } }
78+ disabled = { isUserScopeDisabled }
6879 className = { `flex items-start gap-4 p-4 rounded-lg border-2 text-left transition-colors ${
69- selectedScope === CredentialScopeEnum . user
70- ? 'border-primary bg-primary/5'
71- : 'border-border hover:border-primary/50'
80+ isUserScopeDisabled
81+ ? 'opacity-50 cursor-not-allowed border-border bg-muted/30'
82+ : selectedScope === CredentialScopeEnum . user
83+ ? 'border-primary bg-primary/5'
84+ : 'border-border hover:border-primary/50'
7285 } `}
7386 >
74- < User className = "w-5 h-5 mt-0.5 text-muted-foreground" />
87+ < User className = "h-4 w-4 mt-1 shrink-0 text-muted-foreground" />
7588 < div className = "flex-1" >
7689 < div className = "font-medium" > User (Per-user)</ div >
7790 < p className = "text-sm text-muted-foreground mt-1" >
7891 Each team member connects their own account. No authentication required now.
7992 </ p >
8093 </ div >
8194 </ button >
95+
96+ { isUserScopeDisabled && (
97+ < Alert variant = "default" className = "bg-muted/50" >
98+ < Info className = "h-4 w-4" />
99+ < AlertDescription >
100+ User-scoped credentials require authentication to be enabled.
101+ </ AlertDescription >
102+ </ Alert >
103+ ) }
82104 </ div >
83105
84106 < DialogFooter >
0 commit comments