fix: system-wide GitHub apps (#5114)

- fix(ui): system-wide GitHub Apps are not shown in the create a new Application dialog
- fix: query logic error that shows all system-wide apps, regardless of whether they are public or private.
- fix: clicking on a system-wide GitHub app from a team other than the one that created it resulted in a 404 error.
This commit is contained in:
🏔️ Peak 2025-02-11 17:07:57 +01:00 committed by GitHub
parent 9c04834dab
commit e73c9b5f98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 9 deletions

View file

@ -33,17 +33,30 @@ protected static function booted(): void
public static function ownedByCurrentTeam() public static function ownedByCurrentTeam()
{ {
return GithubApp::whereTeamId(currentTeam()->id); return GithubApp::where(function ($query) {
$query->where('team_id', currentTeam()->id)
->orWhere('is_system_wide', true);
});
} }
public static function public() public static function public()
{ {
return GithubApp::whereTeamId(currentTeam()->id)->whereisPublic(true)->whereNotNull('app_id')->get(); return GithubApp::where(function ($query) {
$query->where(function ($q) {
$q->where('team_id', currentTeam()->id)
->orWhere('is_system_wide', true);
})->where('is_public', true);
})->whereNotNull('app_id')->get();
} }
public static function private() public static function private()
{ {
return GithubApp::whereTeamId(currentTeam()->id)->whereisPublic(false)->whereNotNull('app_id')->get(); return GithubApp::where(function ($query) {
$query->where(function ($q) {
$q->where('team_id', currentTeam()->id)
->orWhere('is_system_wide', true);
})->where('is_public', false);
})->whereNotNull('app_id')->get();
} }
public function team() public function team()

View file

@ -248,15 +248,17 @@ public function sources()
{ {
$sources = collect([]); $sources = collect([]);
$github_apps = GithubApp::where(function ($query) { $github_apps = GithubApp::where(function ($query) {
$query->where('team_id', $this->id) $query->where(function ($q) {
->Where('is_public', false) $q->where('team_id', $this->id)
->orWhere('is_system_wide', true); ->orWhere('is_system_wide', true);
})->where('is_public', false);
})->get(); })->get();
$gitlab_apps = GitlabApp::where(function ($query) { $gitlab_apps = GitlabApp::where(function ($query) {
$query->where('team_id', $this->id) $query->where(function ($q) {
->Where('is_public', false) $q->where('team_id', $this->id)
->orWhere('is_system_wide', true); ->orWhere('is_system_wide', true);
})->where('is_public', false);
})->get(); })->get();
return $sources->merge($github_apps)->merge($gitlab_apps); return $sources->merge($github_apps)->merge($gitlab_apps);