Merge pull request 'The Federation admin page like the mockup' (#153) from feat/ui-federation into main
This commit is contained in:
commit
d207787575
11 changed files with 191 additions and 99 deletions
|
|
@ -389,9 +389,12 @@
|
|||
"address": "Public address",
|
||||
"addressHint": "Where friends reach this server, like https://music.example.org. Plain http is only for a network of your own.",
|
||||
"saveSettings": "Save settings",
|
||||
"keyOfThis": "Key of this server: {{id}}.",
|
||||
"keyOfThis": "Key of this server",
|
||||
"thisServer": "This server",
|
||||
"keyHint": "The other admin sees the same key for your server: compare them to be sure.",
|
||||
"invites": "Invites",
|
||||
"makeTitle": "Invite a friend",
|
||||
"useTitle": "You got an invite",
|
||||
"makeInvite": "Make an invite",
|
||||
"invite": "Invite",
|
||||
"copy": "Copy",
|
||||
|
|
|
|||
|
|
@ -389,9 +389,12 @@
|
|||
"address": "Indirizzo pubblico",
|
||||
"addressHint": "Dove gli amici raggiungono questo server, come https://musica.example.org. Il semplice http va bene solo su una rete tua.",
|
||||
"saveSettings": "Salva le impostazioni",
|
||||
"keyOfThis": "Chiave di questo server: {{id}}.",
|
||||
"keyOfThis": "Chiave di questo server",
|
||||
"thisServer": "Questo server",
|
||||
"keyHint": "L'altro admin vede la stessa chiave per il tuo server: confrontatele per essere sicuri.",
|
||||
"invites": "Inviti",
|
||||
"makeTitle": "Invita un amico",
|
||||
"useTitle": "Hai ricevuto un invito",
|
||||
"makeInvite": "Crea un invito",
|
||||
"invite": "Invito",
|
||||
"copy": "Copia",
|
||||
|
|
|
|||
4
web/src/lib/groupKey.ts
Normal file
4
web/src/lib/groupKey.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
/** A key in groups of four, the way two admins read it to each other: "81ae 4d57 0686 356c". */
|
||||
export function groupKey(id: string): string {
|
||||
return id.replace(/(.{4})(?=.)/g, '$1 ')
|
||||
}
|
||||
11
web/src/pages/admin/FederationBlock.tsx
Normal file
11
web/src/pages/admin/FederationBlock.tsx
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import type { ReactNode } from 'react'
|
||||
|
||||
/** A part of the Federation page: its title, then what is in it, divided from the part before by a line. */
|
||||
export default function FederationBlock({ title, children }: { title: string; children: ReactNode }) {
|
||||
return (
|
||||
<section aria-label={title} className="flex flex-col gap-5 border-t border-border pt-10">
|
||||
<h2 className="text-[28px] leading-none font-extrabold tracking-tight">{title}</h2>
|
||||
{children}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
|
@ -4,6 +4,8 @@ import { useApproveFriend, useCheckFriend, useRemoveFriend, type FederationFrien
|
|||
import { Button } from '@/components/ui/button'
|
||||
import Confirm from './Confirm'
|
||||
import { errorText } from './errorText'
|
||||
import { groupKey } from '@/lib/groupKey'
|
||||
import FederationBlock from './FederationBlock'
|
||||
|
||||
const SCOPES = ['admin.federation.errors', 'admin.errors']
|
||||
|
||||
|
|
@ -17,36 +19,52 @@ export default function FederationFriends({ friends }: { friends: FederationFrie
|
|||
const error = approve.error ?? remove.error ?? check.error
|
||||
|
||||
return (
|
||||
<section aria-label={t('admin.federation.friends')} className="flex flex-col gap-3">
|
||||
<h3 className="text-lg font-bold">{t('admin.federation.friends')}</h3>
|
||||
<FederationBlock title={t('admin.federation.friends')}>
|
||||
{friends.length === 0 ? (
|
||||
<p className="text-muted-foreground">{t('admin.federation.none')}</p>
|
||||
) : (
|
||||
<ul className="flex flex-col gap-3">
|
||||
<ul className="flex flex-col">
|
||||
{friends.map((friend) => (
|
||||
<li key={friend.id} className="flex flex-wrap items-center justify-between gap-3 border-b border-border py-4">
|
||||
<div className="flex min-w-0 flex-col gap-1">
|
||||
<span className="font-bold">{friend.name}</span>
|
||||
<span className="break-all text-sm">{friend.address}</span>
|
||||
<span className="flex flex-wrap gap-x-3 text-sm text-muted-foreground">
|
||||
<span>{t(`admin.federation.state.${friend.state}`)}</span>
|
||||
<span>{t('admin.federation.keyOf', { id: friend.key_id })}</span>
|
||||
<span className="flex flex-wrap items-center gap-3">
|
||||
<span className="text-[22px] font-bold">{friend.name}</span>
|
||||
<span className="rounded-full border border-friend px-3 text-[13px] font-semibold text-friend">
|
||||
{t(`admin.federation.state.${friend.state}`)}
|
||||
</span>
|
||||
</span>
|
||||
<span className="break-all text-sm">{friend.address}</span>
|
||||
<span className="text-[13px] text-muted-foreground tabular-nums">{t('admin.federation.keyOf', { id: groupKey(friend.key_id) })}</span>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{friend.state === 'incoming' && (
|
||||
<Button aria-label={t('admin.federation.approveOne', { name: friend.name })} disabled={approve.isPending} onClick={() => approve.mutate(friend.id)}>
|
||||
<Button
|
||||
aria-label={t('admin.federation.approveOne', {
|
||||
name: friend.name,
|
||||
})}
|
||||
disabled={approve.isPending}
|
||||
onClick={() => approve.mutate(friend.id)}
|
||||
>
|
||||
{t('admin.federation.approve')}
|
||||
</Button>
|
||||
)}
|
||||
{friend.state === 'outgoing' && (
|
||||
<Button variant="outline" aria-label={t('admin.federation.checkOne', { name: friend.name })} disabled={check.isPending} onClick={() => check.mutate(friend.id)}>
|
||||
<Button
|
||||
variant="outline"
|
||||
aria-label={t('admin.federation.checkOne', {
|
||||
name: friend.name,
|
||||
})}
|
||||
disabled={check.isPending}
|
||||
onClick={() => check.mutate(friend.id)}
|
||||
>
|
||||
{t('admin.federation.check')}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
variant="outline"
|
||||
aria-label={t(`admin.federation.remove.${friend.state}One`, { name: friend.name })}
|
||||
aria-label={t(`admin.federation.remove.${friend.state}One`, {
|
||||
name: friend.name,
|
||||
})}
|
||||
onClick={() => setRemoving(friend)}
|
||||
>
|
||||
{t(`admin.federation.remove.${friend.state}`)}
|
||||
|
|
@ -74,6 +92,6 @@ export default function FederationFriends({ friends }: { friends: FederationFrie
|
|||
}}
|
||||
/>
|
||||
)}
|
||||
</section>
|
||||
</FederationBlock>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { Button } from '@/components/ui/button'
|
|||
import { Input } from '@/components/ui/input'
|
||||
import { Label } from '@/components/ui/label'
|
||||
import { errorText } from './errorText'
|
||||
import FederationBlock from './FederationBlock'
|
||||
|
||||
const SCOPES = ['admin.federation.errors', 'admin.errors']
|
||||
|
||||
|
|
@ -25,13 +26,18 @@ function MakeInvite() {
|
|||
}
|
||||
}
|
||||
|
||||
const until = invite ? new Intl.DateTimeFormat(i18n.language, { dateStyle: 'medium', timeStyle: 'short' }).format(new Date(invite.expires_at)) : ''
|
||||
const until = invite
|
||||
? new Intl.DateTimeFormat(i18n.language, {
|
||||
dateStyle: 'medium',
|
||||
timeStyle: 'short',
|
||||
}).format(new Date(invite.expires_at))
|
||||
: ''
|
||||
|
||||
return (
|
||||
<div className="flex max-w-xl flex-col gap-3">
|
||||
<div className="flex flex-col gap-3">
|
||||
<h3 className="text-xl font-bold">{t('admin.federation.makeTitle')}</h3>
|
||||
<div>
|
||||
<Button
|
||||
variant="outline"
|
||||
disabled={create.isPending}
|
||||
onClick={() => {
|
||||
setCopied(false)
|
||||
|
|
@ -76,7 +82,8 @@ function UseInvite() {
|
|||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={submit} className="flex max-w-xl flex-col gap-2">
|
||||
<form onSubmit={submit} className="flex flex-col gap-2">
|
||||
<h3 className="text-xl font-bold">{t('admin.federation.useTitle')}</h3>
|
||||
<Label htmlFor="federation-use">{t('admin.federation.use')}</Label>
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<Input id="federation-use" className="min-w-60 flex-1" value={text} autoCapitalize="off" spellCheck={false} onChange={(e) => setText(e.target.value)} />
|
||||
|
|
@ -98,10 +105,11 @@ function UseInvite() {
|
|||
export default function FederationInvites() {
|
||||
const { t } = useTranslation()
|
||||
return (
|
||||
<section aria-label={t('admin.federation.invites')} className="flex flex-col gap-4">
|
||||
<h3 className="text-lg font-bold">{t('admin.federation.invites')}</h3>
|
||||
<MakeInvite />
|
||||
<UseInvite />
|
||||
</section>
|
||||
<FederationBlock title={t('admin.federation.invites')}>
|
||||
<div className="grid grid-cols-[repeat(auto-fit,minmax(min(360px,100%),1fr))] gap-x-10 gap-y-8">
|
||||
<MakeInvite />
|
||||
<UseInvite />
|
||||
</div>
|
||||
</FederationBlock>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { Button } from '@/components/ui/button'
|
|||
import { Input } from '@/components/ui/input'
|
||||
import { Label } from '@/components/ui/label'
|
||||
import { errorText } from './errorText'
|
||||
import FederationBlock from './FederationBlock'
|
||||
|
||||
const SCOPES = ['admin.federation.errors', 'admin.errors']
|
||||
|
||||
|
|
@ -22,16 +23,25 @@ function Form({ federation }: { federation: Federation }) {
|
|||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={submit} className="flex max-w-xl flex-col gap-4">
|
||||
<div className="flex flex-col gap-2">
|
||||
<Label htmlFor="federation-streams">{t('admin.federation.streams')}</Label>
|
||||
<Input id="federation-streams" type="number" inputMode="numeric" value={streams} onChange={(e) => setStreams(e.target.value)} />
|
||||
<p className="text-sm text-muted-foreground">{t('admin.federation.streamsHint')}</p>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<Label htmlFor="federation-rate">{t('admin.federation.rate')}</Label>
|
||||
<Input id="federation-rate" type="number" inputMode="numeric" value={rate} onChange={(e) => setRate(e.target.value)} />
|
||||
<p className="text-sm text-muted-foreground">{t('admin.federation.rateHint')}</p>
|
||||
<form onSubmit={submit} className="flex flex-col gap-6">
|
||||
<div className="grid grid-cols-[repeat(auto-fit,minmax(min(360px,100%),1fr))] gap-x-10 gap-y-6">
|
||||
<div className="flex flex-col gap-2">
|
||||
<Label htmlFor="federation-streams">{t('admin.federation.streams')}</Label>
|
||||
<Input
|
||||
id="federation-streams"
|
||||
className="w-36 tabular-nums"
|
||||
type="number"
|
||||
inputMode="numeric"
|
||||
value={streams}
|
||||
onChange={(e) => setStreams(e.target.value)}
|
||||
/>
|
||||
<p className="text-sm text-muted-foreground">{t('admin.federation.streamsHint')}</p>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<Label htmlFor="federation-rate">{t('admin.federation.rate')}</Label>
|
||||
<Input id="federation-rate" className="w-36 tabular-nums" type="number" inputMode="numeric" value={rate} onChange={(e) => setRate(e.target.value)} />
|
||||
<p className="text-sm text-muted-foreground">{t('admin.federation.rateHint')}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<Button type="submit" variant="outline" disabled={unchanged || !ready || update.isPending}>
|
||||
|
|
@ -51,10 +61,9 @@ function Form({ federation }: { federation: Federation }) {
|
|||
export default function FederationLimits({ federation }: { federation: Federation }) {
|
||||
const { t } = useTranslation()
|
||||
return (
|
||||
<section aria-label={t('admin.federation.limits')} className="flex flex-col gap-3">
|
||||
<h3 className="text-lg font-bold">{t('admin.federation.limits')}</h3>
|
||||
<FederationBlock title={t('admin.federation.limits')}>
|
||||
{/* Remounts the form when the server's values change, so it always starts from what the server keeps. */}
|
||||
<Form key={`${federation.max_streams}|${federation.max_kib_per_sec}`} federation={federation} />
|
||||
</section>
|
||||
</FederationBlock>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,8 @@ test('turning it on asks first with what is sent, and nothing is sent before the
|
|||
|
||||
await user.click(within(dialog).getByRole('button', { name: 'Turn on' }))
|
||||
await waitFor(() => expect(bodies.PUT).toEqual([{ enabled: true }]))
|
||||
expect(await screen.findByText(/Key of this server: abcdef0123456789/)).toBeInTheDocument()
|
||||
expect(await screen.findByText('abcd ef01 2345 6789')).toBeInTheDocument()
|
||||
expect(screen.getByText('Key of this server')).toBeInTheDocument()
|
||||
expect(screen.getByRole('switch', { name: 'Federation' })).toHaveAttribute('aria-checked', 'true')
|
||||
})
|
||||
|
||||
|
|
@ -221,7 +222,27 @@ test('each friend shows where it is and its key, so two admins can compare them'
|
|||
renderPage()
|
||||
const item = (await screen.findByText('Anna')).closest('li') as HTMLElement
|
||||
expect(within(item).getByText('https://anna.example.org')).toBeInTheDocument()
|
||||
expect(within(item).getByText(/feedfeedfeedfeed/)).toBeInTheDocument()
|
||||
expect(within(item).getByText(/feed feed feed feed/)).toBeInTheDocument()
|
||||
})
|
||||
|
||||
test('the key of this server is big and in groups of four, in the colour of this server', async () => {
|
||||
server({ enabled: true, key_id: 'abcdef0123456789' })
|
||||
renderPage()
|
||||
expect(await screen.findByText('abcd ef01 2345 6789')).toHaveClass('text-primary', 'text-3xl')
|
||||
})
|
||||
|
||||
test('the state of a friend is a pill in the friend colour', async () => {
|
||||
server({ enabled: true, key_id: 'abcdef0123456789', friends: [friend({ name: 'Bruno', state: 'incoming', approved_at: null })] })
|
||||
renderPage()
|
||||
expect(await screen.findByText('Wants to be your friend')).toHaveClass('border-friend', 'text-friend', 'rounded-full')
|
||||
})
|
||||
|
||||
test('the parts are divided by lines, not put in boxes', async () => {
|
||||
server({ enabled: true, key_id: 'abcdef0123456789' })
|
||||
renderPage()
|
||||
for (const name of ['Invites', 'Friends', 'Limits for each friend', 'Recent requests']) {
|
||||
expect(await screen.findByRole('region', { name })).toHaveClass('border-t', 'border-border')
|
||||
}
|
||||
})
|
||||
|
||||
test('removing a friend asks first and says the other server is not told', async () => {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useFederation, useUpdateFederation } from '@/api/adminFederation'
|
||||
import Section from '@/components/Section'
|
||||
import { ErrorMessage, Loading } from '@/components/Status'
|
||||
import { Switch } from '@/components/ui/switch'
|
||||
import Confirm from './Confirm'
|
||||
|
|
@ -27,39 +26,42 @@ export default function FederationPage() {
|
|||
const label = t('admin.sectionFederation')
|
||||
|
||||
return (
|
||||
<Section title={label}>
|
||||
<p className="text-sm text-muted-foreground">{t('admin.federation.intro')}</p>
|
||||
{federation.isError ? (
|
||||
<ErrorMessage error={federation.error} onRetry={() => void federation.refetch()} />
|
||||
) : federation.isPending ? (
|
||||
<Loading />
|
||||
) : (
|
||||
<>
|
||||
<div className="flex flex-wrap items-center gap-4">
|
||||
<Switch
|
||||
checked={federation.data.enabled}
|
||||
aria-label={label}
|
||||
disabled={update.isPending}
|
||||
onClick={() => (federation.data.enabled ? update.mutate({ enabled: false }) : setAsking(true))}
|
||||
/>
|
||||
<span className="text-sm text-muted-foreground">{t(federation.data.enabled ? 'admin.federation.on' : 'admin.federation.off')}</span>
|
||||
</div>
|
||||
<p className="max-w-prose text-sm">{federation.data.sends}</p>
|
||||
{update.isError && (
|
||||
<p role="alert" className="text-sm text-destructive">
|
||||
{errorText(t, update.error, FEDERATION_ERRORS)}
|
||||
</p>
|
||||
)}
|
||||
<section aria-label={label} className="flex max-w-[920px] flex-col gap-10">
|
||||
<div className="flex flex-col gap-5">
|
||||
<h2 className="text-4xl leading-none font-extrabold tracking-tight">{label}</h2>
|
||||
<p className="max-w-[680px] text-[17px] text-pretty">{t('admin.federation.intro')}</p>
|
||||
{federation.isError ? (
|
||||
<ErrorMessage error={federation.error} onRetry={() => void federation.refetch()} />
|
||||
) : federation.isPending ? (
|
||||
<Loading />
|
||||
) : (
|
||||
<>
|
||||
<div className="flex flex-wrap items-center gap-4">
|
||||
<Switch
|
||||
checked={federation.data.enabled}
|
||||
aria-label={label}
|
||||
disabled={update.isPending}
|
||||
onClick={() => (federation.data.enabled ? update.mutate({ enabled: false }) : setAsking(true))}
|
||||
/>
|
||||
<span className="text-[17px] font-bold">{t(federation.data.enabled ? 'admin.federation.on' : 'admin.federation.off')}</span>
|
||||
</div>
|
||||
<p className="max-w-[680px] text-muted-foreground text-pretty">{federation.data.sends}</p>
|
||||
{update.isError && (
|
||||
<p role="alert" className="text-sm text-destructive">
|
||||
{errorText(t, update.error, FEDERATION_ERRORS)}
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{federation.data.enabled && (
|
||||
<>
|
||||
<FederationSettings federation={federation.data} />
|
||||
<FederationInvites />
|
||||
<FederationFriends friends={federation.data.friends} />
|
||||
<FederationLimits federation={federation.data} />
|
||||
<FederationRequests />
|
||||
</>
|
||||
)}
|
||||
{federation.data?.enabled && (
|
||||
<>
|
||||
<FederationSettings federation={federation.data} />
|
||||
<FederationInvites />
|
||||
<FederationFriends friends={federation.data.friends} />
|
||||
<FederationLimits federation={federation.data} />
|
||||
<FederationRequests />
|
||||
</>
|
||||
)}
|
||||
|
||||
|
|
@ -75,6 +77,6 @@ export default function FederationPage() {
|
|||
}}
|
||||
/>
|
||||
)}
|
||||
</Section>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { useTranslation } from 'react-i18next'
|
||||
import { useFederationRequests } from '@/api/adminFederation'
|
||||
import { ErrorMessage, Loading } from '@/components/Status'
|
||||
import FederationBlock from './FederationBlock'
|
||||
|
||||
/** Every route a friend reads starts like this; the list shows the rest. */
|
||||
const PEER_PREFIX = '/api/v1/peer'
|
||||
|
|
@ -16,12 +17,14 @@ function size(bytes: number): string {
|
|||
export default function FederationRequests() {
|
||||
const { t, i18n } = useTranslation()
|
||||
const requests = useFederationRequests()
|
||||
const when = new Intl.DateTimeFormat(i18n.language, { dateStyle: 'short', timeStyle: 'medium' })
|
||||
const when = new Intl.DateTimeFormat(i18n.language, {
|
||||
dateStyle: 'short',
|
||||
timeStyle: 'medium',
|
||||
})
|
||||
|
||||
return (
|
||||
<section aria-label={t('admin.federation.requests')} className="flex flex-col gap-3">
|
||||
<h3 className="text-lg font-bold">{t('admin.federation.requests')}</h3>
|
||||
<p className="text-sm text-muted-foreground">{t('admin.federation.requestsHint')}</p>
|
||||
<FederationBlock title={t('admin.federation.requests')}>
|
||||
<p className="max-w-[620px] text-muted-foreground text-pretty">{t('admin.federation.requestsHint')}</p>
|
||||
{requests.isError ? (
|
||||
<ErrorMessage error={requests.error} onRetry={() => void requests.refetch()} />
|
||||
) : requests.isPending ? (
|
||||
|
|
@ -42,7 +45,7 @@ export default function FederationRequests() {
|
|||
</thead>
|
||||
<tbody>
|
||||
{requests.data.map((r, i) => (
|
||||
<tr key={`${r.at}-${i}`} className="border-t border-border">
|
||||
<tr key={`${r.at}-${i}`} className="border-t border-border tabular-nums">
|
||||
<td className="py-2 pr-4 whitespace-nowrap">{when.format(new Date(r.at))}</td>
|
||||
<td className="py-2 pr-4">{r.friend}</td>
|
||||
<td className="py-2 pr-4 font-mono whitespace-nowrap" title={r.route}>
|
||||
|
|
@ -56,6 +59,6 @@ export default function FederationRequests() {
|
|||
</table>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</FederationBlock>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import { Button } from '@/components/ui/button'
|
|||
import { Input } from '@/components/ui/input'
|
||||
import { Label } from '@/components/ui/label'
|
||||
import { errorText } from './errorText'
|
||||
import { groupKey } from '@/lib/groupKey'
|
||||
import FederationBlock from './FederationBlock'
|
||||
|
||||
const SCOPES = ['admin.federation.errors', 'admin.errors']
|
||||
|
||||
|
|
@ -21,24 +23,31 @@ function Form({ federation }: { federation: Federation }) {
|
|||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={submit} className="flex max-w-xl flex-col gap-4">
|
||||
<div className="flex flex-col gap-2">
|
||||
<Label htmlFor="federation-name">{t('admin.federation.name')}</Label>
|
||||
<Input id="federation-name" value={name} maxLength={60} autoCapitalize="off" spellCheck={false} onChange={(e) => setName(e.target.value)} />
|
||||
<p className="text-sm text-muted-foreground">{t('admin.federation.nameHint')}</p>
|
||||
<form onSubmit={submit} className="flex flex-col gap-6">
|
||||
<div className="grid grid-cols-[repeat(auto-fit,minmax(min(360px,100%),1fr))] gap-x-10 gap-y-6">
|
||||
<div className="flex flex-col gap-2">
|
||||
<Label htmlFor="federation-name">{t('admin.federation.name')}</Label>
|
||||
<Input id="federation-name" value={name} maxLength={60} autoCapitalize="off" spellCheck={false} onChange={(e) => setName(e.target.value)} />
|
||||
<p className="text-sm text-muted-foreground">{t('admin.federation.nameHint')}</p>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<Label htmlFor="federation-address">{t('admin.federation.address')}</Label>
|
||||
<Input
|
||||
id="federation-address"
|
||||
value={address}
|
||||
maxLength={300}
|
||||
inputMode="url"
|
||||
autoCapitalize="off"
|
||||
spellCheck={false}
|
||||
onChange={(e) => setAddress(e.target.value)}
|
||||
/>
|
||||
<p className="text-sm text-muted-foreground">{t('admin.federation.addressHint')}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<Label htmlFor="federation-address">{t('admin.federation.address')}</Label>
|
||||
<Input
|
||||
id="federation-address"
|
||||
value={address}
|
||||
maxLength={300}
|
||||
inputMode="url"
|
||||
autoCapitalize="off"
|
||||
spellCheck={false}
|
||||
onChange={(e) => setAddress(e.target.value)}
|
||||
/>
|
||||
<p className="text-sm text-muted-foreground">{t('admin.federation.addressHint')}</p>
|
||||
<div className="flex flex-col gap-1.5">
|
||||
<span className="font-semibold">{t('admin.federation.keyOfThis')}</span>
|
||||
<span className="text-3xl leading-tight font-bold tracking-wide text-primary tabular-nums">{groupKey(federation.key_id)}</span>
|
||||
<p className="max-w-[620px] text-sm text-muted-foreground text-pretty">{t('admin.federation.keyHint')}</p>
|
||||
</div>
|
||||
<div>
|
||||
<Button type="submit" variant="outline" disabled={unchanged || update.isPending}>
|
||||
|
|
@ -50,9 +59,6 @@ function Form({ federation }: { federation: Federation }) {
|
|||
{errorText(t, update.error, SCOPES)}
|
||||
</p>
|
||||
)}
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{t('admin.federation.keyOfThis', { id: federation.key_id })} {t('admin.federation.keyHint')}
|
||||
</p>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
|
|
@ -60,5 +66,9 @@ function Form({ federation }: { federation: Federation }) {
|
|||
/** The name friends see, the address they reach this server at, and the key of this server. */
|
||||
export default function FederationSettings({ federation }: { federation: Federation }) {
|
||||
// Remounts the form when the server's values change, so it always starts from what the server keeps.
|
||||
return <Form key={`${federation.name}|${federation.address}`} federation={federation} />
|
||||
return (
|
||||
<FederationBlock title={useTranslation().t('admin.federation.thisServer')}>
|
||||
<Form key={`${federation.name}|${federation.address}`} federation={federation} />
|
||||
</FederationBlock>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue