Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/guardian/frontend into jd…
Browse files Browse the repository at this point in the history
…r-garnett-fixes
  • Loading branch information
joshua-david committed Dec 12, 2017
1 parent 064a3df commit e510193
Show file tree
Hide file tree
Showing 26 changed files with 282 additions and 178 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -5,7 +5,7 @@ Ever thought about joining us?
https://workforus.theguardian.com/careers/digital-development/

# Frontend
[The Guardian](http://www.theguardian.com) website frontend.
[The Guardian](https://www.theguardian.com) website frontend.

Frontend is [a set of Play Framework 2 Scala applications](https://github.com/guardian/frontend/wiki/Applications-architecture).

Expand Down
10 changes: 0 additions & 10 deletions common/app/conf/switches/ABTestSwitches.scala
Expand Up @@ -126,16 +126,6 @@ trait ABTestSwitches {
exposeClientSide = true
)

Switch(
ABTests,
"ab-acquisitions-banner-shorter-copy",
"Test highlighting a different sentance in the epic",
owners = Seq(Owner.withGithub("jranks123")),
safeState = Off,
sellByDate = new LocalDate(2017, 12, 13),
exposeClientSide = true
)

Switch(
ABTests,
"ab-acquisitions-epic-testimonials-group",
Expand Down
16 changes: 9 additions & 7 deletions common/app/views/fragments/nav/newHeaderMenu.scala.html
Expand Up @@ -182,14 +182,16 @@
}

@if(HeaderFeedback.isSwitchedOn) {
<li class="hide-until-desktop feedback-form">
@fragments.inlineSvg("information-circle", "icon", List("feedback-form__icon"))
We&rsquo;d appreciate your feedback on our new navigation.
<a class="feedback-form__link"
data-link-name="nav2 : feedback-form"
<a data-link-name="nav2 : feedback-form"
href="https://goo.gl/forms/j5pMsPSWINu7X2R62">
Share your thoughts here.</a>
</li>

<li class="hide-until-desktop feedback-form">
@fragments.inlineSvg("information-circle", "icon", List("feedback-form__icon"))
We&rsquo;d appreciate your feedback on our new navigation.
<span class="feedback-form__link">
Share your thoughts here.</span>
</li>
</a>
}
</ul>
</div>
Expand Down
Binary file removed dev/sbt-launch.jar
Binary file not shown.
16 changes: 0 additions & 16 deletions dev/teamcity/dist-play-tc

This file was deleted.

13 changes: 0 additions & 13 deletions dev/teamcity/sbt-tc

This file was deleted.

32 changes: 18 additions & 14 deletions identity/app/controllers/EditProfileController.scala
Expand Up @@ -21,6 +21,8 @@ import scala.concurrent.Future
import conf.switches.Switches.IdentityAllowAccessToGdprJourneyPageSwitch
import play.api.http.HttpConfiguration

import pages.JourneyHtmlPage

object PublicEditProfilePage extends IdentityPage("/public/edit", "Edit Public Profile")
object AccountEditProfilePage extends IdentityPage("/account/edit", "Edit Account Details")
object EmailPrefsProfilePage extends IdentityPage("/email-prefs", "Emails")
Expand Down Expand Up @@ -227,20 +229,22 @@ class EditProfileController(

newsletterService.subscriptions(request.user.getId, idRequestParser(request).trackingData).map { emailFilledForm =>

NoCache(Ok(views.html.consentJourney(
page,
user,
forms,
journey,
returnUrlVerifier.getVerifiedReturnUrl(request).getOrElse(returnUrlVerifier.defaultReturnUrl),
idRequestParser(request),
idUrlBuilder,
emailFilledForm,
newsletterService.getEmailSubscriptions(emailFilledForm),
EmailNewsletters.all,
consentHint,
newsletterHint
)))
NoCache(Ok(
JourneyHtmlPage.html(content = views.html.consentJourney(
page,
user,
forms,
journey,
returnUrlVerifier.getVerifiedReturnUrl(request).getOrElse(returnUrlVerifier.defaultReturnUrl),
idRequestParser(request),
idUrlBuilder,
emailFilledForm,
newsletterService.getEmailSubscriptions(emailFilledForm),
EmailNewsletters.all,
consentHint,
newsletterHint
))(page, request, context)
))

}
}
Expand Down
58 changes: 58 additions & 0 deletions identity/app/pages/JourneyHtmlPage.scala
@@ -0,0 +1,58 @@
package pages

import html.HtmlPageHelpers._
import html.Styles
import model.{ApplicationContext, Page}
import play.api.mvc.RequestHeader
import play.twirl.api.Html
import views.html.fragments.{_}
import views.html.fragments.page._
import views.html.fragments.page.body._
import views.html.fragments.page.head.stylesheets.{criticalStyleInline, criticalStyleLink, styles}
import views.html.fragments.page.head.{fixIEReferenceErrors, headTag, titleTag, weAreHiring}
import html.HtmlPageHelpers.ContentCSSFile

object JourneyHtmlPage {

def allStyles(implicit applicationContext: ApplicationContext, request: RequestHeader): Styles = new Styles {
override def criticalCssLink: Html = criticalStyleLink("identity")
override def criticalCssInline: Html = criticalStyleInline(Html(common.Assets.css.head(None)))
override def linkCss: Html = stylesheetLink(s"stylesheets/$ContentCSSFile.css")
override def oldIECriticalCss: Html = stylesheetLink(s"stylesheets/old-ie.head.$ContentCSSFile.css")
override def oldIELinkCss: Html = stylesheetLink(s"stylesheets/old-ie.$ContentCSSFile.css")
override def IE9LinkCss: Html = stylesheetLink(s"stylesheets/ie9.head.$ContentCSSFile.css")
override def IE9CriticalCss: Html = stylesheetLink(s"stylesheets/ie9.$ContentCSSFile.css")
}

def html(
content: Html,
maybeHeadContent: Option[Html] = None
)(implicit page: Page, request: RequestHeader, applicationContext: ApplicationContext): Html = {

val head: Html = maybeHeadContent.getOrElse(Html(""))
val bodyClasses: Map[String, Boolean] = defaultBodyClasses()

htmlTag(
headTag(
titleTag(),
metaData(),
head,
styles(allStyles),
fixIEReferenceErrors(),
inlineJSBlocking()
),
bodyTag(classes = bodyClasses)(
skipToMainContent(),
guardianHeaderHtml(),
mainContent(),
content,
inlineJSNonBlocking(),
views.html.fragments.identitySlimFooter(),
analytics.base()
),
devTakeShot()
)
}

}

5 changes: 2 additions & 3 deletions identity/app/services/NewsletterService.scala
Expand Up @@ -2,7 +2,7 @@ package services

import actions.AuthenticatedActions
import actions.AuthenticatedActions.AuthRequest
import com.gu.identity.model.{EmailList, Subscriber}
import com.gu.identity.model.{EmailList, EmailNewsletters, Subscriber}
import idapiclient.{IdApiClient, TrackingData}
import idapiclient.responses.Error
import play.api.data._
Expand Down Expand Up @@ -81,8 +81,7 @@ class NewsletterService(
form: Form[EmailPrefsData],
add: List[String] = List(),
remove: List[String] = List()): List[String] = {
//TODO: only return V1 subscriptions when V2 subscriptions are in place
getEmailSubscriptions(form,add,remove)
getEmailSubscriptions(form, add, remove).filter(EmailNewsletters.v1ListIds.contains)
}
}

Expand Down
97 changes: 50 additions & 47 deletions identity/app/views/consentJourney.scala.html
Expand Up @@ -22,9 +22,15 @@
newsletterHint: Option[String] = None
)(implicit request: RequestHeader, messages: play.api.i18n.Messages, context: model.ApplicationContext)

@onlySubscribedToNewsletters = @{
EmailNewsletters.all.subscriptions.filter { newsletter =>
emailSubscriptions.contains(newsletter.listId.toString)
@onlySubscribedToNewsletters(onlyV1Newsletters: Boolean) = @{
if (onlyV1Newsletters) {
EmailNewsletters.all.subscriptions.filter { newsletter =>
emailSubscriptions.intersect(newsletter.aliasedIds.map(_.toString)).nonEmpty
}
} else {
EmailNewsletters.all.subscriptions.filter { newsletter =>
emailSubscriptions.intersect(newsletter.allIds.map(_.toString)).nonEmpty
}
}
}

Expand Down Expand Up @@ -85,12 +91,13 @@ <h2 class="identity-title">Your existing newsletters</h2>
}
<div class="manage-account__switches">
<ul>
@onlySubscribedToNewsletters.zipWithRowInfo.map { case (newsletter, row) =>
@onlySubscribedToNewsletters(isNarrow).zipWithRowInfo.map { case (newsletter, row) =>
<li>
@fragments.newsletterSwitch(
emailPrefsForm,
emailSubscriptions,
newsletter = newsletter
newsletter = newsletter,
isNarrow
)(nonInputFields, messages, request)
</li>
}
Expand Down Expand Up @@ -137,57 +144,53 @@ <h2 class="manage-account-consent-thanks__title">Thank you</h2>
</div>
}

<div class="identity-wrapper-for-bg identity-wrapper-for-bg--overflows">
<div class="gs-container">
<div class="monocol-wrapper">

@mainLegacy(page, projectName = Option("identity")) { } {
<div class="u-cf identity-section identity-wrapper identity-wrapper--with-wizard">

<div class="identity-wrapper-for-bg identity-wrapper-for-bg--overflows">
<div class="gs-container">
<div class="monocol-wrapper">
<div class="js-errorHolder manage-account__errors"></div>

<div class="u-cf identity-section identity-wrapper">
<div class="manage-account-wizard manage-account-wizard--consent" data-journey="@journey">

<div class="js-errorHolder manage-account__errors"></div>

<div class="manage-account-wizard manage-account-wizard--consent" data-journey="@journey">

@journey match {
case "repermission-narrow" => {
@emailStep(isNarrow = true)
}
case "repermission" => {
@consentStep(journey = "repermission")
@emailStep()
}
case "signup" => {
@consentStep(journey = "signup")
@emailSignupStep()
}
@journey match {
case "repermission-narrow" => {
@emailStep(isNarrow = true)
}
case "repermission" => {
@consentStep(journey = "repermission")
@emailStep()
}
case "signup" => {
@consentStep(journey = "signup")
@emailSignupStep()
}
}

@endcardStep()

<div class="manage-account-wizard__controls">
<button
data-link-name="consent : @journey : navigation : prev"
class="manage-account-consent-wizard-button-back manage-account-consent-wizard__revealable manage-account__button--round manage-account__button js-manage-account-wizard__prev"
>
<span class="u-h">Previous</span>
@fragments.inlineSvg("arrow-left-stem", "icon")
</button>
<div class="manage-account-consent-wizard__revealable manage-account-consent-wizard-counter">
</div>
<button
data-link-name="consent : @journey : navigation : next"
class="manage-account__button--icon manage-account__button js-manage-account-consent-wizard__next"
>
<span>Next</span>
@fragments.inlineSvg("arrow-right", "icon")
</button>
@endcardStep()

<div class="manage-account-wizard__controls">
<button
data-link-name="consent : @journey : navigation : prev"
class="manage-account-consent-wizard-button-back manage-account-consent-wizard__revealable manage-account__button--round manage-account__button js-manage-account-wizard__prev"
>
<span class="u-h">Previous</span>
@fragments.inlineSvg("arrow-left-stem", "icon")
</button>
<div class="manage-account-consent-wizard__revealable manage-account-consent-wizard-counter">
</div>
<button
data-link-name="consent : @journey : navigation : next"
class="manage-account__button--icon manage-account__button js-manage-account-consent-wizard__next"
>
<span>Next</span>
@fragments.inlineSvg("arrow-right", "icon")
</button>
</div>

</div>

</div>
</div>
</div>
}
</div>
9 changes: 9 additions & 0 deletions identity/app/views/fragments/identitySlimFooter.scala.html
@@ -0,0 +1,9 @@
@import org.joda.time.LocalDate

@()

<footer class="manage-account-consent-slim-footer">
<div class="gs-container">
© @(new LocalDate().getYear) Guardian News and Media Limited or its affiliated companies. All rights reserved.
</div>
</footer>
12 changes: 10 additions & 2 deletions identity/app/views/fragments/newsletterSwitch.scala.html
Expand Up @@ -8,7 +8,8 @@
@(
emailPrefsForm: Form[_],
emailSubscriptions: List[String],
newsletter: EmailNewsletter
newsletter: EmailNewsletter,
transferV1SubscriptionsPrompt: Boolean = false
)(implicit handler: views.html.helper.FieldConstructor, messages: play.api.i18n.Messages, request: RequestHeader)

@buildFooter(newsletter: EmailNewsletter) = {
Expand All @@ -23,14 +24,21 @@
}
}

@isPreTicked = @{
if (transferV1SubscriptionsPrompt)
None
else
Some(newsletter.subscribedTo(emailSubscriptions).toString)
}

@newsletterField = @{
new Field(
form = emailPrefsForm,
name = newsletter.listId.toString,
constraints = Nil,
format = None,
errors = Nil,
value = Some(newsletter.subscribedTo(emailSubscriptions).toString)
value = isPreTicked
)
}

Expand Down

0 comments on commit e510193

Please sign in to comment.