PolicySelection.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { noop } from 'lodash'
  2. import { Edit, ExternalLink, FlaskConical, Grid } from 'lucide-react'
  3. import { Alert, AlertDescription, AlertTitle, Button, Modal } from 'ui'
  4. import CardButton from '@/components/ui/CardButton'
  5. interface PolicySelectionProps {
  6. description: string
  7. showAssistantPreview: boolean
  8. onViewTemplates: () => void
  9. onViewEditor: () => void
  10. onToggleFeaturePreviewModal?: () => void
  11. }
  12. const PolicySelection = ({
  13. description = '',
  14. showAssistantPreview,
  15. onViewTemplates = noop,
  16. onViewEditor = noop,
  17. onToggleFeaturePreviewModal,
  18. }: PolicySelectionProps) => {
  19. return (
  20. <Modal.Content className="space-y-4 py-4">
  21. <div className="flex flex-col gap-y-2">
  22. <p className="text-sm text-foreground-light">{description}</p>
  23. <div className="grid grid-cols-1 gap-2 lg:grid-cols-1">
  24. <CardButton
  25. title="Get started quickly"
  26. description="Create a policy from a template"
  27. icon={
  28. <div className="flex">
  29. <div
  30. className="
  31. flex h-8 w-8 items-center
  32. justify-center
  33. rounded-sm bg-foreground text-background
  34. "
  35. >
  36. <Grid size={14} strokeWidth={2} />
  37. </div>
  38. </div>
  39. }
  40. onClick={onViewTemplates}
  41. />
  42. <CardButton
  43. title="For full customization"
  44. description="Create a policy from scratch"
  45. icon={
  46. <div className="flex">
  47. <div
  48. className="
  49. flex h-8 w-8 items-center
  50. justify-center
  51. rounded-sm bg-foreground text-background
  52. "
  53. >
  54. <Edit size={14} strokeWidth={2} />
  55. </div>
  56. </div>
  57. }
  58. onClick={onViewEditor}
  59. />
  60. </div>
  61. </div>
  62. {showAssistantPreview && onToggleFeaturePreviewModal !== undefined && (
  63. <Alert>
  64. <FlaskConical />
  65. <AlertTitle>Try the new Briven Assistant for RLS policies</AlertTitle>
  66. <AlertDescription>
  67. Create RLS policies for your tables with the help of AI
  68. </AlertDescription>
  69. <div className="flex items-center gap-x-2 mt-3">
  70. <Button type="default" onClick={onToggleFeaturePreviewModal}>
  71. Toggle feature preview
  72. </Button>
  73. <Button asChild type="default" icon={<ExternalLink strokeWidth={1.5} />}>
  74. <a
  75. href="https://supabase.com/blog/studio-introducing-assistant#introducing-the-supabase-assistant"
  76. target="_blank"
  77. rel="noreferrer"
  78. >
  79. Learn more
  80. </a>
  81. </Button>
  82. </div>
  83. </Alert>
  84. )}
  85. </Modal.Content>
  86. )
  87. }
  88. export default PolicySelection