Default cert to open when just added

This commit is contained in:
Gregory Schier
2025-12-10 15:08:59 -08:00
parent c4b559f34b
commit 3484db3371

View File

@@ -1,7 +1,7 @@
import type { ClientCertificate } from '@yaakapp-internal/models'; import type { ClientCertificate } from '@yaakapp-internal/models';
import { patchModel, settingsAtom } from '@yaakapp-internal/models'; import { patchModel, settingsAtom } from '@yaakapp-internal/models';
import classNames from 'classnames';
import { useAtomValue } from 'jotai'; import { useAtomValue } from 'jotai';
import { useRef } from 'react';
import { showConfirmDelete } from '../../lib/confirm'; import { showConfirmDelete } from '../../lib/confirm';
import { Button } from '../core/Button'; import { Button } from '../core/Button';
import { Checkbox } from '../core/Checkbox'; import { Checkbox } from '../core/Checkbox';
@@ -49,9 +49,11 @@ function CertificateEditor({ certificate, index, onUpdate, onRemove }: Certifica
// Determine certificate type for display // Determine certificate type for display
const certType = hasPfx ? 'PFX' : hasCrtKey ? 'CERT' : null; const certType = hasPfx ? 'PFX' : hasCrtKey ? 'CERT' : null;
const defaultOpen = useRef<boolean>(!certificate.host);
return ( return (
<DetailsBanner <DetailsBanner
open={defaultOpen.current}
summary={ summary={
<HStack alignItems="center" justifyContent="between" space={2} className="w-full"> <HStack alignItems="center" justifyContent="between" space={2} className="w-full">
<HStack space={1.5}> <HStack space={1.5}>
@@ -63,10 +65,14 @@ function CertificateEditor({ certificate, index, onUpdate, onRemove }: Certifica
onChange={(enabled) => updateField('enabled', enabled)} onChange={(enabled) => updateField('enabled', enabled)}
/> />
<InlineCode className={classNames(!certificate.host && 'border-danger')}> {certificate.host ? (
{certificate.host || <>&nbsp;</>} <InlineCode>
{certificate.port != null && `:${certificate.port}`} {certificate.host || <>&nbsp;</>}
</InlineCode> {certificate.port != null && `:${certificate.port}`}
</InlineCode>
) : (
<span className="italic text-sm text-text-subtlest">Configure Certificate</span>
)}
{certType && <InlineCode>{certType}</InlineCode>} {certType && <InlineCode>{certType}</InlineCode>}
</HStack> </HStack>
<IconButton <IconButton