Skip to content

Add possibility to cancel server cancellation - #1355

Open
KroZen-Dev wants to merge 6 commits into
Ctrlpanel-gg:developmentfrom
KroZen-Dev:fix/server-cancellation-revoke
Open

Add possibility to cancel server cancellation#1355
KroZen-Dev wants to merge 6 commits into
Ctrlpanel-gg:developmentfrom
KroZen-Dev:fix/server-cancellation-revoke

Conversation

@KroZen-Dev

Copy link
Copy Markdown
Contributor

This pull request improves the server uncancel (restore) workflow by introducing proper JSON response handling for API/AJAX requests and updating the UI logic across themes to fully support asynchronous operations and error states.

Backend: Improved Response Handling & Security

  • The uncancel method in ServerController now checks for JSON expectations and returns a 204 No Content response on success, or a 500 JSON error on failure.
  • For standard web requests, the catch block error message was updated to a secure, translatable string, removing direct exception message exposure to the end-user.

Frontend: Enhanced Uncancel Workflow & Theme Consistency

  • Implemented the handleServerUncancel JavaScript function sending proper Accept: application/json and X-Requested-With headers to trigger the new backend JSON logic.
  • Fixed a critical JS bug in handleServerCancel where the response variable was undefined in the callback.
  • Added a SweetAlert confirmation/handling flow for the uncancel action in the default theme list (index.blade.php), ensuring seamless page reloads on success and explicit error alerts on failure.
  • Fixed a 500 RouteNotFoundException on the server settings page in the Phoenix theme by ensuring the template aligns with the defined routing structure.

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

All contributors have signed the CLA! ✅

Thank you for taking the time to complete this step. We'll now proceed with reviewing your pull request. We appreciate your contribution to Ctrlpanel! 🙌
Posted by the CLA Assistant Lite bot.

@KroZen-Dev

Copy link
Copy Markdown
Contributor Author

I have read and agree to the CLA.

github-actions Bot added a commit that referenced this pull request Jun 16, 2026
Comment thread routes/web.php Outdated
Route::get('notifications/readAll', [NotificationController::class, 'readAll'])->name('notifications.readAll');
Route::resource('notifications', NotificationController::class);
Route::patch('/servers/cancel/{server}', [ServerController::class, 'cancel'])->name('servers.cancel');
Route::patch('/servers/{server}/uncancel', [App\Http\Controllers\ServerController::class, 'uncancel'])->name('servers.uncancel');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  1. Why are you not following existing route naming? We have /servers/cancel/:id, so why are you using /servers/:id/uncancel. But at the same time I can agree that /servers/:id/:action format is better from hierarchy point, so if you update old route to use same format it will be ok.
  2. You're using full namespace while we already have ServerController class imported on L27

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here's exactly the same style: /servers/{server}/billing_priority

Screenshot_2026-06-18-08-09-55-200_com.github.android.png

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Here's exactly the same style: /servers/{server}/billing_priority

Screenshot_2026-06-18-08-09-55-200_com.github.android.png

I'm not arguing that you chose a more correct format, but we're talking about uncancel route that does opposite of cancel so logically new route should follow its naming pattern OR old one should be adjusted to have same naming pattern as new and other routes.

Comment thread themes/default/views/servers/index.blade.php
@MrWeez MrWeez added the Low Priority Can wait, not urgent. Handle when possible label Jun 16, 2026
@KroZen-Dev
KroZen-Dev requested a review from MrWeez July 1, 2026 18:32

@MrWeez MrWeez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  1. No check of current server state before uncancel. If the server isn't currently canceled (duplicate click / race between two tabs), uncancel() just silently sets canceled = null again. Not harmful, but also isn't good
  2. Naming uncancel also stands out. It's a negation of a verb rather than an action verb itself, so it worth changing the method/route/name to something like resume. servers.resume, ServerController::resume() reads and sound way better

Comment thread app/Http/Controllers/ServerController.php Outdated
@MrWeez MrWeez changed the title Fix/server cancellation revoke Add possibility to revoke cancellation of the server Jul 28, 2026
@MrWeez MrWeez changed the title Add possibility to revoke cancellation of the server Add possibility to cancel server cancellation Jul 28, 2026
@KroZen-Dev
KroZen-Dev requested a review from MrWeez July 28, 2026 12:01

@MrWeez MrWeez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Except this one small thing everything is ok.

Special thanks for changing servers.cancel route, which was the only one that did not comply with RESTful standards in servers related part.

use Exception;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Client\Response;
use Illuminate\Http\Client\Response as ClientResponse;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This import isn't used anywhere in this file, so could be removed completely instead of importing it under different name

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.

2 participants