File: Components\ResourcesGridColumns\UrlsColumnDisplay.razor.cs
Web Access
Project: src\src\Aspire.Dashboard\Aspire.Dashboard.csproj (Aspire.Dashboard)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using Aspire.Dashboard.Model;
using Aspire.Dashboard.Resources;
using Aspire.Dashboard.Utils;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
 
namespace Aspire.Dashboard.Components;
 
public partial class UrlsColumnDisplay
{
    // Credentials (redis://:password@host), fragments (#access_token=...) and query values (?token=...) can carry
    // secrets, so the address is shown without the first two and with the values masked, as the resource overview does
    // (see DashboardUIHelpers.MaskUrlForDisplay).
    internal static string GetTooltipText(DisplayedUrl displayedUrl)
    {
        return DashboardUIHelpers.MaskUrlForDisplay(displayedUrl.Url ?? displayedUrl.OriginalUrlString);
    }
 
    // A URL's display name is shown as is. Without one, the text is the address, masked like the tooltip.
    internal static string GetDisplayText(DisplayedUrl displayedUrl)
    {
        return string.IsNullOrEmpty(displayedUrl.DisplayName) ? DashboardUIHelpers.MaskUrlForDisplay(displayedUrl.Text) : displayedUrl.Text;
    }
 
    [Parameter, EditorRequired]
    public required ResourceViewModel Resource { get; set; }
 
    [Parameter, EditorRequired]
    public required bool HasMultipleReplicas { get; set; }
 
    [Parameter, EditorRequired]
    public required IList<DisplayedUrl> DisplayedUrls { get; set; }
 
    [Parameter]
    public bool UseNeutralOverflowButton { get; set; }
 
    [Parameter]
    public int MaxRenderedItems { get; set; } = 20;
 
    [Inject]
    public required IStringLocalizer<Columns> Loc { get; init; }
 
    private bool _popoverVisible;
}