InternalOnlyConfiguration.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import { useParams } from 'common'
  2. import { ChevronRight } from 'lucide-react'
  3. import { UseFormReturn } from 'react-hook-form'
  4. import { type CloudProvider } from 'shared-data'
  5. import {
  6. Collapsible,
  7. CollapsibleContent,
  8. CollapsibleTrigger,
  9. FormControl,
  10. FormField,
  11. Input,
  12. } from 'ui'
  13. import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
  14. import { CloudProviderSelector } from './CloudProviderSelector'
  15. import { HighAvailabilityInput } from './HighAvailabilityInput'
  16. import { PostgresVersionSelector } from './PostgresVersionSelector'
  17. import { CreateProjectForm } from './ProjectCreation.schema'
  18. import Panel from '@/components/ui/Panel'
  19. interface InternalOnlyConfigurationProps {
  20. form: UseFormReturn<CreateProjectForm>
  21. }
  22. export const InternalOnlyConfiguration = ({ form }: InternalOnlyConfigurationProps) => {
  23. const { slug } = useParams()
  24. const showNonProdFields = process.env.NEXT_PUBLIC_ENVIRONMENT !== 'prod'
  25. return (
  26. <Panel.Content>
  27. <Collapsible>
  28. <CollapsibleTrigger className="group/advanced-trigger font-mono uppercase tracking-widest text-xs flex items-center gap-1 text-foreground-lighter/75 hover:text-foreground-light transition data-open:text-foreground-light">
  29. Internal-only Configuration
  30. <ChevronRight
  31. size={16}
  32. strokeWidth={1}
  33. className="mr-2 group-data-open/advanced-trigger:rotate-90 group-hover/advanced-trigger:text-foreground-light transition"
  34. />
  35. </CollapsibleTrigger>
  36. <CollapsibleContent className="pt-2 data-closed:animate-collapsible-up data-open:animate-collapsible-down flex flex-col gap-y-6">
  37. <div>
  38. <p className="text-xs text-foreground-lighter mb-6">
  39. These settings are only visible to internal staff
  40. </p>
  41. <div className="flex flex-col gap-y-4">
  42. <FormField
  43. control={form.control}
  44. name="postgresVersionSelection"
  45. render={({ field }) => (
  46. <PostgresVersionSelector
  47. field={field}
  48. form={form}
  49. cloudProvider={form.getValues('cloudProvider') as CloudProvider}
  50. organizationSlug={slug}
  51. dbRegion={form.getValues('dbRegion')}
  52. />
  53. )}
  54. />
  55. <HighAvailabilityInput form={form} />
  56. </div>
  57. </div>
  58. {showNonProdFields && (
  59. <div>
  60. <p className="text-xs text-foreground-lighter mb-6">
  61. The settings below are only applicable for local/staging projects
  62. </p>
  63. <div className="flex flex-col gap-y-4">
  64. <CloudProviderSelector form={form} />
  65. <FormField
  66. control={form.control}
  67. name="postgresVersion"
  68. render={({ field }) => (
  69. <FormItemLayout
  70. label="Custom Postgres version"
  71. layout="horizontal"
  72. description="Specify a custom version of Postgres (defaults to the latest)."
  73. >
  74. <FormControl>
  75. <Input placeholder="e.g 17.6.1.104" {...field} autoComplete="off" />
  76. </FormControl>
  77. </FormItemLayout>
  78. )}
  79. />
  80. <FormField
  81. control={form.control}
  82. name="instanceType"
  83. render={({ field }) => (
  84. <FormItemLayout
  85. label="Custom instance type"
  86. layout="horizontal"
  87. description="Specify a custom instance type."
  88. >
  89. <FormControl>
  90. <Input placeholder="e.g t3.nano" {...field} autoComplete="off" />
  91. </FormControl>
  92. </FormItemLayout>
  93. )}
  94. />
  95. </div>
  96. </div>
  97. )}
  98. </CollapsibleContent>
  99. </Collapsible>
  100. </Panel.Content>
  101. )
  102. }