Skip to content
Open
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
19 changes: 5 additions & 14 deletions app/Http/Controllers/ViewProjectsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,12 @@
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Gate;
use Illuminate\View\View;

final class ViewProjectsController extends AbstractController
{
public function viewAllProjects(): View|RedirectResponse
{
return $this->viewProjects(true);
}

public function viewActiveProjects(): View|RedirectResponse
{
return $this->viewProjects();
}

private function viewProjects(bool $all = false): View|RedirectResponse
public function viewProjects(): View|RedirectResponse
{
$num_public_projects = (int) DB::select('
SELECT COUNT(*) AS c FROM project WHERE public=?
Expand All @@ -31,8 +22,8 @@ private function viewProjects(bool $all = false): View|RedirectResponse
return $this->redirectToLogin();
}

return $this->vue('all-projects', 'Projects', [
'show-all' => $all,
], false);
return $this->vue('projects-page', 'Projects', [
'can-create-projects' => Gate::allows('create', Project::class),
]);
}
}
18 changes: 18 additions & 0 deletions app/Models/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
Expand Down Expand Up @@ -46,6 +47,7 @@
* @property bool $viewsubprojectslink
* @property ?string $ldapfilter
* @property ?string $banner
* @property ?string $logoUrl
*
* @method Builder<Project> forUser()
* @method Builder<Project> administeredByUser()
Expand Down Expand Up @@ -119,6 +121,22 @@ class Project extends Model
public const ACCESS_PUBLIC = 1;
public const ACCESS_PROTECTED = 2;

/**
* @return Attribute<?string,void>
*/
protected function logoUrl(): Attribute
{
return Attribute::make(
get: function (mixed $value, array $attributes): ?string {
if ((int) $attributes['imageid'] === 0) {
return null;
}

return url('/image/' . $attributes['imageid']);
},
);
}

/**
* Get the users who have been added to this project. Note that this selects users with all roles.
*
Expand Down
5 changes: 4 additions & 1 deletion app/cdash/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ add_browser_test(/Browser/Pages/ProjectSitesPageTest)

add_browser_test(/Browser/Pages/ProjectMembersPageTest)

add_browser_test(/Browser/Pages/ProjectPageTest)
add_browser_test(/Browser/Pages/ProjectBuildsPageTest)

add_browser_test(/Browser/Pages/ProjectsPageTest)
set_property(TEST /Browser/Pages/ProjectsPageTest APPEND PROPERTY RUN_SERIAL TRUE)

add_feature_test(/Feature/PurgeUnusedProjectsCommand)
set_property(TEST /Feature/PurgeUnusedProjectsCommand APPEND PROPERTY RUN_SERIAL TRUE)
Expand Down
3 changes: 3 additions & 0 deletions graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ type Project {
"A LDAP group users must be a member of to access the project."
ldapFilter: String @rename(attribute: "ldapfilter")

"A full URL string pointing to the location of the project's logo."
logoUrl: String

builds(
filters: _ @filter
): [Build!]! @hasMany(type: CONNECTION) @orderBy(column: "id")
Expand Down
12 changes: 12 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5835,6 +5835,18 @@ parameters:
count: 1
path: app/Models/CoverageView.php

-
rawMessage: Binary operation "." between '/image/' and mixed results in an error.
identifier: binaryOp.invalid
count: 1
path: app/Models/Project.php

-
rawMessage: Cannot cast mixed to int.
identifier: cast.int
count: 1
path: app/Models/Project.php

-
rawMessage: Binary operation "." between non-falsy-string and mixed results in an error.
identifier: binaryOp.invalid
Expand Down
4 changes: 2 additions & 2 deletions resources/js/vue/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const TestDetails = Vue.defineAsyncComponent(() => import('./components/TestDeta
const HeaderNav = Vue.defineAsyncComponent(() => import('./components/page-header/HeaderNav.vue'));
const ViewDynamicAnalysis = Vue.defineAsyncComponent(() => import('./components/ViewDynamicAnalysis.vue'));
const ViewDynamicAnalysisFile = Vue.defineAsyncComponent(() => import('./components/ViewDynamicAnalysisFile.vue'));
const AllProjects = Vue.defineAsyncComponent(() => import('./components/AllProjects.vue'));
const ProjectsPage = Vue.defineAsyncComponent(() => import('./components/ProjectsPage.vue'));
const SubProjectDependencies = Vue.defineAsyncComponent(() => import('./components/SubProjectDependencies.vue'));
const BuildTestsPage = Vue.defineAsyncComponent(() => import('./components/BuildTestsPage.vue'));
const ProjectSitesPage = Vue.defineAsyncComponent(() => import('./components/ProjectSitesPage.vue'));
Expand All @@ -47,7 +47,7 @@ const cdash_components = {
HeaderNav,
ViewDynamicAnalysis,
ViewDynamicAnalysisFile,
AllProjects,
ProjectsPage,
SubProjectDependencies,
BuildTestsPage,
ProjectSitesPage,
Expand Down
189 changes: 0 additions & 189 deletions resources/js/vue/components/AllProjects.vue

This file was deleted.

Loading
Loading