Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork218
FE: Add JSON formatting for produce message fields#1484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
aaron-seq wants to merge3 commits intokafbat:mainChoose a base branch fromaaron-seq:feature/issue-1244-json-formatting
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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
Implements JSON formatting functionality as requested in issuekafbat#1244:- Add format toggle buttons for Key, Value, and Headers fields- Implement JSON formatting utility with 2-space indentation- Add optional JSON validation checkbox before form submission- Enhanced ACE editor with conditional JSON syntax highlighting- Comprehensive error handling with user-friendly feedback- Full accessibility support with ARIA labels and keyboard navigation- Resizable headers field for improved usabilityFeatures:- Smart format state management that resets on manual edits- Event-driven formatting operations (button-triggered, not on-type)- Integration with existing validation system- Backward compatibility with zero breaking changes- Performance optimized with memoized utilitiesTesting:- Comprehensive error handling for malformed JSON- Preserves original content when formatting fails- Works with all existing Kafka message formats- Full keyboard navigation and screen reader support
Adds new styled components to support JSON formatting functionality:- ValidationSection: Layout for JSON validation checkbox- FieldGroup: Wrapper for field label and editor with format button- FieldHeader: Flex layout for field label and format button- FormatButton: Compact button styling with accessibility features- ResizableEditorWrapper: CSS-based resize functionality for headers field- ValidationError/FormatSuccess: Feedback styling for user interactions- ScreenReaderOnly: Accessibility helper for screen reader textFeatures:- Responsive design following existing patterns- Theme-aware styling with proper fallbacks- Focus management and accessibility compliance- Visual feedback for formatting state changes- Enhanced resize handle for better usability
2 tasks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Hi aaron-seq! 👋
Welcome, and thank you for opening your first PR in the repo!
Please wait for triaging by our maintainers.
Please take a look at ourcontributing guide.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
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.
Uh oh!
There was an error while loading.Please reload this page.
What changes did you make?
Implemented JSON formatting functionality for the produce message modal as requested in issue#1244. This enhancement addresses the need for formatted JSON display when working with Schema Registry examples and manual JSON input.
Core Implementation:
Format Toggle Buttons: Added format buttons adjacent to Key, Value, and Headers field labels. These buttons trigger JSON formatting on-demand using JSON.stringify with 2-space indentation.
JSON Formatting Utility: Implemented a safe formatting function that parses and stringifies JSON with proper error handling. If parsing fails, the original content is preserved and an error message is displayed to the user.
Optional Validation: Added a validation checkbox that allows users to enable JSON syntax validation before form submission. This is opt-in and does not interrupt existing workflows.
Enhanced Editor Configuration: Modified ACE editor to conditionally use JSON mode when formatting is active, providing syntax highlighting for better readability.
Resizable Headers Field: Implemented CSS-based resize functionality for the headers textarea, addressing the usability issue with multi-line JSON headers.
Accessibility Features: Added comprehensive ARIA labels, keyboard navigation support (Tab, Enter, Space), screen reader announcements, and proper focus management.
Technical Details:
State management using React hooks:
Event-driven architecture:
Error handling:
Integration approach:
Files Modified:
frontend/src/components/Topics/Topic/SendMessage/SendMessage.tsx: Core formatting logic, state management, event handlers (189 additions, 26 deletions)frontend/src/components/Topics/Topic/SendMessage/SendMessage.styled.tsx: UI components and accessibility styles (144 additions)Is there anything you'd like reviewers to focus on?
How Has This Been Tested?
Manually (please, describe, if necessary)
Manual Testing Performed:
Edge Cases Tested:
Unit checks
Integration checks
Covered by existing automation
Checklist
Check outContributing andCode of Conduct
Closes#1244
Additional Context
Alignment with Maintainer Feedback:
This implementation directly addresses all points from the maintainer discussion:
Design Rationale:
Button Placement: Format buttons positioned next to field labels for discoverability while maintaining clean layout hierarchy
Validation Approach: Checkbox-based opt-in validation respects existing user workflows while providing safety net for users who want it
Event-Driven Formatting: Button-triggered formatting (versus on-type) provides explicit user control and avoids performance overhead during rapid input
State Reset on Edit: Format state automatically clears when users manually modify content, preventing confusion about current formatting state
Error Preservation: Failed formatting operations preserve original content to prevent accidental data loss
Performance Characteristics:
Security Considerations:
Browser Compatibility:
Future Enhancement Opportunities:
Thank you for reviewing this contribution. I am happy to make any adjustments based on code review feedback or maintainer preferences.