Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/Aspire.Dashboard/Components/Controls/ResourceDetails.razor
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,20 @@
<AspireTemplateColumn Sortable="true" SortBy="@_urlValueSort" Title="@ControlStringsLoc[nameof(ControlsStrings.LinkAddressColumnHeader)]">
<GridValue ValueDescription="@ControlStringsLoc[nameof(ControlsStrings.LinkAddressColumnHeader)]"
Value="@context.OriginalUrlString"
ValueTemplate="@(_ => RenderUrlValue(context, _filter))"
ValueTemplate="@(_ => RenderAddressValue(context, _filter))"
EnableHighlighting="@(!string.IsNullOrEmpty(_filter))"
IsMaskedChanged="@(_ => OnValueMaskedChanged(context))"
HighlightText="@_filter" />
</AspireTemplateColumn>
<AspireTemplateColumn Sortable="true" SortBy="@_urlValueSort" Title="@ControlStringsLoc[nameof(ControlsStrings.LinkTextColumnHeader)]">
<GridValue ValueDescription="@ControlStringsLoc[nameof(ControlsStrings.LinkTextColumnHeader)]"
Value="@context.Text"
Value="@context.DisplayName"
ValueTemplate="@(_ => RenderTextValue(context, _filter))"
EnableHighlighting="@(!string.IsNullOrEmpty(_filter))"
EnableHighlighting="@(!string.IsNullOrEmpty(_filter) && !string.IsNullOrEmpty(context.DisplayName))"
IsMaskedChanged="@(_ => OnValueMaskedChanged(context))"
HighlightText="@_filter" />
</AspireTemplateColumn>
<AspireTemplateColumn Sortable="true" SortBy="@(GridSort<DisplayedUrl>.ByAscending(i => i.DisplayName))" Title="@ControlStringsLoc[nameof(ControlsStrings.EndpointNameColumnHeader)]">
<AspireTemplateColumn Sortable="true" SortBy="@(GridSort<DisplayedUrl>.ByAscending(i => i.Name))" Title="@ControlStringsLoc[nameof(ControlsStrings.EndpointNameColumnHeader)]">
<GridValue ValueDescription="@ControlStringsLoc[nameof(ControlsStrings.EndpointNameColumnHeader)]"
Value="@context.Name"
EnableHighlighting="@(!string.IsNullOrEmpty(_filter) && context.Name != "-")"
Expand Down Expand Up @@ -287,14 +287,14 @@
</div>

@code {
private static RenderFragment RenderUrlValue(DisplayedUrl vm, string filter)
private static RenderFragment RenderAddressValue(DisplayedUrl vm, string filter)
{
var highlighting = !string.IsNullOrEmpty(filter) && vm.Text != "-";
var highlighting = !string.IsNullOrEmpty(filter);

// If there's no URL, e.g. this is a tcp:// URI, just show the text
if (vm.Url is null)
{
if (highlighting)
if (highlighting && vm.Text != "-")
{
return @<FluentHighlighter HighlightedText="@filter" Text="@vm.Text" />;
}
Expand All @@ -313,21 +313,21 @@

private static RenderFragment RenderTextValue(DisplayedUrl vm, string filter)
{
var highlighting = !string.IsNullOrEmpty(filter) && vm.Text != "-";
var highlighting = !string.IsNullOrEmpty(filter) && !string.IsNullOrEmpty(vm.DisplayName);

// If there's no URL, e.g. this is a tcp:// URI, show nothing, or URL is same as Text, then show nothing
if (vm.Url is null || string.Equals(vm.Url, vm.Text, StringComparison.Ordinal))
// If there's no DisplayName then show nothing
if (string.IsNullOrEmpty(vm.DisplayName))
{
return @<span></span>;
return @<span>-</span>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other places we have <span class="empty-data"></span> and the dash is added by CSS. Change this to be consistent.

<span class="empty-data"></span>

}
// Otherwise, render a link with the text as the anchor text & title as the URL
else
{
if (highlighting)
{
return @<a href="@vm.Url" title="@vm.Url" target="_blank"><FluentHighlighter HighlightedText="@filter" Text="@vm.Text" /></a>;
return @<a href="@vm.Url" title="@vm.Url" target="_blank"><FluentHighlighter HighlightedText="@filter" Text="@vm.DisplayName" /></a>;
}
return @<a href="@vm.Url" title="@vm.Url" target="_blank">@vm.Text</a>;
return @<a href="@vm.Url" title="@vm.Url" target="_blank">@vm.DisplayName</a>;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static ResourceDto MapResource(ResourceViewModel r, IDictionary<string, R

private static string ResolvedEndpointText(DisplayedUrl? endpoint)
{
var text = endpoint?.Url;
var text = endpoint?.OriginalUrlString;
if (string.IsNullOrEmpty(text))
{
return ControlsStrings.ResourceGraphNoEndpoints;
Expand Down
6 changes: 3 additions & 3 deletions src/Aspire.Dashboard/Model/ResourceUrlHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static List<DisplayedUrl> GetUrls(ResourceViewModel resource, bool includ
Port = url.Url.Port,
Url = url.Url.Scheme is "http" or "https" ? url.Url.OriginalString : null,
SortOrder = url.DisplayProperties.SortOrder,
DisplayName = url.DisplayProperties.DisplayName,
DisplayName = string.IsNullOrEmpty(url.DisplayProperties.DisplayName) ? null : url.DisplayProperties.DisplayName,
OriginalUrlString = url.Url.OriginalString,
Text = string.IsNullOrEmpty(url.DisplayProperties.DisplayName) ? url.Url.OriginalString : url.DisplayProperties.DisplayName
});
Expand Down Expand Up @@ -69,12 +69,12 @@ public sealed class DisplayedUrl : IPropertyGridItem
public int? Port { get; set; }
public string? Url { get; set; }
public int SortOrder { get; set; }
public required string DisplayName { get; set; }
public string? DisplayName { get; set; }
public required string OriginalUrlString { get; set; }

/// <summary>
/// Don't display a plain string value here. The URL will be displayed as a hyperlink
/// in <see cref="ResourceDetails.RenderUrlValue(DisplayedUrl, string)"/> instead.
/// in <see cref="ResourceDetails.RenderAddressValue(DisplayedUrl, string)"/> instead.
/// </summary>
string? IPropertyGridItem.Value => null;

Expand Down