diff --git a/apps/studio/hooks/misc/useIsWarehouseEnabled.ts b/apps/studio/hooks/misc/useIsWarehouseEnabled.ts index 03859a480ba..e72376e85f8 100644 --- a/apps/studio/hooks/misc/useIsWarehouseEnabled.ts +++ b/apps/studio/hooks/misc/useIsWarehouseEnabled.ts @@ -1,12 +1,23 @@ import { useFlag } from 'common' +import { useSelectedOrganizationQuery } from './useSelectedOrganization' + /** * Whether the Warehouse product is enabled for the current session. * * Gates every Warehouse surface while in preview: the table Storage section ("Copy to Warehouse"), * the per-table storage chips/badges, the Warehouse Catalog integration, and the Connect-sheet - * catalog tab. Backed by the `warehouse` ConfigCat flag (defaults to off until registered). + * catalog tab. Backed by the `warehouse` ConfigCat flag, configured as a comma-separated + * organization slug allowlist. Use `all` to enable every organization. */ export function useIsWarehouseEnabled(): boolean { - return useFlag('warehouse') === true + const flagValue = useFlag('warehouse') + const { data: organization } = useSelectedOrganizationQuery() + + const allowedOrgSlugs = + typeof flagValue === 'string' ? flagValue.split(',').map((slug) => slug.trim()) : [] + + if (allowedOrgSlugs.includes('all')) return true + + return allowedOrgSlugs.includes(organization?.slug ?? '') }