Fix lint errors in SignInPage: use Relay fragment for OIDC providers
- Add blank line between import groups (import-x/order) - Use Relay fragment in OIDCButtons to colocate field queries (relay/unused-fields) Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -6,14 +6,14 @@ import { graphql } from "relay-runtime";
|
|||||||
|
|
||||||
import type { SignInPageQuery } from "#/__generated__/iam/SignInPageQuery.graphql";
|
import type { SignInPageQuery } from "#/__generated__/iam/SignInPageQuery.graphql";
|
||||||
import { useSafeContinueUrl } from "#/hooks/useSafeContinueUrl";
|
import { useSafeContinueUrl } from "#/hooks/useSafeContinueUrl";
|
||||||
|
|
||||||
import { Divider } from "./_components/Divider";
|
import { Divider } from "./_components/Divider";
|
||||||
import { OIDCButtons } from "./_components/OIDCButtons";
|
import { OIDCButtons } from "./_components/OIDCButtons";
|
||||||
|
|
||||||
const signInPageQuery = graphql`
|
const signInPageQuery = graphql`
|
||||||
query SignInPageQuery {
|
query SignInPageQuery {
|
||||||
oidcProviders {
|
oidcProviders {
|
||||||
name
|
...OIDCButtonsFragment
|
||||||
loginURL
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -1,6 +1,17 @@
|
|||||||
import { useTranslate } from "@probo/i18n";
|
import { useTranslate } from "@probo/i18n";
|
||||||
import { Button, Google, Microsoft } from "@probo/ui";
|
import { Button, Google, Microsoft } from "@probo/ui";
|
||||||
import type { ComponentProps } from "react";
|
import type { ComponentProps } from "react";
|
||||||
|
import { useFragment } from "react-relay";
|
||||||
|
import { graphql } from "relay-runtime";
|
||||||
|
|
||||||
|
import type { OIDCButtonsFragment$key } from "#/__generated__/iam/OIDCButtonsFragment.graphql";
|
||||||
|
|
||||||
|
const fragment = graphql`
|
||||||
|
fragment OIDCButtonsFragment on OIDCProviderInfo {
|
||||||
|
name
|
||||||
|
loginURL
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
const providerIcons: Record<
|
const providerIcons: Record<
|
||||||
string,
|
string,
|
||||||
@@ -14,22 +25,39 @@ export function OIDCButtons({
|
|||||||
providers,
|
providers,
|
||||||
safeContinueUrl,
|
safeContinueUrl,
|
||||||
}: {
|
}: {
|
||||||
providers: ReadonlyArray<{ readonly name: string; readonly loginURL: string }>;
|
providers: ReadonlyArray<OIDCButtonsFragment$key>;
|
||||||
safeContinueUrl: URL;
|
safeContinueUrl: URL;
|
||||||
}) {
|
}) {
|
||||||
const { __ } = useTranslate();
|
const { __ } = useTranslate();
|
||||||
|
|
||||||
if (providers.length === 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{providers.map((provider) => {
|
{providers.map((providerRef, index) => (
|
||||||
|
<OIDCButton
|
||||||
|
key={index}
|
||||||
|
providerRef={providerRef}
|
||||||
|
safeContinueUrl={safeContinueUrl}
|
||||||
|
__={__}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function OIDCButton({
|
||||||
|
providerRef,
|
||||||
|
safeContinueUrl,
|
||||||
|
__,
|
||||||
|
}: {
|
||||||
|
providerRef: OIDCButtonsFragment$key;
|
||||||
|
safeContinueUrl: URL;
|
||||||
|
__: (s: string) => string;
|
||||||
|
}) {
|
||||||
|
const provider = useFragment(fragment, providerRef);
|
||||||
const Icon = providerIcons[provider.name];
|
const Icon = providerIcons[provider.name];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
key={provider.name}
|
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
className="w-full h-10"
|
className="w-full h-10"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -45,7 +73,4 @@ export function OIDCButtons({
|
|||||||
</span>
|
</span>
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
})}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user