Skip to content

Commit

Permalink
Merge pull request #14431 from artsy/review-app-new-auth
Browse files Browse the repository at this point in the history
feat(auth): implements new auth dialog
  • Loading branch information
dzucconi authored Sep 12, 2024
2 parents 1019492 + 914d354 commit 87f127d
Show file tree
Hide file tree
Showing 73 changed files with 767 additions and 627 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/alerts.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe("user/alerts", () => {
describe("unauthenticated", () => {
it("redirects to the login page", () => {
cy.visit("user/alerts")
cy.contains("Log in")
cy.contains("Sign up or log in")
})
})
})
2 changes: 1 addition & 1 deletion cypress/e2e/notifications.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe("/notifications", () => {
describe("unauthenticated", () => {
it("redirects to the login page", () => {
cy.visit("/notifications")
cy.contains("Log in")
cy.contains("Sign up or log in")
})
})
})
2 changes: 1 addition & 1 deletion cypress/e2e/userPayments.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe("user/payments", () => {
describe("unauthenticated", () => {
it("redirects to the login page", () => {
cy.visit("user/payments")
cy.contains("Log in")
cy.contains("Sign up or log in")
})
})
})
2 changes: 1 addition & 1 deletion cypress/e2e/userShipping.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe("user/shipping", () => {
describe("unauthenticated", () => {
it("redirects to the login page", () => {
cy.visit("user/shipping")
cy.contains("Log in")
cy.contains("Sign up or log in")
})
})
})
1 change: 0 additions & 1 deletion docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const YourComponent = () => {
<Button
onClick={() => {
showAuthDialog({
mode: "Login",
options: {
title: "Login to save artworks",
},
Expand Down
12 changes: 2 additions & 10 deletions src/Apps/Artist/Routes/AuctionResults/ArtistAuctionResultItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,8 @@ export const ArtistAuctionResultItem: React.FC<Props> = props => {
if (!user) {
event.preventDefault()
showAuthDialog({
mode: "SignUp",
options: {
title: mode => {
const action = mode === "SignUp" ? "Sign up" : "Log in"
return `${action} to see full auction records — for free`
},
title: "Sign up or log in to see full auction records — for free",
},
analytics: {
contextModule: ContextModule.auctionResult,
Expand Down Expand Up @@ -258,12 +254,8 @@ const ArtistAuctionResultItemPrice: React.FC<Props> = props => {
textDecoration="underline"
onClick={() => {
showAuthDialog({
mode: "SignUp",
options: {
title: mode => {
const action = mode === "SignUp" ? "Sign up" : "Log in"
return `${action} to see full auction records — for free`
},
title: "Sign up or log in to see full auction records — for free",
},
analytics: {
contextModule: ContextModule.auctionResults,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,8 @@ const AuctionResultsContainer: React.FC<AuctionResultsProps> = ({
// If user is not logged-in, show auth modal, but only if it was never shown before.
if (!user && !authShownForFiltering) {
showAuthDialog({
mode: "SignUp",
options: {
title: mode => {
const action = mode === "SignUp" ? "Sign up" : "Log in"
return `${action} to see auction results for ${artist.name}`
},
title: `Sign up or log in to see auction results for ${artist.name}`,
},
analytics: {
contextModule: ContextModule.auctionResults,
Expand Down
6 changes: 1 addition & 5 deletions src/Apps/Artwork/ArtworkApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,8 @@ export const ArtworkApp: React.FC<Props> = props => {
if (expectingPartnerOffer) {
if (!isLoggedIn) {
showAuthDialog({
mode: "Login",
options: {
title: mode =>
mode === "Login"
? "Log in to view gallery offer"
: "Sign up to buy art with ease",
title: "Log in or sign up to view gallery offer",
},
analytics: {
// TODO: Placeholder - Determine correct tracking - EMI-1783
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export const RequestConditionReport: React.FC<RequestConditionReportProps> = pro

const handleLoginClick = () => {
showAuthDialog({
mode: "Login",
analytics: {
contextModule: ContextModule.aboutTheWork,
intent: Intent.requestConditionReport,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ describe("RequestConditionReport", () => {
await page.clickLogInButton()

expect(showAuthDialog).toHaveBeenCalledWith({
mode: "Login",
analytics: {
contextModule: "aboutTheWork",
intent: "requestConditionReport",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export class ArtworkSidebarBidAction extends React.Component<

if (!this.props.me) {
this.props.showAuthDialog({
mode: "Login",
options: {
redirectTo,
title: mode => {
Expand Down Expand Up @@ -174,26 +173,31 @@ export class ArtworkSidebarBidAction extends React.Component<
let PreviewAction: React.FC

if (registrationAttempted) {
// FIXME: Extract to a real component
if (qualifiedForBidding) {
// eslint-disable-next-line react/no-unstable-nested-components
PreviewAction = () => (
<Button width="100%" size="large" mt={1} disabled>
Registration complete
</Button>
)
} else if (shouldPromptIdVerification) {
// eslint-disable-next-line react/no-unstable-nested-components
PreviewAction = () => (
<VerifyIdentityButton
id={pendingIdentityVerification?.internalID || ""}
/>
)
} else {
// eslint-disable-next-line react/no-unstable-nested-components
PreviewAction = () => (
<Button width="100%" size="large" mt={1} disabled>
Registration pending
</Button>
)
}
} else {
// eslint-disable-next-line react/no-unstable-nested-components
PreviewAction = () => (
<RegisterToBidButton onClick={this.redirectToRegister} />
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,8 @@ export const ArtworkSidebarCommercialButtons: React.FC<ArtworkSidebarCommercialB
}
} else {
showAuthDialog({
mode: "SignUp",
options: {
title: mode => {
const action = mode === "SignUp" ? "Sign up" : "Log in"
return `${action} to buy art with ease`
},
title: "Sign up or log in to buy art with ease",
afterAuthAction: {
action: "buyNow",
kind: "artworks",
Expand Down Expand Up @@ -302,12 +298,8 @@ export const ArtworkSidebarCommercialButtons: React.FC<ArtworkSidebarCommercialB
}
} else {
showAuthDialog({
mode: "SignUp",
options: {
title: mode => {
const action = mode === "SignUp" ? "Sign up" : "Log in"
return `${action} to make an offer`
},
title: "Sign up or log in to make an offer",
afterAuthAction: {
action: "makeOffer",
kind: "artworks",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,8 @@ describe("ArtworkSidebarCommercialButtons", () => {
fireEvent.click(screen.getByText("Purchase"))

expect(showAuthDialog).toBeCalledWith({
mode: "SignUp",
options: {
title: expect.any(Function),
title: expect.any(String),
afterAuthAction: {
action: "buyNow",
kind: "artworks",
Expand Down Expand Up @@ -570,9 +569,8 @@ describe("ArtworkSidebarCommercialButtons", () => {
fireEvent.click(screen.getByText("Make an Offer"))

expect(showAuthDialog).toBeCalledWith({
mode: "SignUp",
options: {
title: expect.any(Function),
title: expect.any(String),
afterAuthAction: {
action: "makeOffer",
kind: "artworks",
Expand Down
3 changes: 1 addition & 2 deletions src/Apps/Artwork/__tests__/ArtworkApp.jest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,8 @@ describe("ArtworkApp", () => {
analytics: {
contextModule: "artworkSidebar",
},
mode: "Login",
options: {
title: expect.any(Function),
title: expect.any(String),
},
})
})
Expand Down
8 changes: 2 additions & 6 deletions src/Apps/Auction/Components/RegisterButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@ export const RegisterButton: React.FC<RegisterButtonProps> = ({ me, sale }) => {

if (!me?.internalID) {
showAuthDialog({
mode: "Login",
options: {
redirectTo: `${saleURL}/register`,
title: mode => {
const action = mode === "Login" ? "Log in" : "Sign up"
return `${action} to bid on artworks`
},
title: "Sign up or log in to bid on artworks",
},
analytics: {
contextModule: ContextModule.auctionSidebar,
Expand Down Expand Up @@ -68,7 +64,7 @@ export const RegisterButton: React.FC<RegisterButtonProps> = ({ me, sale }) => {
}

case conditions.LIVE_OPEN: {
const liveUrl = sale.liveURLIfOpen!
const liveUrl = `${sale.liveURLIfOpen}`
const href = me ? liveUrl + "/login" : liveUrl

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,12 @@ describe("RegisterButton", () => {
;(wrapper.find("ButtonAction").props() as any).onClick()

expect(showAuthDialog).toHaveBeenCalledWith({
mode: "Login",
analytics: {
contextModule: "auctionSidebar",
intent: "registerToBid",
},
options: {
title: expect.any(Function),
title: expect.any(String),
redirectTo: "/auction/sale-slug/register",
},
})
Expand Down
18 changes: 5 additions & 13 deletions src/Apps/Authentication/Components/AuthenticationInlineDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { Box, Flex, Join, Spacer, Text, useToasts } from "@artsy/palette"
import { Box, Flex, Stack, Text, useToasts } from "@artsy/palette"
import { AuthDialogView } from "Components/AuthDialog/AuthDialog"
import { FC, useEffect } from "react"
import { useRecaptcha } from "Utils/EnableRecaptcha"
import ArtsyLogoIcon from "@artsy/icons/ArtsyLogoIcon"
import { useAuthDialogOptions } from "Apps/Authentication/Hooks/useAuthDialogOptions"
import { MetaTags } from "Components/MetaTags"
import { AuthenticationInlineDialogProvider } from "Apps/Authentication/Components/AuthenticationInlineDialogProvider"
import { AuthDialogMode } from "Components/AuthDialog/AuthDialogContext"
import { useRouter } from "System/Hooks/useRouter"
import { AuthDialogTitle } from "Components/AuthDialog/AuthDialogTitle"

const AuthenticationInlineDialogContents: FC = () => {
useRecaptcha()

const { title, pageTitle, description } = useAuthDialogOptions()

const { sendToast } = useToasts()
Expand Down Expand Up @@ -54,15 +53,8 @@ const AuthenticationInlineDialogContents: FC = () => {
maxWidth={["100%", 450]}
>
<Box width="100%">
<Join separator={<Spacer y={2} />}>
<ArtsyLogoIcon
display="block"
style={{ width: "75px", height: "26px" }}
/>

<Text variant="lg-display" lineClamp={6}>
{title}
</Text>
<Stack gap={2}>
<AuthDialogTitle title={title} />

{description && (
<Text variant="sm-display" lineClamp={6}>
Expand All @@ -71,7 +63,7 @@ const AuthenticationInlineDialogContents: FC = () => {
)}

<AuthDialogView />
</Join>
</Stack>
</Box>
</Flex>
</>
Expand Down
Loading

0 comments on commit 87f127d

Please sign in to comment.