PartitionConfigFields.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { UseFormReturn } from 'react-hook-form'
  2. import {
  3. FormField,
  4. InputGroup,
  5. InputGroupAddon,
  6. InputGroupInput,
  7. InputGroupText,
  8. Separator,
  9. SheetSection,
  10. } from 'ui'
  11. import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
  12. import { CreateQueueForm } from './CreateQueueSheet.schema'
  13. export function PartitionConfigFields({ form }: { form: UseFormReturn<CreateQueueForm> }) {
  14. const queueType = form.watch('values.type')
  15. if (queueType !== 'partitioned') return null
  16. return (
  17. <>
  18. <SheetSection className="flex flex-col gap-3">
  19. <FormField
  20. control={form.control}
  21. name="values.partitionInterval"
  22. render={({ field: { ref, ...rest } }) => (
  23. <FormItemLayout
  24. label="Partition interval"
  25. description="Number of messages per partition"
  26. className="gap-1"
  27. >
  28. <InputGroup>
  29. <InputGroupInput {...rest} type="number" placeholder="10000" />
  30. <InputGroupAddon align="inline-end">
  31. <InputGroupText>messages</InputGroupText>
  32. </InputGroupAddon>
  33. </InputGroup>
  34. </FormItemLayout>
  35. )}
  36. />
  37. <FormField
  38. control={form.control}
  39. name="values.retentionInterval"
  40. render={({ field: { ref, ...rest } }) => (
  41. <FormItemLayout
  42. label="Retention interval"
  43. description="Partitions older than this many messages behind the latest will be dropped"
  44. className="gap-1"
  45. >
  46. <InputGroup>
  47. <InputGroupInput {...rest} type="number" placeholder="10000" />
  48. <InputGroupAddon align="inline-end">
  49. <InputGroupText>messages</InputGroupText>
  50. </InputGroupAddon>
  51. </InputGroup>
  52. </FormItemLayout>
  53. )}
  54. />
  55. </SheetSection>
  56. <Separator />
  57. </>
  58. )
  59. }