Skip to content

Commit

Permalink
show appeal status on user mod section
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Nov 14, 2024
1 parent 4fb6dd1 commit 32ed577
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
4 changes: 4 additions & 0 deletions app/controllers/User.scala
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ final class User(
.map: prefs =>
ui.prefs(user, prefs.hasKeyboardMove, prefs.botCompatible)

val appeal = isGranted(_.Appeals).so:
env.appeal.api.byId(user).mapz(views.appeal.ui.modSection(lila.mod.ui.mzSection("appeal")))

val rageSit = isGranted(_.CheatHunter).so(
env.playban.api
.rageSitOf(user.id)
Expand Down Expand Up @@ -438,6 +441,7 @@ final class User(
.merge(modZoneSegment(student, "student", user))
.merge(modZoneSegment(teacher, "teacher", user))
.merge(modZoneSegment(prefs, "prefs", user))
.merge(modZoneSegment(appeal, "appeal", user))
.merge(modZoneSegment(rageSit, "rageSit", user))
.merge(modZoneSegment(othersAndLogins.map(_._1), "others", user))
.merge(modZoneSegment(identification, "identification", user))
Expand Down
6 changes: 6 additions & 0 deletions modules/appeal/src/main/ui/AppealUi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@ final class AppealUi(helpers: Helpers):
userIdLink(UserId.lichess.some),
Granter.opt(_.Appeals).option(frag(" (", userIdLink(userId.some), ")"))
)

def modSection(section: Tag)(ap: Appeal): Frag =
section(
strong(cls := "text inline")("Appeal status"),
strong(cls := "fat")(a(href := routes.Appeal.show(ap.userId))(ap.status.toString))
)
33 changes: 16 additions & 17 deletions modules/mod/src/main/ui/ModUserUi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,18 @@ final class ModUserUi(helpers: Helpers, modUi: ModUi):
Granter.opt(_.ChangePermission) || (Granter.opt(_.Admin) && user.roles.nonEmpty)

def prefs(u: User, hasKeyboardMove: Boolean, botCompatible: Boolean)(using Context) =
val prefList = List(
hasKeyboardMove.option(li("keyboard moves")),
botCompatible.option:
li:
strong:
a(
cls := "text",
dataIcon := Icon.CautionCircle,
href := lila.common.String.base64
.decode("aHR0cDovL2NoZXNzLWNoZWF0LmNvbS9ob3dfdG9fY2hlYXRfYXRfbGljaGVzcy5odG1s")
)("BOT-COMPATIBLE SETTINGS")
).flatten
frag(
canViewRolesOf(u).option(
mzSection("roles")(
Expand All @@ -285,24 +297,11 @@ final class ModUserUi(helpers: Helpers, modUi: ModUi):
)
)
),
mzSection("preferences")(
strong(cls := "text inline", dataIcon := Icon.Gear)("Notable preferences"),
ul(
hasKeyboardMove.option(li("keyboard moves")),
botCompatible.option(
li(
strong(
a(
cls := "text",
dataIcon := Icon.CautionCircle,
href := lila.common.String.base64
.decode("aHR0cDovL2NoZXNzLWNoZWF0LmNvbS9ob3dfdG9fY2hlYXRfYXRfbGljaGVzcy5odG1s")
)("BOT-COMPATIBLE SETTINGS")
)
)
)
prefList.nonEmpty.option:
mzSection("preferences")(
strong(cls := "text inline", dataIcon := Icon.Gear)("Notable preferences"),
ul(prefList)
)
)
)

def showRageSitAndPlaybans(rageSit: RageSit, playbans: Int): Frag =
Expand Down
5 changes: 5 additions & 0 deletions ui/mod/css/_user.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
flex: 1 1 auto;
}

&--appeal {
order: 5;
flex: 1 1 auto;
}

&--boardTokens {
order: 6;
flex: 1 1 auto;
Expand Down

0 comments on commit 32ed577

Please sign in to comment.