Skip to content

Commit

Permalink
BDOG-237 Display source of outage page template
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-lamed committed Aug 1, 2019
1 parent f738afb commit 2c3e076
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,17 @@ class ShutterServiceController @Inject()(
.outagePageByAppAndEnv(serviceName, step1Out.env)
).map(_.collect { case Some(op) => op })
outageMessageTemplate = outagePages
.flatMap(_.templatedMessages)
.flatMap(op => op.templatedMessages.map((op, _)))
.headOption
requiresOutageMessage = outageMessageTemplate.isDefined || outagePages.flatMap(_.warnings).nonEmpty
defaultOutageMessage = outageMessageTemplate.fold("")(_.innerHtml)
outageMessageSrc = outageMessageTemplate.map(_._1)
defaultOutageMessage = outageMessageTemplate.fold("")(_._2.innerHtml)
outagePageStatus = shutterService.toOutagePageStatus(step1Out.serviceNames, outagePages)
form2 = step2Form.fill {
val s2f = form.get
if (s2f.outageMessage.isEmpty) s2f.copy(outageMessage = defaultOutageMessage) else s2f
}
} yield page2(form2, step1Out, requiresOutageMessage, defaultOutageMessage, outagePageStatus)
} yield page2(form2, step1Out, requiresOutageMessage, outageMessageSrc, defaultOutageMessage, outagePageStatus)


def step2Get =
Expand Down
4 changes: 3 additions & 1 deletion app/views/shuttering/shutterService/Page2.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*@

@import uk.gov.hmrc.cataloguefrontend.ViewMessages
@import uk.gov.hmrc.cataloguefrontend.shuttering.{Environment, OutagePageStatus, ShutterStatusValue, ShutterState}
@import uk.gov.hmrc.cataloguefrontend.shuttering.{Environment, OutagePage, OutagePageStatus, ShutterStatusValue, ShutterState}
@import uk.gov.hmrc.cataloguefrontend.shuttering.ShutterServiceController.{Step1Out, Step2Form}
@import helper._

Expand All @@ -24,6 +24,7 @@
@( form : Form[Step2Form]
, step1Out : Step1Out
, requiresOutageMessage : Boolean
, outageMessageSrc : Option[OutagePage]
, defaultOutageMessage : String
, outagePages : Seq[OutagePageStatus]
)(implicit request : Request[_]
Expand Down Expand Up @@ -124,6 +125,7 @@ <h1>Shutter Service</h1>
, 'rows -> 5
, 'cols -> 60
)
<p>@Html(outageMessageSrc.map(src => s"The templated value was extracted from the <a target='_blank' href='${src.outagePageURL}'>${src.serviceName} outage page</a>.").getOrElse(""))</p>
</div>
<div class="col-sm-4" style="display:table-cell; float:none; vertical-align: middle;">
<a id="back-btn" href="javascript:revertTemplate()" class="btn btn-default">
Expand Down

0 comments on commit 2c3e076

Please sign in to comment.