Open a TaskStream board for a project that has none yet
The project form gets «Crear en TaskStream» while the project has no board, and `taskstream: true` on a PATCH does the same through the API. A refusal leaves the edit unsaved; a project with a board keeps it, and `taskstream_key` without the flag is still ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -72,11 +72,22 @@ class ProjectController extends Controller
|
||||
return ProjectResource::make($project->load(self::WITH));
|
||||
}
|
||||
|
||||
public function update(ProjectRequest $request, Project $project): ProjectResource
|
||||
/**
|
||||
* `taskstream: true` opens a board for a project that has none yet, as on
|
||||
* creation (and nothing is saved if that fails); one that has a board
|
||||
* keeps it.
|
||||
*/
|
||||
public function update(ProjectRequest $request, Project $project, OpenInTaskStream $openInTaskStream): ProjectResource
|
||||
{
|
||||
$this->authorize('update', $project);
|
||||
|
||||
return ProjectResource::make($this->persist($this->fill($project, $request), $request));
|
||||
$project = $this->fill($project, $request);
|
||||
|
||||
if ($request->boolean('taskstream') && $project->taskstream_project_id === null) {
|
||||
$openInTaskStream->handle($project, $request->user(), $request->bearerToken(), $request->validated('taskstream_key'));
|
||||
}
|
||||
|
||||
return ProjectResource::make($this->persist($project, $request));
|
||||
}
|
||||
|
||||
public function destroy(Project $project): JsonResponse
|
||||
|
||||
@@ -20,8 +20,9 @@ use Illuminate\Validation\Validator;
|
||||
* Relations travel as ids and are replaced whole when sent: `technology_ids`,
|
||||
* `service_ids`, and `members` with each one's role on the project.
|
||||
*
|
||||
* `taskstream` (on creation only) opens a public board in TaskStream for the
|
||||
* project, keyed `taskstream_key` or one derived from the slug.
|
||||
* `taskstream` opens a public board in TaskStream for the project, keyed
|
||||
* `taskstream_key` or one derived from the slug; on an update, only when the
|
||||
* project has none yet.
|
||||
*/
|
||||
class ProjectRequest extends FormRequest
|
||||
{
|
||||
@@ -78,10 +79,10 @@ class ProjectRequest extends FormRequest
|
||||
'members.*.id' => ['required', 'integer', 'distinct', Rule::exists('members', 'id')->whereNull('deleted_at')],
|
||||
'members.*.role' => ['nullable', 'string', 'max:120'],
|
||||
|
||||
// Only when creating; a client PATCHing back what it read sends
|
||||
// the key it got, which is ignored rather than refused.
|
||||
'taskstream' => [$creating ? 'sometimes' : 'exclude', 'boolean'],
|
||||
'taskstream_key' => [$creating ? 'sometimes' : 'exclude', 'nullable', 'string', 'regex:/^[A-Za-z][A-Za-z0-9]{1,9}$/'],
|
||||
// The key is only read along with `taskstream`: a client PATCHing
|
||||
// back what it read sends the key it got, which changes nothing.
|
||||
'taskstream' => ['sometimes', 'boolean'],
|
||||
'taskstream_key' => ['sometimes', 'nullable', 'string', 'regex:/^[A-Za-z][A-Za-z0-9]{1,9}$/'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user