Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PODS-9772 - Removed toggle related code - phase1 #871

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/config/FrontendAppConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,6 @@ class FrontendAppConfig @Inject()(runModeConfiguration: Configuration, environme
}"
}"

def featureToggleUrl(toggle: String): String = s"$pensionAdministratorUrl${runModeConfiguration.get[String]("urls.featureToggle").format(toggle)}"

def identityValidationFrontEndEntry(relativeCompletionURL: RedirectUrl, relativeFailureURL: RedirectUrl): String = {
val url = loadConfig("urls.iv-uplift-entry")
val query = s"?origin=pods&confidenceLevel=250&completionURL=${relativeCompletionURL.get(OnlyRelative).url}&failureURL=${relativeFailureURL.get(OnlyRelative).url}"
Expand Down
57 changes: 0 additions & 57 deletions app/connectors/cache/FeatureToggleConnector.scala

This file was deleted.

14 changes: 3 additions & 11 deletions app/controllers/register/BusinessTypeController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@
package controllers.register

import config.FrontendAppConfig
import connectors.cache.{FeatureToggleConnector, UserAnswersCacheConnector}
import connectors.cache.UserAnswersCacheConnector
import controllers.actions._
import forms.register.BusinessTypeFormProvider
import identifiers.register.BusinessTypeId
import models.FeatureToggleName.PsaRegistration

import javax.inject.Inject
import models.Mode
import play.api.data.Form
import play.api.i18n.I18nSupport
Expand All @@ -33,6 +30,7 @@ import utils.annotations.{Register, RegisterV2}
import utils.{Enumerable, Navigator, UserAnswers}
import views.html.register.businessType

import javax.inject.Inject
import scala.concurrent.{ExecutionContext, Future}

class BusinessTypeController @Inject()(appConfig: FrontendAppConfig,
Expand All @@ -45,7 +43,6 @@ class BusinessTypeController @Inject()(appConfig: FrontendAppConfig,
requireData: DataRequiredAction,
formProvider: BusinessTypeFormProvider,
val controllerComponents: MessagesControllerComponents,
featureToggleConnector: FeatureToggleConnector,
val view: businessType
)(implicit val executionContext: ExecutionContext)
extends FrontendBaseController with I18nSupport with Enumerable.Implicits {
Expand All @@ -68,14 +65,9 @@ class BusinessTypeController @Inject()(appConfig: FrontendAppConfig,
Future.successful(BadRequest(view(formWithErrors, mode))),
value =>
for {
isFeatureEnabled <- featureToggleConnector.get(PsaRegistration.asString).map(_.isEnabled)
newCache <- dataCacheConnector.save(request.externalId, BusinessTypeId, value)
} yield {
if (isFeatureEnabled) {
Redirect(navigatorV2.nextPage(BusinessTypeId, mode, UserAnswers(newCache)))
} else {
Redirect(navigator.nextPage(BusinessTypeId, mode, UserAnswers(newCache)))
}
Redirect(navigatorV2.nextPage(BusinessTypeId, mode, UserAnswers(newCache)))
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@

package controllers.register

import connectors.cache.{FeatureToggleConnector, UserAnswersCacheConnector}
import connectors.cache.UserAnswersCacheConnector
import controllers.Retrievals
import controllers.actions._
import forms.register.DeclarationWorkingKnowledgeFormProvider
import identifiers.register.DeclarationWorkingKnowledgeId
import models.FeatureToggleName.PsaRegistration
import models.Mode
import models.register.DeclarationWorkingKnowledge
import play.api.data.Form
Expand All @@ -43,8 +42,7 @@ class DeclarationWorkingKnowledgeController @Inject()(
requireData: DataRequiredAction,
formProvider: DeclarationWorkingKnowledgeFormProvider,
val controllerComponents: MessagesControllerComponents,
val view: declarationWorkingKnowledge,
featureToggleConnector: FeatureToggleConnector
val view: declarationWorkingKnowledge
)(implicit val executionContext: ExecutionContext)
extends FrontendBaseController with I18nSupport with Enumerable.Implicits with Retrievals {

Expand All @@ -66,9 +64,8 @@ class DeclarationWorkingKnowledgeController @Inject()(
Future.successful(BadRequest(view(formWithErrors, mode, psaName(), taskListReturnLinkUrl()))),
value => {
for {
isFeatureEnabled <- featureToggleConnector.get(PsaRegistration.asString).map(_.isEnabled)
cacheMap <- dataCacheConnector.save(request.externalId, DeclarationWorkingKnowledgeId,
DeclarationWorkingKnowledge.declarationWorkingKnowledge(value, isFeatureEnabled))
DeclarationWorkingKnowledge.declarationWorkingKnowledge(value, isRegistrationToggleEnabled = true))
} yield {
Redirect(navigator.nextPage(DeclarationWorkingKnowledgeId, mode, UserAnswers(cacheMap)))
}
Expand Down
12 changes: 4 additions & 8 deletions app/controllers/register/RegisterAsBusinessController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ package controllers.register
import audit.{AuditService, PSAStartEvent}
import com.google.inject.Inject
import config.FrontendAppConfig
import connectors.cache.{FeatureToggleConnector, UserAnswersCacheConnector}
import connectors.cache.UserAnswersCacheConnector
import controllers.actions.{AllowAccessActionProvider, AuthAction, DataRetrievalAction}
import forms.register.RegisterAsBusinessFormProvider
import identifiers.register.{BusinessTypeId, RegisterAsBusinessId, RegistrationInfoId}
import models.FeatureToggleName.PsaRegistration
import models.RegistrationCustomerType.UK
import models.{Mode, NormalMode}
import play.api.data.Form
Expand All @@ -41,7 +40,6 @@ class RegisterAsBusinessController @Inject()(appConfig: FrontendAppConfig,
allowAccess: AllowAccessActionProvider,
getData: DataRetrievalAction,
cache: UserAnswersCacheConnector,
featureToggleConnector: FeatureToggleConnector,
auditService: AuditService,
val controllerComponents: MessagesControllerComponents,
val view: registerAsBusiness
Expand All @@ -68,12 +66,10 @@ class RegisterAsBusinessController @Inject()(appConfig: FrontendAppConfig,
for {
_ <- cache.save(request.externalId, RegisterAsBusinessId, isBusiness)
_ = PSAStartEvent.sendEvent(auditService)
isFeatureEnabled <- featureToggleConnector.get(PsaRegistration.asString).map(_.isEnabled)
} yield {
(isBusiness, isFeatureEnabled) match {
case (false, _) => Redirect(individual.routes.WhatYouWillNeedController.onPageLoad())
case (true, false) => Redirect(routes.WhatYouWillNeedController.onPageLoad(NormalMode))
case (true, true) =>
isBusiness match {
case false => Redirect(individual.routes.WhatYouWillNeedController.onPageLoad())
case true =>
val businessType = request.userAnswers.flatMap(_.get(BusinessTypeId))
val customerType = request.userAnswers.flatMap(_.get(RegistrationInfoId).map(_.customerType))
(businessType, customerType) match {
Expand Down
20 changes: 6 additions & 14 deletions app/controllers/register/adviser/AdviserAddressController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@ package controllers.register.adviser

import audit.AuditService
import config.FrontendAppConfig
import connectors.cache.{FeatureToggleConnector, UserAnswersCacheConnector}
import connectors.cache.UserAnswersCacheConnector
import controllers.actions._
import controllers.address.ManualAddressController
import forms.AddressFormProvider
import identifiers.UpdateContactAddressId
import identifiers.register.adviser.{AdviserAddressId, AdviserAddressListId, AdviserNameId}
import models.FeatureToggleName.PsaRegistration

import javax.inject.Inject
import models.requests.DataRequest
import models.{Address, Mode}
import play.api.data.Form
Expand All @@ -38,6 +35,7 @@ import viewmodels.Message
import viewmodels.address.ManualAddressViewModel
import views.html.address.manualAddress

import javax.inject.Inject
import scala.concurrent.ExecutionContext

class AdviserAddressController @Inject()(override val appConfig: FrontendAppConfig,
Expand All @@ -51,8 +49,7 @@ class AdviserAddressController @Inject()(override val appConfig: FrontendAppConf
val countryOptions: CountryOptions,
val auditService: AuditService,
val controllerComponents: MessagesControllerComponents,
val view: manualAddress,
featureToggleConnector: FeatureToggleConnector
val view: manualAddress
)(implicit val executionContext: ExecutionContext) extends ManualAddressController {

protected val form: Form[Address] = formProvider()
Expand All @@ -72,17 +69,12 @@ class AdviserAddressController @Inject()(override val appConfig: FrontendAppConf

def onPageLoad(mode: Mode): Action[AnyContent] = (authenticate andThen allowAccess(mode) andThen getData andThen requireData).async {
implicit request =>
featureToggleConnector.enabled(PsaRegistration).flatMap { featureEnabled =>
val returnLink = if (featureEnabled) Some(companyTaskListUrl()) else None
get(AdviserAddressId, AdviserAddressListId, addressViewModel(mode, request.userAnswers.get(UpdateContactAddressId).isEmpty, returnLink), mode)
}
get(AdviserAddressId, AdviserAddressListId,
addressViewModel(mode, request.userAnswers.get(UpdateContactAddressId).isEmpty, Some(companyTaskListUrl())), mode)
}

def onSubmit(mode: Mode): Action[AnyContent] = (authenticate andThen getData andThen requireData).async {
implicit request =>
featureToggleConnector.enabled(PsaRegistration).flatMap { featureEnabled =>
val returnLink = if (featureEnabled) Some(companyTaskListUrl()) else None
post(AdviserAddressId, addressViewModel(mode, request.userAnswers.get(UpdateContactAddressId).isEmpty, returnLink), mode)
}
post(AdviserAddressId, addressViewModel(mode, request.userAnswers.get(UpdateContactAddressId).isEmpty, Some(companyTaskListUrl())), mode)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,24 @@
package controllers.register.adviser

import config.FrontendAppConfig
import connectors.cache.{FeatureToggleConnector, UserAnswersCacheConnector}
import connectors.cache.UserAnswersCacheConnector
import controllers.Retrievals
import controllers.actions._
import controllers.address.AddressListController
import forms.address.AddressListFormProvider
import identifiers.UpdateContactAddressId
import identifiers.register.adviser._
import models.FeatureToggleName.PsaRegistration

import javax.inject.Inject
import models.requests.DataRequest
import models.{Mode, TolerantAddress}
import play.api.data.Form
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents, Result}
import utils.Navigator
import utils.annotations.Adviser
import utils.annotations.NoRLSCheck
import utils.annotations.{Adviser, NoRLSCheck}
import viewmodels.Message
import viewmodels.address.AddressListViewModel
import views.html.address.addressList

import javax.inject.Inject
import scala.concurrent.{ExecutionContext, Future}

class AdviserAddressListController @Inject()(override val appConfig: FrontendAppConfig,
Expand All @@ -49,30 +46,23 @@ class AdviserAddressListController @Inject()(override val appConfig: FrontendApp
requireData: DataRequiredAction,
formProvider: AddressListFormProvider,
val controllerComponents: MessagesControllerComponents,
val view: addressList,
featureToggleConnector: FeatureToggleConnector
val view: addressList
)(implicit val executionContext: ExecutionContext) extends AddressListController with Retrievals {

def form(addresses: Seq[TolerantAddress], name: String)(implicit request: DataRequest[AnyContent]): Form[Int] =
formProvider(addresses, Message("select.address.required.error").withArgs(name))

def onPageLoad(mode: Mode): Action[AnyContent] = (authenticate andThen getData andThen requireData).async {
implicit request =>
featureToggleConnector.enabled(PsaRegistration).flatMap { featureEnabled =>
val returnLink = if (featureEnabled) Some(companyTaskListUrl()) else None
viewModel(mode, request.userAnswers.get(UpdateContactAddressId).isEmpty, returnLink).map { vm =>
get(vm, mode, form(vm.addresses, entityName))
}
viewModel(mode, request.userAnswers.get(UpdateContactAddressId).isEmpty, Some(companyTaskListUrl())).map { vm =>
get(vm, mode, form(vm.addresses, entityName))
}
}

def onSubmit(mode: Mode): Action[AnyContent] = (authenticate andThen allowAccess(mode) andThen getData andThen requireData).async {
implicit request =>
featureToggleConnector.enabled(PsaRegistration).flatMap { featureEnabled =>
val returnLink = if (featureEnabled) Some(companyTaskListUrl()) else None
viewModel(mode, request.userAnswers.get(UpdateContactAddressId).isEmpty, returnLink)
.map(vm => post(vm, AdviserAddressId, AdviserAddressListId, AdviserAddressPostCodeLookupId, mode, form(vm.addresses, entityName)))
}
viewModel(mode, request.userAnswers.get(UpdateContactAddressId).isEmpty, Some(companyTaskListUrl()))
.map(vm => post(vm, AdviserAddressId, AdviserAddressListId, AdviserAddressPostCodeLookupId, mode, form(vm.addresses, entityName)))
}

def viewModel(mode: Mode, displayReturnLink: Boolean, returnLink: Option[String])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,23 @@ package controllers.register.adviser

import config.FrontendAppConfig
import connectors.AddressLookupConnector
import connectors.cache.{FeatureToggleConnector, UserAnswersCacheConnector}
import connectors.cache.UserAnswersCacheConnector
import controllers.actions._
import controllers.address.PostcodeLookupController
import forms.address.PostCodeLookupFormProvider
import identifiers.UpdateContactAddressId
import identifiers.register.adviser.{AdviserAddressPostCodeLookupId, AdviserNameId}
import models.FeatureToggleName.PsaRegistration

import javax.inject.Inject
import models.Mode
import models.requests.DataRequest
import play.api.data.Form
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents}
import utils.Navigator
import utils.annotations.Adviser
import utils.annotations.NoRLSCheck
import utils.annotations.{Adviser, NoRLSCheck}
import viewmodels.Message
import viewmodels.address.PostcodeLookupViewModel
import views.html.address.postcodeLookup

import javax.inject.Inject
import scala.concurrent.ExecutionContext

class AdviserAddressPostCodeLookupController @Inject()(
Expand All @@ -51,8 +48,7 @@ class AdviserAddressPostCodeLookupController @Inject()(
requireData: DataRequiredAction,
formProvider: PostCodeLookupFormProvider,
val controllerComponents: MessagesControllerComponents,
val view: postcodeLookup,
featureToggleConnector: FeatureToggleConnector
val view: postcodeLookup
)(implicit val executionContext: ExecutionContext) extends PostcodeLookupController {

override protected def form: Form[String] = formProvider()
Expand All @@ -74,18 +70,12 @@ class AdviserAddressPostCodeLookupController @Inject()(

def onPageLoad(mode: Mode): Action[AnyContent] = (authenticate andThen allowAccess(mode) andThen getData andThen requireData).async {
implicit request =>
featureToggleConnector.enabled(PsaRegistration).flatMap { featureEnabled =>
val returnLink = if (featureEnabled) Some(companyTaskListUrl()) else None
get(viewModel(mode, request.userAnswers.get(UpdateContactAddressId).isEmpty, returnLink), mode)
}
get(viewModel(mode, request.userAnswers.get(UpdateContactAddressId).isEmpty, Some(companyTaskListUrl())), mode)
}

def onSubmit(mode: Mode): Action[AnyContent] = (authenticate andThen getData andThen requireData).async {
implicit request =>
featureToggleConnector.enabled(PsaRegistration).flatMap { featureEnabled =>
val returnLink = if (featureEnabled) Some(companyTaskListUrl()) else None
post(AdviserAddressPostCodeLookupId, viewModel(mode, request.userAnswers.get(UpdateContactAddressId).isEmpty, returnLink), mode)
}
post(AdviserAddressPostCodeLookupId, viewModel(mode, request.userAnswers.get(UpdateContactAddressId).isEmpty, Some(companyTaskListUrl())), mode)
}
}

Expand Down
Loading