mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-26 22:48:20 +01:00
Project UserGroup PermissionSets
This commit is contained in:
@@ -19,6 +19,11 @@ namespace Tgstation.Server.Host.GraphQL.Types
|
||||
[Node]
|
||||
public sealed class UserGroup : NamedEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="Types.PermissionSet"/> for the <see cref="UserGroup"/>.
|
||||
/// </summary>
|
||||
public required PermissionSet PermissionSet { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Node resolver for <see cref="User"/>s.
|
||||
/// </summary>
|
||||
@@ -36,22 +41,6 @@ namespace Tgstation.Server.Host.GraphQL.Types
|
||||
authority => authority.GetId(id, false, cancellationToken));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="PermissionSet"/> owned by the <see cref="UserGroup"/>.
|
||||
/// </summary>
|
||||
/// <param name="permissionSetAuthority">The <see cref="IGraphQLAuthorityInvoker{TAuthority}"/> for the <see cref="IPermissionSetAuthority"/>.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
|
||||
/// <returns>A <see cref="ValueTask{TResult}"/> resulting in the <see cref="PermissionSet"/> owned by the <see cref="UserGroup"/>.</returns>
|
||||
public async ValueTask<PermissionSet> PermissionSet(
|
||||
[Service] IGraphQLAuthorityInvoker<IPermissionSetAuthority> permissionSetAuthority,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(permissionSetAuthority);
|
||||
|
||||
return await permissionSetAuthority.InvokeTransformable<Models.PermissionSet, PermissionSet, PermissionSetGraphQLTransformer>(
|
||||
authority => authority.GetId(Id, PermissionSetLookupType.GroupId, cancellationToken));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Queries all registered <see cref="User"/>s in the <see cref="UserGroup"/>.
|
||||
/// </summary>
|
||||
@@ -60,7 +49,7 @@ namespace Tgstation.Server.Host.GraphQL.Types
|
||||
[UsePaging]
|
||||
[UseFiltering]
|
||||
[UseSorting]
|
||||
public async ValueTask<IQueryable<User>> QueryableUsersByGroup(
|
||||
public async ValueTask<IQueryable<User>> Users(
|
||||
[Service] IGraphQLAuthorityInvoker<IUserAuthority> userAuthority)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(userAuthority);
|
||||
|
||||
@@ -9,11 +9,15 @@
|
||||
/// Initializes a new instance of the <see cref="UserGroupGraphQLTransformer"/> class.
|
||||
/// </summary>
|
||||
public UserGroupGraphQLTransformer()
|
||||
: base(model => new GraphQL.Types.UserGroup
|
||||
{
|
||||
Id = model.Id!.Value,
|
||||
Name = model.Name!,
|
||||
})
|
||||
: base(
|
||||
BuildSubProjection<PermissionSet, GraphQL.Types.PermissionSet, PermissionSetGraphQLTransformer>(
|
||||
(model, permissionSet) => new GraphQL.Types.UserGroup
|
||||
{
|
||||
Id = model.Id!.Value,
|
||||
Name = model.Name!,
|
||||
PermissionSet = permissionSet!,
|
||||
},
|
||||
model => model.PermissionSet))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user