HighAvailabilityInput.tsx44 lines · main
| 1 | import Link from 'next/link' |
| 2 | import { UseFormReturn } from 'react-hook-form' |
| 3 | import { FormControl, FormField, Switch } from 'ui' |
| 4 | import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout' |
| 5 | |
| 6 | import { CreateProjectForm } from './ProjectCreation.schema' |
| 7 | import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements' |
| 8 | |
| 9 | interface HighAvailabilityInputProps { |
| 10 | form: UseFormReturn<CreateProjectForm> |
| 11 | } |
| 12 | |
| 13 | export const HighAvailabilityInput = ({ form }: HighAvailabilityInputProps) => { |
| 14 | const { hasAccess } = useCheckEntitlements('instances.high_availability') |
| 15 | |
| 16 | if (!hasAccess) return null |
| 17 | |
| 18 | return ( |
| 19 | <FormField |
| 20 | control={form.control} |
| 21 | name="highAvailability" |
| 22 | render={({ field }) => ( |
| 23 | <FormItemLayout |
| 24 | label="High Availability" |
| 25 | description={ |
| 26 | <> |
| 27 | Powered by{' '} |
| 28 | <Link href="https://multigres.com/" target="_blank" className="text-link"> |
| 29 | Multigres |
| 30 | </Link> |
| 31 | : horizontally scalable Postgres for multi-tenant, highly available, globally |
| 32 | distributed deployments while staying true to standard Postgres. |
| 33 | </> |
| 34 | } |
| 35 | layout="horizontal" |
| 36 | > |
| 37 | <FormControl> |
| 38 | <Switch checked={field.value} onCheckedChange={field.onChange} /> |
| 39 | </FormControl> |
| 40 | </FormItemLayout> |
| 41 | )} |
| 42 | /> |
| 43 | ) |
| 44 | } |