Skip to content

Commit

Permalink
Tool sticky liveblog ask (#669)
Browse files Browse the repository at this point in the history
* WIP: tool sticky liveblog ask

* WIP: Basic preview changes

* making sure it's using all the test elements for now

* lint fix

* WIP: add scala components

* WIP: add execution context, attempt at fixes

* consistent naming

* Remove duplication, comment

* Switch gutters on by default

* change gutter-ask to gutter-test as not working otherwise

* Fix heading name on menu item

* hide gutter-tests menu item in case we merge.

* Added tabs with previews

* Add image selection

* Remove old comments, set body copy limit closer to current.

* Update gutter content model for image

* hide all but excludedTags

* move tags to top level for saving, body copy in RTE,

* reinstate banner-test2 - accidental cut rather than copy and paste?

* ensure tags are nested under PageContextTargeting

* Remove hide some tag form elements, nest tags

* rename to logically separate potential article gutter tests

* remove unused getEmptyParagraphError

* rename to LiveblogGutter in case we want a separate version for Articles later.

* Rename from liveblog-gutter to gutter-liveblog to match pattern for epics

* remove unnecessary TODO

* Rename channe switch enableGutters to allow for liveblog

* Rename continued

* Add prod default variant to prod default test

* ensure controller is picking up bodyCopy from controlled FormData

* Change max body copy length and errror message, include noHtml in RTE restrictions

* Set default to not_for_sale svg file in S3 and update helper text in variant editor

* Add gutter to S3 bucket in CDK

* Remove methodology, ensure signed-in status radio buttons are working.

* Add gutter to bucket resources

* delete old comments

---------

Co-authored-by: Sue Burt <“sue.burt@guardian.co.uk”>
  • Loading branch information
sookburt and Sue Burt authored Jan 28, 2025
1 parent 155b708 commit 9634040
Show file tree
Hide file tree
Showing 22 changed files with 937 additions and 2 deletions.
34 changes: 34 additions & 0 deletions app/controllers/gutter/GutterLiveblogTestsController.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package controllers.gutter

import com.gu.googleauth.AuthAction
import controllers.ChannelTestsController
import models.{GutterTest, Channel}
import models.GutterTest._
import play.api.libs.circe.Circe
import play.api.mvc.{ActionBuilder, AnyContent, ControllerComponents}
import services.{DynamoArchivedChannelTests, DynamoChannelTests}
import zio.ZEnv

import scala.concurrent.ExecutionContext

object GutterLiveblogTestsController {
val name = "gutter-liveblog-tests"
}

class GutterLiveblogTestsController(
authAction: ActionBuilder[AuthAction.UserIdentityRequest, AnyContent],
components: ControllerComponents,
stage: String,
runtime: zio.Runtime[ZEnv],
dynamoTests: DynamoChannelTests,
dynamoArchivedTests: DynamoArchivedChannelTests
)(implicit ec: ExecutionContext) extends ChannelTestsController[GutterTest](
authAction,
components,
stage,
lockFileName = GutterLiveblogTestsController.name,
channel = Channel.GutterLiveblog,
runtime = runtime,
dynamoTests,
dynamoArchivedTests
) with Circe
1 change: 1 addition & 0 deletions app/models/Channel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ object Channel {
case object Banner1 extends Channel
case object Banner2 extends Channel
case object Header extends Channel
case object GutterLiveblog extends Channel

implicit val customConfig: Configuration = Configuration.default.withDefaults
implicit val statusEncoder = deriveEnumerationEncoder[Channel]
Expand Down
1 change: 1 addition & 0 deletions app/models/ChannelSwitches.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ case class ChannelSwitches(
enableHardcodedEpicTests: Boolean,
enableHardcodedBannerTests: Boolean,
enableScheduledBannerDeploys: Boolean = true,
enableGutterLiveblogs: Boolean = true,
)

object ChannelSwitches {
Expand Down
51 changes: 51 additions & 0 deletions app/models/GutterTests.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package models

import io.circe.generic.extras.Configuration
import io.circe.generic.extras.auto._
import io.circe.generic.extras.semiauto._
import io.circe.{Decoder, Encoder, Json}
import models.Methodology.defaultMethodologies

case class GutterContent(
image: Option[Image],
bodyCopy: Option[List[String]],
cta: Option[Cta],
)

case class GutterVariant(
name: String,
gutterContent: Option[GutterContent],
)

case class GutterTest(
name: String,
channel: Option[Channel],
status: Option[Status],
lockStatus: Option[LockStatus],
priority: Option[Int],
nickname: Option[String],
userCohort: UserCohort,
locations: List[Region] = Nil,
contextTargeting: PageContextTargeting = PageContextTargeting(Nil,Nil,Nil,Nil),
variants: List[GutterVariant],
controlProportionSettings: Option[ControlProportionSettings] = None,
deviceType: Option[DeviceType] = None,
campaignName: Option[String] = Some("NOT_IN_CAMPAIGN"),
signedInStatus: Option[SignedInStatus] = Some(SignedInStatus.All),
consentStatus: Option[ConsentStatus] = Some(ConsentStatus.All),
methodologies: List[Methodology] = defaultMethodologies
)extends ChannelTest[GutterTest] {

override def withChannel(channel: Channel): GutterTest =
this.copy(channel = Some(channel))
override def withPriority(priority: Int): GutterTest =
this.copy(priority = Some(priority))
}

object GutterTest {
implicit val customConfig: Configuration = Configuration.default.withDefaults
implicit val gutterTestDecoder: Decoder[GutterTest] =
deriveConfiguredDecoder[GutterTest]
implicit val gutterTestEncoder: Encoder[GutterTest] =
deriveConfiguredEncoder[GutterTest]
}
2 changes: 2 additions & 0 deletions app/wiring/AppComponents.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import play.api.routing.Router
import controllers._
import controllers.banner._
import controllers.epic._
import controllers.gutter._
import play.api.ApplicationLoader.Context
import play.api.libs.ws.ahc.AhcWSComponents
import play.api.mvc.AnyContent
Expand Down Expand Up @@ -97,6 +98,7 @@ class AppComponents(context: Context, stage: String) extends BuiltInComponentsFr
new BannerTestsController2(authAction, controllerComponents, stage, runtime, dynamoTestsService, dynamoArchivedChannelTests),
new BannerDeployController(authAction, controllerComponents, stage, runtime),
new BannerDeployController2(authAction, controllerComponents, stage, runtime),
new GutterLiveblogTestsController(authAction, controllerComponents, stage, runtime, dynamoTestsService, dynamoArchivedChannelTests),
new ChannelSwitchesController(authAction, controllerComponents, stage, runtime),
new CampaignsController(authAction, controllerComponents, stage, runtime, dynamoTestsService, dynamoCampaignsService),
new BannerDesignsController(authAction, controllerComponents, stage, runtime, dynamoBannerDesigns, dynamoTestsService, dynamoArchivedBannerDesigns),
Expand Down
1 change: 1 addition & 0 deletions cdk/lib/__snapshots__/admin-console.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cdk/lib/admin-console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ export class AdminConsole extends GuStack {
`arn:aws:s3:::gu-contributions-public/epic/${this.stage}/*`,
`arn:aws:s3:::gu-contributions-public/banner/${this.stage}/*`,
`arn:aws:s3:::gu-contributions-public/header/${this.stage}/*`,
`arn:aws:s3:::gu-contributions-public/gutter/${this.stage}/*`,
],
}),
...channelTestsDynamoPolicies,
Expand Down
19 changes: 19 additions & 0 deletions conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ GET /banner-tests2/:name controllers.Application.inde
GET /banner-deploy controllers.Application.index
GET /channel-switches controllers.Application.index

GET /gutter-liveblog-tests controllers.Application.index
GET /gutter-liveblog-tests/:name controllers.Application.indexWithName(name: String)

GET /campaigns controllers.Application.index
GET /campaigns/:name controllers.Application.indexWithName(name: String)

Expand Down Expand Up @@ -187,6 +190,22 @@ POST /frontend/banner-deploy/update controllers.banner.Banner
GET /frontend/banner-deploy2 controllers.banner.BannerDeployController2.get
POST /frontend/banner-deploy2/update controllers.banner.BannerDeployController2.set

# ----- Gutter channel tests ----- #
GET /frontend/gutter-liveblog-tests controllers.gutter.GutterLiveblogTestsController.get
# gutter list endpoints
POST /frontend/gutter-liveblog-tests/list/lock controllers.gutter.GutterLiveblogTestsController.lockList
POST /frontend/gutter-liveblog-tests/list/unlock controllers.gutter.GutterLiveblogTestsController.unlockList
POST /frontend/gutter-liveblog-tests/list/takecontrol controllers.gutter.GutterLiveblogTestsController.takeControlOfList
POST /frontend/gutter-liveblog-tests/list/reorder controllers.gutter.GutterLiveblogTestsController.reorderList
# gutter test endpoints
GET /frontend/gutter-liveblog-tests/test/:testName controllers.gutter.GutterLiveblogTestsController.getTest(testName: String)
POST /frontend/gutter-liveblog-tests/test/update controllers.gutter.GutterLiveblogTestsController.updateTest
POST /frontend/gutter-liveblog-tests/test/create controllers.gutter.GutterLiveblogTestsController.createTest
POST /frontend/gutter-liveblog-tests/test/lock/:testName controllers.gutter.GutterLiveblogTestsController.lockTest(testName: String)
POST /frontend/gutter-liveblog-tests/test/unlock/:testName controllers.gutter.GutterLiveblogTestsController.unlockTest(testName: String)
POST /frontend/gutter-liveblog-tests/test/takecontrol/:testName controllers.gutter.GutterLiveblogTestsController.forceLockTest(testName: String)
POST /frontend/gutter-liveblog-tests/test/status/:rawStatus controllers.gutter.GutterLiveblogTestsController.setStatus(rawStatus: String)

# ----- channel switches ----- #
GET /frontend/channel-switches controllers.ChannelSwitchesController.get
POST /frontend/channel-switches/update controllers.ChannelSwitchesController.set
Expand Down
9 changes: 8 additions & 1 deletion public/src/components/channelManagement/ChannelSwitches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ type SwitchName =
| 'enableSuperMode'
| 'enableHardcodedEpicTests'
| 'enableHardcodedBannerTests'
| 'enableScheduledBannerDeploys';
| 'enableScheduledBannerDeploys'
| 'enableGutterLiveblogs';

type ChannelSwitches = {
[key in SwitchName]: boolean;
Expand Down Expand Up @@ -129,6 +130,12 @@ const ChannelSwitches: React.FC<InnerProps<ChannelSwitches>> = ({
enabled={switches.enableScheduledBannerDeploys}
setSwitch={onSwitchChange}
/>
<ChannelSwitch
name="enableGutterLiveblogs"
label="Enable Gutter Liveblogs"
enabled={switches.enableGutterLiveblogs}
setSwitch={onSwitchChange}
/>

<Button
onClick={sendToS3}
Expand Down
Loading

0 comments on commit 9634040

Please sign in to comment.