@@ -20,7 +20,7 @@ import { Card, CardContent, CardHeader, CardTitle, CardVariant } from 'component
2020import { Field , FieldDescription , FieldError , FieldLabel } from 'components/redpanda-ui/components/field' ;
2121import { Input , InputEnd } from 'components/redpanda-ui/components/input' ;
2222import { Text } from 'components/redpanda-ui/components/typography' ;
23- import { Check , Key , Loader2 , Plus } from 'lucide-react' ;
23+ import { Check , Key , Loader2 , Plus , X } from 'lucide-react' ;
2424import { CreateSecretRequestSchema } from 'protogen/redpanda/api/console/v1alpha1/secret_pb' ;
2525import {
2626 CreateSecretRequestSchema as CreateSecretRequestSchemaDataPlane ,
@@ -97,6 +97,10 @@ export const QuickAddSecrets: React.FC<QuickAddSecretsProps> = ({
9797 const { mutateAsync : createSecret } = useCreateSecretMutation ( ) ;
9898 const [ createdSecrets , setCreatedSecrets ] = useState < string [ ] > ( [ ] ) ;
9999 const [ newlyCreatedSecrets , setNewlyCreatedSecrets ] = useState < string [ ] > ( [ ] ) ;
100+ // When required secrets exist, the ad-hoc "create another" form starts
101+ // collapsed so the dialog focuses on the missing-secrets task. Without
102+ // required secrets (e.g. template gallery), it stays expanded.
103+ const [ showAddAnotherForm , setShowAddAnotherForm ] = useState ( requiredSecrets . length === 0 ) ;
100104
101105 /**
102106 * Normalizes secret name to uppercase and validates characters
@@ -379,7 +383,7 @@ export const QuickAddSecrets: React.FC<QuickAddSecretsProps> = ({
379383
380384 < Field data-invalid = { ! ! newSecretForm . formState . errors . value } >
381385 < FieldLabel className = "font-medium text-sm" htmlFor = "new-secret-value" >
382- Secret Value
386+ Secret value
383387 </ FieldLabel >
384388 < Input
385389 id = "new-secret-value"
@@ -412,9 +416,10 @@ export const QuickAddSecrets: React.FC<QuickAddSecretsProps> = ({
412416 </ >
413417 ) ;
414418
419+ const hasRequiredSection = missingSecrets . length > 0 ;
415420 return (
416421 < div className = "space-y-4" >
417- { missingSecrets . length > 0 &&
422+ { hasRequiredSection &&
418423 ( inline ? (
419424 < div className = "space-y-4" > { requiredSecretsForm } </ div >
420425 ) : (
@@ -432,7 +437,38 @@ export const QuickAddSecrets: React.FC<QuickAddSecretsProps> = ({
432437 ) ) }
433438 { enableNewSecrets &&
434439 ( inline ? (
435- < div className = "space-y-4" > { newSecretFormBody } </ div >
440+ showAddAnotherForm ? (
441+ < div className = { hasRequiredSection ? 'space-y-3 border-t pt-4' : 'space-y-4' } >
442+ { hasRequiredSection && (
443+ < div className = "flex items-center justify-between gap-2" >
444+ < Text className = "font-medium" variant = "bodyStrongMedium" >
445+ Add a custom secret
446+ </ Text >
447+ < Button
448+ aria-label = "Hide custom secret form"
449+ icon = { < X /> }
450+ onClick = { ( ) => setShowAddAnotherForm ( false ) }
451+ size = "icon-xs"
452+ type = "button"
453+ variant = "secondary-ghost"
454+ />
455+ </ div >
456+ ) }
457+ { newSecretFormBody }
458+ </ div >
459+ ) : (
460+ < div className = { hasRequiredSection ? 'border-t pt-4' : '' } >
461+ < Button
462+ className = "w-full"
463+ onClick = { ( ) => setShowAddAnotherForm ( true ) }
464+ type = "button"
465+ variant = "secondary-ghost"
466+ >
467+ < Plus className = "h-4 w-4" />
468+ Add a custom secret
469+ </ Button >
470+ </ div >
471+ )
436472 ) : (
437473 < Card size = "full" >
438474 { hideHeader ? null : (
0 commit comments