Skip to content

Commit

Permalink
Merge pull request #218 from hmrc/PODS-9720-squash
Browse files Browse the repository at this point in the history
Pods 9720 squash
  • Loading branch information
PavelVjalicin authored Sep 9, 2024
2 parents 781737f + 7243f91 commit 6f1b259
Show file tree
Hide file tree
Showing 165 changed files with 2,126 additions and 2,401 deletions.
5 changes: 3 additions & 2 deletions app/controllers/AgentCannotRegisterController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class AgentCannotRegisterController @Inject()(
val controllerComponents: MessagesControllerComponents,
renderer: Renderer,
config: FrontendAppConfig,
agentCannotRegisterView: AgentCannotRegisterView
agentCannotRegisterView: AgentCannotRegisterView,
twirlMigration: TwirlMigration
)(implicit ec: ExecutionContext)
extends FrontendBaseController
with I18nSupport {
Expand All @@ -43,7 +44,7 @@ class AgentCannotRegisterController @Inject()(
"govUkUrl" -> config.govUkUrl
)

def template = TwirlMigration.duoTemplate(
def template = twirlMigration.duoTemplate(
renderer.render("agentCannotRegister.njk", json),
agentCannotRegisterView()
)
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/AssistantNoAccessController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ import scala.concurrent.ExecutionContext
class AssistantNoAccessController @Inject()(
val controllerComponents: MessagesControllerComponents,
renderer: Renderer,
assistantNoAccessView: AssistantNoAccessView
assistantNoAccessView: AssistantNoAccessView,
twirlMigration: TwirlMigration
)(implicit ec: ExecutionContext)
extends FrontendBaseController
with I18nSupport {

def onPageLoad: Action[AnyContent] = Action.async { implicit request =>
def template = TwirlMigration.duoTemplate(renderer.render("assistantNoAccess.njk"), assistantNoAccessView())
def template = twirlMigration.duoTemplate(renderer.render("assistantNoAccess.njk"), assistantNoAccessView())
template.map(Ok(_))
}
}
7 changes: 4 additions & 3 deletions app/controllers/CannotRegisterPractitionerController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class CannotRegisterPractitionerController @Inject()(
val controllerComponents: MessagesControllerComponents,
renderer: Renderer,
config: FrontendAppConfig,
cannotRegisterPractitionerView: CannotRegisterPractitionerView
cannotRegisterPractitionerView: CannotRegisterPractitionerView,
twirlMigration: TwirlMigration
)(implicit ec: ExecutionContext)
extends FrontendBaseController
with I18nSupport {
Expand All @@ -42,9 +43,9 @@ class CannotRegisterPractitionerController @Inject()(
"contactHmrcUrl" -> config.contactHmrcUrl
)

def template = TwirlMigration.duoTemplate(
def template = twirlMigration.duoTemplate(
renderer.render("cannotRegisterPractitioner.njk",json),
cannotRegisterPractitionerView(config.contactHmrcUrl)
cannotRegisterPractitionerView()
)

template.map(Ok(_))
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/NeedAnOrganisationAccountController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class NeedAnOrganisationAccountController @Inject()(
val controllerComponents: MessagesControllerComponents,
renderer: Renderer,
config: FrontendAppConfig,
needAnOrganisationAccountView: NeedAnOrganisationAccountView
needAnOrganisationAccountView: NeedAnOrganisationAccountView,
twirlMigration: TwirlMigration
)(implicit ec: ExecutionContext)
extends FrontendBaseController
with I18nSupport {
Expand All @@ -45,7 +46,7 @@ class NeedAnOrganisationAccountController @Inject()(
"govUkUrl" -> config.govUkUrl
)

val template = TwirlMigration.duoTemplate(
val template = twirlMigration.duoTemplate(
renderer.render("needAnOrganisationAccount.njk", json),
needAnOrganisationAccountView(config.govUkUrl, config.registerAsPensionAdministratorUrl, config.createGovGatewayUrl)
)
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/SessionExpiredController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ import scala.concurrent.ExecutionContext
class SessionExpiredController @Inject()(
val controllerComponents: MessagesControllerComponents,
renderer: Renderer,
sessionExpiredView: SessionExpiredView
sessionExpiredView: SessionExpiredView,
twirlMigration: TwirlMigration
)(implicit ec: ExecutionContext)
extends FrontendBaseController
with I18nSupport {

def onPageLoad: Action[AnyContent] = Action.async { implicit request =>
val template = TwirlMigration.duoTemplate(
val template = twirlMigration.duoTemplate(
renderer.render("session-expired.njk"),
sessionExpiredView()
)
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/TellHMRCController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class TellHMRCController @Inject()(
config: FrontendAppConfig,
val controllerComponents: MessagesControllerComponents,
renderer: Renderer,
tellHMRCView: TellHMRCView
tellHMRCView: TellHMRCView,
twirlMigration: TwirlMigration
)(implicit ec: ExecutionContext) extends FrontendBaseController with I18nSupport {

def onPageLoad(entityType: String): Action[AnyContent] = (authenticate andThen getData andThen requireData).async {
Expand All @@ -49,7 +50,7 @@ class TellHMRCController @Inject()(
"hmrcUrl" -> config.hmrcChangesMustReportUrl
)

val template = TwirlMigration.duoTemplate(
val template = twirlMigration.duoTemplate(
renderer.render("tellHMRC.njk", json),
tellHMRCView(entityType, config.companiesHouseFileChangesUrl, config.hmrcChangesMustReportUrl)
)
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/UnauthorisedController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ import scala.concurrent.ExecutionContext
class UnauthorisedController @Inject()(
val controllerComponents: MessagesControllerComponents,
renderer: Renderer,
unauthorisedView: UnauthorisedView
unauthorisedView: UnauthorisedView,
twirlMigration: TwirlMigration
)(implicit ec: ExecutionContext)
extends FrontendBaseController
with I18nSupport {

def onPageLoad: Action[AnyContent] = Action.async { implicit request =>
val template = TwirlMigration.duoTemplate(
val template = twirlMigration.duoTemplate(
renderer.render("unauthorised.njk"),
unauthorisedView()
)
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/UpdateContactAddressController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class UpdateContactAddressController @Inject()(
getData: DataRetrievalAction,
countryOptions: CountryOptions,
pspDetailsService: PspDetailsService,
updateContactAddressView: UpdateContactAddressView
updateContactAddressView: UpdateContactAddressView,
twirlMigration: TwirlMigration
)(implicit ec: ExecutionContext)
extends FrontendBaseController
with I18nSupport {
Expand All @@ -58,7 +59,7 @@ class UpdateContactAddressController @Inject()(
"continueUrl" -> url,
"address" -> address.lines(countryOptions)
)
val template = TwirlMigration.duoTemplate(
val template = twirlMigration.duoTemplate(
renderer.render("updateContactAddress.njk", json),
updateContactAddressView(address.lines(countryOptions), url)
)
Expand Down
15 changes: 12 additions & 3 deletions app/controllers/WhatTypeBusinessController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class WhatTypeBusinessController @Inject()(override val messagesApi: MessagesApi
val controllerComponents: MessagesControllerComponents,
renderer: Renderer,
auditService: AuditService,
whatTypeBusinessView: WhatTypeBusinessView
whatTypeBusinessView: WhatTypeBusinessView,
twirlMigration: TwirlMigration
)(implicit ec: ExecutionContext) extends FrontendBaseController with I18nSupport with NunjucksSupport {

private val form = formProvider()
Expand All @@ -64,7 +65,7 @@ class WhatTypeBusinessController @Inject()(override val messagesApi: MessagesApi
"radios" -> WhatTypeBusiness.radios(preparedForm)
)

val template = TwirlMigration.duoTemplate(
val template = twirlMigration.duoTemplate(
renderer.render("whatTypeBusiness.njk", json),
whatTypeBusinessView(
routes.WhatTypeBusinessController.onSubmit(),
Expand All @@ -85,8 +86,16 @@ class WhatTypeBusinessController @Inject()(override val messagesApi: MessagesApi
"submitUrl" -> routes.WhatTypeBusinessController.onSubmit().url,
"radios" -> WhatTypeBusiness.radios(formWithErrors)
)
val template = twirlMigration.duoTemplate(
renderer.render("whatTypeBusiness.njk", json),
whatTypeBusinessView(
routes.WhatTypeBusinessController.onSubmit(),
formWithErrors,
TwirlMigration.toTwirlRadios(WhatTypeBusiness.radios(formWithErrors))
)
)

renderer.render("whatTypeBusiness.njk", json).map(BadRequest(_))
template.map(BadRequest(_))
},
value => {
val ua = request.userAnswers.getOrElse(UserAnswers())
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/YourActionWasNotProcessedController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class YourActionWasNotProcessedController @Inject()(appConfig: FrontendAppConfig
getData: DataRetrievalAction,
pspDetailsService: PspDetailsService,
renderer: Renderer,
yourActionWasNotProcessedView: YourActionWasNotProcessedView
yourActionWasNotProcessedView: YourActionWasNotProcessedView,
twirlMigration: TwirlMigration
)(implicit val executionContext: ExecutionContext)
extends FrontendBaseController
with I18nSupport {
Expand All @@ -53,7 +54,7 @@ class YourActionWasNotProcessedController @Inject()(appConfig: FrontendAppConfig
} else {
Json.obj()
}
val template = TwirlMigration.duoTemplate(
val template = twirlMigration.duoTemplate(
renderer.render("yourActionWasNotProcessed.njk", json),
yourActionWasNotProcessedView(
appConfig.returnToPspDashboardUrl,
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/address/AddressListController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController
import utils.TwirlMigration
import utils.countryOptions.CountryOptions
import viewmodels.CommonViewModelTwirl
import views.html.address.AddressListView

import scala.concurrent.{ExecutionContext, Future}

Expand All @@ -46,6 +45,7 @@ trait AddressListController extends FrontendBaseController with Retrievals with
protected def navigator: CompoundNavigator
protected def form(implicit messages: Messages): Form[Int]
protected def viewTemplate = "address/addressList.njk"
protected def twirlMigration: TwirlMigration

def get(json: Form[Int] => JsObject, onSubmitCall: Call, manualUrl: String, twirlView: (CommonViewModelTwirl, Seq[RadioItem]) => Html)
(implicit request: DataRequest[AnyContent], ec: ExecutionContext, messages: Messages): Future[Result] = {
Expand All @@ -57,7 +57,7 @@ trait AddressListController extends FrontendBaseController with Retrievals with
submitUrl = onSubmitCall,
enterManuallyUrl = Some(manualUrl))

TwirlMigration.duoTemplate(
twirlMigration.duoTemplate(
renderer.render(viewTemplate, jsonValue),
twirlView(model, twirlAddressRadios(jsonValue))
).map(Ok(_))
Expand All @@ -82,7 +82,7 @@ trait AddressListController extends FrontendBaseController with Retrievals with

val radios = twirlAddressRadios(jsonObject)

TwirlMigration.duoTemplate(
twirlMigration.duoTemplate(
renderer.render(viewTemplate, json(formWithErrors)),
twirlView(model, radios, formWithErrors)
).map(BadRequest(_))
Expand Down
14 changes: 8 additions & 6 deletions app/controllers/address/ManualAddressController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ package controllers.address
import config.FrontendAppConfig
import connectors.cache.UserAnswersCacheConnector
import controllers.{Retrievals, Variation}
import models.requests.DataRequest
import uk.gov.hmrc.viewmodels.NunjucksSupport
import models.AddressConfiguration.AddressConfiguration
import models.{Address, AddressConfiguration, Country, Mode, TolerantAddress}
import models.requests.DataRequest
import models.{Address, AddressConfiguration, Mode, TolerantAddress}
import navigators.CompoundNavigator
import pages.{AddressChange, QuestionPage}
import pages.company.CompanyAddressPage
import pages.{AddressChange, QuestionPage}
import play.api.data.Form
import play.api.i18n.{I18nSupport, Messages}
import play.api.libs.json.{JsArray, JsObject, Json}
import play.api.mvc.{AnyContent, Call, Result}
import renderer.Renderer
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController
import uk.gov.hmrc.viewmodels.NunjucksSupport
import utils.TwirlMigration
import views.html.address.ManualAddressView

Expand Down Expand Up @@ -66,6 +66,8 @@ trait ManualAddressController

protected val h1MessageKey: String = pageTitleMessageKey

protected val twirlMigration: TwirlMigration

protected def addressConfigurationForPostcodeAndCountry(isUK:Boolean): AddressConfiguration =
if(isUK) AddressConfiguration.PostcodeFirst else AddressConfiguration.CountryFirst

Expand All @@ -85,7 +87,7 @@ trait ManualAddressController
case Some(value) => form.fill(value)
}
val jsonValue: JsObject = json(mode, name, preparedForm, addressLocation)
val template = TwirlMigration.duoTemplate(
val template = twirlMigration.duoTemplate(
renderer.render(viewTemplate, jsonValue),
manualAddressView(
(jsonValue \ "pageTitle").asOpt[String].getOrElse(""),
Expand All @@ -111,7 +113,7 @@ trait ManualAddressController
.fold(
formWithErrors => {
val jsonValue: JsObject = json(mode, name, formWithErrors, addressLocation)
val template = TwirlMigration.duoTemplate(
val template = twirlMigration.duoTemplate(
renderer.render(viewTemplate, jsonValue),
manualAddressView((jsonValue \ "pageTitle").asOpt[String].getOrElse(""),
(jsonValue \ "h1").asOpt[String].getOrElse(""),
Expand Down
8 changes: 5 additions & 3 deletions app/controllers/address/PostcodeController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ trait PostcodeController extends FrontendBaseController with Retrievals {
protected def addressLookupConnector: AddressLookupConnector
protected def viewTemplate = "address/postcode.njk"

protected def twirlMigration: TwirlMigration

def get(json: Form[String] => JsObject, twirlTemplate: Option[Html] = None)
(implicit request: DataRequest[AnyContent], ec: ExecutionContext, messages: Messages): Future[Result] = {
twirlTemplate match {
case Some(template) =>
TwirlMigration.duoTemplate(
twirlMigration.duoTemplate(
renderer.render(viewTemplate, json(form)),
template
).map(Ok(_))
Expand All @@ -65,7 +67,7 @@ trait PostcodeController extends FrontendBaseController with Retrievals {
formWithErrors =>
formToTwirlTemplate match {
case Some(formToTemplate) =>
TwirlMigration.duoTemplate(
twirlMigration.duoTemplate(
renderer.render(viewTemplate, formToJson(formWithErrors)),
formToTemplate(formWithErrors)
).map(BadRequest(_))
Expand All @@ -78,7 +80,7 @@ trait PostcodeController extends FrontendBaseController with Retrievals {
val json = formToJson(formWithErrors)
formToTwirlTemplate match {
case Some(formToTemplate) =>
TwirlMigration.duoTemplate(
twirlMigration.duoTemplate(
renderer.render(viewTemplate, json),
formToTemplate(formWithErrors)
).map(BadRequest(_))
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/amend/ConfirmationController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class ConfirmationController @Inject()(appConfig: FrontendAppConfig,
requireData: DataRequiredAction,
val controllerComponents: MessagesControllerComponents,
renderer: Renderer,
confirmationView: views.html.amend.ConfirmationView
confirmationView: views.html.amend.ConfirmationView,
twirlMigration: TwirlMigration
)(implicit ec: ExecutionContext) extends FrontendBaseController
with Retrievals with I18nSupport with NunjucksSupport {

Expand All @@ -59,7 +60,7 @@ class ConfirmationController @Inject()(appConfig: FrontendAppConfig,
)

userAnswersCacheConnector.removeAll.flatMap { _ =>
val template = TwirlMigration.duoTemplate(
val template = twirlMigration.duoTemplate(
renderer.render("amend/confirmation.njk", json),
confirmationView(email, confirmationPanelText(pspid).toString(), appConfig.returnToPspDashboardUrl)
)
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/amend/DeclarationController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class DeclarationController @Inject()(
auditService: AuditService,
pspDetailsService: PspDetailsService,
config: FrontendAppConfig,
declarationView: views.html.amend.DeclarationView
declarationView: views.html.amend.DeclarationView,
twirlMigration: TwirlMigration
)(implicit ec: ExecutionContext)
extends FrontendBaseController
with Retrievals
Expand All @@ -66,7 +67,7 @@ class DeclarationController @Inject()(

if (pspDetailsService.amendmentsExist(request.userAnswers)) {
val json: JsObject = Json.obj("submitUrl" -> routes.DeclarationController.onSubmit().url)
val template = TwirlMigration.duoTemplate(
val template = twirlMigration.duoTemplate(
renderer.render("amend/declaration.njk", json),
declarationView(routes.DeclarationController.onSubmit())
)
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/amend/ViewDetailsController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ class ViewDetailsController @Inject()(@AuthMustHaveEnrolmentWithNoIV authenticat
pspDetailsService: PspDetailsService,
renderer: Renderer,
val controllerComponents: MessagesControllerComponents,
viewDetailsView: views.html.amend.ViewDetailsView
viewDetailsView: views.html.amend.ViewDetailsView,
twirlMigration: TwirlMigration
)(implicit val executionContext: ExecutionContext) extends FrontendBaseController with I18nSupport {

def onPageLoad: Action[AnyContent] = (authenticate andThen getData).async {
implicit request =>
request.user.alreadyEnrolledPspId.map { pspId =>
pspDetailsService.getData(request.userAnswers, pspId).flatMap { data =>
val template = TwirlMigration.duoTemplate(
val template = twirlMigration.duoTemplate(
renderer.render("amend/viewDetails.njk", data.toJson),
viewDetailsView(
data.pageTitle,
Expand Down
Loading

0 comments on commit 6f1b259

Please sign in to comment.