Skip to content
This repository has been archived by the owner on Aug 21, 2019. It is now read-only.

support multiple generic marketing modals #119

Merged
merged 2 commits into from
Feb 10, 2017

Conversation

xtina-starr
Copy link
Contributor

closes: https://github.com/artsy/collector-experience/issues/121

This is the mg equivalent for artsy/force#826 and adds support for multiple marketing campaign modals using a hardcoded stringified JSON object set in heroku.

screen shot 2017-02-08 at 1 57 53 pm

screen shot 2017-02-08 at 1 57 13 pm

screen shot 2017-02-08 at 1 56 51 pm

screen shot 2017-02-08 at 1 56 28 pm

@ArtsyOpenSource
Copy link

ArtsyOpenSource commented Feb 8, 2017

<tr>
  <td>:warning:</td>
  <td data-sticky="false">Please assign someone to your PR</td>
</tr>
1 Warning

Generated by 🚫 danger

modalData = _.findWhere(sd.MARKETING_SIGNUP_MODALS, { slug: slug })

if modalData
sd.MARKETING_SIGNUP_MODAL_IMG = modalData.image
Copy link
Contributor

@craigspaeth craigspaeth Feb 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a clever way to inject data into sd to leverage the existing code, but be careful because sd is a global object. On the server that means it's shared across requests and can cause unexpected behaviors, or worse, leak user-specific data across requests if you're not careful.

You could address this by simply modifying the request level sd via res.locals.sd. MARKETING_SIGNUP_MODAL_IMG = ... or refactor the code downstream so that you're passing the modal data through locals e.g. res.locals.modal = modalData and changing the template to use modal.image modal.copy etc. to be more like the refactor we did in Force.

Either works for me, but the latter might be nicer as it's more consistent with what we do in Force.

@craigspaeth
Copy link
Contributor

Thanks for the refactors, looks great!

@craigspaeth craigspaeth merged commit 577472d into artsy:master Feb 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants