Fix Resource Preview Functionality #16777
Open
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.
What does it do?
Why is it needed?
Primarily, as noted in the issue solved, weblink URLs were not being built because the target Resource's URL was not being parsed/built. Also, discovered along the way of fixing this, the view button/tree item was not always showing/hiding/being disabled as expected. Lastly, one could pass obviously malformed content for weblinks resulting in bad links and previews.
How to test
Note
I made the choice to disable instead of hide the View button for invalid web/symlinks, in contrast to how it's hidden for deleted Resources. I'm of the mind that action buttons/links shouldn't be hidden at all, just disabled. (It seems somewhat jarring for items to appear and disappear from the main UI.) This would be similar to the common pattern of showing, say, a Submit or Save button in a disabled state until the form it relates to is completely filled out. Let me know your thoughts on this, as I'd move to make a few more changes to make this behavior consistent.
Related issue(s)/PR(s)
Resolves #16195