feat: overhaul project workspace navigation
This commit is contained in:
@@ -2,41 +2,28 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Actions\Notifications\BuildProjectNotificationSettingsPayload;
|
||||
use App\Actions\Notifications\DeleteProjectNotificationAction;
|
||||
use App\Actions\Notifications\StoreProjectNotificationAction;
|
||||
use App\Actions\Notifications\UpdateProjectNotificationAction;
|
||||
use App\Actions\Permissions\PermissionService;
|
||||
use App\Enums\Permission;
|
||||
use App\Enums\ProjectSettingsSection;
|
||||
use App\Http\Requests\StoreProjectNotificationActionRequest;
|
||||
use App\Http\Requests\UpdateProjectNotificationActionRequest;
|
||||
use App\Models\NotificationAction;
|
||||
use App\Models\Project;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class ProjectNotificationSettingsController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly BuildProjectNotificationSettingsPayload $buildProjectNotificationSettingsPayload,
|
||||
private readonly DeleteProjectNotificationAction $deleteProjectNotificationAction,
|
||||
private readonly PermissionService $permissionService,
|
||||
private readonly StoreProjectNotificationAction $storeProjectNotificationAction,
|
||||
private readonly UpdateProjectNotificationAction $updateProjectNotificationAction,
|
||||
) {}
|
||||
|
||||
public function show(Request $request, Project $project): Response
|
||||
{
|
||||
$this->abortUnlessCanManage($request, $project);
|
||||
|
||||
return Inertia::render(
|
||||
'projects/settings/Notifications',
|
||||
$this->buildProjectNotificationSettingsPayload->handle($project, session('status')),
|
||||
);
|
||||
}
|
||||
|
||||
public function store(
|
||||
StoreProjectNotificationActionRequest $request,
|
||||
Project $project,
|
||||
@@ -45,7 +32,7 @@ class ProjectNotificationSettingsController extends Controller
|
||||
|
||||
$notificationAction = $this->storeProjectNotificationAction->handle($project, $request->validated());
|
||||
|
||||
return to_route('projects.settings.notifications', $project)
|
||||
return $this->settingsRedirect($project)
|
||||
->with('status', "{$notificationAction->name} notification was added.");
|
||||
}
|
||||
|
||||
@@ -62,7 +49,7 @@ class ProjectNotificationSettingsController extends Controller
|
||||
$request->validated(),
|
||||
);
|
||||
|
||||
return to_route('projects.settings.notifications', $project)
|
||||
return $this->settingsRedirect($project)
|
||||
->with('status', "{$notificationAction->name} notification was updated.");
|
||||
}
|
||||
|
||||
@@ -80,7 +67,7 @@ class ProjectNotificationSettingsController extends Controller
|
||||
|
||||
$this->deleteProjectNotificationAction->handle($project, $notificationAction);
|
||||
|
||||
return to_route('projects.settings.notifications', $project)
|
||||
return $this->settingsRedirect($project)
|
||||
->with('status', "{$deletedName} notification was deleted.");
|
||||
}
|
||||
|
||||
@@ -91,4 +78,12 @@ class ProjectNotificationSettingsController extends Controller
|
||||
403,
|
||||
);
|
||||
}
|
||||
|
||||
private function settingsRedirect(Project $project): RedirectResponse
|
||||
{
|
||||
return to_route('projects.settings.index', [
|
||||
'project' => $project,
|
||||
'section' => ProjectSettingsSection::Notifications->value,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user