feat: add organization settings UI
This commit is contained in:
@@ -122,6 +122,7 @@ public static class DevelopmentSeedExtensions
|
||||
|
||||
await EnsureOrganizationDataAsync(
|
||||
manager.Id,
|
||||
dev.Id,
|
||||
dbContext,
|
||||
cancellationToken);
|
||||
|
||||
@@ -234,6 +235,7 @@ public static class DevelopmentSeedExtensions
|
||||
|
||||
private static async Task EnsureOrganizationDataAsync(
|
||||
Guid managerUserId,
|
||||
Guid developerUserId,
|
||||
AppDbContext dbContext,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -255,25 +257,51 @@ public static class DevelopmentSeedExtensions
|
||||
organization.Slug = "northstar-collective";
|
||||
organization.OwnerUserId = managerUserId;
|
||||
|
||||
await UpsertOrganizationMembershipAsync(
|
||||
dbContext,
|
||||
Guid.Parse("99999999-9999-9999-9999-000000000001"),
|
||||
OrganizationId,
|
||||
managerUserId,
|
||||
OrganizationRoles.Owner,
|
||||
cancellationToken);
|
||||
|
||||
await UpsertOrganizationMembershipAsync(
|
||||
dbContext,
|
||||
Guid.Parse("99999999-9999-9999-9999-000000000002"),
|
||||
OrganizationId,
|
||||
developerUserId,
|
||||
OrganizationRoles.Admin,
|
||||
cancellationToken);
|
||||
|
||||
await dbContext.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
|
||||
private static async Task UpsertOrganizationMembershipAsync(
|
||||
AppDbContext dbContext,
|
||||
Guid membershipId,
|
||||
Guid organizationId,
|
||||
Guid userId,
|
||||
string role,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
OrganizationMembership? membership = await dbContext.OrganizationMemberships
|
||||
.SingleOrDefaultAsync(
|
||||
candidate => candidate.OrganizationId == OrganizationId && candidate.UserId == managerUserId,
|
||||
candidate => candidate.OrganizationId == organizationId && candidate.UserId == userId,
|
||||
cancellationToken);
|
||||
if (membership is null)
|
||||
{
|
||||
membership = new OrganizationMembership
|
||||
{
|
||||
Id = Guid.Parse("99999999-9999-9999-9999-000000000001"),
|
||||
OrganizationId = OrganizationId,
|
||||
UserId = managerUserId,
|
||||
Role = OrganizationRoles.Owner,
|
||||
Id = membershipId,
|
||||
OrganizationId = organizationId,
|
||||
UserId = userId,
|
||||
Role = role,
|
||||
CreatedAt = DateTimeOffset.UtcNow,
|
||||
};
|
||||
dbContext.OrganizationMemberships.Add(membership);
|
||||
}
|
||||
|
||||
membership.Role = OrganizationRoles.Owner;
|
||||
await dbContext.SaveChangesAsync(cancellationToken);
|
||||
membership.Role = role;
|
||||
}
|
||||
|
||||
private static async Task EnsureWorkspaceDataAsync(
|
||||
|
||||
Reference in New Issue
Block a user