-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from hmrc/develop
Develop
- Loading branch information
Showing
159 changed files
with
4,339 additions
and
1,578 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,36 @@ | ||
package config | ||
|
||
import com.google.inject.{Inject, Singleton} | ||
import play.api.{Configuration, Environment} | ||
import play.api.i18n.Lang | ||
import controllers.routes | ||
import uk.gov.hmrc.play.config.ServicesConfig | ||
import play.api.Configuration | ||
import play.api.i18n.Lang | ||
import play.api.mvc.Call | ||
|
||
@Singleton | ||
class FrontendAppConfig @Inject() (override val runModeConfiguration: Configuration, environment: Environment) extends ServicesConfig { | ||
class FrontendAppConfig @Inject() (configuration: Configuration) { | ||
|
||
override protected def mode = environment.mode | ||
private val contactHost = configuration.get[String]("contact-frontend.host") | ||
private val contactFormServiceIdentifier = "play26frontend" | ||
|
||
private def loadConfig(key: String) = runModeConfiguration.getString(key).getOrElse(throw new Exception(s"Missing configuration key: \$key")) | ||
val analyticsToken: String = configuration.get[String](s"google-analytics.token") | ||
val analyticsHost: String = configuration.get[String](s"google-analytics.host") | ||
val reportAProblemPartialUrl = s"\$contactHost/contact/problem_reports_ajax?service=\$contactFormServiceIdentifier" | ||
val reportAProblemNonJSUrl = s"\$contactHost/contact/problem_reports_nonjs?service=\$contactFormServiceIdentifier" | ||
val betaFeedbackUrl = s"\$contactHost/contact/beta-feedback" | ||
val betaFeedbackUnauthenticatedUrl = s"\$contactHost/contact/beta-feedback-unauthenticated" | ||
|
||
private lazy val contactHost = runModeConfiguration.getString("contact-frontend.host").getOrElse("") | ||
private val contactFormServiceIdentifier = "$name;format="lower,word"$" | ||
lazy val authUrl: String = configuration.get[Service]("auth").baseUrl | ||
lazy val loginUrl: String = configuration.get[String]("urls.login") | ||
lazy val loginContinueUrl: String = configuration.get[String]("urls.loginContinue") | ||
|
||
lazy val analyticsToken = loadConfig(s"google-analytics.token") | ||
lazy val analyticsHost = loadConfig(s"google-analytics.host") | ||
lazy val reportAProblemPartialUrl = s"\$contactHost/contact/problem_reports_ajax?service=\$contactFormServiceIdentifier" | ||
lazy val reportAProblemNonJSUrl = s"\$contactHost/contact/problem_reports_nonjs?service=\$contactFormServiceIdentifier" | ||
lazy val betaFeedbackUrl = s"\$contactHost/contact/beta-feedback" | ||
lazy val betaFeedbackUnauthenticatedUrl = s"\$contactHost/contact/beta-feedback-unauthenticated" | ||
lazy val languageTranslationEnabled: Boolean = | ||
configuration.get[Boolean]("microservice.services.features.welsh-translation") | ||
|
||
lazy val authUrl = baseUrl("auth") | ||
lazy val loginUrl = loadConfig("urls.login") | ||
lazy val loginContinueUrl = loadConfig("urls.loginContinue") | ||
|
||
lazy val languageTranslationEnabled = runModeConfiguration.getBoolean("microservice.services.features.welsh-translation").getOrElse(true) | ||
def languageMap: Map[String, Lang] = Map( | ||
"english" -> Lang("en"), | ||
"cymraeg" -> Lang("cy")) | ||
def routeToSwitchLanguage = (lang: String) => routes.LanguageSwitchController.switchToLanguage(lang) | ||
"cymraeg" -> Lang("cy") | ||
) | ||
|
||
def routeToSwitchLanguage: String => Call = | ||
(lang: String) => routes.LanguageSwitchController.switchToLanguage(lang) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,19 @@ | ||
/* | ||
* Copyright 2018 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package config | ||
|
||
import com.google.inject.AbstractModule | ||
import connectors._ | ||
import controllers.actions._ | ||
import repositories.{DefaultSessionRepository, SessionRepository} | ||
|
||
class Module extends AbstractModule { | ||
|
||
override def configure(): Unit = { | ||
|
||
// Bind the actions for DI | ||
bind(classOf[DataRetrievalAction]).to(classOf[DataRetrievalActionImpl]).asEagerSingleton() | ||
bind(classOf[DataRequiredAction]).to(classOf[DataRequiredActionImpl]).asEagerSingleton() | ||
|
||
// For session based storage instead of cred based, change to SessionIdentifierAction | ||
bind(classOf[IdentifierAction]).to(classOf[AuthenticatedIdentifierAction]).asEagerSingleton() | ||
|
||
bind(classOf[DataCacheConnector]).to(classOf[MongoCacheConnector]).asEagerSingleton() | ||
bind(classOf[SessionRepository]).to(classOf[DefaultSessionRepository]).asEagerSingleton() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package config | ||
|
||
import play.api.{ConfigLoader, Configuration} | ||
|
||
import scala.language.implicitConversions | ||
|
||
final case class Service(host: String, port: String, protocol: String) { | ||
|
||
def baseUrl: String = | ||
s"\$protocol://\$host:\$port" | ||
|
||
override def toString: String = | ||
baseUrl | ||
} | ||
|
||
object Service { | ||
|
||
implicit lazy val configLoader: ConfigLoader[Service] = ConfigLoader { | ||
config => | ||
prefix => | ||
|
||
val service = Configuration(config).get[Configuration](prefix) | ||
val host = service.get[String]("host") | ||
val port = service.get[String]("port") | ||
val protocol = service.get[String]("protocol") | ||
|
||
Service(host, port, protocol) | ||
} | ||
|
||
implicit def convertToString(service: Service): String = | ||
service.baseUrl | ||
} |
This file was deleted.
Oops, something went wrong.
28 changes: 17 additions & 11 deletions
28
src/main/g8/app/controllers/CheckYourAnswersController.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,30 @@ | ||
package controllers | ||
|
||
import com.google.inject.Inject | ||
import controllers.actions.{DataRequiredAction, DataRetrievalAction, IdentifierAction} | ||
import play.api.i18n.{I18nSupport, MessagesApi} | ||
import controllers.actions.{IdentifierAction, DataRequiredAction, DataRetrievalAction} | ||
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents} | ||
import uk.gov.hmrc.play.bootstrap.controller.FrontendBaseController | ||
import utils.CheckYourAnswersHelper | ||
import viewmodels.AnswerSection | ||
import views.html.check_your_answers | ||
import config.FrontendAppConfig | ||
import uk.gov.hmrc.play.bootstrap.controller.FrontendController | ||
import views.html.CheckYourAnswersView | ||
|
||
class CheckYourAnswersController @Inject()(appConfig: FrontendAppConfig, | ||
override val messagesApi: MessagesApi, | ||
authenticate: IdentifierAction, | ||
getData: DataRetrievalAction, | ||
requireData: DataRequiredAction) extends FrontendController with I18nSupport { | ||
class CheckYourAnswersController @Inject()( | ||
override val messagesApi: MessagesApi, | ||
identify: IdentifierAction, | ||
getData: DataRetrievalAction, | ||
requireData: DataRequiredAction, | ||
val controllerComponents: MessagesControllerComponents, | ||
view: CheckYourAnswersView | ||
) extends FrontendBaseController with I18nSupport { | ||
|
||
def onPageLoad() = (authenticate andThen getData andThen requireData) { | ||
def onPageLoad(): Action[AnyContent] = (identify andThen getData andThen requireData) { | ||
implicit request => | ||
|
||
val checkYourAnswersHelper = new CheckYourAnswersHelper(request.userAnswers) | ||
|
||
val sections = Seq(AnswerSection(None, Seq())) | ||
Ok(check_your_answers(appConfig, sections)) | ||
|
||
Ok(view(sections)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
package controllers | ||
|
||
import javax.inject.Inject | ||
import play.api.i18n.I18nSupport | ||
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents} | ||
import uk.gov.hmrc.play.bootstrap.controller.FrontendBaseController | ||
import views.html.IndexView | ||
|
||
import play.api.i18n.{I18nSupport, MessagesApi} | ||
import play.api.mvc.{Action, AnyContent} | ||
import uk.gov.hmrc.play.bootstrap.controller.FrontendController | ||
import config.FrontendAppConfig | ||
import views.html.index | ||
|
||
class IndexController @Inject()(val appConfig: FrontendAppConfig, | ||
val messagesApi: MessagesApi) extends FrontendController with I18nSupport { | ||
class IndexController @Inject()( | ||
val controllerComponents: MessagesControllerComponents, | ||
view: IndexView | ||
) extends FrontendBaseController with I18nSupport { | ||
|
||
def onPageLoad: Action[AnyContent] = Action { implicit request => | ||
Ok(index(appConfig)) | ||
Ok(view()) | ||
} | ||
} |
27 changes: 13 additions & 14 deletions
27
src/main/g8/app/controllers/LanguageSwitchController.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,36 @@ | ||
package controllers | ||
|
||
import com.google.inject.Inject | ||
import config.FrontendAppConfig | ||
import play.api.Configuration | ||
import play.api.i18n.{I18nSupport, Lang, MessagesApi} | ||
import play.api.mvc.{Action, AnyContent, Call, Controller} | ||
import config.FrontendAppConfig | ||
import uk.gov.hmrc.play.language.LanguageUtils | ||
import play.api.mvc._ | ||
import uk.gov.hmrc.play.bootstrap.controller.FrontendBaseController | ||
|
||
// TODO, upstream this into play-language | ||
class LanguageSwitchController @Inject() ( | ||
configuration: Configuration, | ||
appConfig: FrontendAppConfig, | ||
implicit val messagesApi: MessagesApi | ||
) extends Controller with I18nSupport { | ||
|
||
private def langToCall(lang: String): (String) => Call = appConfig.routeToSwitchLanguage | ||
class LanguageSwitchController @Inject()( | ||
configuration: Configuration, | ||
appConfig: FrontendAppConfig, | ||
override implicit val messagesApi: MessagesApi, | ||
val controllerComponents: MessagesControllerComponents | ||
) extends FrontendBaseController with I18nSupport { | ||
|
||
private def fallbackURL: String = routes.IndexController.onPageLoad().url | ||
|
||
private def languageMap: Map[String, Lang] = appConfig.languageMap | ||
|
||
def switchToLanguage(language: String): Action[AnyContent] = Action { | ||
implicit request => | ||
|
||
val enabled = isWelshEnabled | ||
val lang = if (enabled) { | ||
languageMap.getOrElse(language, LanguageUtils.getCurrentLang) | ||
languageMap.getOrElse(language, Lang.defaultLang) | ||
} else { | ||
Lang("en") | ||
} | ||
val redirectURL = request.headers.get(REFERER).getOrElse(fallbackURL) | ||
Redirect(redirectURL).withLang(Lang.apply(lang.code)).flashing(LanguageUtils.FlashWithSwitchIndicator) | ||
Redirect(redirectURL).withLang(Lang.apply(lang.code)) | ||
} | ||
|
||
private def isWelshEnabled: Boolean = | ||
configuration.getBoolean("microservice.services.features.welsh-translation").getOrElse(true) | ||
configuration.getOptional[Boolean]("microservice.services.features.welsh-translation").getOrElse(true) | ||
} |
20 changes: 9 additions & 11 deletions
20
src/main/g8/app/controllers/SessionExpiredController.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
package controllers | ||
|
||
import javax.inject.Inject | ||
import play.api.i18n.I18nSupport | ||
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents} | ||
import uk.gov.hmrc.play.bootstrap.controller.FrontendBaseController | ||
import views.html.SessionExpiredView | ||
|
||
import play.api.i18n.{I18nSupport, MessagesApi} | ||
import play.api.mvc.{Action, AnyContent} | ||
import uk.gov.hmrc.play.bootstrap.controller.FrontendController | ||
import config.FrontendAppConfig | ||
import views.html.session_expired | ||
|
||
import scala.concurrent.Future | ||
|
||
class SessionExpiredController @Inject()(val appConfig: FrontendAppConfig, | ||
val messagesApi: MessagesApi) extends FrontendController with I18nSupport { | ||
class SessionExpiredController @Inject()( | ||
val controllerComponents: MessagesControllerComponents, | ||
view: SessionExpiredView | ||
) extends FrontendBaseController with I18nSupport { | ||
|
||
def onPageLoad: Action[AnyContent] = Action { implicit request => | ||
Ok(session_expired(appConfig)) | ||
Ok(view()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
package controllers | ||
|
||
import javax.inject.Inject | ||
import play.api.i18n.I18nSupport | ||
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents} | ||
import uk.gov.hmrc.play.bootstrap.controller.FrontendBaseController | ||
import views.html.UnauthorisedView | ||
|
||
import play.api.i18n.{I18nSupport, MessagesApi} | ||
import play.api.mvc.{Action, AnyContent} | ||
import uk.gov.hmrc.play.bootstrap.controller.FrontendController | ||
import config.FrontendAppConfig | ||
import views.html.unauthorised | ||
|
||
class UnauthorisedController @Inject()(val appConfig: FrontendAppConfig, | ||
val messagesApi: MessagesApi) extends FrontendController with I18nSupport { | ||
class UnauthorisedController @Inject()( | ||
val controllerComponents: MessagesControllerComponents, | ||
view: UnauthorisedView | ||
) extends FrontendBaseController with I18nSupport { | ||
|
||
def onPageLoad: Action[AnyContent] = Action { implicit request => | ||
Ok(unauthorised(appConfig)) | ||
Ok(view()) | ||
} | ||
} |
Oops, something went wrong.