Skip to content

Commit 500e7da

Browse files
Unify header menu templates (#3481)
The header menu is currently generated differently on Vue and AngularJS-based pages, which has led them to diverge slightly. This PR combines the two, using a single source the render the header on all pages. I plan to follow up with a series of PRs which make additional adjustments to the header.
1 parent 320b05f commit 500e7da

3 files changed

Lines changed: 28 additions & 132 deletions

File tree

resources/views/components/header.blade.php

Lines changed: 27 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@php
2+
use Illuminate\Support\Carbon;
23
use Illuminate\Support\Str;
34
use App\Services\ProjectService;
45
use Illuminate\Support\Facades\Auth;
@@ -9,9 +10,14 @@
910
1011
$hideRegistration = config('cdash.user_registration_form_enabled') === false;
1112
12-
$currentDateString = now()->toDateString();
13+
$userInProject = false;
14+
if (isset($project)) {
15+
$eloquentProject = \App\Models\Project::findOrFail((int) $project->Id);
16+
17+
$currentDateString = Carbon::parse($eloquentProject->builds()->max('starttime'))->toDateString();
1318
14-
$userInProject = isset($project) && auth()->user() !== null && \App\Models\Project::findOrFail($project->Id)->users()->where('id', auth()->user()->id)->exists();
19+
$userInProject = auth()->user() !== null && $eloquentProject->users()->where('id', auth()->user()->id)->exists();
20+
}
1521
1622
$showHeaderNav = isset($build);
1723
@endphp
@@ -105,124 +111,9 @@
105111
</nav>
106112

107113

108-
@if(isset($angular) && $angular === true)
109-
<div id="headermenu" style="float: right;">
110-
<ul id="navigation">
111-
<li ng-if="!cdash.noproject && cdash.projectname_encoded !== undefined">
112-
<a class="cdash-link" ng-href="{{ url('/index.php') }}?project=@{{::cdash.projectname_encoded}}&date=@{{::cdash.date}}">
113-
Dashboard
114-
</a>
115-
<ul>
116-
<li ng-if="cdash.menu.subprojects == 1">
117-
<a class="cdash-link" ng-href="{{ url('/viewSubProjects.php') }}?project=@{{::cdash.projectname_encoded}}&date=@{{::cdash.date}}">
118-
SubProjects
119-
</a>
120-
</li>
121-
<li>
122-
<a class="cdash-link" ng-href="{{ url('/overview.php') }}?project=@{{::cdash.projectname_encoded}}&date=@{{::cdash.date}}">
123-
Overview
124-
</a>
125-
</li>
126-
<li>
127-
<a class="cdash-link" ng-href="{{ url('/buildOverview.php') }}?project=@{{::cdash.projectname_encoded}}&date=@{{::cdash.date}}@{{::cdash.extraurl}}">
128-
Builds
129-
</a>
130-
</li>
131-
<li>
132-
<a class="cdash-link" ng-href="{{ url('/testOverview.php') }}?project=@{{::cdash.projectname_encoded}}&date=@{{::cdash.date}}@{{::cdash.extraurl}}">
133-
Tests
134-
</a>
135-
</li>
136-
<li>
137-
<a class="cdash-link" ng-if="!cdash.parentid || cdash.parentid <= 0"
138-
ng-href="{{ url('/queryTests.php') }}?project=@{{::cdash.projectname_encoded}}&date=@{{::cdash.date}}@{{::cdash.extraurl}}@{{::cdash.querytestfilters}}">
139-
Tests Query
140-
</a>
141-
<a class="cdash-link" ng-if="cdash.parentid > 0"
142-
ng-href="{{ url('/queryTests.php') }}?project=@{{::cdash.projectname_encoded}}&parentid=@{{::cdash.parentid}}@{{::cdash.extraurl}}@{{::cdash.extrafilterurl}}">
143-
Tests Query
144-
</a>
145-
</li>
146-
<li class="endsubmenu">
147-
<a class="cdash-link" ng-href="{{ url('/projects') }}/@{{::cdash.projectid}}/sites@{{::cdash.extraurl}}">
148-
Sites
149-
</a>
150-
</li>
151-
</ul>
152-
</li>
153-
<li id="Back" ng-if="cdash.menu.back">
154-
<a class="cdash-link"
155-
ng-href="@{{::cdash.menu.back}}@{{::cdash.extrafilterurl}}"
156-
tooltip-popup-delay="1500"
157-
tooltip-append-to-body="true"
158-
tooltip-placement="bottom"
159-
uib-tooltip="Go back up one level in the hierarchy of results">Up</a>
160-
</li>
161-
<li ng-if="cdash.showcalendar">
162-
<a class="cdash-link" id="cal" href="" ng-click="toggleCalendar()">Calendar</a>
163-
<span id="date_now" style="display:none;">@{{::cdash.date}}</span>
164-
</li>
165-
<li ng-if="!cdash.hidenav && cdash.projectname_encoded !== undefined">
166-
<a class="cdash-link" href="#">Project</a>
167-
<ul>
168-
<li>
169-
<a class="cdash-link" ng-href="@{{::cdash.home}}">Home</a>
170-
</li>
171-
<li ng-if="cdash.documentation.replace('https://', '').replace('http://', '').trim() !== ''">
172-
<a class="cdash-link" ng-href="@{{::cdash.documentation}}">Documentation</a>
173-
</li>
174-
<li ng-if="cdash.vcs.replace('https://', '').replace('http://', '').trim() !== ''">
175-
<a class="cdash-link" ng-href="@{{::cdash.vcs}}">Repository</a>
176-
</li>
177-
<li ng-if="cdash.bugtracker.replace('https://', '').replace('http://', '').trim() !== ''"
178-
ng-class="::{endsubmenu: cdash.projectrole}">
179-
<a class="cdash-link" ng-href="@{{::cdash.bugtracker}}"> Bug Tracker</a>
180-
</li>
181-
<li class="endsubmenu">
182-
<a class="cdash-link" ng-href="{{ url('/projects') }}/@{{::cdash.projectid}}/members">Members</a>
183-
</li>
184-
@if($userInProject)
185-
<li class="endsubmenu">
186-
<a class="cdash-link" ng-href="{{ url('/subscribeProject.php') }}?projectid=@{{::cdash.projectid}}">Notifications</a>
187-
</li>
188-
@endif
189-
</ul>
190-
</li>
191-
<li ng-if="cdash.user.admin == 1 && !cdash.noproject && cdash.projectid !== undefined" id="admin">
192-
<a class="cdash-link" href="#">Settings</a>
193-
<ul>
194-
<li>
195-
<a class="cdash-link" ng-href="{{ url('/project') }}/@{{::cdash.projectid}}/edit">
196-
Project
197-
</a>
198-
</li>
199-
<li>
200-
<a class="cdash-link" ng-href="{{ url('/manageBuildGroup.php') }}?projectid=@{{::cdash.projectid}}">
201-
Groups
202-
</a>
203-
</li>
204-
<li>
205-
<a class="cdash-link" ng-href="{{ url('/project') }}/@{{::cdash.projectid}}/testmeasurements">
206-
Measurements
207-
</a>
208-
</li>
209-
<li>
210-
<a class="cdash-link" ng-href="{{ url('/manageSubProject.php') }}?projectid=@{{::cdash.projectid}}">
211-
SubProjects
212-
</a>
213-
</li>
214-
<li class="endsubmenu">
215-
<a class="cdash-link" ng-href="{{ url('/manageOverview.php') }}?projectid=@{{::cdash.projectid}}">
216-
Overview
217-
</a>
218-
</li>
219-
</ul>
220-
</li>
221-
</ul>
222-
</div>
223-
@elseif(isset($project))
224-
<div id="headermenu">
225-
<ul id="navigation">
114+
<div id="headermenu">
115+
<ul id="navigation">
116+
@if(isset($project))
226117
<li>
227118
<a href="#">Dashboard</a>
228119
<ul>
@@ -242,6 +133,11 @@
242133
Tests
243134
</a>
244135
</li>
136+
<li>
137+
<a href="{{ url('/testOverview.php') }}?project={{rawurlencode($project->Name)}}&date={{$currentDateString}}">
138+
Test Overview
139+
</a>
140+
</li>
245141
<li>
246142
<a href="{{ url("/projects/$project->Id/sites") }}">
247143
Sites
@@ -256,6 +152,14 @@
256152
@endif
257153
</ul>
258154
</li>
155+
@endif
156+
@if(isset($angular) && $angular === true)
157+
<li ng-if="cdash.showcalendar">
158+
<a class="cdash-link" id="cal" href="" ng-click="toggleCalendar()">Calendar</a>
159+
<span id="date_now" style="display:none;">@{{::cdash.date}}</span>
160+
</li>
161+
@endif
162+
@if(isset($project))
259163
<li>
260164
<a href="#">Project</a>
261165
<ul>
@@ -335,9 +239,9 @@
335239
</ul>
336240
</li>
337241
@endcan
338-
</ul>
339-
</div>
340-
@endif
242+
@endif
243+
</ul>
244+
</div>
341245
</div>
342246

343247
@if(isset($angular) && $angular === true)

tests/cypress/e2e/query-tests.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('query tests', () => {
4444
it('displays the correct default filters', () => {
4545
cy.visit('index.php?project=Trilinos');
4646
const expected_url = 'queryTests.php?project=Trilinos&date=2011-07-22&filtercount=1&showfilters=1&field1=status&compare1=62&value1=passed';
47-
cy.get('#navigation').find('a').contains('Tests Query').should('have.attr', 'href').and('contains', expected_url);
47+
cy.get('#navigation').find('a').contains('Tests').should('have.attr', 'href').and('contains', expected_url);
4848

4949
// load the page and verify the expected number of tests.
5050
cy.visit(expected_url);

tests/cypress/e2e/view-test.cy.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ describe('viewTest', () => {
66
});
77

88

9-
it('shows link to queryTests.php', () => {
10-
cy.visit('viewTest.php?buildid=1');
11-
12-
const default_filters = 'queryTests.php?project=TestCompressionExample&date=2009-12-18&filtercount=1&showfilters=1&field1=status&compare1=62&value1=passed';
13-
cy.get('#navigation').find('a').contains('Tests Query').should('have.attr', 'href').and('contains', default_filters);
14-
});
15-
16-
179
it('accounts for missing tests', () => {
1810
// go to the viewTest page corresponding to build with name 'Win32-MSVC2009'
1911
cy.visit('index.php?project=EmailProjectExample&date=2009-02-26');

0 commit comments

Comments
 (0)