Skip to content

Fix/server cancellation revoke#1355

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

Fix/server cancellation revoke#1355
KroZen-Dev wants to merge 5 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.

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.

Why are you removed all comments? They can be useful. Leaving comments in the code is a good practice so that feature devs can easily understand code/function meaning without reading it

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.

It's very rare for contributors to leave comments in code. You do not write such remarks to them, so, please do not write to me too

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.

I'm not asking you to leave comments, I'm asking you not to delete existing ones without reason

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.

Please tell me, is this comment in the right place? ("delete server" in the logic of the cancel button)

Screenshot_2026-06-18-08-13-11-550_com.github.android.png

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.

As for the full namespace of the controller, I agree, I will correct for a short class

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.

Please tell me, is this comment in the right place? ("delete server" in the logic of the cancel button)

Screenshot_2026-06-18-08-13-11-550_com.github.android.png

I agree that the comment is incorrect, and was probably just copied from the delete method and forgotten to be renamed. But is that a reason to delete it? Why not just fix it if you notice a typo instead of deleting it?

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.

You mentioned not deleting comments without a reason. The reason here is that the comment was completely wrong and misleading (stating "Delete" instead of "Cancel")

​The code fetch(route('servers.cancel', ...)) is already 100% self-explanatory and doesn't need a comment to explain what it does. Keeping obvious or broken comments just litters the codebase

@MrWeez MrWeez added the Low Priority Can wait, not urgent. Handle when possible label Jun 16, 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.

2 participants