Skip to content

Add ability to revoke server cancellation#1311

Open
KroZen-Dev wants to merge 6 commits intoCtrlpanel-gg:developmentfrom
KroZen-Dev:feature/add-server-cancellation-revoke
Open

Add ability to revoke server cancellation#1311
KroZen-Dev wants to merge 6 commits intoCtrlpanel-gg:developmentfrom
KroZen-Dev:feature/add-server-cancellation-revoke

Conversation

@KroZen-Dev
Copy link
Collaborator

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

  • Introduce a PATCH route to uncancel a server
  • Add uncancel() method in ServerController to restore canceled servers
  • Update the server index Blade template to show conditional Cancel (yellow) or Restore (green) buttons
  • Add SweetAlert2 confirmation dialog for uncancel action
  • Ensure users can restore canceled servers before the billing period ends

Changes

  • routes/web.php
  • app/Http/Controllers/ServerController.php
  • themes/default/views/servers/index.blade.php

Features

  • Active servers show a yellow Cancel button
  • Canceled servers show a green Restore button
  • Users receive proper feedback on server restoration

…cture by removing unnecessary comments and organizing the content sections more clearly
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 and uncancel() controller method to clear the canceled timestamp 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.

Comment on lines +391 to +405
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());
}
}
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Preventing uncancellation if the server is already suspended (add a check like if ($server->suspended) and return an error), or
  2. Also unsuspending the server (calling $server->unSuspend()) when uncanceling a suspended server, similar to how the admin panel might handle it.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@KroZen-Dev KroZen-Dev requested a review from Copilot March 6, 2026 10:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@MrWeez MrWeez requested review from 1day2die and simbabimba-dev and removed request for MrWeez March 7, 2026 03:03
@MrWeez MrWeez added the Low Priority Can wait, not urgent. Handle when possible label Mar 7, 2026
@1day2die 1day2die requested a review from Copilot March 11, 2026 08:16
@1day2die
Copy link
Collaborator

Thanks for this!

please add what copilot suggested. Checking for current suspension is a good idea i think

grafik

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +285 to +295
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) => {
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Ctrlpanel-gg Ctrlpanel-gg deleted a comment from Copilot AI Mar 13, 2026
@Ctrlpanel-gg Ctrlpanel-gg deleted a comment from Copilot AI Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Low Priority Can wait, not urgent. Handle when possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants