From 3150f9322cc561ef053ada26554853ebc59c494e Mon Sep 17 00:00:00 2001 From: Rushaway Date: Thu, 3 Sep 2026 10:55:20 +0200 Subject: [PATCH] fix(banlist): surface demo download in the player drawer The SourceBans 1.x sliding ban panel rendered a "Review Demo" link when a ban had an uploaded demo. The 2.0 player drawer dropped it: `bans.detail` still returns `demo_count`, but `renderOverviewPane` in theme.js never turned it into a download affordance, so demos attached to bans were unreachable from the review surface. Add a "Download demo" button to the Overview pane (ban-focal only) linking to `getdemo.php?type=B&id=` when `demo_count > 0`. Ports sbpp/sourcebans-pp#1554. Co-Authored-By: Claude Sonnet 5 --- .../integration/BanDrawerDemoDownloadTest.php | 36 +++++++++++++++++++ web/themes/default/js/theme.js | 18 +++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 web/tests/integration/BanDrawerDemoDownloadTest.php diff --git a/web/tests/integration/BanDrawerDemoDownloadTest.php b/web/tests/integration/BanDrawerDemoDownloadTest.php new file mode 100644 index 000000000..583b37f24 --- /dev/null +++ b/web/tests/integration/BanDrawerDemoDownloadTest.php @@ -0,0 +1,36 @@ +assertStringContainsString('data.demo_count', $src); + $this->assertStringContainsString('getdemo.php?type=B&id=', $src); + $this->assertStringContainsString('data-testid="drawer-demo-download"', $src); + } + + public function testBansDetailApiExposesDemoCount(): void + { + $src = (string) file_get_contents(self::panelRoot() . '/api/handlers/bans.php'); + $this->assertStringContainsString("'demo_count'", $src); + } +} diff --git a/web/themes/default/js/theme.js b/web/themes/default/js/theme.js index 4324beb85..df9bb91f7 100644 --- a/web/themes/default/js/theme.js +++ b/web/themes/default/js/theme.js @@ -778,6 +778,22 @@ ).join('') + ''; + // #1554 — surface the demo download affordance the way SB 1.x's + // sliding ban panel did. `bans.detail` carries `demo_count`; when a + // ban has an uploaded demo the file is served by `getdemo.php?type=B` + // (see web/getdemo.php). Comm-blocks have no demo column, so this is + // ban-focal only. + let demoHtml = ''; + if (!isComm && Number((data && data.demo_count) || 0) > 0) { + const demoUrl = 'getdemo.php?type=B&id=' + encodeURIComponent(String(data.bid)); + demoHtml = '
' + + '

Demo

' + + '' + + ' Download demo' + + '' + + '
'; + } + let commentsHtml = ''; if (commentsVisible) { commentsHtml = '
' @@ -798,7 +814,7 @@ + '
'; } - return idHtml + focalHtml + commentsHtml; + return idHtml + focalHtml + demoHtml + commentsHtml; } /**