-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved code from Razor components to code-behind to fix Identity UI sc…
…affolding.
- Loading branch information
Showing
20 changed files
with
439 additions
and
304 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
160 changes: 117 additions & 43 deletions
160
Server/Areas/Identity/Pages/Account/Manage/ManageNavPages.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 |
---|---|---|
@@ -1,49 +1,123 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc.Rendering; | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
#nullable disable | ||
|
||
namespace Remotely.Server.Areas.Identity.Pages.Account.Manage; | ||
using System; | ||
using Microsoft.AspNetCore.Mvc.Rendering; | ||
|
||
public static class ManageNavPages | ||
namespace Remotely.Server.Areas.Identity.Pages.Account.Manage | ||
{ | ||
public static string Index => "Index"; | ||
|
||
public static string Email => "Email"; | ||
|
||
public static string ChangePassword => "ChangePassword"; | ||
|
||
public static string DownloadPersonalData => "DownloadPersonalData"; | ||
|
||
public static string DeletePersonalData => "DeletePersonalData"; | ||
|
||
public static string ExternalLogins => "ExternalLogins"; | ||
|
||
public static string PersonalData => "PersonalData"; | ||
|
||
public static string TwoFactorAuthentication => "TwoFactorAuthentication"; | ||
|
||
public static string IndexNavClass(ViewContext viewContext) => PageNavClass(viewContext, Index); | ||
|
||
public static string EmailNavClass(ViewContext viewContext) => PageNavClass(viewContext, Email); | ||
|
||
public static string ChangePasswordNavClass(ViewContext viewContext) => PageNavClass(viewContext, ChangePassword); | ||
|
||
public static string DownloadPersonalDataNavClass(ViewContext viewContext) => PageNavClass(viewContext, DownloadPersonalData); | ||
|
||
public static string DeletePersonalDataNavClass(ViewContext viewContext) => PageNavClass(viewContext, DeletePersonalData); | ||
|
||
public static string ExternalLoginsNavClass(ViewContext viewContext) => PageNavClass(viewContext, ExternalLogins); | ||
|
||
public static string PersonalDataNavClass(ViewContext viewContext) => PageNavClass(viewContext, PersonalData); | ||
|
||
public static string TwoFactorAuthenticationNavClass(ViewContext viewContext) => PageNavClass(viewContext, TwoFactorAuthentication); | ||
|
||
private static string PageNavClass(ViewContext viewContext, string page) | ||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public static class ManageNavPages | ||
{ | ||
var activePage = viewContext.ViewData["ActivePage"] as string | ||
?? System.IO.Path.GetFileNameWithoutExtension(viewContext.ActionDescriptor.DisplayName); | ||
return string.Equals(activePage, page, StringComparison.OrdinalIgnoreCase) ? "active" : ""; | ||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public static string Index => "Index"; | ||
|
||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public static string Email => "Email"; | ||
|
||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public static string ChangePassword => "ChangePassword"; | ||
|
||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public static string DownloadPersonalData => "DownloadPersonalData"; | ||
|
||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public static string DeletePersonalData => "DeletePersonalData"; | ||
|
||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public static string ExternalLogins => "ExternalLogins"; | ||
|
||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public static string PersonalData => "PersonalData"; | ||
|
||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public static string TwoFactorAuthentication => "TwoFactorAuthentication"; | ||
|
||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public static string IndexNavClass(ViewContext viewContext) => PageNavClass(viewContext, Index); | ||
|
||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public static string EmailNavClass(ViewContext viewContext) => PageNavClass(viewContext, Email); | ||
|
||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public static string ChangePasswordNavClass(ViewContext viewContext) => PageNavClass(viewContext, ChangePassword); | ||
|
||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public static string DownloadPersonalDataNavClass(ViewContext viewContext) => PageNavClass(viewContext, DownloadPersonalData); | ||
|
||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public static string DeletePersonalDataNavClass(ViewContext viewContext) => PageNavClass(viewContext, DeletePersonalData); | ||
|
||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public static string ExternalLoginsNavClass(ViewContext viewContext) => PageNavClass(viewContext, ExternalLogins); | ||
|
||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public static string PersonalDataNavClass(ViewContext viewContext) => PageNavClass(viewContext, PersonalData); | ||
|
||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public static string TwoFactorAuthenticationNavClass(ViewContext viewContext) => PageNavClass(viewContext, TwoFactorAuthentication); | ||
|
||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public static string PageNavClass(ViewContext viewContext, string page) | ||
{ | ||
var activePage = viewContext.ViewData["ActivePage"] as string | ||
?? System.IO.Path.GetFileNameWithoutExtension(viewContext.ActionDescriptor.DisplayName); | ||
return string.Equals(activePage, page, StringComparison.OrdinalIgnoreCase) ? "active" : null; | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Server/Areas/Identity/Pages/_ValidationScriptsPartial.cshtml
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,18 @@ | ||
<environment include="Development"> | ||
<script src="~/Identity/lib/jquery-validation/dist/jquery.validate.js"></script> | ||
<script src="~/Identity/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script> | ||
</environment> | ||
<environment exclude="Development"> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.17.0/jquery.validate.min.js" | ||
asp-fallback-src="~/Identity/lib/jquery-validation/dist/jquery.validate.min.js" | ||
asp-fallback-test="window.jQuery && window.jQuery.validator" | ||
crossorigin="anonymous" | ||
integrity="sha384-rZfj/ogBloos6wzLGpPkkOr/gpkBNLZ6b6yLy4o+ok+t/SAKlL5mvXLr0OXNi1Hp"> | ||
</script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validation-unobtrusive/3.2.11/jquery.validate.unobtrusive.min.js" | ||
asp-fallback-src="~/Identity/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js" | ||
asp-fallback-test="window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive" | ||
crossorigin="anonymous" | ||
integrity="sha384-R3vNCHsZ+A2Lo3d5A6XNP7fdQkeswQWTIPfiYwSpEP3YV079R+93YzTeZRah7f/F"> | ||
</script> | ||
</environment> |
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,63 @@ | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Components; | ||
using Remotely.Server.Services; | ||
using Remotely.Shared.Entities; | ||
using Remotely.Shared.Models; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Remotely.Server.Components.ModalContents; | ||
|
||
[Authorize] | ||
public partial class EditDeviceGroup : AuthComponentBase | ||
{ | ||
public static string DeviceGroupsPropName => nameof(DeviceGroups); | ||
public static string EditUserPropName => nameof(EditUser); | ||
[Parameter] | ||
public required DeviceGroup[] DeviceGroups { get; set; } | ||
|
||
[Parameter] | ||
public required RemotelyUser EditUser { get; set; } | ||
|
||
[Inject] | ||
private IDataService DataService { get; init; } = null!; | ||
|
||
[Inject] | ||
private IToastService ToastService { get; init; } = null!; | ||
|
||
|
||
private bool DoesGroupContainUser(DeviceGroup group) | ||
{ | ||
return group.Users.Any(x => x.Id == EditUser.Id); | ||
} | ||
|
||
private async Task GroupCheckChanged(ChangeEventArgs args, DeviceGroup group) | ||
{ | ||
if (!string.IsNullOrWhiteSpace(EditUser.UserName) && | ||
args.Value is bool boolValue && | ||
boolValue) | ||
{ | ||
if (!DataService.AddUserToDeviceGroup(EditUser.OrganizationID, group.ID, EditUser.UserName, out var result)) | ||
{ | ||
ToastService.ShowToast(result, classString: "bg-warning"); | ||
} | ||
else | ||
{ | ||
ToastService.ShowToast("User added to group."); | ||
} | ||
|
||
} | ||
else | ||
{ | ||
var result = await DataService.RemoveUserFromDeviceGroup(EditUser.OrganizationID, group.ID, EditUser.Id); | ||
if (!result) | ||
{ | ||
ToastService.ShowToast("Failed to remove from group.", classString: "bg-warning"); | ||
} | ||
else | ||
{ | ||
ToastService.ShowToast("Removed user from group."); | ||
} | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
Server/Components/ModalContents/QuickScriptsSelector.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,7 @@ | ||
using Microsoft.AspNetCore.Components; | ||
|
||
namespace Remotely.Server.Components.ModalContents; | ||
|
||
public partial class QuickScriptsSelector : ComponentBase | ||
{ | ||
} |
Oops, something went wrong.