-
Notifications
You must be signed in to change notification settings - Fork 475
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add viewer for long strings in GridValue #5018
Add viewer for long strings in GridValue #5018
Conversation
This is nice. This might be relevant for DevTunnels support where we want to be able to render a QR code associated with a particular endpoint so people can point their mobile device at it. |
Just curious: Do we have any indication how common it is that people just want to copy? Are we trading quick one-click access to that most-common task for two-clicks for all tasks? I'm fine accepting either "the two clicks aren't that bad" or "copy isn't that much more common than what we expect visualize will be" or even "we don't know and we'll see if users complain after we do this", I just want to make sure that's an intentional usability decision. |
This looks good. I haven't tested it yet, but from my first impression of the screenshots, here are some ideas to make it better:
|
This is already done by default when you open the dialog, do you feel that a separate option is important to have rather than preselecting?
I would assume the formatted value so as not to confuse the user, or both options? |
I don’t think we have any information on that. @kvenkatrajan |
I think we can mitigate this issue by only displaying the |
Nice, I didn't know that. I don't know which is best, I'll try it out and see what it's like. Preselecting like is already happening is probably fine. That's the important part. |
Let's go with copying the formatted value. If someone wants to copy without formatting, then they can select plaintext and then copy. We can change if there is feedback. |
Here is an idea: color formatting of JSON and XML keywords. We could do it server side, but that would be a fair amount of work. There are JS libraries that do this that we could use: https://github.com/highlightjs/highlight.js We know the content type so we can tell the JS library for highlight as JSON for JSON, etc. |
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.
LGTM though would be good to get a UI expert's input. I share Tim's view about the extra click for copy, so would be interested to know if we have additional options here.
src/Aspire.Dashboard/Components/Dialogs/TextVisualizerDialog.razor.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Dashboard/Components/Dialogs/TextVisualizerDialog.razor
Outdated
Show resolved
Hide resolved
src/Aspire.Dashboard/Components/Dialogs/TextVisualizerDialog.razor.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Dashboard/Components/Dialogs/TextVisualizerDialog.razor.cs
Outdated
Show resolved
Hide resolved
doc.WriteTo(utf8JsonWriter); | ||
utf8JsonWriter.Flush(); | ||
|
||
_formattedText = Encoding.Default.GetString(memoryStream.ToArray()); |
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.
I don't think it's correct to use the default encoding here. The Utf8JsonWriter
will write UTF8 bytes, which can only be decoded as UTF8.
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.
+1. Add some unit tests with various width unicode characters.
src/Aspire.Dashboard/Components/Dialogs/TextVisualizerDialog.razor.cs
Outdated
Show resolved
Hide resolved
TryFormatXml(); | ||
} | ||
else if (_selectedOption == JsonFormat) | ||
{ | ||
TryFormatJson(); |
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.
If these "try" operations fail, should we set _selectedOption
back to the item representing no formatting?
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.
I don't think so. The 'JSON' view for a non-JSON string is just the same as the unformatted view.
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.
What happens if you have invalid JSON or xml? Is it only going to format if its valid? I almost want the errors if the user explicitly selects json, but it's not valid json.
Large content doesn't overflow with a scrollbar: And long content doesn't wrap: I think the content here should act like the console logs text display:
Console logs does all of this already. CSS can either be copied, or ideally, reused. |
Add an example of formatted data to stress app: #5021 |
|
…-view # Conflicts: # src/Aspire.Dashboard/Components/Controls/GridValue.razor
Max width is now set to 600px @JamesNK. |
I think 1000px is the right spot. Enough room for most values, without growing too large on wide screens. |
src/Aspire.Dashboard/Components/Dialogs/TextVisualizerDialog.razor
Outdated
Show resolved
Hide resolved
I made style fixes. It's quicker for me to do it rather than communicate here. Also, there was a regression in the old console viewer that I fixed. |
var effectiveTheme = await _jsModule.InvokeAsync<string>("getCurrentTheme"); | ||
ThemeManager.EffectiveTheme = effectiveTheme; | ||
|
||
await InvokeAsync(StateHasChanged); |
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.
Be careful with calling StateHasChanged and minimize how often it is used. I think in this case, it could be limited to just the new text dialog. Listening to theme change and calling state change in the dialog would be better than doing it globally.
src/Aspire.Dashboard/Components/Dialogs/TextVisualizerDialog.razor.cs
Outdated
Show resolved
Hide resolved
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.
The only major remaining issue is the interaction with splitters. It would be good to know a fix is coming in fluentui.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Fixes #4412, and converts the copy button to a menu where the user can select whether to open a popup viewer or copy the cell text.
Menu appearance:
Dialog appearance:
Per spec, adds a plaintext, xml, and json formatting option. The initial formatting option is selected by trying to parse the string using an xml/json parser.
demo:
https://github.com/user-attachments/assets/5d0ef395-13f3-4e59-9a3f-9b6842469ca2
Normally, we would trigger popup opening just by adding an
OnClick
listener to the FluentMenuItems, but we are encountering a bug (probably in fluentui-blazor or fluent webcomponents) causing this to be swallowed sometimes when enclosed inPropertyGrid
. @vnbaaij is aware, I am looking into this. A workaround is invoking a function from JS similar to how the copy button currently works.Microsoft Reviewers: Open in CodeFlow