AdvancedConfiguration.tsx 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import { useFlag } from 'common'
  2. import { ChevronRight } from 'lucide-react'
  3. import { UseFormReturn } from 'react-hook-form'
  4. import {
  5. Badge,
  6. cn,
  7. Collapsible,
  8. CollapsibleContent,
  9. CollapsibleTrigger,
  10. FormControl,
  11. FormField,
  12. FormItem,
  13. RadioGroupStacked,
  14. RadioGroupStackedItem,
  15. Tooltip,
  16. TooltipContent,
  17. TooltipTrigger,
  18. } from 'ui'
  19. import { Admonition } from 'ui-patterns'
  20. import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
  21. import { CreateProjectForm } from './ProjectCreation.schema'
  22. import { DocsButton } from '@/components/ui/DocsButton'
  23. import Panel from '@/components/ui/Panel'
  24. import { DOCS_URL } from '@/lib/constants'
  25. interface AdvancedConfigurationProps {
  26. form: UseFormReturn<CreateProjectForm>
  27. }
  28. export const AdvancedConfiguration = ({ form }: AdvancedConfigurationProps) => {
  29. const disableOrioleProjectCreation = useFlag('disableOrioleProjectCreation')
  30. return (
  31. <Panel.Content>
  32. <Collapsible>
  33. <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">
  34. Advanced Configuration
  35. <ChevronRight
  36. size={16}
  37. strokeWidth={1}
  38. className="mr-2 group-data-open/advanced-trigger:rotate-90 group-hover/advanced-trigger:text-foreground-light transition"
  39. />
  40. </CollapsibleTrigger>
  41. <CollapsibleContent
  42. className={cn(
  43. 'pt-2 data-closed:animate-collapsible-up data-open:animate-collapsible-down'
  44. )}
  45. >
  46. <p className="text-xs text-foreground-lighter mb-6">
  47. These settings cannot be changed after the project is created
  48. </p>
  49. <FormField
  50. name="useOrioleDb"
  51. control={form.control}
  52. render={({ field }) => (
  53. <>
  54. <FormItemLayout
  55. layout="horizontal"
  56. label="Postgres Type"
  57. className="[&>div>label]:break-normal!"
  58. >
  59. <FormControl>
  60. <RadioGroupStacked
  61. // Due to radio group not supporting boolean values
  62. // value is converted to boolean
  63. onValueChange={(value) => field.onChange(value === 'true')}
  64. defaultValue={field.value.toString()}
  65. >
  66. <FormItem asChild>
  67. <FormControl>
  68. <RadioGroupStackedItem
  69. value="false"
  70. // @ts-ignore
  71. label={
  72. <>
  73. Postgres
  74. <Badge>Default</Badge>
  75. </>
  76. }
  77. description="Recommended for production workloads"
  78. className="[&>div>div>p]:text-left [&>div>div>p]:text-xs [&>div>div>label]:flex [&>div>div>label]:items-center [&>div>div>label]:gap-x-2"
  79. />
  80. </FormControl>
  81. </FormItem>
  82. <FormItem asChild>
  83. <FormControl>
  84. <Tooltip>
  85. <TooltipTrigger asChild>
  86. <RadioGroupStackedItem
  87. value="true"
  88. // @ts-ignore
  89. label={
  90. <>
  91. Postgres with OrioleDB
  92. <Badge variant="warning">Alpha</Badge>
  93. </>
  94. }
  95. description="Not recommended for production workloads"
  96. className={cn(
  97. '[&>div>div>p]:text-left [&>div>div>p]:text-xs [&>div>div>label]:flex [&>div>div>label]:items-center [&>div>div>label]:gap-x-2',
  98. form.getValues('useOrioleDb') ? 'rounded-b-none!' : ''
  99. )}
  100. disabled={disableOrioleProjectCreation}
  101. />
  102. </TooltipTrigger>
  103. {disableOrioleProjectCreation && (
  104. <TooltipContent side="right" className="w-60 text-center">
  105. OrioleDB is temporarily disabled for new projects. Please try again
  106. later.
  107. </TooltipContent>
  108. )}
  109. </Tooltip>
  110. </FormControl>
  111. </FormItem>
  112. </RadioGroupStacked>
  113. </FormControl>
  114. {form.getValues('useOrioleDb') && (
  115. <Admonition
  116. type="warning"
  117. className="rounded-t-none [&>div]:text-xs"
  118. title="OrioleDB is not production ready"
  119. description="Postgres with OrioleDB extension is currently in Public Alpha and not recommended for production usage yet."
  120. >
  121. <DocsButton className="mt-2" href={`${DOCS_URL}/guides/database/orioledb`} />
  122. </Admonition>
  123. )}
  124. </FormItemLayout>
  125. </>
  126. )}
  127. />
  128. </CollapsibleContent>
  129. </Collapsible>
  130. </Panel.Content>
  131. )
  132. }