From 34d6aabf330dd4ea0bf69fca138c8c1ba1250fce Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Thu, 31 Oct 2024 14:35:34 +0800 Subject: [PATCH] Don't display telemetry actions when no telemetry (#6568) --- .../Controls/ResourceActions.razor.cs | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/Aspire.Dashboard/Components/Controls/ResourceActions.razor.cs b/src/Aspire.Dashboard/Components/Controls/ResourceActions.razor.cs index a245d8826c..fd1af1c7ac 100644 --- a/src/Aspire.Dashboard/Components/Controls/ResourceActions.razor.cs +++ b/src/Aspire.Dashboard/Components/Controls/ResourceActions.razor.cs @@ -81,44 +81,44 @@ protected override void OnParametersSet() // Show telemetry menu items if there is telemetry for the resource. var hasTelemetryApplication = TelemetryRepository.GetApplicationByCompositeName(Resource.Name) != null; - var telemetryTooltip = !hasTelemetryApplication ? Loc[nameof(Resources.Resources.ResourceActionTelemetryTooltip)] : string.Empty; - _menuItems.Add(new MenuButtonItem { IsDivider = true }); - _menuItems.Add(new MenuButtonItem + if (hasTelemetryApplication) { - Text = Loc[nameof(Resources.Resources.ResourceActionStructuredLogsText)], - Icon = s_structuredLogsIcon, - OnClick = () => + var telemetryTooltip = !hasTelemetryApplication ? Loc[nameof(Resources.Resources.ResourceActionTelemetryTooltip)] : string.Empty; + _menuItems.Add(new MenuButtonItem { IsDivider = true }); + _menuItems.Add(new MenuButtonItem { - NavigationManager.NavigateTo(DashboardUrls.StructuredLogsUrl(resource: GetResourceName(Resource))); - return Task.CompletedTask; - }, - Tooltip = telemetryTooltip, - IsDisabled = !hasTelemetryApplication - }); - _menuItems.Add(new MenuButtonItem - { - Text = Loc[nameof(Resources.Resources.ResourceActionTracesText)], - Icon = s_tracesIcon, - OnClick = () => + Text = Loc[nameof(Resources.Resources.ResourceActionStructuredLogsText)], + Icon = s_structuredLogsIcon, + OnClick = () => + { + NavigationManager.NavigateTo(DashboardUrls.StructuredLogsUrl(resource: GetResourceName(Resource))); + return Task.CompletedTask; + }, + Tooltip = telemetryTooltip + }); + _menuItems.Add(new MenuButtonItem { - NavigationManager.NavigateTo(DashboardUrls.TracesUrl(resource: GetResourceName(Resource))); - return Task.CompletedTask; - }, - Tooltip = telemetryTooltip, - IsDisabled = !hasTelemetryApplication - }); - _menuItems.Add(new MenuButtonItem - { - Text = Loc[nameof(Resources.Resources.ResourceActionMetricsText)], - Icon = s_metricsIcon, - OnClick = () => + Text = Loc[nameof(Resources.Resources.ResourceActionTracesText)], + Icon = s_tracesIcon, + OnClick = () => + { + NavigationManager.NavigateTo(DashboardUrls.TracesUrl(resource: GetResourceName(Resource))); + return Task.CompletedTask; + }, + Tooltip = telemetryTooltip + }); + _menuItems.Add(new MenuButtonItem { - NavigationManager.NavigateTo(DashboardUrls.MetricsUrl(resource: GetResourceName(Resource))); - return Task.CompletedTask; - }, - Tooltip = telemetryTooltip, - IsDisabled = !hasTelemetryApplication - }); + Text = Loc[nameof(Resources.Resources.ResourceActionMetricsText)], + Icon = s_metricsIcon, + OnClick = () => + { + NavigationManager.NavigateTo(DashboardUrls.MetricsUrl(resource: GetResourceName(Resource))); + return Task.CompletedTask; + }, + Tooltip = telemetryTooltip + }); + } // If display is desktop then we display highlighted commands next to the ... button. if (ViewportInformation.IsDesktop)