Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR modernizes AJAX endpoints by migrating from plain text/HTML responses to structured JSON responses, improving API consistency and making client-side data handling more robust.
- Refactored SSH key generation and validation endpoints to return JSON instead of HTML-wrapped text
- Updated page content retrieval endpoint to return JSON instead of plain text
- Modified all corresponding JavaScript AJAX calls to expect and parse JSON responses with proper dataType specification
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| webroot/panel/modal/new_key.php | Updated JavaScript to parse JSON responses for SSH key generation and validation, accessing structured fields instead of parsing HTML sections |
| webroot/js/ajax/ssh_validate.php | Converted endpoint to return JSON with is_valid field and proper Content-Type header |
| webroot/js/ajax/ssh_generate.php | Converted endpoint to return JSON with public and private fields, removed HTML section wrappers |
| webroot/admin/content.php | Updated JavaScript to parse JSON response and extract content field from structured response |
| webroot/admin/ajax/get_page_contents.php | Converted endpoint to return JSON with content field and proper Content-Type header |
Comments suppressed due to low confidence (1)
webroot/panel/modal/new_key.php:112
- The AJAX request lacks error handling. If the validation request fails, the UI state may be inconsistent (the button could remain in the wrong state). Consider adding an error callback to handle network failures or server-side errors gracefully.
$.ajax({
url: "<?php echo getURL("js/ajax/ssh_validate.php"); ?>",
dataType: "json",
type: "POST",
data: {
key: key
},
success: function(result) {
if (result.is_valid) {
$("input[id=add-key]").prop("disabled", false);
$("textarea[name=key]").css("box-shadow", "none");
} else {
$("input[id=add-key]").prop("disabled", true);
$("textarea[name=key]").css("box-shadow", "0 0 0 0.3rem rgba(220,53,69,0.25)");
}
}
});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #330
Screen.Recording.2025-12-18.at.10.14.52.AM.2.mov