Skip to content

Commit d19d94e

Browse files
Add gallery menu item to top-level taskbar (#165)
Added a "gallery" item to the top-level main toolbar that navigates directly to the gallery page (`/gallery`). Modified `MainToolbar` to support rendering top-level items as buttons for direct navigation when a `Page` is specified. Renamed the existing `Page.Gallery` to `Page.ImportGallery` to distinguish the import tab from the main gallery page. Updated unit tests to verify the new navigation routing. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent 9dc13ac commit d19d94e

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

Octans.Client/Components/MainToolbar/MainToolbar.razor

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@
44
<MudToolBar Class="mud-bar">
55
@foreach (var menu in Viewmodel.Menu)
66
{
7-
<MudMenu Size="Size.Small" ActivationEvent="MouseEvent.MouseOver" Label="@menu.Name">
8-
@foreach (var item in menu.Items)
9-
{
10-
<MudMenuItem Label="@item.Name" OnClick="@(() => Viewmodel.Navigate(item.Page))"/>
11-
}
12-
</MudMenu>
7+
@if (menu.Page is not null)
8+
{
9+
<MudButton OnClick="@(() => Viewmodel.Navigate(menu.Page.Value))" Variant="Variant.Text" Size="Size.Small">@menu.Name</MudButton>
10+
}
11+
else
12+
{
13+
<MudMenu Size="Size.Small" ActivationEvent="MouseEvent.MouseOver" Label="@menu.Name">
14+
@foreach (var item in menu.Items)
15+
{
16+
<MudMenuItem Label="@item.Name" OnClick="@(() => Viewmodel.Navigate(item.Page))"/>
17+
}
18+
</MudMenu>
19+
}
1320
}
1421
</MudToolBar>
1522
</div>

Octans.Client/Components/MainToolbar/MainToolbarViewmodel.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ public void OnInitialized()
1010
{
1111
Menu =
1212
[
13+
new()
14+
{
15+
Name = "gallery",
16+
Page = Page.Gallery
17+
},
1318
new()
1419
{
1520
Name = "import",
@@ -28,7 +33,7 @@ public void OnInitialized()
2833
new()
2934
{
3035
Name = "gallery",
31-
Page = Page.Gallery
36+
Page = Page.ImportGallery
3237
},
3338
new()
3439
{
@@ -97,7 +102,8 @@ public Task Navigate(Page page)
97102
{
98103
Page.LocalFiles => "/imports?tab=files",
99104
Page.WebUrls => "/imports?tab=url",
100-
Page.Gallery => "/imports?tab=gallery",
105+
Page.ImportGallery => "/imports?tab=gallery",
106+
Page.Gallery => "/gallery",
101107
Page.Watchable => "/imports?tab=watchable",
102108
Page.Downloaders => "/downloaders",
103109
Page.Settings => "/settings",
@@ -116,6 +122,7 @@ public enum Page
116122
{
117123
LocalFiles,
118124
WebUrls,
125+
ImportGallery,
119126
Gallery,
120127
Watchable,
121128
Settings,
@@ -127,6 +134,7 @@ public enum Page
127134
public class MenuItem
128135
{
129136
public required string Name { get; init; }
137+
public Page? Page { get; init; }
130138
public List<ToolbarItem> Items { get; init; } = [];
131139
}
132140

Octans.Tests/Viewmodels/MainToolbarViewmodelTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public MainToolbarViewmodelTests()
2020
[Theory]
2121
[InlineData(Page.LocalFiles, "/imports?tab=files")]
2222
[InlineData(Page.WebUrls, "/imports?tab=url")]
23-
[InlineData(Page.Gallery, "/imports?tab=gallery")]
23+
[InlineData(Page.Gallery, "/gallery")]
24+
[InlineData(Page.ImportGallery, "/imports?tab=gallery")]
2425
[InlineData(Page.Watchable, "/imports?tab=watchable")]
2526
[InlineData(Page.Downloaders, "/downloaders")]
2627
[InlineData(Page.Settings, "/settings")]

0 commit comments

Comments
 (0)