Files
supabase/apps/studio/hooks/misc/useEnabledIdentityProviders.ts
T
Cemal Kılıç b8310dbf23 feat(studio): move SIWC rollout gate to ConfigCat (#48360)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Replace the deploy-gated `dashboard_auth:sign_in_with_chatgpt` AND-gate
with useFlag('ShowSignInWithChatGptButton') OR'd against the existing
localStorage opt-in switch, so rollout/rollback no longer requires a
frontend deploy. Remove the now-dead static flag, its only consumer was
this gate.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* ChatGPT sign-in availability now responds to either the local opt-in
setting or the updated configuration flag.
  * GitHub sign-in continues to follow its dedicated feature setting.

* **Bug Fixes**
* Corrected identity provider visibility across different sign-in
configuration combinations.

* **Chores**
  * Removed the obsolete ChatGPT sign-in feature setting.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-07-28 10:31:17 +02:00

42 lines
1.7 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 is a deliberate exception: it's rolled out via the `ShowSignInWithChatGptButton`
* ConfigCat flag OR'd with a manual, localStorage-only opt-in switch
* (`LOCAL_STORAGE_KEYS.SIGN_IN_CHATGPT_ENABLED`, flippable via the `?siwc-enabled=1` query param —
* see `useSiwcQueryParamOptIn`), instead of the static `dashboard_auth:sign_in_with_*` pattern.
*/
export function useEnabledIdentityProviders(): ExternalIdentityProviderConfig[] {
const { dashboardAuthSignInWithGithub: githubEnabled } = useIsFeatureEnabled([
'dashboard_auth:sign_in_with_github',
])
const [chatgptLocalStorageEnabled] = useLocalStorageQuery(
LOCAL_STORAGE_KEYS.SIGN_IN_CHATGPT_ENABLED,
false
)
const chatGptConfigCatFlagEnabled = useFlag('ShowSignInWithChatGptButton')
return useMemo(
() =>
[
githubEnabled && GITHUB_IDENTITY_PROVIDER,
(chatgptLocalStorageEnabled || chatGptConfigCatFlagEnabled) && CHATGPT_IDENTITY_PROVIDER,
].filter((p): p is ExternalIdentityProviderConfig => Boolean(p)),
[githubEnabled, chatgptLocalStorageEnabled, chatGptConfigCatFlagEnabled]
)
}