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

Set maximum number of stories in a flexible general container #27708

Merged
merged 19 commits into from
Jan 22, 2025
Merged
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
6 changes: 5 additions & 1 deletion common/app/layout/slices/ContainerDefinition.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ object ContainerDefinition {
customCssClasses = Set.empty,
)

def fromContainer(container: Container, items: Seq[PressedContent]): Option[ContainerDefinition] =
def fromContainer(
container: Container,
items: Seq[PressedContent],
): Option[ContainerDefinition] = {
container match {
case Dynamic(dynamicContainer) =>
dynamicContainer.containerDefinitionFor(items.map(Story.fromFaciaContent))
Expand All @@ -32,6 +35,7 @@ object ContainerDefinition {
case _ =>
None
}
}

/** Fast container that looks good for the number of items provided */
def fastForNumberOfItems(n: Int): ContainerDefinition =
Expand Down
18 changes: 0 additions & 18 deletions common/app/layout/slices/FlexibleContainers.scala

This file was deleted.

5 changes: 4 additions & 1 deletion common/app/layout/slices/FlexibleGeneral.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ object FlexibleGeneral extends FlexibleContainer {
}
}

override protected def standardSlices(storiesIncludingBackfill: Seq[Story], firstSlice: Option[Slice]): Seq[Slice] = {
override protected def standardSlices(
storiesIncludingBackfill: Seq[Story],
firstSlice: Option[Slice],
): Seq[Slice] = {

storiesIncludingBackfill.length match {
case 0 => Nil
Expand Down
5 changes: 4 additions & 1 deletion common/app/layout/slices/FlexibleSpecial.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ object FlexibleSpecial extends FlexibleContainer {
}
}

override protected def standardSlices(storiesIncludingBackfill: Seq[Story], firstSlice: Option[Slice]): Seq[Slice] = {
override protected def standardSlices(
storiesIncludingBackfill: Seq[Story],
firstSlice: Option[Slice],
): Seq[Slice] = {

storiesIncludingBackfill.length match {
case 0 => Nil
Expand Down
7 changes: 7 additions & 0 deletions facia-press/app/frontpress/FapiFrontPress.scala
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,13 @@ trait FapiFrontPress extends EmailFrontPress with GuLogging {
case "scrollable/highlights" => 6
// scrollable small and medium containers are capped at 8 stories
case "scrollable/small" | "scrollable/medium" => 8
// flexible general containers are capped at the maxItemsToDisplay value (set in the config tool)
// In the event the field isn't populated, the fallback cap is 9 stories
case "flexible/general" =>
collection.collectionConfig.displayHints match {
case Some(displayHints) => displayHints.maxItemsToDisplay.getOrElse(9)
case None => 9
}
// other container types should be capped at a maximum number of stories set in the app config
case _ => Math.min(Configuration.facia.collectionCap, storyCountTotal)
}
Expand Down
Loading