refactor: Replace 'reach' field with 'public' boolean in service registration and related components

This commit is contained in:
2026-07-10 02:13:37 +00:00
parent fffc84e14c
commit 4feaa63da0
12 changed files with 112 additions and 220 deletions

View File

@@ -55,7 +55,7 @@ export function ServicesComponent() {
// Add form state
const [newDomain, setNewDomain] = useState('');
const [newBackendAddr, setNewBackendAddr] = useState('');
const [newReach, setNewReach] = useState<string>('public');
const [newPublic, setNewPublic] = useState(true);
const [newSubdomains, setNewSubdomains] = useState(false);
const [newTls, setNewTls] = useState<string>('passthrough');
@@ -68,7 +68,7 @@ export function ServicesComponent() {
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['services'] });
setShowAddForm(false);
setNewDomain(''); setNewBackendAddr(''); setNewReach('public'); setNewSubdomains(false); setNewTls('passthrough');
setNewDomain(''); setNewBackendAddr(''); setNewPublic(true); setNewSubdomains(false); setNewTls('passthrough');
},
});
@@ -147,7 +147,7 @@ export function ServicesComponent() {
</div>
<div className="flex items-center gap-6">
<label className="flex items-center gap-2 text-sm">
<Switch checked={newReach === 'public'} onCheckedChange={v => setNewReach(v ? 'public' : 'internal')} />
<Switch checked={newPublic} onCheckedChange={setNewPublic} />
Public
</label>
<label className="flex items-center gap-2 text-sm">
@@ -165,7 +165,7 @@ export function ServicesComponent() {
onClick={() => registerMutation.mutate({
domain: newDomain,
backend: { address: newBackendAddr, type: newTls === 'passthrough' ? 'tcp-passthrough' : 'http' },
reach: newReach, subdomains: newSubdomains, tls: newTls, source: 'manual',
public: newPublic, subdomains: newSubdomains, tls: newTls, source: 'manual',
})}>
{registerMutation.isPending ? <Loader2 className="h-3 w-3 animate-spin mr-1" /> : <Plus className="h-3 w-3 mr-1" />}
Register
@@ -196,7 +196,7 @@ export function ServicesComponent() {
{services.map(service => {
const isExpanded = expandedDomains.has(service.domain);
const tlsStatus = getTlsStatus(service, certDomains);
const ddnsStatus2 = service.reach === 'public' ? 'ok' as const : 'na' as const;
const ddnsStatus2 = service.public ? 'ok' as const : 'na' as const;
const isPassthrough = service.tls === 'passthrough' || service.backend.type === 'tcp-passthrough';
return (
@@ -242,11 +242,11 @@ export function ServicesComponent() {
<div className="flex items-center gap-2">
<Switch
checked={service.reach === 'public'}
onCheckedChange={v => updateMutation.mutate({ domain: service.domain, updates: { reach: v ? 'public' : 'internal' } })}
checked={service.public}
onCheckedChange={v => updateMutation.mutate({ domain: service.domain, updates: { public: v } })}
disabled={updateMutation.isPending}
/>
<Label className="text-sm">{service.reach === 'public' ? 'Public' : 'Private'}</Label>
<Label className="text-sm">{service.public ? 'Public' : 'Private'}</Label>
</div>
<div className="flex items-center gap-2">