Add ability to revoke server cancellation#1311
Add ability to revoke server cancellation#1311KroZen-Dev wants to merge 6 commits intoCtrlpanel-gg:developmentfrom
Conversation
…cture by removing unnecessary comments and organizing the content sections more clearly
…and processing errors
There was a problem hiding this comment.
Pull request overview
This PR adds the ability for users to revoke (uncancel) a server cancellation. Previously, once a server was canceled, the action was irreversible from the user's perspective. Now, users see a conditional button — yellow "Cancel" for active servers or green "Restore" for canceled servers — and can restore a canceled server before the billing period ends.
Changes:
- New
PATCH /servers/uncancel/{server}route anduncancel()controller method to clear thecanceledtimestamp on a server - Conditional button rendering in the Blade template showing Cancel or Restore based on the server's cancellation status
- SweetAlert2 confirmation dialog for the uncancel action, following existing patterns
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| routes/web.php | Adds new PATCH route for server uncancellation |
| app/Http/Controllers/ServerController.php | Adds uncancel() method that sets canceled to null with ownership check |
| themes/default/views/servers/index.blade.php | Replaces single Cancel button with conditional Cancel/Restore buttons; adds JS handler for uncancel; removes HTML comments; fixes indentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public function uncancel(Server $server): RedirectResponse | ||
| { | ||
| if ($server->user_id !== Auth::id()) { | ||
| return back()->with('error', __('This is not your Server!')); | ||
| } | ||
|
|
||
| try { | ||
| $server->update(['canceled' => null]); | ||
| return redirect()->route('servers.index') | ||
| ->with('success', __('Server cancellation has been revoked')); | ||
| } catch (Exception $e) { | ||
| return redirect()->route('servers.index') | ||
| ->with('error', __('Server cancellation revoke failed: ') . $e->getMessage()); | ||
| } | ||
| } |
There was a problem hiding this comment.
The uncancel method doesn't check whether the server has already been suspended. According to ChargeServers.php (lines 99-105), a canceled server gets suspended when the billing period ends. If a user uncancels an already-suspended server, this method only clears the canceled flag but leaves the server suspended in both the database and Pterodactyl. This creates an inconsistent state where the server appears "active" (not canceled) but remains suspended.
Consider either:
- Preventing uncancellation if the server is already suspended (add a check like
if ($server->suspended)and return an error), or - Also unsuspending the server (calling
$server->unSuspend()) when uncanceling a suspended server, similar to how the admin panel might handle it.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fetch("{{ route('servers.uncancel', '') }}" + '/' + serverId, { | ||
| method: 'PATCH', | ||
| headers: { | ||
| 'X-CSRF-TOKEN': '{{ csrf_token() }}' | ||
| } | ||
| }).then((response) => { | ||
| if (!response.ok) { | ||
| throw new Error('Failed to restore server'); | ||
| } | ||
| window.location.reload(); | ||
| }).catch((error) => { |
There was a problem hiding this comment.
fetch() will follow the controller’s redirect response by default; if the redirect GET consumes the flashed success/error message, the subsequent window.location.reload() can result in the user never seeing the feedback. Consider returning JSON/204 for AJAX requests (and showing a SweetAlert success), or use redirect: 'manual' and then navigate to the redirect location.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Problem
Currently, once a server is canceled, the Cancel button becomes inactive and users cannot revert the cancellation. This prevents restoring a server if the cancellation was accidental.
Solution
Changes
Features