BucketsUpgradePlan.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { useParams } from 'common'
  2. import { AnalyticsBucket as AnalyticsBucketIcon, VectorBucket as VectorBucketIcon } from 'icons'
  3. import { EmptyStatePresentational } from 'ui-patterns'
  4. import { PageContainer } from 'ui-patterns/PageContainer'
  5. import { PageSection, PageSectionContent } from 'ui-patterns/PageSection'
  6. import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
  7. import { BUCKET_TYPES } from './Storage.constants'
  8. import { AlphaNotice } from '@/components/ui/AlphaNotice'
  9. import { UpgradePlanButton } from '@/components/ui/UpgradePlanButton'
  10. import { useProjectStorageConfigQuery } from '@/data/config/project-storage-config-query'
  11. import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
  12. import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
  13. export const BucketsUpgradePlan = ({ type }: { type: 'analytics' | 'vector' }) => {
  14. const { ref: projectRef } = useParams()
  15. const { isLoading: isLoadingStorageConfig } = useProjectStorageConfigQuery({ projectRef })
  16. const { data: organization, isLoading: isLoadingOrganization } = useSelectedOrganizationQuery()
  17. const { data: project, isLoading: isLoadingProject } = useSelectedProjectQuery()
  18. const isLoading =
  19. isLoadingStorageConfig || isLoadingOrganization || isLoadingProject || !organization || !project
  20. if (isLoading) {
  21. return (
  22. <PageContainer>
  23. <PageSection>
  24. <PageSectionContent className="flex flex-col gap-y-8">
  25. <GenericSkeletonLoader />
  26. </PageSectionContent>
  27. </PageSection>
  28. </PageContainer>
  29. )
  30. }
  31. const isFreePlan = organization.plan?.id === 'free'
  32. const isNanoCompute = project.infra_compute_size === 'nano'
  33. const requiresComputeUpgrade = !isFreePlan && isNanoCompute
  34. return (
  35. <PageContainer>
  36. <PageSection>
  37. <PageSectionContent className="flex flex-col gap-y-8">
  38. <AlphaNotice
  39. entity={type === 'analytics' ? 'Analytics buckets' : 'Vector buckets'}
  40. feedbackUrl={
  41. type === 'analytics'
  42. ? 'https://github.com/orgs/briven/discussions/40116'
  43. : 'https://github.com/orgs/briven/discussions/40815'
  44. }
  45. />
  46. <EmptyStatePresentational
  47. icon={type === 'analytics' ? AnalyticsBucketIcon : VectorBucketIcon}
  48. title={
  49. type === 'analytics'
  50. ? BUCKET_TYPES.analytics.valueProp
  51. : BUCKET_TYPES.vectors.valueProp
  52. }
  53. description={
  54. requiresComputeUpgrade
  55. ? `Upgrade your project's compute size to Micro or larger to use ${type} buckets`
  56. : `Upgrade to Pro to use ${type} buckets for your project`
  57. }
  58. >
  59. <UpgradePlanButton
  60. source={`${type}Buckets`}
  61. featureProposition={`use ${type} buckets`}
  62. addon={requiresComputeUpgrade ? 'computeSize' : undefined}
  63. />
  64. </EmptyStatePresentational>
  65. </PageSectionContent>
  66. </PageSection>
  67. </PageContainer>
  68. )
  69. }