fix(ui): pretty print JSON annotations in application summary#28232
Open
shhivakr wants to merge 1 commit into
Open
fix(ui): pretty print JSON annotations in application summary#28232shhivakr wants to merge 1 commit into
shhivakr wants to merge 1 commit into
Conversation
Signed-off-by: Shiva Kumar <shivakrwpa1@gmail.com>
❗ Preview Environment stop on Bunnyshell failedSee: Environment Details | Pipeline Logs Available commands (reply to this comment):
|
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the Application Summary annotations display to be more readable by rendering annotations in a <pre> block with line breaks and pretty-printing JSON-looking values.
Changes:
- Added
formatAnnotationValue()to pretty-print JSON annotation values. - Switched ANNOTATIONS rendering from a single-line space-joined string to a multi-line
<pre>with newline separation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+63
to
+75
| function formatAnnotationValue(value: string) { | ||
| const trimmed = value.trim(); | ||
|
|
||
| try { | ||
| if (trimmed.startsWith('{') || trimmed.startsWith('[')) { | ||
| return JSON.stringify(JSON.parse(trimmed), null, 2); | ||
| } | ||
| } catch { | ||
| // Ignore invalid JSON and return original value | ||
| } | ||
|
|
||
| return value; | ||
| } |
Comment on lines
+131
to
+132
| .map(annotation => `${annotation}=${formatAnnotationValue(app.metadata.annotations[annotation])}`) | ||
| .join('\n\n')} |
Comment on lines
+130
to
+132
| {Object.keys(app.metadata.annotations || {}) | ||
| .map(annotation => `${annotation}=${formatAnnotationValue(app.metadata.annotations[annotation])}`) | ||
| .join('\n\n')} |
Bundle ReportChanges will increase total bundle size by 205 bytes (0.0%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: argo-cd-ui-array-pushAssets Changed:
|
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.
Fixes #27836
What does this PR do?
Annotations in the Application Summary view are currently rendered as plain strings, which makes JSON annotation values difficult to read.
This PR adds formatting for annotation values that contain valid JSON objects or arrays. When a valid JSON value is detected, it is pretty-printed with indentation to improve readability. Non-JSON annotation values continue to be rendered unchanged.
The annotations section is rendered inside a
<pre>element to preserve indentation and line breaks while remaining within the existing expandable view.Testing
pnpm lintpnpm buildChecklist: