Files

47 lines
1.5 KiB
TypeScript
Raw Permalink Normal View History

2026-10-05 18:10:18 -04:00
import { useAdminNodesGroupedByLocation } from '@/api/admin/nodes/queries';
import Select from '@/components/ui/Select';
import Label from '@/components/elements/Label';
2026-11-23 14:16:00 +00:00
import { useTranslation } from '@/sdk/localization';
2026-10-05 18:10:18 -04:00
interface Props {
id: string;
value: string;
onChange: (value: string) => void;
}
export default function DatabaseHostNodeSelect({ id, value, onChange }: Props) {
2026-11-23 14:16:00 +00:00
const { t } = useTranslation();
2026-10-05 18:10:18 -04:00
const { data: locations } = useAdminNodesGroupedByLocation();
const groups = [
{
2026-11-23 14:16:00 +00:00
label: t('Global'),
options: [{ value: '', label: t('None') }],
2026-10-05 18:10:18 -04:00
},
...(locations ?? []).map((group) => ({
label: `${group.location.attributes.long || group.location.attributes.short} (${group.location.attributes.short})`,
options: group.nodes.map((node) => ({
value: String(node.id),
label: `${node.name} (${node.fqdn})`,
})),
})),
];
return (
<div>
2026-11-23 14:16:00 +00:00
<Label htmlFor={id}>{t('Linked Node')}</Label>
2026-10-05 18:10:18 -04:00
<Select
id={id}
value={value}
2026-11-23 14:16:00 +00:00
placeholder={t('None')}
2026-10-05 18:10:18 -04:00
groups={groups}
disabled={locations === undefined}
onChange={(value) => onChange(String(value))}
/>
2026-10-08 16:53:20 -04:00
<p className='input-help'>
2026-11-23 14:16:00 +00:00
{t('Default to this database host when adding databases to servers on selected node.')}
2026-10-05 18:10:18 -04:00
</p>
</div>
);
}