From 887e994ff1e38840732f7ce820329f3fe1d80e77 Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Mon, 23 Mar 2026 13:57:50 +0100 Subject: [PATCH] Refactor OIDC buttons: extract OIDCButton component, inline loops Address PR review feedback: - Remove OIDCButtons wrapper components that only loop, inline .map() directly in SignInPage and ConnectPage - OIDCButton uses useTranslate() and useSafeContinueUrl() hooks internally instead of receiving hook results as props - Move OIDCButton to local _components folders - Fix eslint import grouping in SignInPage Signed-off-by: Bryan Frimin --- .../src/pages/iam/auth/sign-in/SignInPage.tsx | 14 +-- .../{OIDCButtons.tsx => OIDCButton.tsx} | 38 ++----- apps/trust/src/pages/auth/ConnectPage.tsx | 103 +++--------------- .../src/pages/auth/_components/OIDCButton.tsx | 52 +++++++++ 4 files changed, 78 insertions(+), 129 deletions(-) rename apps/console/src/pages/iam/auth/sign-in/_components/{OIDCButtons.tsx => OIDCButton.tsx} (61%) create mode 100644 apps/trust/src/pages/auth/_components/OIDCButton.tsx diff --git a/apps/console/src/pages/iam/auth/sign-in/SignInPage.tsx b/apps/console/src/pages/iam/auth/sign-in/SignInPage.tsx index 8a57c43a8..f1cb2ff5f 100644 --- a/apps/console/src/pages/iam/auth/sign-in/SignInPage.tsx +++ b/apps/console/src/pages/iam/auth/sign-in/SignInPage.tsx @@ -2,8 +2,7 @@ import { formatError, type GraphQLError } from "@probo/helpers"; import { useTranslate } from "@probo/i18n"; import { Button, Field, useToast } from "@probo/ui"; import type { FormEventHandler } from "react"; -import { useMutation, usePreloadedQuery } from "react-relay"; -import type { PreloadedQuery } from "react-relay"; +import { type PreloadedQuery, useMutation, usePreloadedQuery } from "react-relay"; import { Link, matchPath, useLocation } from "react-router"; import { graphql } from "relay-runtime"; @@ -12,7 +11,7 @@ import type { SignInPageQuery } from "#/__generated__/iam/SignInPageQuery.graphq import { useSafeContinueUrl } from "#/hooks/useSafeContinueUrl"; import { Divider } from "./_components/Divider"; -import { OIDCButtons } from "./_components/OIDCButtons"; +import { OIDCButton } from "./_components/OIDCButton"; const signInMutation = graphql` mutation SignInPageMutation($input: SignInInput!) { @@ -27,7 +26,7 @@ const signInMutation = graphql` export const signInPageQuery = graphql` query SignInPageQuery { oidcProviders { - ...OIDCButtonsFragment + ...OIDCButtonFragment } } `; @@ -140,10 +139,9 @@ export default function SignInPage(props: Props) {
{__("Or")} - + {data.oidcProviders.map((providerRef, index) => ( + + ))} - ); -} - export function ConnectPage(props: { queryRef: PreloadedQuery; }) { @@ -234,12 +155,14 @@ export function ConnectPage(props: {

-
- -
+ {oidcProviders.length > 0 && ( +
+ {oidcProviders.map((providerRef, index) => ( + + ))} + {__("Or")} +
+ )}
void handleSubmit(e)} className="space-y-6"> ) => React.ReactNode +> = { + google: Google, + microsoft: Microsoft, +}; + +export function OIDCButton({ + providerRef, +}: { + providerRef: OIDCButtonFragment$key; +}) { + const { __ } = useTranslate(); + const safeContinueUrl = useSafeContinueUrl(); + const provider = useFragment(fragment, providerRef); + const Icon = providerIcons[provider.name]; + + return ( + + ); +}