mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 19:05:06 +03:00
Adds a `dashboard_auth:sign_in_with_chatgpt` enabled-features flag so deployments can disable the sign in with ChatGPT button via `disabled_features`, the same way `dashboard_auth:sign_in_with_github` works. Previously the button was only gated by the ConfigCat rollout flag / localStorage opt-in, so white-labeled deployments with custom auth providers had no way to turn it off. **Added:** - `dashboard_auth:sign_in_with_chatgpt` (default `true`) in `enabled-features.json` + schema - Tests covering the feature-disabled state **Changed:** - `useEnabledIdentityProviders` now gates ChatGPT as `featureEnabled && (localStorageOptIn || configCatFlag)` — the feature flag is the static kill switch, the existing OR'd pair remains the rollout mechanism ## To test - Sign-in and sign-up pages behave exactly as before by default (flag defaults to `true`, ConfigCat/localStorage rollout gate unchanged) - With `dashboard_auth:sign_in_with_chatgpt` in a profile's `disabled_features`, the ChatGPT button no longer renders even with `?siwc-enabled=1` or the ConfigCat flag on - GitHub button gating unaffected <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added a feature flag to control ChatGPT sign-in availability. - ChatGPT sign-in is now available only when the feature is enabled and an applicable rollout or opt-in condition is met. - **Tests** - Expanded coverage for ChatGPT and GitHub sign-in provider availability under different feature-flag and rollout conditions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
50 lines
1.9 KiB
TypeScript
50 lines
1.9 KiB
TypeScript
import { LOCAL_STORAGE_KEYS, useFlag } from 'common'
|
|
import { useMemo } from 'react'
|
|
|
|
import { useIsFeatureEnabled } from './useIsFeatureEnabled'
|
|
import { useLocalStorageQuery } from './useLocalStorage'
|
|
import {
|
|
CHATGPT_IDENTITY_PROVIDER,
|
|
GITHUB_IDENTITY_PROVIDER,
|
|
type ExternalIdentityProviderConfig,
|
|
} from '@/lib/external-identity-providers'
|
|
|
|
/**
|
|
* Returns the statically-declared identity providers whose feature flag is currently enabled.
|
|
* To add a provider: declare its config in `lib/external-identity-providers.ts`, add a
|
|
* `dashboard_auth:sign_in_with_*` flag, and gate it here.
|
|
*
|
|
* ChatGPT carries an extra rollout gate on top of its `dashboard_auth:sign_in_with_chatgpt` flag:
|
|
* the feature flag must be enabled AND either the `ShowSignInWithChatGptButton` ConfigCat flag or a
|
|
* manual, localStorage-only opt-in switch (`LOCAL_STORAGE_KEYS.SIGN_IN_CHATGPT_ENABLED`, flippable
|
|
* via the `?siwc-enabled=1` query param — see `useSiwcQueryParamOptIn`) must be on. The feature flag
|
|
* is the static kill switch; the OR'd pair is the progressive rollout mechanism.
|
|
*/
|
|
export function useEnabledIdentityProviders(): ExternalIdentityProviderConfig[] {
|
|
const {
|
|
dashboardAuthSignInWithGithub: githubEnabled,
|
|
dashboardAuthSignInWithChatgpt: chatgptFeatureEnabled,
|
|
} = useIsFeatureEnabled([
|
|
'dashboard_auth:sign_in_with_github',
|
|
'dashboard_auth:sign_in_with_chatgpt',
|
|
])
|
|
|
|
const [chatgptLocalStorageEnabled] = useLocalStorageQuery(
|
|
LOCAL_STORAGE_KEYS.SIGN_IN_CHATGPT_ENABLED,
|
|
false
|
|
)
|
|
const chatGptConfigCatFlagEnabled = useFlag('ShowSignInWithChatGptButton')
|
|
|
|
const isChatGptEnabled =
|
|
chatgptFeatureEnabled && (chatgptLocalStorageEnabled || chatGptConfigCatFlagEnabled)
|
|
|
|
return useMemo(
|
|
() =>
|
|
[
|
|
githubEnabled && GITHUB_IDENTITY_PROVIDER,
|
|
isChatGptEnabled && CHATGPT_IDENTITY_PROVIDER,
|
|
].filter((p): p is ExternalIdentityProviderConfig => Boolean(p)),
|
|
[githubEnabled, isChatGptEnabled]
|
|
)
|
|
}
|