From 51f973d7be48f74030d42d016188ee626526f23e Mon Sep 17 00:00:00 2001 From: Christopher Pappas Date: Tue, 26 May 2020 17:30:49 -0700 Subject: [PATCH] [Refactor] Delete Conversation and Purchases apps --- src/desktop/apps/conversations/client.tsx | 28 ---------- src/desktop/apps/conversations/server.tsx | 54 ------------------ src/desktop/apps/purchases/client.tsx | 32 ----------- src/desktop/apps/purchases/server.tsx | 55 ------------------- src/desktop/assets/conversations.styl | 0 src/desktop/assets/conversations.tsx | 1 - src/desktop/assets/purchases.js | 1 - src/desktop/index.ts | 4 +- .../Routes/Conversation/index.tsx | 2 - src/v2/Apps/Conversation/routes.tsx | 3 +- src/v2/Apps/Purchase/PurchaseApp.tsx | 21 +++---- .../Purchase/__tests__/PurchaseApp.jest.tsx | 9 +-- src/v2/Apps/Purchase/routes.tsx | 6 +- src/v2/Apps/getAppRoutes.tsx | 4 ++ 14 files changed, 23 insertions(+), 197 deletions(-) delete mode 100644 src/desktop/apps/conversations/client.tsx delete mode 100644 src/desktop/apps/conversations/server.tsx delete mode 100644 src/desktop/apps/purchases/client.tsx delete mode 100644 src/desktop/apps/purchases/server.tsx delete mode 100644 src/desktop/assets/conversations.styl delete mode 100644 src/desktop/assets/conversations.tsx delete mode 100644 src/desktop/assets/purchases.js diff --git a/src/desktop/apps/conversations/client.tsx b/src/desktop/apps/conversations/client.tsx deleted file mode 100644 index 454d52f6dfd..00000000000 --- a/src/desktop/apps/conversations/client.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { buildClientApp } from "v2/Artsy/Router/client" -import { data as sd } from "sharify" -import { conversationRoutes } from "v2/Apps/Conversation/routes" -import React from "react" -import ReactDOM from "react-dom" -import { loadableReady } from "@loadable/component" - -const mediator = require("desktop/lib/mediator.coffee") - -buildClientApp({ - routes: conversationRoutes, - context: { - user: sd.CURRENT_USER, - mediator, - } as any, -}) - .then(({ ClientApp }) => { - loadableReady(() => { - ReactDOM.hydrate(, document.getElementById("react-root")) - }) - }) - .catch(error => { - console.error(error) - }) - -if (module.hot) { - module.hot.accept() -} diff --git a/src/desktop/apps/conversations/server.tsx b/src/desktop/apps/conversations/server.tsx deleted file mode 100644 index 46bf050b532..00000000000 --- a/src/desktop/apps/conversations/server.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import { buildServerApp } from "v2/Artsy/Router/server" -import { stitch } from "@artsy/stitch" -import { conversationRoutes } from "v2/Apps/Conversation/routes" -import React from "react" -import { buildServerAppContext } from "desktop/lib/buildServerAppContext" -import express, { Request, Response, NextFunction } from "express" - -export const app = express() - -app.get( - "/user/conversations*", - async (req: Request, res: Response, next: NextFunction) => { - try { - const { - bodyHTML, - redirect, - status, - headTags, - styleTags, - scripts, - } = await buildServerApp({ - context: buildServerAppContext(req, res), - routes: conversationRoutes, - url: req.url, - userAgent: req.header("User-Agent"), - }) - - if (redirect) { - res.redirect(302, redirect.url) - return - } - - // Render layout - const layout = await stitch({ - basePath: __dirname, - layout: "../../components/main_layout/templates/react_redesign.jade", - blocks: { - head: () => {headTags}, - body: bodyHTML, - }, - locals: { - ...res.locals, - assetPackage: "conversations", - scripts, - styleTags, - }, - }) - - res.status(status).send(layout) - } catch (error) { - next(error) - } - } -) diff --git a/src/desktop/apps/purchases/client.tsx b/src/desktop/apps/purchases/client.tsx deleted file mode 100644 index 3b816e1bc1a..00000000000 --- a/src/desktop/apps/purchases/client.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { buildClientApp } from "v2/Artsy/Router/client" -import { data as sd } from "sharify" -import { routes } from "v2/Apps/Purchase/routes" -import React from "react" -import ReactDOM from "react-dom" -import { setupArtistSignUpModal } from "desktop/components/artistSignupModal/artistSignupModal" - -const mediator = require("desktop/lib/mediator.coffee") - -buildClientApp({ - routes, - context: { - user: sd.CURRENT_USER, - mediator, - } as any, -}) - .then(({ ClientApp }) => { - ReactDOM.hydrate( - , - document.getElementById("react-root"), - () => { - setupArtistSignUpModal() - } - ) - }) - .catch(error => { - console.error(error) - }) - -if (module.hot) { - module.hot.accept() -} diff --git a/src/desktop/apps/purchases/server.tsx b/src/desktop/apps/purchases/server.tsx deleted file mode 100644 index dd697500a50..00000000000 --- a/src/desktop/apps/purchases/server.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import { buildServerApp } from "v2/Artsy/Router/server" -import { stitch } from "@artsy/stitch" -import { routes } from "v2/Apps/Purchase/routes" -import React from "react" -import { buildServerAppContext } from "desktop/lib/buildServerAppContext" -import express, { Request, Response, NextFunction } from "express" - -export const app = express() - -app.get( - "/user/purchases", - async (req: Request, res: Response, next: NextFunction) => { - try { - const context = buildServerAppContext(req, res, {}) - const { - bodyHTML, - redirect, - status, - headTags, - styleTags, - scripts, - } = await buildServerApp({ - routes, - url: req.url, - userAgent: req.header("User-Agent"), - context, - }) - - if (redirect) { - res.redirect(302, redirect.url) - return - } - - // Render layout - const layout = await stitch({ - basePath: __dirname, - layout: "../../components/main_layout/templates/react_redesign.jade", - blocks: { - head: () => {headTags}, - body: bodyHTML, - }, - locals: { - ...res.locals, - assetPackage: "purchases", - scripts, - styleTags, - }, - }) - - res.status(status).send(layout) - } catch (error) { - next(error) - } - } -) diff --git a/src/desktop/assets/conversations.styl b/src/desktop/assets/conversations.styl deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/desktop/assets/conversations.tsx b/src/desktop/assets/conversations.tsx deleted file mode 100644 index 5cd782417f5..00000000000 --- a/src/desktop/assets/conversations.tsx +++ /dev/null @@ -1 +0,0 @@ -import "desktop/apps/conversations/client" diff --git a/src/desktop/assets/purchases.js b/src/desktop/assets/purchases.js deleted file mode 100644 index 0c90b83d77d..00000000000 --- a/src/desktop/assets/purchases.js +++ /dev/null @@ -1 +0,0 @@ -import "desktop/apps/purchases/client" diff --git a/src/desktop/index.ts b/src/desktop/index.ts index 8a946ee4ce0..03b1a42f926 100644 --- a/src/desktop/index.ts +++ b/src/desktop/index.ts @@ -26,9 +26,7 @@ app.use(require("./apps/auctions")) app.use(require("./apps/auctions2").app) app.use(require("./apps/auction_lots")) -// TODO: Remove after AB test ends. -app.use(require("./apps/purchases/server").app) -app.use(require("./apps/conversations/server").app) +// FIXME: Remove once JSONPage + new app shell is worked out app.use(require("./apps/art_keeps_going/server").app) app.use(require("./apps/artists")) diff --git a/src/v2/Apps/Conversation/Routes/Conversation/index.tsx b/src/v2/Apps/Conversation/Routes/Conversation/index.tsx index 8cc613eae1a..92b493b467b 100644 --- a/src/v2/Apps/Conversation/Routes/Conversation/index.tsx +++ b/src/v2/Apps/Conversation/Routes/Conversation/index.tsx @@ -80,5 +80,3 @@ export const ConversationFragmentContainer = createFragmentContainer( `, } ) - -export default ConversationFragmentContainer diff --git a/src/v2/Apps/Conversation/routes.tsx b/src/v2/Apps/Conversation/routes.tsx index f95e556bf9e..859e95db292 100644 --- a/src/v2/Apps/Conversation/routes.tsx +++ b/src/v2/Apps/Conversation/routes.tsx @@ -1,6 +1,7 @@ import loadable from "@loadable/component" import { RouteConfig } from "found" import { graphql } from "react-relay" +import { ConversationFragmentContainer as ConversationRoute } from "./Routes/Conversation" export const conversationRoutes: RouteConfig[] = [ { @@ -26,7 +27,7 @@ export const conversationRoutes: RouteConfig[] = [ { path: "/user/conversations/:conversationID", displayFullPage: true, - getComponent: () => loadable(() => import("./Routes/Conversation")), + Component: ConversationRoute, prepareVariables: (params, _props) => { return { conversationID: params.conversationID, diff --git a/src/v2/Apps/Purchase/PurchaseApp.tsx b/src/v2/Apps/Purchase/PurchaseApp.tsx index c44959c2cc1..8545924299f 100644 --- a/src/v2/Apps/Purchase/PurchaseApp.tsx +++ b/src/v2/Apps/Purchase/PurchaseApp.tsx @@ -7,6 +7,7 @@ import { Title } from "react-head" import { createFragmentContainer, graphql } from "react-relay" import { userIsAdmin } from "v2/Utils/user" import { PurchaseHistoryFragmentContainer as PurchaseHistory } from "./Components/PurchaseHistory" +import { Spacer } from "@artsy/palette" export interface PurchaseAppProps { me: PurchaseApp_me @@ -20,6 +21,7 @@ export const PurchaseApp = (props: any) => { return ( My Orders | Artsy + ) @@ -29,13 +31,12 @@ export const PurchaseApp = (props: any) => { } } -export const PurchaseAppFragmentContainer = createFragmentContainer( - PurchaseApp, - { - me: graphql` - fragment PurchaseApp_me on Me { - ...PurchaseHistory_me - } - `, - } -) +const PurchaseAppFragmentContainer = createFragmentContainer(PurchaseApp, { + me: graphql` + fragment PurchaseApp_me on Me { + ...PurchaseHistory_me + } + `, +}) + +export default PurchaseAppFragmentContainer diff --git a/src/v2/Apps/Purchase/__tests__/PurchaseApp.jest.tsx b/src/v2/Apps/Purchase/__tests__/PurchaseApp.jest.tsx index 0f5d7c7b5f0..730fec26a69 100644 --- a/src/v2/Apps/Purchase/__tests__/PurchaseApp.jest.tsx +++ b/src/v2/Apps/Purchase/__tests__/PurchaseApp.jest.tsx @@ -9,7 +9,7 @@ import React from "react" import { HeadProvider } from "react-head" import { graphql } from "react-relay" import { PurchaseHistoryProps } from "../Components/PurchaseHistory" -import { PurchaseAppFragmentContainer } from "../PurchaseApp" +import PurchaseAppFragmentContainer from "../PurchaseApp" jest.unmock("react-relay") @@ -72,7 +72,7 @@ const render = (me: PurchaseAppTestQueryRawResponse["me"], user: User) => } } `, - wrapper: children => ( + wrapper: (children) => ( {children} @@ -126,10 +126,7 @@ describe("Purchase app", () => { const pagination = component.find("LargePagination") expect(pagination.length).toBe(1) expect(pagination.text()).toContain("1234...7") - pagination - .find("button") - .at(1) - .simulate("click") + pagination.find("button").at(1).simulate("click") expect(refetchSpy).toHaveBeenCalledTimes(1) expect(refetchSpy.mock.calls[0][0]).toEqual( expect.objectContaining({ first: 10, after: "NQ" }) diff --git a/src/v2/Apps/Purchase/routes.tsx b/src/v2/Apps/Purchase/routes.tsx index e61e828018f..d400b436f1b 100644 --- a/src/v2/Apps/Purchase/routes.tsx +++ b/src/v2/Apps/Purchase/routes.tsx @@ -1,13 +1,11 @@ +import loadable from "@loadable/component" import { graphql } from "react-relay" - -// @ts-ignore import { RouteConfig } from "found" -import { PurchaseAppFragmentContainer as PurchaseApp } from "./PurchaseApp" export const routes: RouteConfig[] = [ { path: "/user/purchases", - Component: PurchaseApp, + getComponent: () => loadable(() => import("./PurchaseApp")), query: graphql` query routes_PurchaseQuery { me { diff --git a/src/v2/Apps/getAppRoutes.tsx b/src/v2/Apps/getAppRoutes.tsx index 8ad532cba2c..7d4a6fe272a 100644 --- a/src/v2/Apps/getAppRoutes.tsx +++ b/src/v2/Apps/getAppRoutes.tsx @@ -6,6 +6,7 @@ import { collectRoutes } from "v2/Apps/Collect/collectRoutes" import { conversationRoutes } from "v2/Apps/Conversation/routes" import { routes as identityVerificationRoutes } from "v2/Apps/IdentityVerification/routes" import { routes as orderRoutes } from "v2/Apps/Order/routes" +import { routes as purchasesRoutes } from "v2/Apps/Purchase/routes" import { routes as searchRoutes } from "v2/Apps/Search/routes" import { routes as viewingRoomRoutes } from "./ViewingRoom/routes" @@ -29,6 +30,9 @@ export function getAppRoutes(): RouteConfig[] { { routes: orderRoutes, }, + { + routes: purchasesRoutes, + }, { routes: searchRoutes, },