Skip to content

Commit 5d939d8

Browse files
authored
feat(templates): add manage Roles page to Boilerplate #10671 (#10686)
1 parent 116b8b3 commit 5d939d8

File tree

57 files changed

+1333
-226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1333
-226
lines changed

src/Templates/Boilerplate/Bit.Boilerplate/.template.config/template.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,12 @@
517517
"src/Server/Boilerplate.Server.Api/Data/Configurations/PushNotification/**"
518518
]
519519
},
520+
{
521+
"condition": "(signalR != true && notification != PostgreSQL)",
522+
"exclude": [
523+
"src/Shared/Boilerplate.Shared/Dtos/Identity/SendNotificationToRoleDto.cs"
524+
]
525+
},
520526
{
521527
"condition": "(captcha != reCaptcha)",
522528
"exclude": [

src/Templates/Boilerplate/Bit.Boilerplate/Boilerplate.slnx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
<Configurations>
33
<BuildType Name="Debug" />
44
<BuildType Name="DebugBlazorServer" />
5-
<BuildType Name="DebugBlazorWasm" />
6-
<BuildType Name="DebugBlazorHybridMaui" />
7-
<BuildType Name="DebugBlazorHybridWindows" />
85
<BuildType Name="Release" />
96
</Configurations>
107
<Folder Name="/.SolutionItems/">
@@ -40,32 +37,22 @@
4037
<Project Path="src/Client/Boilerplate.Client.Core/Boilerplate.Client.Core.csproj" />
4138
<Project Path="src/Client/Boilerplate.Client.Maui/Boilerplate.Client.Maui.csproj">
4239
<Build Solution="DebugBlazorServer|*" Project="false" />
43-
<Build Solution="DebugBlazorWasm|*" Project="false" />
44-
<Build Solution="DebugBlazorHybridWindows|*" Project="false" />
45-
<Deploy Solution="DebugBlazorHybridMaui|*" />
4640
<Deploy Solution="Debug|*" />
4741
<Deploy Solution="Release|*" />
4842
</Project>
4943
<Project Path="src/Client/Boilerplate.Client.Web/Boilerplate.Client.Web.csproj">
50-
<Build Solution="DebugBlazorHybridMaui|*" Project="false" />
5144
<Build Solution="DebugBlazorServer|*" Project="false" />
52-
<Build Solution="DebugBlazorHybridWindows|*" Project="false" />
5345
</Project>
5446
<Project Path="src/Client/Boilerplate.Client.Windows/Boilerplate.Client.Windows.csproj">
55-
<Build Solution="DebugBlazorHybridMaui|*" Project="false" />
5647
<Build Solution="DebugBlazorServer|*" Project="false" />
57-
<Build Solution="DebugBlazorWasm|*" Project="false" />
5848
</Project>
5949
</Folder>
6050
<Folder Name="/Shared/">
6151
<Project Path="src/Shared/Boilerplate.Shared.csproj" />
6252
</Folder>
6353
<Folder Name="/Tests/">
6454
<Project Path="src/Tests/Boilerplate.Tests.csproj">
65-
<Build Solution="DebugBlazorHybridMaui|*" Project="false" />
6655
<Build Solution="DebugBlazorServer|*" Project="false" />
67-
<Build Solution="DebugBlazorWasm|*" Project="false" />
68-
<Build Solution="DebugBlazorHybridWindows|*" Project="false" />
6956
</Project>
7057
</Folder>
7158
</Solution>

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/AppComponentBase.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,7 @@ protected async Task Abort()
260260
using var currentCts = cts;
261261
cts = new();
262262

263-
if (currentCts.IsCancellationRequested is false)
264-
{
265-
await currentCts.CancelAsync();
266-
}
263+
await currentCts.CancelAsync();
267264
}
268265

269266
public async ValueTask DisposeAsync()
@@ -272,10 +269,7 @@ public async ValueTask DisposeAsync()
272269
{
273270
using var currentCts = cts;
274271
cts = null;
275-
if (currentCts.IsCancellationRequested is false)
276-
{
277-
await currentCts.CancelAsync();
278-
}
272+
await currentCts.CancelAsync();
279273
}
280274

281275
await PrerenderStateService.DisposeAsync();

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Layout/AppDiagnosticModal.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
IconName="@BitIconName.DeveloperTools" />
108108

109109
@*#if (signalR == true)*@
110-
<AuthorizeView Policy="@AppPermissions.Management.ViewLogs">
110+
<AuthorizeView Policy="@AppPermissions.System.ManageLogs">
111111
<Authorized>
112112
<BitButton IconOnly AutoLoading
113113
OnClick="ReadAnotherUserLogs"

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Layout/Header.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@inherits AppComponentBase
22

33
<header>
4-
<BitStack Horizontal>
4+
<BitStack Horizontal VerticalAlign="BitAlignment.Center" Gap="0.25rem">
55
<BitButton IconOnly FixedColor
66
Class="menu-btn"
77
Size="BitSize.Large"
@@ -11,7 +11,7 @@
1111
IconName="@BitIconName.CollapseMenu" />
1212

1313
<BitStack VerticalAlign="BitAlignment.Center" Gap="0.5rem" AutoSize>
14-
<BitStack VerticalAlign="BitAlignment.Center" Gap="0.5rem" Horizontal>
14+
<BitStack VerticalAlign="BitAlignment.Center" Gap="0.25rem" Horizontal>
1515
@if (showGoBackButton)
1616
{
1717
<BitButton Variant="BitVariant.Text"

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Layout/MainLayout.razor.items.cs

Lines changed: 86 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,47 +22,54 @@ private async Task SetNavPanelItems()
2222
if (user?.IsAuthenticated() is true)
2323
{
2424
//#if (module == "Admin")
25-
BitNavItem adminPanelItem = new()
26-
{
27-
Text = localizer[nameof(AppStrings.AdminPanel)],
28-
IconName = BitIconName.Admin,
29-
ChildItems = []
30-
};
3125

32-
navPanelItems.Add(adminPanelItem);
26+
var (dashboard, manageProductCatalog) = await (authorizationService.IsAuthorizedAsync(user, AppPermissions.AdminPanel.Dashboard),
27+
authorizationService.IsAuthorizedAsync(user, AppPermissions.AdminPanel.ManageProductCatalog));
3328

34-
if ((await authorizationService.AuthorizeAsync(user, AppPermissions.AdminPanel.Dashboard)).Succeeded)
29+
if (dashboard || manageProductCatalog)
3530
{
36-
adminPanelItem.ChildItems.Add(new()
31+
BitNavItem adminPanelItem = new()
3732
{
38-
Text = localizer[nameof(AppStrings.Dashboard)],
39-
IconName = BitIconName.BarChartVerticalFill,
40-
Url = Urls.DashboardPage,
41-
});
42-
}
33+
Text = localizer[nameof(AppStrings.AdminPanel)],
34+
IconName = BitIconName.Admin,
35+
ChildItems = []
36+
};
4337

44-
if ((await authorizationService.AuthorizeAsync(user, AppPermissions.AdminPanel.ManageProductCatalog)).Succeeded)
45-
{
46-
adminPanelItem.ChildItems.AddRange(
47-
[
48-
new()
49-
{
50-
Text = localizer[nameof(AppStrings.Categories)],
51-
IconName = BitIconName.BuildQueue,
52-
Url = Urls.CategoriesPage,
53-
},
54-
new()
38+
navPanelItems.Add(adminPanelItem);
39+
40+
if (dashboard)
41+
{
42+
adminPanelItem.ChildItems.Add(new()
5543
{
56-
Text = localizer[nameof(AppStrings.Products)],
57-
IconName = BitIconName.Product,
58-
Url = Urls.ProductsPage,
59-
}
60-
]);
44+
Text = localizer[nameof(AppStrings.Dashboard)],
45+
IconName = BitIconName.BarChartVerticalFill,
46+
Url = Urls.DashboardPage,
47+
});
48+
}
49+
50+
if (manageProductCatalog)
51+
{
52+
adminPanelItem.ChildItems.AddRange(
53+
[
54+
new()
55+
{
56+
Text = localizer[nameof(AppStrings.Categories)],
57+
IconName = BitIconName.BuildQueue,
58+
Url = Urls.CategoriesPage,
59+
},
60+
new()
61+
{
62+
Text = localizer[nameof(AppStrings.Products)],
63+
IconName = BitIconName.Product,
64+
Url = Urls.ProductsPage,
65+
}
66+
]);
67+
}
6168
}
6269
//#endif
6370

6471
//#if (sample == true)
65-
if ((await authorizationService.AuthorizeAsync(user, AppPermissions.Todo.ManageTodo)).Succeeded)
72+
if (await authorizationService.IsAuthorizedAsync(user, AppPermissions.Todo.ManageTodo))
6673
{
6774
navPanelItems.Add(new()
6875
{
@@ -81,15 +88,6 @@ private async Task SetNavPanelItems()
8188
Url = Urls.OfflineEditProfilePage,
8289
});
8390
//#endif
84-
85-
//#if (signalR == true)
86-
navPanelItems.Add(new()
87-
{
88-
Text = localizer[nameof(AppStrings.SystemPromptsTitle)],
89-
IconName = BitIconName.TextDocumentSettings,
90-
Url = Urls.SystemPrompts,
91-
});
92-
//#endif
9391
}
9492

9593
navPanelItems.Add(new()
@@ -108,6 +106,54 @@ private async Task SetNavPanelItems()
108106

109107
if (user?.IsAuthenticated() is true)
110108
{
109+
var (manageRoles, manageUsers, manageAiPrompt) = await (authorizationService.IsAuthorizedAsync(user, AppPermissions.Management.ManageRoles),
110+
authorizationService.IsAuthorizedAsync(user, AppPermissions.Management.ManageUsers),
111+
authorizationService.IsAuthorizedAsync(user, AppPermissions.Management.ManageAiPrompt));
112+
113+
if (manageRoles || manageUsers || manageAiPrompt)
114+
{
115+
BitNavItem managementItem = new()
116+
{
117+
Text = localizer[nameof(AppStrings.Management)],
118+
IconName = BitIconName.SettingsSecure,
119+
ChildItems = []
120+
};
121+
122+
navPanelItems.Add(managementItem);
123+
124+
if (manageRoles)
125+
{
126+
managementItem.ChildItems.Add(new()
127+
{
128+
Text = localizer[nameof(AppStrings.UserGroups)],
129+
IconName = BitIconName.SecurityGroup,
130+
Url = Urls.RolesPage,
131+
});
132+
}
133+
134+
if (manageUsers)
135+
{
136+
managementItem.ChildItems.Add(new()
137+
{
138+
Text = localizer[nameof(AppStrings.Users)],
139+
IconName = BitIconName.SecurityGroup,
140+
Url = Urls.UsersPage,
141+
});
142+
}
143+
144+
//#if (signalR == true)
145+
if (manageAiPrompt)
146+
{
147+
managementItem.ChildItems.Add(new()
148+
{
149+
Text = localizer[nameof(AppStrings.SystemPromptsTitle)],
150+
IconName = BitIconName.TextDocumentSettings,
151+
Url = Urls.SystemPrompts,
152+
});
153+
}
154+
//#endif
155+
}
156+
111157
navPanelItems.Add(new()
112158
{
113159
Text = localizer[nameof(AppStrings.Settings)],

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Chatbot/SystemPromptsPage.razor

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@attribute [Route(Urls.SystemPrompts)]
22
@attribute [Route("{culture?}" + Urls.SystemPrompts)]
3+
@attribute [Authorize(Policy = AppPermissions.Management.ManageAiPrompt)]
34
@inherits AppPageBase
45

56

@@ -12,21 +13,14 @@
1213
}
1314
else
1415
{
15-
<AuthorizeView Policy="@AppPermissions.Management.ManageAI">
16-
<Authorized>
17-
<BitSticky Top="5rem" Style="margin-bottom:8px">
18-
<BitButton IconName="@BitIconName.Save" OnClick="WrapHandled(SaveChanges)" AutoLoading>
19-
Save prompt
20-
</BitButton>
21-
</BitSticky>
22-
</Authorized>
23-
<NotAuthorized>
24-
<BitText Typography="BitTypography.H4" Color="BitColor.Warning">You don't have access to change the system prompts.</BitText>
25-
</NotAuthorized>
26-
</AuthorizeView>
16+
<BitSticky Top="5rem" Style="margin-bottom:8px">
17+
<BitButton IconName="@BitIconName.Save" OnClick="WrapHandled(SaveChanges)" AutoLoading>
18+
@Localizer[nameof(AppStrings.Save)]
19+
</BitButton>
20+
</BitSticky>
2721

2822
<BitStack VerticalAlign="BitAlignment.Stretch" Horizontal>
29-
<AuthorizeView Policy="@AppPermissions.Management.ManageAI">
23+
<AuthorizeView Policy="@AppPermissions.Management.ManageAiPrompt">
3024
<BitMarkdownEditor @bind-Value="systemPromptMarkdown" Class="md-editor" />
3125
</AuthorizeView>
3226
<BitMarkdownViewer Markdown="@systemPromptMarkdown" Style="word-break:break-all" />

0 commit comments

Comments
 (0)