Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy #5062

Merged
merged 39 commits into from
Feb 20, 2020
Merged

Deploy #5062

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7a076d8
[Clientside Routing] Ensure search loads main bundle when directly li…
damassi Feb 15, 2020
5c9d21d
Merge pull request #5057 from damassi/fix-search
damassi Feb 15, 2020
fe7e80d
[Clientside Routing] Use assetMiddleware helper to return search scri…
damassi Feb 15, 2020
7b15fae
Merge pull request #5059 from damassi/use-asset-helper
damassi Feb 15, 2020
ef814aa
Fix artist.css 404 and inquire form css
damassi Feb 15, 2020
2286c09
Merge pull request #5060 from damassi/fix-styles
damassi Feb 15, 2020
dea8b01
Update dep @artsy/reaction from 25.9.3 to v25.9.4
renovate-bot Feb 15, 2020
f13906c
Merge pull request #5061 from artsy/renovate/artsy-reaction-25.x
damassi Feb 15, 2020
899faee
Fix buyers premium css
damassi Feb 16, 2020
2d316b4
Merge pull request #5065 from damassi/fix-buyers-premium-css
damassi Feb 16, 2020
5e9b9c9
Update yarn orb to v3
renovate-bot Feb 18, 2020
81ab749
Update dep @artsy/reaction from 25.9.4 to v25.9.5
renovate-bot Feb 18, 2020
b50a44e
Merge pull request #5066 from artsy/renovate/docker-yarn-3.x
zephraph Feb 18, 2020
e7f8a4d
[Clientside Routing] Wire in Order app
damassi Feb 15, 2020
65a6bad
Add orderApp middleware
damassi Feb 15, 2020
92f677f
Bump reaction 25.10.0
damassi Feb 18, 2020
601def9
Merge pull request #5063 from damassi/add-order-app-to-global-router
damassi Feb 18, 2020
4b40668
Wire in Auction app to global router
damassi Feb 16, 2020
3a798a9
Bump reaction 25.11.0
damassi Feb 18, 2020
7b26297
Merge pull request #5064 from damassi/add-auction-app-to-router
damassi Feb 18, 2020
d98e9c3
Update yarn orb to v4
renovate-bot Feb 19, 2020
08d4679
Update yarn orb to v4 (#5072)
artsy-peril[bot] Feb 19, 2020
a55ecdc
Update dep @artsy/reaction from 25.11.0 to v25.11.1
renovate-bot Feb 19, 2020
33c19fc
Update dep @artsy/reaction from 25.11.1 to v25.11.2
renovate-bot Feb 19, 2020
259bae2
Update dep @artsy/reaction from 25.11.2 to v25.11.3
renovate-bot Feb 19, 2020
71ed177
Merge pull request #5076 from artsy/renovate/artsy-reaction-25.x
damassi Feb 19, 2020
17ec292
Update dep @artsy/reaction from 25.11.3 to v25.11.4
renovate-bot Feb 19, 2020
f8748e6
Merge pull request #5077 from artsy/renovate/artsy-reaction-25.x
damassi Feb 19, 2020
9ac1f41
Update dep @artsy/reaction from 25.11.4 to v25.11.6
renovate-bot Feb 19, 2020
6a711e1
Update dep @artsy/reaction from 25.11.6 to v25.12.0
renovate-bot Feb 20, 2020
67a5439
[Clientside Nav] Fix path to orders
damassi Feb 20, 2020
d5ede71
Update dep @artsy/reaction from 25.12.0 to v25.13.0
renovate-bot Feb 20, 2020
8809cdd
[Clientside Nav] Fix path to orders (#5081)
artsy-peril[bot] Feb 20, 2020
8571b87
Add specific redirects for Gallery Insights articles
dblandin Feb 20, 2020
655d133
Redirect Gallery Insights link to /gallery-resources page
dblandin Feb 20, 2020
4b2cbbe
Remove trailing ? from article redirect slug
dblandin Feb 20, 2020
19ac552
Remove trailing ? from article redirect slug (#5083)
artsy-peril[bot] Feb 20, 2020
8088ae9
Update dep @artsy/reaction from 25.13.0 to v25.13.1
renovate-bot Feb 20, 2020
18328ec
Merge pull request #5084 from artsy/renovate/artsy-reaction-25.x
damassi Feb 20, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1

orbs:
yarn: artsy/yarn@2.1.1
yarn: artsy/yarn@4.0.0
hokusai: artsy/hokusai@0.7.2
node: artsy/node@0.1.0
horizon: artsy/release@0.0.1
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"@artsy/gemup": "0.0.3",
"@artsy/palette": "5.1.16",
"@artsy/passport": "1.1.11",
"@artsy/reaction": "25.9.2",
"@artsy/reaction": "25.13.1",
"@artsy/stitch": "6.1.6",
"@babel/core": "7.6.0",
"@babel/node": "7.6.1",
Expand Down
17 changes: 17 additions & 0 deletions src/desktop/apps/article/__tests__/routes.jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getCurrentUnixTimestamp } from "@artsy/reaction/dist/Components/Publish
import * as fixtures from "@artsy/reaction/dist/Components/Publishing/Fixtures/Articles"
import * as routes from "../routes"
import { extend } from "lodash"
import { GalleryInsightsRedirects } from "../gallery_insights_redirects"
const Article = require("desktop/models/article.coffee")
const Channel = require("desktop/models/channel.coffee")

Expand Down Expand Up @@ -173,6 +174,22 @@ describe("Article Routes", () => {
})
})

it("redirects to specific partners.artsy.net content if slug exists in redirect mapping", done => {
const slug = Object.keys(GalleryInsightsRedirects)[0]
const redirectSlug = GalleryInsightsRedirects[slug]

article.channel_id = "987"
article.slug = slug
positronql.mockReturnValue(Promise.resolve({ article }))

routes.index(req, res, next).then(() => {
expect(res.redirect).toBeCalledWith(
`https://partners.artsy.net/${redirectSlug}`
)
done()
})
})

describe("templates", () => {
it("sets the blank template for video layout", done => {
article = extend(fixtures.VideoArticle, {
Expand Down
30 changes: 30 additions & 0 deletions src/desktop/apps/article/gallery_insights_redirects.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export const GalleryInsightsRedirects = {
"elena-soboleva-what-we-learned-from-writing-7-000-artist-bios":
"resource/what-we-learned-from-writing-artist-bios",

"gallery-insights-practical-digital-security-for-your-gallery":
"resource/digital-security-for-your-gallery",

"gallery-insights-brett-gorvy-new-storefont":
"resource/brett-gorvy-online-storefront",

"gallery-insights-the-pop-up-gallery-checklist?": "resource/pop-up-galleries",

"gallery-insights-artful-pitch": "resource/press-for-your-gallery",

"elena-soboleva-how-to-write-an-effective-press-release":
"resource/write-an-effective-press-release-for-your-gallery",

"gallery-insights-3-misconceptions-about-professional-art-buyers":
"resource/professional-art-buyers",

"gallery-insights-vr-galleries-04-04-17": "resource/vr-for-galleries",

"gallery-insights-focus-in-on-better-gallery-photography":
"resource/focus-in-on-better-gallery-photography",

"elena-soboleva-sale-scam-verifying-online-inquiries":
"resource/verify-online-inquiries",

"gallery-insights-collectors-engaged": "resource/keep-collectors-engaged",
}
13 changes: 11 additions & 2 deletions src/desktop/apps/article/routes.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as _ from "underscore"
import embed from "particle"
import { URL } from "url"
import { URL, resolve } from "url"
import { App } from "desktop/apps/article/components/App"
import ArticleQuery from "desktop/apps/article/queries/article"
import {
Expand Down Expand Up @@ -28,6 +28,7 @@ import {
import cheerio from "cheerio"
import React from "react"
import { ArticleMeta } from "@artsy/reaction/dist/Components/Publishing/ArticleMeta"
import { GalleryInsightsRedirects } from "./gallery_insights_redirects"
const Articles = require("desktop/collections/articles.coffee")
const markdown = require("desktop/components/util/markdown.coffee")
const { crop, resize } = require("desktop/components/resizer/index.coffee")
Expand Down Expand Up @@ -61,7 +62,15 @@ export const index = async (req, res, next) => {
if (article.channel_id !== sd.ARTSY_EDITORIAL_CHANNEL) {
// Redirect deprecated Gallery Insights articles
if (article.channel_id === sd.GALLERY_INSIGHTS_CHANNEL) {
return res.redirect("https://partners.artsy.net")
const resourceSlug = GalleryInsightsRedirects[article.slug]

if (resourceSlug) {
return res.redirect(
resolve("https://partners.artsy.net", resourceSlug)
)
} else {
return res.redirect("https://partners.artsy.net")
}
}
return classic(req, res, next)
}
Expand Down
21 changes: 17 additions & 4 deletions src/desktop/apps/auction_reaction/server.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
import express from "express"
import { skipIfClientSideRoutingEnabled } from "desktop/components/split_test/skipIfClientSideRoutingEnabled"
import { bidderRegistration, auctionFAQRoute, confirmBidRoute } from "./routes"

export const app = express()

app.get("/auction-faq", auctionFAQRoute)
app.get("/auction-registration/:auctionID", bidderRegistration)
app.get("/auction-registration2/:auctionID*", bidderRegistration)
app.get("/auction/:auctionID/bid/:artworkID", confirmBidRoute)
app.get("/auction-faq", skipIfClientSideRoutingEnabled, auctionFAQRoute)
app.get(
"/auction-registration/:auctionID",
skipIfClientSideRoutingEnabled,
bidderRegistration
)
app.get(
"/auction-registration2/:auctionID*",
skipIfClientSideRoutingEnabled,
bidderRegistration
)
app.get(
"/auction/:auctionID/bid/:artworkID",
skipIfClientSideRoutingEnabled,
confirmBidRoute
)
10 changes: 8 additions & 2 deletions src/desktop/apps/auction_support/index.coffee
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
express = require 'express'
routes = require './routes'
{ skipIfClientSideRoutingEnabled } = require("../../components/split_test/skipIfClientSideRoutingEnabled")

app = module.exports = express()
app.set 'views', __dirname + '/templates'
app.set 'view engine', 'jade'

app.get '/auction-registration/:id', routes.modalAuctionRegistration
app.get '/auction/:id/buyers-premium', routes.buyersPremium
# FIXME: Remove once A/B test completes
if process.env.EXPERIMENTAL_APP_SHELL
app.get '/auction-registration-modal/:id', routes.modalAuctionRegistration
else
app.get '/auction-registration/:id', routes.modalAuctionRegistration

app.get '/auction/:id/buyers-premium', routes.buyersPremium
8 changes: 7 additions & 1 deletion src/desktop/apps/auction_support/routes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ registerAndRedirect = (sale, req, res, next) ->
req.user.fetchCreditCards
error: res.backboneError
success: (creditCards) ->

# FIXME: What happens when creditCards.length === 0? Noticing that the app hangs
if (creditCards.length > 0)
# If the user did not accept conditions explicitly
# (through the AcceptConditionsOfSaleModal) redirect to the auction flow
Expand All @@ -29,12 +31,16 @@ registerAndRedirect = (sale, req, res, next) ->
}
)
res.redirect sale.registrationSuccessUrl()
else
# FIXME: Not sure how to handle this case
console.log('Error: No credit card...')
res.redirect sale.redirectUrl(sale.get('href'))


@modalAuctionRegistration = (req, res, next) ->
unless req.user
return res.redirect "/log_in?redirect_uri=/auction-registration/#{req.params.id}"

new Sale(id: req.params.id).fetch
error: res.backboneError
success: (sale) ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export const bidderRegistrationMiddleware = (req, res, next) => {
const pageParts = req.path.split("/")
const pageType = pageParts[1]
console.log(req.params)

if (
pageType === "auction-registration" ||
pageType === "auction-registration2"
) {
/**
* If this request is from a registration modal (trying to create a bidder),
* defer to the auction_support app router.
*
* @see Force: src/desktop/apps/auction_support/index.coffee
*/
if (req.query["accepted-conditions"] === "true") {
const newUrl = req.url.replace(
"/auction-registration/",
"/auction-registration-modal/"
)
return res.redirect(newUrl)
} else if (!res.locals.sd.CURRENT_USER) {
return res.redirect(
`/login?redirectTo=${encodeURIComponent(req.originalUrl)}`
)
}
}

next()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const confirmBidMiddleware = (req, res, next) => {
const pageParts = req.path.split("/")
const pageType = pageParts[1]

if (pageType === "auction") {
if (!res.locals.sd.CURRENT_USER) {
return res.redirect(
`/login?redirectTo=${encodeURIComponent(req.originalUrl)}`
)
}
}

next()
}
24 changes: 13 additions & 11 deletions src/desktop/apps/experimental-app-shell/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { getAppRoutes } from "reaction/Apps/getAppRoutes"
import { data as sd } from "sharify"
import { client as artworkClient } from "./artwork/client"
import { client as artistClient } from "./artist/client"
import { loadableReady } from "@loadable/component"

/**
* FIXME: Do we actually need this to rehydrate split bundles? Noticing that
* when used things break, get laggy, etc. (Seems) as though it's not actually
* needed, or we're doing something incorrect when emitting split bundled scripts
* from `Reaction/Router/buildServerApp`.
*/
// import { loadableReady } from "@loadable/component"

const mediator = require("desktop/lib/mediator.coffee")

Expand All @@ -24,18 +24,20 @@ buildClientApp({
} as any,
})
.then(({ ClientApp }) => {
ReactDOM.hydrate(
<ClientApp />,
document.getElementById("react-root"),
() => {
const pageType = window.location.pathname.split("/")[1]
loadableReady(() => {
ReactDOM.hydrate(
<ClientApp />,
document.getElementById("react-root"),
() => {
const pageType = window.location.pathname.split("/")[1]

if (pageType === "search") {
document.getElementById("loading-container").remove()
document.getElementById("search-page-header").remove()
if (pageType === "search") {
document.getElementById("loading-container").remove()
document.getElementById("search-page-header").remove()
}
}
}
)
)
})
})
.catch(error => {
console.error(error)
Expand Down
14 changes: 14 additions & 0 deletions src/desktop/apps/experimental-app-shell/order/orderMiddleware.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const orderMiddleware = (req, res, next) => {
const pageParts = req.path.split("/")
const pageType = pageParts[1]

if (pageType === "orders") {
if (!res.locals.sd.CURRENT_USER) {
return res.redirect(
`/login?redirectTo=${encodeURIComponent(req.originalUrl)}`
)
}
}

next()
}
57 changes: 48 additions & 9 deletions src/desktop/apps/experimental-app-shell/server.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,64 @@
import React from "react"
import express, { Request } from "express"
import { buildServerApp } from "@artsy/reaction/dist/Artsy/Router/server"
import {
buildServerApp,
ServerAppResolve,
} from "@artsy/reaction/dist/Artsy/Router/server"
import { getAppRoutes } from "reaction/Apps/getAppRoutes"
import { stitch } from "@artsy/stitch"
import { buildServerAppContext } from "desktop/lib/buildServerAppContext"
import { SearchResultsSkeleton } from "reaction/Apps/Search/Components/SearchResultsSkeleton"
import { StitchWrapper } from "desktop/components/react/stitch_components/StitchWrapper"
import { artistMiddleware } from "./artist/middleware"

import { handleArtworkImageDownload } from "./artwork/artworkMiddleware"
import { artistMiddleware } from "./artist/artistMiddleware"
import { bidderRegistrationMiddleware } from "./auction/bidderRegistrationMiddleware"
import { confirmBidMiddleware } from "./auction/confirmBidMiddleware"
import { orderMiddleware } from "./order/orderMiddleware"
import { searchMiddleware } from "./search/middleware"
import { handleArtworkImageDownload } from "./artwork/middleware"

export const app = express()

// Non-Reaction routes
app.get("/artwork/:artworkID/download/:filename", handleArtworkImageDownload)

/**
* Mount routes that will connect to global SSR router
*/
app.get(
"/*",
searchMiddleware,

/**
* Mount middleware for handling server-side portions of apps mounted into
* global router.
*/
artistMiddleware,
bidderRegistrationMiddleware,
confirmBidMiddleware,
orderMiddleware,
searchMiddleware,

/**
* Route handler
*/
async (req: Request, res, next) => {
try {
const pageParts = req.path.split("/")
const pageType = pageParts[1]
let serverApp
let serverApp: ServerAppResolve = {}

// Search intentionally bypasses SSR
if (pageType !== "search") {
/**
* Search intentionally bypasses SSR, but we still need to inject the
* experimental-app-shell asset into the page. Because of bundle splitting
* we now get that back dynamically from `buildServerApp` below.
*
* @see https://github.com/artsy/reaction/blob/master/src/Artsy/Router/buildServerApp.tsx#L157
*/
if (pageType === "search") {
// Use helper defined in assetMiddleware to return fingerprinted url
const scriptUrl = res.locals.asset("/assets/experimental-app-shell.js")
serverApp.scripts = `<script async data-chunk="experimental-app-shell" src="${scriptUrl}"></script>`
} else {
serverApp = await buildServerApp({
context: buildServerAppContext(req, res),
routes: getAppRoutes(),
Expand All @@ -35,8 +67,7 @@ app.get(
})
}

const { styleTags, scripts, redirect, bodyHTML, headTags } =
serverApp || {}
const { styleTags, scripts, redirect, bodyHTML, headTags } = serverApp

if (redirect) {
res.redirect(302, redirect.url)
Expand Down Expand Up @@ -80,6 +111,14 @@ app.get(
styleTags,
pageType,

// TODO: Follow up with Justin on stripe include in scripts.jade
// template. Right now the order app explicitly sets this to true,
// but looking over there it seems we're already including it on
// every page, with `async` and `defer`.
// options: {
// stripev3: true, // for order app
// },

/**
* NOTE: The asset package isn't needed here because we're dynamically
* injecting it into `scripts` array in buildServerApp.tsx, which gets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ block body
a.gallery-partnership-link.fine-faux-underline( data-context='galleries header' href='/#{type}-partnerships' )
| Partner with Artsy
if type === 'gallery'
a.fine-faux-underline( href='https://partners.artsy.net' )
a.fine-faux-underline( href='https://partners.artsy.net/gallery-resources' )
| Gallery Insights

block content
Expand Down
Loading