diff --git a/apps/studio/components/interfaces/SignIn/SignInWithCustom.tsx b/apps/studio/components/interfaces/SignIn/SignInWithCustom.tsx index 05ea9935e2d..19feedfb1c1 100644 --- a/apps/studio/components/interfaces/SignIn/SignInWithCustom.tsx +++ b/apps/studio/components/interfaces/SignIn/SignInWithCustom.tsx @@ -10,6 +10,10 @@ interface SignInWithCustomProps { providerName: string } +const formatProviderName = (name: string) => { + return name.replace('custom:', '') +} + export const SignInWithCustom = ({ providerName }: SignInWithCustomProps) => { const [loading, setLoading] = useState(false) @@ -42,7 +46,7 @@ export const SignInWithCustom = ({ providerName }: SignInWithCustomProps) => { return ( ) } diff --git a/apps/studio/hooks/custom-content/CustomContent.types.ts b/apps/studio/hooks/custom-content/CustomContent.types.ts index b62e124743d..d965508912d 100644 --- a/apps/studio/hooks/custom-content/CustomContent.types.ts +++ b/apps/studio/hooks/custom-content/CustomContent.types.ts @@ -5,6 +5,8 @@ export type CustomContentTypes = { dashboardAuthCustomProvider: string + dashboardAuthCustomProviders: string[] + docsRowLevelSecurityGuidePath: string organizationLegalDocuments: { diff --git a/apps/studio/hooks/custom-content/custom-content.json b/apps/studio/hooks/custom-content/custom-content.json index 717ecb5852b..a3ffff7d1d0 100644 --- a/apps/studio/hooks/custom-content/custom-content.json +++ b/apps/studio/hooks/custom-content/custom-content.json @@ -5,6 +5,8 @@ "dashboard_auth:custom_provider": null, + "dashboard_auth:custom_providers": null, + "docs:row_level_security_guide_path": "/guides/auth/row-level-security", "organization:legal_documents": null, diff --git a/apps/studio/hooks/custom-content/custom-content.sample.json b/apps/studio/hooks/custom-content/custom-content.sample.json index 6cc90b3f621..23ac2df49b5 100644 --- a/apps/studio/hooks/custom-content/custom-content.sample.json +++ b/apps/studio/hooks/custom-content/custom-content.sample.json @@ -5,6 +5,8 @@ "dashboard_auth:custom_provider": "Nimbus", + "dashboard_auth:custom_providers": ["Nimbus"], + "docs:row_level_security_guide_path": "/guides/database/postgres/row-level-security", "organization:legal_documents": [ diff --git a/apps/studio/hooks/custom-content/custom-content.schema.json b/apps/studio/hooks/custom-content/custom-content.schema.json index f6f80dd2722..3fed50e746c 100644 --- a/apps/studio/hooks/custom-content/custom-content.schema.json +++ b/apps/studio/hooks/custom-content/custom-content.schema.json @@ -13,7 +13,15 @@ "dashboard_auth:custom_provider": { "type": ["string", "null"], - "description": "Show a custom provider on the sign in page (Continue with X)" + "description": "Show a custom provider on the sign in page (Continue with X). Will be deprecated by dashboard_auth:custom_providers." + }, + + "dashboard_auth:custom_providers": { + "type": ["array", "null"], + "description": "Show a custom provider on the sign in page (Continue with X)", + "items": { + "type": "string" + } }, "docs:row_level_security_guide_path": { diff --git a/apps/studio/hooks/custom-content/useCustomContent.ts b/apps/studio/hooks/custom-content/useCustomContent.ts index f125025178e..bbf69aec53e 100644 --- a/apps/studio/hooks/custom-content/useCustomContent.ts +++ b/apps/studio/hooks/custom-content/useCustomContent.ts @@ -27,16 +27,12 @@ function contentToCamelCase(feature: CustomContent) { export const useCustomContent = ( contents: T ): { - [key in CustomContentToCamelCase]: - | CustomContentTypes[CustomContentToCamelCase] - | null + [key in CustomContentToCamelCase]: CustomContentTypes[key] | null } => { // [Joshen] Running into some TS errors without the `as` here - must be overlooking something super simple return Object.fromEntries( contents.map((content) => [contentToCamelCase(content), customContentStaticObj[content]]) ) as { - [key in CustomContentToCamelCase]: - | CustomContentTypes[CustomContentToCamelCase] - | null + [key in CustomContentToCamelCase]: CustomContentTypes[key] | null } } diff --git a/apps/studio/pages/sign-in.tsx b/apps/studio/pages/sign-in.tsx index aeffd266dc3..9cf0b1c6ea5 100644 --- a/apps/studio/pages/sign-in.tsx +++ b/apps/studio/pages/sign-in.tsx @@ -32,9 +32,14 @@ const SignInPage: NextPageWithLayout = () => { 'dashboard_auth:sign_up', ]) - const { dashboardAuthCustomProvider: customProvider } = useCustomContent([ - 'dashboard_auth:custom_provider', - ]) + const { + dashboardAuthCustomProvider: customProvider, + dashboardAuthCustomProviders: customProvidersNew, + } = useCustomContent(['dashboard_auth:custom_provider', 'dashboard_auth:custom_providers']) + + // [Joshen] This is just for backward compatibility - singular customProvider needs to be deprecated subsequently + // Just need to remove customProvider and rename customProvidersNew to customProviders + const customProviders = customProvidersNew ?? (customProvider ? [customProvider] : []) const { focusProvider } = useInboundBranding('sign-in') const signInProviders = useEnabledIdentityProviders().filter((provider) => provider.showOnSignIn) @@ -44,11 +49,15 @@ const SignInPage: NextPageWithLayout = () => { dividerBgClass = 'bg-studio' ) => { const showOrDivider = - (providers.length > 0 || signInWithSsoEnabled || !!customProvider) && signInWithEmailEnabled + (providers.length > 0 || signInWithSsoEnabled || customProviders.length > 0) && + signInWithEmailEnabled return ( <> - {customProvider && } + {Array.isArray(customProviders) && + customProviders.map((providerName: string) => ( + + ))} {providers.map((provider) => ( ))} @@ -90,7 +99,7 @@ const SignInPage: NextPageWithLayout = () => { const hasOtherOptions = otherProviders.length > 0 || signInWithSsoEnabled || - !!customProvider || + customProviders.length > 0 || signInWithEmailEnabled return (