Skip to content

Commit 9cbf38d

Browse files
More URL fixes (#8749)
* URL fixes - Show "-" for URLs with no display text & disable visualizer & disable visualizer when URL has no display text (Fixes #8745) - Show non-HTTP endpoints on Resources Graph (Fixes #8682) * PR feedback * Update ResourceDetails.razor
1 parent 9918f8b commit 9cbf38d

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

src/Aspire.Dashboard/Components/Controls/ResourceDetails.razor

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,23 @@
7979
<AspireTemplateColumn Sortable="true" SortBy="@_urlValueSort" Title="@ControlStringsLoc[nameof(ControlsStrings.LinkAddressColumnHeader)]">
8080
<GridValue ValueDescription="@ControlStringsLoc[nameof(ControlsStrings.LinkAddressColumnHeader)]"
8181
Value="@context.OriginalUrlString"
82-
ValueTemplate="@(_ => RenderUrlValue(context, _filter))"
82+
ValueTemplate="@(_ => RenderAddressValue(context, _filter))"
8383
EnableHighlighting="@(!string.IsNullOrEmpty(_filter))"
8484
IsMaskedChanged="@(_ => OnValueMaskedChanged(context))"
8585
HighlightText="@_filter" />
8686
</AspireTemplateColumn>
8787
<AspireTemplateColumn Sortable="true" SortBy="@_urlValueSort" Title="@ControlStringsLoc[nameof(ControlsStrings.LinkTextColumnHeader)]">
8888
<GridValue ValueDescription="@ControlStringsLoc[nameof(ControlsStrings.LinkTextColumnHeader)]"
89-
Value="@context.Text"
89+
Value="@context.DisplayName"
9090
ValueTemplate="@(_ => RenderTextValue(context, _filter))"
91-
EnableHighlighting="@(!string.IsNullOrEmpty(_filter))"
91+
EnableHighlighting="@(!string.IsNullOrEmpty(_filter) && !string.IsNullOrEmpty(context.DisplayName))"
9292
IsMaskedChanged="@(_ => OnValueMaskedChanged(context))"
9393
HighlightText="@_filter" />
9494
</AspireTemplateColumn>
95-
<AspireTemplateColumn Sortable="true" SortBy="@(GridSort<DisplayedUrl>.ByAscending(i => i.DisplayName))" Title="@ControlStringsLoc[nameof(ControlsStrings.EndpointNameColumnHeader)]">
95+
<AspireTemplateColumn Sortable="true" SortBy="@(GridSort<DisplayedUrl>.ByAscending(i => i.Name))" Title="@ControlStringsLoc[nameof(ControlsStrings.EndpointNameColumnHeader)]">
9696
<GridValue ValueDescription="@ControlStringsLoc[nameof(ControlsStrings.EndpointNameColumnHeader)]"
9797
Value="@context.Name"
98-
EnableHighlighting="@(!string.IsNullOrEmpty(_filter) && context.Name != "-")"
98+
EnableHighlighting="@(!string.IsNullOrEmpty(_filter))"
9999
HighlightText="@_filter" />
100100
</AspireTemplateColumn>
101101
</FluentDataGrid>
@@ -287,10 +287,10 @@
287287
</div>
288288

289289
@code {
290-
private static RenderFragment RenderUrlValue(DisplayedUrl vm, string filter)
290+
private static RenderFragment RenderAddressValue(DisplayedUrl vm, string filter)
291291
{
292-
var highlighting = !string.IsNullOrEmpty(filter) && vm.Text != "-";
293-
292+
var highlighting = !string.IsNullOrEmpty(filter);
293+
294294
// If there's no URL, e.g. this is a tcp:// URI, just show the text
295295
if (vm.Url is null)
296296
{
@@ -313,21 +313,21 @@
313313

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

318-
// If there's no URL, e.g. this is a tcp:// URI, show nothing, or URL is same as Text, then show nothing
319-
if (vm.Url is null || string.Equals(vm.Url, vm.Text, StringComparison.Ordinal))
318+
// If there's no DisplayName then show nothing
319+
if (string.IsNullOrEmpty(vm.DisplayName))
320320
{
321-
return @<span></span>;
321+
return @<span class="empty-data"></span>;
322322
}
323323
// Otherwise, render a link with the text as the anchor text & title as the URL
324324
else
325325
{
326326
if (highlighting)
327327
{
328-
return @<a href="@vm.Url" title="@vm.Url" target="_blank"><FluentHighlighter HighlightedText="@filter" Text="@vm.Text" /></a>;
328+
return @<a href="@vm.Url" title="@vm.Url" target="_blank"><FluentHighlighter HighlightedText="@filter" Text="@vm.DisplayName" /></a>;
329329
}
330-
return @<a href="@vm.Url" title="@vm.Url" target="_blank">@vm.Text</a>;
330+
return @<a href="@vm.Url" title="@vm.Url" target="_blank">@vm.DisplayName</a>;
331331
}
332332
}
333333
}

src/Aspire.Dashboard/Model/ResourceGraph/ResourceGraphMapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static ResourceDto MapResource(ResourceViewModel r, IDictionary<string, R
6868

6969
private static string ResolvedEndpointText(DisplayedUrl? endpoint)
7070
{
71-
var text = endpoint?.Url;
71+
var text = endpoint?.OriginalUrlString;
7272
if (string.IsNullOrEmpty(text))
7373
{
7474
return ControlsStrings.ResourceGraphNoEndpoints;

src/Aspire.Dashboard/Model/ResourceUrlHelpers.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static List<DisplayedUrl> GetUrls(ResourceViewModel resource, bool includ
3535
Port = url.Url.Port,
3636
Url = url.Url.Scheme is "http" or "https" ? url.Url.OriginalString : null,
3737
SortOrder = url.DisplayProperties.SortOrder,
38-
DisplayName = url.DisplayProperties.DisplayName,
38+
DisplayName = string.IsNullOrEmpty(url.DisplayProperties.DisplayName) ? null : url.DisplayProperties.DisplayName,
3939
OriginalUrlString = url.Url.OriginalString,
4040
Text = string.IsNullOrEmpty(url.DisplayProperties.DisplayName) ? url.Url.OriginalString : url.DisplayProperties.DisplayName
4141
});
@@ -69,12 +69,12 @@ public sealed class DisplayedUrl : IPropertyGridItem
6969
public int? Port { get; set; }
7070
public string? Url { get; set; }
7171
public int SortOrder { get; set; }
72-
public required string DisplayName { get; set; }
72+
public string? DisplayName { get; set; }
7373
public required string OriginalUrlString { get; set; }
7474

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

@@ -83,6 +83,8 @@ public sealed class DisplayedUrl : IPropertyGridItem
8383
public string? ValueToVisualize => Url ?? Text;
8484

8585
public bool MatchesFilter(string filter)
86-
=> Name.Contains(filter, StringComparison.CurrentCultureIgnoreCase) ||
87-
Text.Contains(filter, StringComparison.CurrentCultureIgnoreCase);
86+
=> Url?.Contains(filter, StringComparison.CurrentCultureIgnoreCase) == true ||
87+
Text.Contains(filter, StringComparison.CurrentCultureIgnoreCase) ||
88+
Name.Contains(filter, StringComparison.CurrentCultureIgnoreCase) ||
89+
DisplayName?.Contains(filter, StringComparison.CurrentCultureIgnoreCase) == true;
8890
}

0 commit comments

Comments
 (0)