Skip to content

Commit 8b66946

Browse files
authored
Merge pull request #1417 from guardian/pf/switch-for-iconik-ui
Add cookie-based switch for whether or not to show Iconik UI
2 parents 55ea67c + 736007e commit 8b66946

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

app/controllers/IconikController.scala

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ import com.gu.pandahmac.HMACAuthActions
66
import com.typesafe.config.Config
77
import data.{DataStores, UnpackedDataStores}
88
import play.api.libs.json.Json
9-
import play.api.mvc.{Action, AnyContent, BaseController, ControllerComponents}
9+
import play.api.mvc.{
10+
Action,
11+
AnyContent,
12+
BaseController,
13+
ControllerComponents,
14+
Cookie
15+
}
1016
import util.AWSConfig
1117

1218
class IconikController(
@@ -20,7 +26,15 @@ class IconikController(
2026
with JsonRequestParsing
2127
with Logging {
2228

23-
import authActions.{APIAuthAction, APIHMACAuthAction}
29+
import authActions.{APIAuthAction, APIHMACAuthAction, AuthAction}
30+
31+
def switchShowIconikUiOn(): Action[AnyContent] = AuthAction { implicit req =>
32+
Redirect("/", FOUND).withCookies(Cookie("showIconik", "true"))
33+
}
34+
35+
def switchShowIconikUiOff(): Action[AnyContent] = AuthAction { implicit req =>
36+
Redirect("/", FOUND).withCookies(Cookie("showIconik", "false"))
37+
}
2438

2539
def getWorkingGroup(groupId: String): Action[AnyContent] = APIAuthAction {
2640
stores.iconikDataStore.getWorkingGroup(groupId) match {

app/controllers/VideoUIApp.scala

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ import com.gu.pandomainauth.model.User
88
import model.{ClientConfig, Presence}
99
import play.api.Configuration
1010
import play.api.libs.json.Json
11-
import play.api.mvc.{Action, AnyContent, BaseController, ControllerComponents}
11+
import play.api.mvc.{
12+
Action,
13+
AnyContent,
14+
BaseController,
15+
ControllerComponents,
16+
Cookie
17+
}
1218
import util.{AWSConfig, TrainingMode}
1319
import views.html.helper.CSRF
1420

@@ -30,6 +36,11 @@ class VideoUIApp(
3036

3137
def index(id: String = ""): Action[AnyContent] = AuthAction { implicit req =>
3238
val isTrainingMode = isInTrainingMode(req)
39+
val shouldShowIconikUi = req.cookies.get("showIconik") match {
40+
case Some(cookie) if cookie.value == "true" => true
41+
case Some(cookie) if cookie.value == "false" => false
42+
case None => conf.get[String]("stage") != "PROD"
43+
}
3344

3445
val jsFileName = "video-ui/build/app.js"
3546

@@ -61,7 +72,7 @@ class VideoUIApp(
6172
workflowUrl = awsConfig.workflowUrl,
6273
targetingUrl = awsConfig.targetingUrl,
6374
tagManagerUrl = awsConfig.tagManagerUrl,
64-
showIconik = conf.get[String]("stage") != "PROD"
75+
showIconik = shouldShowIconikUi
6576
)
6677

6778
Ok(

conf/routes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,7 @@ GET /healthcheck controllers.Heal
8080

8181
#static assets
8282
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
83+
84+
85+
GET /switches/iconik/off controllers.IconikController.switchShowIconikUiOff()
86+
GET /switches/iconik/on controllers.IconikController.switchShowIconikUiOn()

0 commit comments

Comments
 (0)