-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
515 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/Aspire.Dashboard/Components/Controls/ResourceActions.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@namespace Aspire.Dashboard.Components | ||
@using Aspire.Dashboard.Model | ||
@using Microsoft.FluentUI.AspNetCore.Components | ||
|
||
@foreach (var highlightedCommand in Commands.Where(c => c.IsHighlighted)) | ||
{ | ||
<FluentButton Appearance="Appearance.Lightweight" Title="@(highlightedCommand.DisplayDescription ?? highlightedCommand.DisplayName)" OnClick="@(() => CommandSelected.InvokeAsync(highlightedCommand))"> | ||
@if (!string.IsNullOrEmpty(highlightedCommand.IconName) && CommandViewModel.ResolveIconName(highlightedCommand.IconName) is { } icon) | ||
{ | ||
<FluentIcon Value="icon" /> | ||
} | ||
else | ||
{ | ||
@highlightedCommand.DisplayName | ||
} | ||
</FluentButton> | ||
} | ||
|
||
<AspireMenuButton | ||
ButtonAppearance="Appearance.Lightweight" | ||
Icon="@(new Icons.Regular.Size24.MoreHorizontal())" | ||
Items="@_menuItems" | ||
@ref="_menuButton" /> |
71 changes: 71 additions & 0 deletions
71
src/Aspire.Dashboard/Components/Controls/ResourceActions.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// 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 Microsoft.AspNetCore.Components; | ||
using Microsoft.Extensions.Localization; | ||
using Microsoft.FluentUI.AspNetCore.Components; | ||
|
||
namespace Aspire.Dashboard.Components; | ||
|
||
public partial class ResourceActions : ComponentBase | ||
{ | ||
private static readonly Icon s_viewDetailsIcon = new Icons.Regular.Size20.Info(); | ||
private static readonly Icon s_consoleLogsIcon = new Icons.Regular.Size20.SlideText(); | ||
|
||
private AspireMenuButton? _menuButton; | ||
|
||
[Inject] | ||
public required IStringLocalizer<Resources.Resources> Loc { get; set; } | ||
|
||
[Parameter] | ||
public required IList<CommandViewModel> Commands { get; set; } | ||
|
||
[Parameter] | ||
public required EventCallback<CommandViewModel> CommandSelected { get; set; } | ||
|
||
[Parameter] | ||
public required EventCallback<string> OnViewDetails { get; set; } | ||
|
||
[Parameter] | ||
public required EventCallback OnConsoleLogs { get; set; } | ||
|
||
private readonly List<MenuButtonItem> _menuItems = new(); | ||
|
||
protected override void OnParametersSet() | ||
{ | ||
_menuItems.Clear(); | ||
|
||
_menuItems.Add(new MenuButtonItem | ||
{ | ||
Text = Loc[nameof(Resources.Resources.ResourceActionViewDetailsText)], | ||
Icon = s_viewDetailsIcon, | ||
OnClick = () => OnViewDetails.InvokeAsync(_menuButton?.MenuButtonId) | ||
}); | ||
_menuItems.Add(new MenuButtonItem | ||
{ | ||
Text = Loc[nameof(Resources.Resources.ResourceActionConsoleLogsText)], | ||
Icon = s_consoleLogsIcon, | ||
OnClick = OnConsoleLogs.InvokeAsync | ||
}); | ||
|
||
var menuCommands = Commands.Where(c => !c.IsHighlighted).ToList(); | ||
if (menuCommands.Count > 0) | ||
{ | ||
_menuItems.Add(new MenuButtonItem { IsDivider = true }); | ||
|
||
foreach (var command in menuCommands) | ||
{ | ||
var icon = (!string.IsNullOrEmpty(command.IconName) && CommandViewModel.ResolveIconName(command.IconName) is { } i) ? i : null; | ||
|
||
_menuItems.Add(new MenuButtonItem | ||
{ | ||
Text = command.DisplayName, | ||
Tooltip = command.DisplayDescription, | ||
Icon = icon, | ||
OnClick = () => CommandSelected.InvokeAsync(command) | ||
}); | ||
} | ||
} | ||
} | ||
} |
10 changes: 0 additions & 10 deletions
10
src/Aspire.Dashboard/Components/Controls/ResourceCommands.razor
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
src/Aspire.Dashboard/Components/Controls/ResourceCommands.razor.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.FluentUI.AspNetCore.Components; | ||
|
||
namespace Aspire.Dashboard.Model; | ||
|
||
public class MenuButtonItem | ||
{ | ||
public bool IsDivider { get; set; } | ||
public string? Text { get; set; } | ||
public string? Tooltip { get; set; } | ||
public Icon? Icon { get; set; } | ||
public Func<Task>? OnClick { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.