pam: use dynamic padding for URL/Code labels alignment#1472
pam: use dynamic padding for URL/Code labels alignment#1472nooreldeenmansour merged 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR replaces hardcoded spacing in the QR-code URL/Code output with a shared helper that computes padding dynamically, aiming to keep the labels visually aligned even when label text changes (e.g., via translation).
Changes:
- Add
formatAlignedFieldshelper to align label/value lines via runtime padding. - Update QR code rendering in both
qrcodeModel.View()andnativeModel.handleQrCode()to use the helper. - Add unit tests covering several ASCII-label alignment scenarios.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
pam/internal/adapter/utils.go |
Adds formatAlignedFields helper used for aligned label/value formatting. |
pam/internal/adapter/qrcodemodel.go |
Switches QR code view label/value lines to use formatAlignedFields. |
pam/internal/adapter/nativemodel.go |
Switches native QR code prompt message label/value lines to use formatAlignedFields. |
pam/internal/adapter/utils_test.go |
Adds unit tests for the new alignment helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1472 +/- ##
==========================================
- Coverage 86.94% 86.86% -0.09%
==========================================
Files 93 93
Lines 6366 6379 +13
Branches 111 111
==========================================
+ Hits 5535 5541 +6
- Misses 775 778 +3
- Partials 56 60 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
71072aa to
2660690
Compare
2660690 to
33a42eb
Compare
3v1n0
left a comment
There was a problem hiding this comment.
This a part, looks good to me, we need to update the tests now though.
Replace hardcoded extra spaces in the URL/Code format strings with a shared `formatAlignedFields` helper that computes padding at runtime based on label widths. This ensures consistent visual alignment regardless of label length, making the output safe for future translations. Follow-up to #1437
33a42eb to
b609b87
Compare
Which tests are you talking about? |
I guess this requires updating the golden files for the SSH tests, no? |
Oh, if not, well, it may worth adding a case in the example broker were we have a url without code, if did not hit that codepath.. |
The CI tests jobs are currently passing, so it doesn't seem to be required? (Please correct me if I am wrong)
The unit tests in this PR has the test I'll examine the broker tests to see if there is a one that covers the single field scenario. if not, I'll create a one. This one would be an integration test? Edit: I've added a test in the |
d0a875d to
170cfda
Compare
adombeck
left a comment
There was a problem hiding this comment.
Not sure I agree it was worth spending time on before we actually support translations (not saying that i18n is not important, but there are many other things on our roadmap and we need to prioritize). Anyway, the implementation looks good to me.
Replace hardcoded extra spaces in the URL/Code format strings with a shared
formatAlignedFieldshelper that computes padding at runtime based on label widths. This ensures consistent visual alignment regardless of label length, making the output safe for future translations.Follow-up to #1437