useIsETLPrivateAlpha.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { useFlag } from 'common'
  2. import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
  3. /**
  4. * Organization level opt in for ETL private alpha, there's 2 flags we're using which controls
  5. * the individual destination types. Access to the ETL UI (`useIsETLPrivateAlpha`) will just
  6. * check if the org has access to at least one of the destination types
  7. */
  8. const useIsCurrentOrgInFlagList = (flag: string) => {
  9. const flagValue = useFlag(flag)
  10. const { data: organization } = useSelectedOrganizationQuery()
  11. const allowedOrgSlugs =
  12. typeof flagValue === 'string'
  13. ? (flagValue as string).split(',').map((x: string) => x.trim())
  14. : []
  15. // [Joshen] Override for to enable for all organizations by setting the flag value as `all`
  16. if (allowedOrgSlugs.includes('all')) return true
  17. // [Joshen] Otherwise fallback to checking against org slug
  18. return allowedOrgSlugs.includes(organization?.slug ?? '')
  19. }
  20. export const useIsETLBigQueryPrivateAlpha = () => {
  21. return useIsCurrentOrgInFlagList('etlEnableBigQueryPrivateAlpha')
  22. }
  23. export const useIsETLIcebergPrivateAlpha = () => {
  24. return useIsCurrentOrgInFlagList('etlEnableIcebergPrivateAlpha')
  25. }
  26. export const useIsETLDucklakePrivateAlpha = () => {
  27. return useIsCurrentOrgInFlagList('etlEnableDucklakePrivateAlpha')
  28. }
  29. export const useIsETLPrivateAlpha = () => {
  30. const hasAccessToETLBigQuery = useIsCurrentOrgInFlagList('etlEnableBigQueryPrivateAlpha')
  31. const hasAccessToETLIceberg = useIsCurrentOrgInFlagList('etlEnableIcebergPrivateAlpha')
  32. const hasAccessToETLDucklake = useIsCurrentOrgInFlagList('etlEnableDucklakePrivateAlpha')
  33. return hasAccessToETLBigQuery || hasAccessToETLIceberg || hasAccessToETLDucklake
  34. }