Point the public site to each project's TaskStream board
A project with a board now carries its key, its address and the address of the board's public showcase in the public API, so the website can show its roadmap, releases and tickets for newcomers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ namespace App\Http\Resources\PublicApi;
|
||||
|
||||
use App\Models\Media;
|
||||
use App\Models\Project;
|
||||
use App\Services\TaskStream\TaskStreamClient;
|
||||
use App\Support\ImagePayload;
|
||||
use App\Support\SiteUrls;
|
||||
use App\Support\TranslatablePayload;
|
||||
@@ -110,11 +111,30 @@ class PublicProjectResource extends JsonResource
|
||||
// alive without anyone maintaining it.
|
||||
'repositories' => PublicRepositoryResource::collection($this->whenLoaded('repositories')),
|
||||
|
||||
// Its board in TaskStream, when it has one: the public site reads
|
||||
// the roadmap, releases and tickets for newcomers from there.
|
||||
'taskstream' => $this->taskstream_key === null ? null : $this->taskstream(),
|
||||
|
||||
'alternates' => SiteUrls::alternates($this->resource, 'project'),
|
||||
'path' => SiteUrls::alternates($this->resource, 'project')[$locale] ?? null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{key: string, url: string, web_url: string, showcase_url: string}
|
||||
*/
|
||||
protected function taskstream(): array
|
||||
{
|
||||
$client = app(TaskStreamClient::class);
|
||||
|
||||
return [
|
||||
'key' => $this->taskstream_key,
|
||||
'url' => $client->projectUrl($this->taskstream_key),
|
||||
'web_url' => $client->webUrl(),
|
||||
'showcase_url' => $client->showcaseUrl($this->taskstream_key),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The media row when the caller loaded it, and null otherwise — never a
|
||||
* lazy load, because this runs once per row in a listing.
|
||||
|
||||
@@ -85,4 +85,21 @@ class TaskStreamClient
|
||||
{
|
||||
return "{$this->webUrl}/p/{$key}";
|
||||
}
|
||||
|
||||
/**
|
||||
* The public summary of a board (roadmap, releases, sprint, tickets for
|
||||
* newcomers). Anyone may read it, so the public site can ask directly.
|
||||
*/
|
||||
public function showcaseUrl(string $key): string
|
||||
{
|
||||
return "{$this->apiUrl}/api/explore/projects/{$key}/showcase";
|
||||
}
|
||||
|
||||
/**
|
||||
* Where the paths of a showcase (`/p/KEY/issues/KEY-3`) are opened.
|
||||
*/
|
||||
public function webUrl(): string
|
||||
{
|
||||
return $this->webUrl;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user