Skip to content

Use common Blade template for Vue-only pages #2880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/Http/Controllers/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ protected function angular_view(string $view, string $title = ''): View
->with('angular_controller', $controller_name);
}

/**
* @param array<string,mixed> $props
*/
protected function vue(string $component, string $title, array $props = [], bool $enableDaisyUI = true): View
{
return $this->view('vue', $title)
->with('componentName', $component)
->with('props', $props)
->with('daisyui', $enableDaisyUI);
}

public static function getCDashVersion(): string
{
return file_get_contents(public_path('VERSION'));
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/AuthTokenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class AuthTokenController extends AbstractController
{
public function manage(): View
{
return $this->view('admin.manage-authtokens', 'Authentication Tokens');
return $this->vue('manage-auth-tokens', 'Authentication Tokens', [], false);
}

/**
Expand Down
6 changes: 4 additions & 2 deletions app/Http/Controllers/BuildController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ public function tests(int $build_id): View

$filters = json_decode(request()->get('filters')) ?? ['all' => []];

return $this->view('build.tests', 'Tests')
->with('filters', $filters);
return $this->vue('build-tests-page', 'Tests', [
'build-id' => $this->build->Id,
'initial-filters' => $filters,
]);
}

protected function renderBuildPage(int $build_id, string $page_name, string $page_title = '')
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/DynamicAnalysisController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class DynamicAnalysisController extends AbstractBuildController
public function viewDynamicAnalysis(int $buildid): View
{
$this->setBuildById($buildid);
return $this->view('dynamicanalysis.dynamic-analysis', 'Dynamic Analysis');
return $this->vue('view-dynamic-analysis', 'Dynamic Analysis', ['buildid' => $this->build->Id], false);
}

public function viewDynamicAnalysisFile(): View
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/EditProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function create()
{
Gate::authorize('create-project');

return $this->view('admin.project', 'Create Project');
return $this->vue('edit-project', 'Create Project', ['projectid' => 0], false);
}

// Render the edit project form.
Expand All @@ -20,6 +20,6 @@ public function edit($project_id)
$this->setProjectById((int) $project_id);
Gate::authorize('edit-project', $this->project);

return $this->view('admin.project', 'Edit Project');
return $this->vue('edit-project', 'Edit Project', ['projectid' => $this->project->Id], false);
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/ManageMeasurementsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function show($project_id)
$this->setProjectById((int) $project_id);
Gate::authorize('edit-project', $this->project);

return $this->view('admin.measurements', 'Test Measurements');
return $this->vue('manage-measurements', 'Test Measurements', ['projectid' => $this->project->Id ?? 0], false);
}

public function apiGet(): JsonResponse
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,6 @@ public function sites(int $project_id): View
{
$this->setProjectById($project_id);

return $this->view('project.sites', 'Sites');
return $this->vue('project-sites-page', 'Sites', ['project-id' => $this->project->Id]);
}
}
14 changes: 13 additions & 1 deletion app/Http/Controllers/ProjectMembersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace App\Http\Controllers;

use App\Models\Project;
use App\Models\User;
use Illuminate\View\View;

final class ProjectMembersController extends AbstractProjectController
Expand All @@ -12,6 +14,16 @@ public function members(int $project_id): View
{
$this->setProjectById($project_id);

return $this->view('project.members', 'Members');
$eloquentProject = Project::findOrFail((int) $this->project->Id);

/** @var ?User $user */
$user = auth()->user();

return $this->vue('project-members-page', 'Members', [
'project-id' => $this->project->Id,
'user-id' => $user?->id,
'can-invite-users' => $user?->can('inviteUser', $eloquentProject) ?? false,
'can-remove-users' => $user?->can('removeUser', $eloquentProject) ?? false,
]);
}
}
6 changes: 4 additions & 2 deletions app/Http/Controllers/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ public function siteStatistics(): View|RedirectResponse

public function viewSite(Site $site): View
{
return $this->view('site.view-site', $site->name)
->with('site', $site);
return $this->vue('sites-id-page', $site->name, [
'site-id' => $site->id,
'user-id' => auth()->user()?->id,
]);
}
}
3 changes: 2 additions & 1 deletion app/Http/Controllers/SubProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public function dependenciesGraph(Request $request, string $project): View
{
$this->setProjectByName($project);

return $this->view('project.subproject-dependencies', 'SubProject Dependencies')->with([
return $this->vue('sub-project-dependencies', 'SubProject Dependencies', [
'project-name' => $this->project->Name,
'date' => $request->string('date'),
]);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/TestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function details($buildtest_id = null)
}

$this->setProjectById($projectid);
return $this->view('test.details', 'Test Results');
return $this->vue('test-details', 'Test Results', [], false);
}

public function apiTestDetails(): JsonResponse|StreamedResponse
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class UserController extends AbstractController
{
public function userPage(): View
{
return $this->view('admin.user', 'My Profile');
return $this->vue('user-homepage', 'My Profile', [], false);
}

public function userPageContent(): JsonResponse
Expand Down
5 changes: 4 additions & 1 deletion app/Http/Controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

namespace App\Http\Controllers;

use App\Models\GlobalInvitation;
use Illuminate\View\View;

final class UsersController extends AbstractController
{
public function users(): View
{
return $this->view('user.users', 'Users');
return $this->vue('users-page', 'Users', [
'can-invite-users' => auth()->user()?->can('createInvitation', GlobalInvitation::class) ?? false,
]);
}
}
15 changes: 15 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,11 @@ parameters:
count: 1
path: app/Http/Controllers/ProjectInvitationController.php

-
message: "#^Dynamic call to static method Illuminate\\\\Contracts\\\\Auth\\\\Guard\\:\\:user\\(\\)\\.$#"
count: 1
path: app/Http/Controllers/ProjectMembersController.php

-
message: "#^Access to an undefined property object\\:\\:\\$numdefects\\.$#"
count: 2
Expand Down Expand Up @@ -2078,6 +2083,11 @@ parameters:
count: 1
path: app/Http/Controllers/RemoteProcessingController.php

-
message: "#^Dynamic call to static method Illuminate\\\\Contracts\\\\Auth\\\\Guard\\:\\:user\\(\\)\\.$#"
count: 1
path: app/Http/Controllers/SiteController.php

-
message: "#^Method App\\\\Http\\\\Controllers\\\\SiteController\\:\\:siteStatistics\\(\\) never returns Illuminate\\\\Http\\\\RedirectResponse so it can be removed from the return type\\.$#"
count: 1
Expand Down Expand Up @@ -2609,6 +2619,11 @@ parameters:
count: 2
path: app/Http/Controllers/UserNoteController.php

-
message: "#^Dynamic call to static method Illuminate\\\\Contracts\\\\Auth\\\\Guard\\:\\:user\\(\\)\\.$#"
count: 1
path: app/Http/Controllers/UsersController.php

-
message: "#^Parameter \\#2 \\$build of class CDash\\\\Controller\\\\Api\\\\ViewTest constructor expects CDash\\\\Model\\\\Build, CDash\\\\Model\\\\Build\\|null given\\.$#"
count: 1
Expand Down
8 changes: 0 additions & 8 deletions resources/views/admin/manage-authtokens.blade.php

This file was deleted.

7 changes: 0 additions & 7 deletions resources/views/admin/measurements.blade.php

This file was deleted.

7 changes: 0 additions & 7 deletions resources/views/admin/project.blade.php

This file was deleted.

10 changes: 0 additions & 10 deletions resources/views/admin/user.blade.php

This file was deleted.

8 changes: 0 additions & 8 deletions resources/views/build/tests.blade.php

This file was deleted.

8 changes: 0 additions & 8 deletions resources/views/dynamicanalysis/dynamic-analysis.blade.php

This file was deleted.

13 changes: 0 additions & 13 deletions resources/views/project/members.blade.php

This file was deleted.

8 changes: 0 additions & 8 deletions resources/views/project/sites.blade.php

This file was deleted.

11 changes: 0 additions & 11 deletions resources/views/project/subproject-dependencies.blade.php

This file was deleted.

8 changes: 0 additions & 8 deletions resources/views/site/view-site.blade.php

This file was deleted.

7 changes: 0 additions & 7 deletions resources/views/test/details.blade.php

This file was deleted.

8 changes: 0 additions & 8 deletions resources/views/user/users.blade.php

This file was deleted.

11 changes: 11 additions & 0 deletions resources/views/vue.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@extends('cdash', [
'vue' => true,
])

@section('main_content')
<{{ $componentName }}
@foreach($props as $prop => $value)
:{{ $prop }}="@js($value)"
@endforeach
></{{ $componentName }}>
@endsection