From c4bae6c9ddda8c1c6306ce2447a72faa29fac12f Mon Sep 17 00:00:00 2001 From: Damian Edwards Date: Sat, 12 Apr 2025 13:19:11 -0700 Subject: [PATCH 1/3] 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) --- .../Components/Controls/ResourceDetails.razor | 28 +++++++++---------- .../ResourceGraph/ResourceGraphMapper.cs | 2 +- .../Model/ResourceUrlHelpers.cs | 6 ++-- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Aspire.Dashboard/Components/Controls/ResourceDetails.razor b/src/Aspire.Dashboard/Components/Controls/ResourceDetails.razor index 8fce4c7bfbb..61925cdf8ea 100644 --- a/src/Aspire.Dashboard/Components/Controls/ResourceDetails.razor +++ b/src/Aspire.Dashboard/Components/Controls/ResourceDetails.razor @@ -79,20 +79,20 @@ - + @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 @; } @@ -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 @; + return @-; } // Otherwise, render a link with the text as the anchor text & title as the URL else { if (highlighting) { - return @; + return @; } - return @@vm.Text; + return @@vm.DisplayName; } } } diff --git a/src/Aspire.Dashboard/Model/ResourceGraph/ResourceGraphMapper.cs b/src/Aspire.Dashboard/Model/ResourceGraph/ResourceGraphMapper.cs index 3f9ea6f3bde..e6c33f549dd 100644 --- a/src/Aspire.Dashboard/Model/ResourceGraph/ResourceGraphMapper.cs +++ b/src/Aspire.Dashboard/Model/ResourceGraph/ResourceGraphMapper.cs @@ -68,7 +68,7 @@ public static ResourceDto MapResource(ResourceViewModel r, IDictionary 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 }); @@ -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; } /// /// Don't display a plain string value here. The URL will be displayed as a hyperlink - /// in instead. + /// in instead. /// string? IPropertyGridItem.Value => null; From 312bc132290437db02cf48a3a8ba812c23c37d39 Mon Sep 17 00:00:00 2001 From: Damian Edwards Date: Sun, 13 Apr 2025 14:12:46 -0700 Subject: [PATCH 2/3] PR feedback --- .../Components/Controls/ResourceDetails.razor | 2 +- src/Aspire.Dashboard/Model/ResourceUrlHelpers.cs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Aspire.Dashboard/Components/Controls/ResourceDetails.razor b/src/Aspire.Dashboard/Components/Controls/ResourceDetails.razor index 61925cdf8ea..70c8ca72e59 100644 --- a/src/Aspire.Dashboard/Components/Controls/ResourceDetails.razor +++ b/src/Aspire.Dashboard/Components/Controls/ResourceDetails.razor @@ -318,7 +318,7 @@ // If there's no DisplayName then show nothing if (string.IsNullOrEmpty(vm.DisplayName)) { - return @-; + return @-; } // Otherwise, render a link with the text as the anchor text & title as the URL else diff --git a/src/Aspire.Dashboard/Model/ResourceUrlHelpers.cs b/src/Aspire.Dashboard/Model/ResourceUrlHelpers.cs index e536a5ab17a..bdeb87b0a9f 100644 --- a/src/Aspire.Dashboard/Model/ResourceUrlHelpers.cs +++ b/src/Aspire.Dashboard/Model/ResourceUrlHelpers.cs @@ -83,6 +83,8 @@ public sealed class DisplayedUrl : IPropertyGridItem public string? ValueToVisualize => Url ?? Text; public bool MatchesFilter(string filter) - => Name.Contains(filter, StringComparison.CurrentCultureIgnoreCase) || - Text.Contains(filter, StringComparison.CurrentCultureIgnoreCase); + => Url?.Contains(filter, StringComparison.CurrentCultureIgnoreCase) == true || + Text.Contains(filter, StringComparison.CurrentCultureIgnoreCase) || + Name.Contains(filter, StringComparison.CurrentCultureIgnoreCase) || + DisplayName?.Contains(filter, StringComparison.CurrentCultureIgnoreCase) == true; } From e8f05bdb9e6af2e33d4c9d50a59ca7551cc24bf3 Mon Sep 17 00:00:00 2001 From: Damian Edwards Date: Sun, 13 Apr 2025 14:22:28 -0700 Subject: [PATCH 3/3] Update ResourceDetails.razor --- .../Components/Controls/ResourceDetails.razor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Aspire.Dashboard/Components/Controls/ResourceDetails.razor b/src/Aspire.Dashboard/Components/Controls/ResourceDetails.razor index 70c8ca72e59..de0601f2441 100644 --- a/src/Aspire.Dashboard/Components/Controls/ResourceDetails.razor +++ b/src/Aspire.Dashboard/Components/Controls/ResourceDetails.razor @@ -95,7 +95,7 @@ @@ -294,7 +294,7 @@ // If there's no URL, e.g. this is a tcp:// URI, just show the text if (vm.Url is null) { - if (highlighting && vm.Text != "-") + if (highlighting) { return @; } @@ -318,7 +318,7 @@ // If there's no DisplayName then show nothing if (string.IsNullOrEmpty(vm.DisplayName)) { - return @-; + return @; } // Otherwise, render a link with the text as the anchor text & title as the URL else