Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/artsy/force into wip_chec…
Browse files Browse the repository at this point in the history
…k_gql_breaking
  • Loading branch information
orta committed Nov 15, 2018
2 parents f2cab46 + d965bf0 commit d8e9c96
Show file tree
Hide file tree
Showing 40 changed files with 371 additions and 268 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ npm-debug.log
dump.rdb
manifest.json
.cache
.cache-loader
COMMIT_HASH.txt

/data
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"javascript.validate.enable": true,
"search.exclude": {
"**/node_modules": true,
"**/graphql": true
"**/graphql": true,
".cache/**": true
},
"files.exclude": {
"**/.git": true
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@artsy/express-reloadable": "^1.3.1",
"@artsy/palette": "^2.18.1",
"@artsy/passport": "^1.1.0",
"@artsy/reaction": "^5.9.7",
"@artsy/reaction": "^6.1.8",
"@artsy/stitch": "^2.0.0",
"@babel/core": "^7.0.0",
"@babel/node": "^7.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,49 @@
import ArticleModel from "desktop/models/article.coffee"
import InfiniteScrollArticle from "../InfiniteScrollArticle"
import { once } from "lodash"
import PropTypes from "prop-types"
import React from "react"
import { once } from "lodash"

import { Article } from "reaction/Components/Publishing"
import Cookies from "desktop/components/cookies/index.coffee"
import _SuperArticleView from "desktop/components/article/client/super_article.coffee"
import { setupFollows, setupFollowButtons } from "../FollowButton.js"
import mediator from "desktop/lib/mediator.coffee"
import { ArticleProps } from "reaction/Components/Publishing/Article"
import {
ModalOptions,
ModalType,
} from "@artsy/reaction/dist/Components/Authentication/Types"

import InfiniteScrollArticle from "../InfiniteScrollArticle"
import { setupFollows, setupFollowButtons } from "../FollowButton"

const _SuperArticleView = require("desktop/components/article/client/super_article.coffee")
const ArticleModel = require("desktop/models/article.coffee")
const Cookies = require("desktop/components/cookies/index.coffee")
const mediator = require("desktop/lib/mediator.coffee")

// FIXME: Rewire
let SuperArticleView = _SuperArticleView

export default class ArticleLayout extends React.Component {
interface ArticleLayoutProps extends ArticleProps {
templates: {
SuperArticleFooter: string
SuperArticleHeader: string
}
}

interface ArticleLayoutState {
following: any // any because the Following class is defined in coffeescript
}

interface ArticleModalOptions extends ModalOptions {
signupIntent: string
}

export default class ArticleLayout extends React.Component<
ArticleLayoutProps,
ArticleLayoutState
> {
constructor(props) {
super(props)
this.state = {
following: setupFollows() || null,
}
}
static propTypes = {
article: PropTypes.object,
isMobile: PropTypes.bool,
isLoggedIn: PropTypes.bool,
isSuper: PropTypes.bool,
templates: PropTypes.object,
showTooltips: PropTypes.bool,
renderTime: PropTypes.number,
}

componentDidMount() {
const { article, isSuper } = this.props
Expand Down Expand Up @@ -64,22 +80,25 @@ export default class ArticleLayout extends React.Component {
once(() => {
setTimeout(() => {
this.handleOpenAuthModal("register", {
mode: "signup",
mode: ModalType.signup,
intent: "Viewed editorial",
signupIntent: "signup",
trigger: "timed",
triggerSeconds: 2,
copy: "Sign up for the Best Stories in Art and Visual Culture",
destination: location.href,
})
afterSignUpAction: {
action: "editorialSignup",
},
} as any)
}, 2000)
}),
{ once: true }
)
}
}

handleOpenAuthModal = (mode, options) => {
handleOpenAuthModal = (mode, options: ArticleModalOptions) => {
mediator.trigger("open:auth", {
mode,
...options,
Expand All @@ -94,10 +113,10 @@ export default class ArticleLayout extends React.Component {
isMobile,
renderTime,
showTooltips,
templates: { SuperArticleFooter, SuperArticleHeader } = {},
templates: { SuperArticleFooter, SuperArticleHeader } = {} as any,
} = this.props
const hasNav = isSuper || article.seriesArticle
const isStatic = hasNav

const isStatic = isSuper || article.seriesArticle

return (
<div>
Expand Down
2 changes: 2 additions & 0 deletions src/desktop/apps/article/queries/articleBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const articleBody = `
partner_light_logo
partner_condensed_logo
partner_logo_link
pixel_tracking_code
}
seriesArticle {
title
Expand All @@ -41,6 +42,7 @@ export const articleBody = `
partner_light_logo
partner_condensed_logo
partner_logo_link
pixel_tracking_code
}
}
super_article {
Expand Down
7 changes: 0 additions & 7 deletions src/desktop/apps/article/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,6 @@ export async function index(req, res, next) {

// Email signup
const isLoggedIn = typeof CURRENT_USER !== "undefined"
let onDailyEditorial = false
// Only need to check subscription on mobile
if (isMobile && CURRENT_USER) {
onDailyEditorial = await subscribedToEditorial(CURRENT_USER.email)
}

const showTooltips = !isMobile && !isTablet
const renderTime = getCurrentUnixTimestamp()

Expand All @@ -159,7 +153,6 @@ export async function index(req, res, next) {
isLoggedIn,
isMobile,
jsonLD,
onDailyEditorial,
renderTime,
showTooltips,
superArticle,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- var auction = artwork.sale
- var sale_artwork = artwork.sale_artwork
- var labFeatures = sd && sd.CURRENT_USER && sd.CURRENT_USER.lab_features

if auction.is_auction_promo
//- Unimplemented
Expand All @@ -10,6 +11,8 @@ else if auction.is_preview || auction.is_open || auction.is_live_open
include ./live
include ./bid
include ./buy_now
if labFeatures && labFeatures.indexOf("Pageviews in Sidebar") > -1
!= stitch.components.ArtworkSidebarPageviews({artworkID: artwork.id})
include ./buyers_premium
include ./help

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
- var auctionPartner = artwork.partner.type === 'Auction' || artwork.partner.type === 'Auction House'
- var labFeatures = sd.CURRENT_USER && sd.CURRENT_USER.lab_features
- var isCommercial = artwork.is_acquireable || artwork.is_offerable || artwork.is_inquireable
- var hasLabFeature = labFeatures && labFeatures.indexOf("Pageviews in Sidebar") > -1

.artwork-commercial( class='js-artwork-commercial' )
form.artwork-commercial__form
Expand All @@ -10,6 +13,9 @@
else if artwork.is_inquireable
include inquire

if isCommercial && hasLabFeature
!= stitch.components.ArtworkSidebarPageviews({artworkID: artwork.id})

include partner
include questions
include consign
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
if artwork.partner && artwork.partner.artworks && artwork.partner.artworks.length
section.artwork-section.artwork-partner-artworks( class='js-artwork-partner-artworks' )
- var link = artwork.partner.type === "Auction House" ? artwork.partner.href : (artwork.partner.href + "/works")
header.artwork-partner-artworks__header
h3.artwork-partner-artworks__header__name
| Other Works from #{artwork.partner.name}

a.artwork-partner-artworks__header__jump(
href='#{artwork.partner.href}/works'
href='#{link}'
) View All

if sd.ENABLE_EXPERIMENTAL_STITCH_INJECTION
Expand All @@ -16,6 +17,6 @@ if artwork.partner && artwork.partner.artworks && artwork.partner.artworks.lengt
include ../../../../components/artwork_masonry/index

.artwork-section__jump
a.avant-garde-jump-link( href='#{artwork.partner.href}/works' )
a.avant-garde-jump-link( href='#{link}' )
| View all #{artwork.partner.counts.artworks} from #{artwork.partner.name}
i.icon-chevron-small-right
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = """
fragment partner_artworks on Artwork {
partner {
type
name
href
counts {
Expand Down
10 changes: 10 additions & 0 deletions src/desktop/apps/auction/__tests__/routes.jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ describe("routes", () => {
await routes.index(req, res, next)
expect(res.send).toBeCalledWith("<html />")
})

it("works even with the Metaphysics module throwing an error", async () => {
metaphysics
.mockReturnValueOnce({ sale: { is_auction: true } })
.mockRejectedValue("oops!")

// FIXME: Need to write more robust output test
await routes.index(req, res, next)
expect(res.send).toBeCalledWith("<html />")
})
})

describe("#redirectLive", async () => {
Expand Down
15 changes: 11 additions & 4 deletions src/desktop/apps/auction/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,17 @@ export async function index(req, res, next) {
let me = {}

if (!isEcommerceSale) {
;({ me } = await metaphysics({
query: MeQuery(sale.id),
req,
}))
try {
;({ me } = await metaphysics({
query: MeQuery(sale.id),
req,
}))
} catch (error) {
console.error(
"(apps/auction/routes.js) Error fetching LotStandings",
error
)
}
}

// If an e-commerce sale, remove all sort options that are Auction related
Expand Down
16 changes: 11 additions & 5 deletions src/desktop/apps/auth2/components/ModalContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
import Cookies from "cookies-js"
import React from "react"
import { ModalManager } from "reaction/Components/Authentication/Desktop/ModalManager"
import { handleSubmit, setCookies } from "../helpers"
import { data as sd } from "sharify"

import { handleSubmit, setCookies } from "../helpers"
import { ModalManager } from "reaction/Components/Authentication/Desktop/ModalManager"
import {
ModalOptions,
ModalType,
} from "reaction/Components/Authentication/Types"

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

export const ModalContainer: React.SFC<any> = () => {
let manager: ModalManager | null

mediator.on("open:auth", options => {
mediator.on("open:auth", (options: ModalOptions) => {
options.destination = options.destination || location.href

setCookies(options)

if (options && options.mode === "register") {
options.mode = "signup"
if (options && (options.mode as any) === "register") {
options.mode = ModalType.signup
}

setTimeout(() => {
Expand Down
11 changes: 2 additions & 9 deletions src/desktop/apps/auth2/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,8 @@ export const index = async (req, res, next) => {
const redirectTo = req.query.redirectTo || "/"
const signupReferer = req.header("Referer") || req.host

if (action && objectId && kind) {
res.cookie(
"afterSignUpAction",
JSON.stringify({
action,
objectId,
kind,
})
)
if (action) {
res.cookie("afterSignUpAction", JSON.stringify({ action, objectId, kind }))
}

try {
Expand Down
6 changes: 0 additions & 6 deletions src/desktop/apps/collect2/meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,9 @@ interface Props {
export const Meta = (props: Props) => {
const { headTags } = props

const description =
"Find artworks by subject matter, style/technique, movement, price, and gallery/institution."

return (
<Fragment>
{headTags}
<meta name="description" content={description} />
<meta property="og:description" content={description} />
<meta property="twitter:description" content={description} />

<meta property="og:type" content="website" />
<meta property="twitter:card" content="summary" />
Expand Down
18 changes: 18 additions & 0 deletions src/desktop/apps/collections/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { buildClientApp } from "reaction/Artsy/Router/client"
import { data as sd } from "sharify"
import { routes } from "reaction/Apps/Collections/routes"
import mediator from "desktop/lib/mediator.coffee"
import React from "react"
import ReactDOM from "react-dom"

buildClientApp({ routes, context: { user: sd.CURRENT_USER, mediator } })
.then(({ ClientApp }) => {
ReactDOM.hydrate(<ClientApp />, document.getElementById("react-root"))
})
.catch(error => {
console.error(error)
})

if (module.hot) {
module.hot.accept()
}
Loading

0 comments on commit d8e9c96

Please sign in to comment.