Skip to content

Commit 2e3b792

Browse files
Move global banner text to top bar (#3049)
The current banner isn't shown on all pages, and it's currently impossible to view the global banner and project-specific banners at the same time. This PR moves the global banner to the middle of the top bar, leaving the original banner as a project-specific feature. A future PR will extend the project-specific banner to all project pages. <img width="2834" height="194" alt="image" src="https://github.com/user-attachments/assets/5719b342-5474-4829-ae76-1e5bd4be6658" />
1 parent adcfcea commit 2e3b792

File tree

7 files changed

+47
-23
lines changed

7 files changed

+47
-23
lines changed

app/Http/Controllers/SubProjectController.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,6 @@ public function apiViewSubProjects(): JsonResponse
141141
$response['showcalendar'] = 1;
142142

143143
$banners = [];
144-
if (config('cdash.global_banner') !== null && strlen(config('cdash.global_banner')) > 0) {
145-
$banners[] = config('cdash.global_banner');
146-
}
147144
if ($this->project->Banner !== null && strlen($this->project->Banner) > 0) {
148145
$banners[] = $this->project->Banner;
149146
}

app/cdash/public/api/v1/index.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@
5151
$response['showcalendar'] = 1;
5252

5353
$banners = [];
54-
if (config('cdash.global_banner') !== null && strlen(config('cdash.global_banner')) > 0) {
55-
$banners[] = config('cdash.global_banner');
56-
}
5754
if ($Project->Banner !== null && strlen($Project->Banner) > 0) {
5855
$banners[] = $Project->Banner;
5956
}

app/cdash/tests/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ add_feature_test(/Feature/SlowPageTest)
156156

157157
add_feature_test(/Feature/GitHubWebhook)
158158

159+
add_feature_test(/Feature/GlobalBannerTest)
160+
159161
add_legacy_unit_test(/CDash/Lib/Repository/GitHub)
160162
set_tests_properties(/CDash/Lib/Repository/GitHub PROPERTIES
161163
DEPENDS /CDash/XmlHandler/UpdateHandler

config/cdash.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
'require_full_email_when_adding_user' => env('REQUIRE_FULL_EMAIL_WHEN_ADDING_USER', false),
8787
// Whether or not project administrators can invite users
8888
'project_admin_registration_form_enabled' => env('PROJECT_ADMIN_REGISTRATION_FORM_ENABLED', true),
89+
// Text displayed at the top of all pages. Limited to 40 characters.
8990
'global_banner' => env('GLOBAL_BANNER'),
9091
// Whether or not "normal" username+password authentication is enabled
9192
'username_password_authentication_enabled' => env('USERNAME_PASSWORD_AUTHENTICATION_ENABLED', true),

phpstan-baseline.neon

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,12 +2400,6 @@ parameters:
24002400
count: 2
24012401
path: app/Http/Controllers/SubProjectController.php
24022402

2403-
-
2404-
message: '#^Parameter \#1 \$string of function strlen expects string, mixed given\.$#'
2405-
identifier: argument.type
2406-
count: 1
2407-
path: app/Http/Controllers/SubProjectController.php
2408-
24092403
-
24102404
message: '#^Parameter \#1 \$string of function strlen expects string, string\|false given\.$#'
24112405
identifier: argument.type
@@ -17163,12 +17157,6 @@ parameters:
1716317157
count: 6
1716417158
path: app/cdash/public/api/v1/index.php
1716517159

17166-
-
17167-
message: '#^Parameter \#1 \$string of function strlen expects string, mixed given\.$#'
17168-
identifier: argument.type
17169-
count: 1
17170-
path: app/cdash/public/api/v1/index.php
17171-
1717217160
-
1717317161
message: '#^Parameter \#1 \$string of function strlen expects string, string\|false given\.$#'
1717417162
identifier: argument.type

resources/views/components/header.blade.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
@php
2+
use Illuminate\Support\Str;
3+
24
if (isset($project)) {
35
$logoid = $project->ImageId;
46
}
@@ -12,13 +14,21 @@
1214

1315
<div id="header">
1416
<div id="headertop">
15-
<div id="topmenu">
16-
<a class="cdash-link" href="{{ url('/projects') }}">All Dashboards</a>
17-
@if(Auth::check())
18-
<a class="cdash-link" href="{{ url('/user') }}">My CDash</a>
17+
<div id="topmenu" style="display: flex; justify-content: space-between;">
18+
<span>
19+
<a class="cdash-link" href="{{ url('/projects') }}">All Dashboards</a>
20+
@if(Auth::check())
21+
<a class="cdash-link" href="{{ url('/user') }}">My CDash</a>
22+
@endif
23+
</span>
24+
25+
@if(config('cdash.global_banner') !== null && strlen(config('cdash.global_banner')) > 0)
26+
<span id="global-banner" style="color: #2ee84a;">
27+
{{ Str::limit(config('cdash.global_banner'), 40) }}
28+
</span>
1929
@endif
2030

21-
<span style="float: right;">
31+
<span>
2232
@if(Auth::check())
2333
<a class="cdash-link" href="{{ url('/logout') }}">Logout</a>
2434
@else

tests/Feature/GlobalBannerTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Tests\Feature;
4+
5+
use Illuminate\Support\Str;
6+
use Tests\TestCase;
7+
8+
class GlobalBannerTest extends TestCase
9+
{
10+
public function testGlobalBannerAppearsWhenSet(): void
11+
{
12+
$bannerText = Str::uuid()->toString();
13+
14+
$this->get('/login')->assertDontSee($bannerText);
15+
16+
config(['cdash.global_banner' => $bannerText]);
17+
18+
$this->get('/login')->assertSee($bannerText);
19+
}
20+
21+
public function testLongGlobalBannerGetsTruncated(): void
22+
{
23+
$bannerText = 'AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMM';
24+
25+
config(['cdash.global_banner' => $bannerText]);
26+
27+
$this->get('/login')->assertSee('AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJ...');
28+
}
29+
}

0 commit comments

Comments
 (0)