Skip to content

Commit

Permalink
mod timeline wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Oct 15, 2024
1 parent 8a20001 commit b833fc5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/controllers/User.scala
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ final class User(

val timeline = env.api
.modTimeline(user, withPlayBans = false)
.map(views.mod.timeline.render)
.map(views.mod.timeline.renderGeneral)
.map(lila.mod.ui.mzSection("timeline")(_))

val modLog = for
Expand Down
2 changes: 1 addition & 1 deletion app/views/mod/communication.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def communication(
)
)
),
views.mod.timeline.render(timeline),
views.mod.timeline.renderComm(timeline),
timeline.reports.nonEmpty.option(
frag(
h2("Comm reports"),
Expand Down
6 changes: 5 additions & 1 deletion modules/api/src/main/ModTimeline.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ object ModTimeline:
case _: ReportNewAtom => "symbols.exclamation-mark"
case _: ReportClose => "objects.package"
case _: TempBan => "objects.hourglass-not-done"
case _: PublicLine => "symbols.triangular-flag"
case _: PublicLine => "symbols.exclamation-mark"
def at: Instant = e match
case e: Modlog => e.date
case e: AppealMsg => e.at
Expand All @@ -85,6 +85,10 @@ object ModTimeline:
// latest first
given Ordering[Event] = Ordering.by(at).reverse

enum Angle:
case None
case Comm

final class ModTimelineApi(
modLogApi: ModlogApi,
appealApi: AppealApi,
Expand Down
16 changes: 12 additions & 4 deletions modules/api/src/main/ui/ModTimelineUi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ final class ModTimelineUi(helpers: Helpers)(
import helpers.{ *, given }
import ModTimeline.*

def renderGeneral(t: ModTimeline)(using Translate) = render(t)(using Angle.None)
def renderComm(t: ModTimeline)(using Translate) = render(t)(using Angle.Comm)

private val eventOrdering = summon[Ordering[Instant]].reverse

def render(t: ModTimeline)(using Translate) = div(cls := "mod-timeline"):
private def render(t: ModTimeline)(using angle: Angle)(using Translate) = div(cls := "mod-timeline"):
t.all
.filter:
case _: TempBan if angle != Angle.Comm => false
case _ => true
.map: e =>
daysFromNow(e.at.date) -> e
.groupBy(_._1)
Expand All @@ -45,9 +51,9 @@ final class ModTimelineUi(helpers: Helpers)(
private def renderEvent(t: ModTimeline)(e: Event)(using Translate) =
div(cls := s"mod-timeline__event mod-timeline__event--${e.key}")(
a(cls := "mod-timeline__event__flair", href := e.url(t.user)):
img(src := flairSrc(e.flair), title := e.key)
img(src := flairSrc(e.flair), title := s"${e.key} ${showInstant(e.at)}")
,
showTime(e.at),
// showInstant(e.at),
div(cls := "mod-timeline__event__body")(renderEventBody(t)(e))
)

Expand Down Expand Up @@ -115,7 +121,9 @@ final class ModTimelineUi(helpers: Helpers)(
else renderMod(e.mod)
frag(
author,
actionTag(cls := "mod-timeline__event__action")(e.showAction),
actionTag(cls := s"mod-timeline__event__action mod-timeline__event__action--${e.action}")(
e.showAction
),
div(cls := "mod-timeline__text"):
e.gameId.fold[Frag](e.details.orZero: String) { gameId =>
a(href := s"${routes.Round.watcher(gameId, Color.white).url}?pov=${e.user.so(_.value)}")(
Expand Down
8 changes: 6 additions & 2 deletions ui/mod/css/_mod-timeline.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
.mod-timeline {
@extend %flex-column, %box-neat;
gap: 4em;
@extend %box-neat;
background: $c-bg-zebra;
padding: 2em 4em;
max-height: 50vh;
max-height: 70vh;
overflow-y: auto;
overflow-x: hidden;
}
Expand All @@ -25,6 +24,11 @@
.mod-timeline__event {
@extend %flex-center-nowrap;
gap: 1em;
padding: 0 1em;
}
.mod-timeline__event:has(.mod-timeline__event__action--modMessage) {
background: $c-bg-zebra2;
padding: 1em;
}
.mod-timeline__event__from {
white-space: nowrap;
Expand Down

0 comments on commit b833fc5

Please sign in to comment.