Skip to content

Commit

Permalink
feat(graphql): Create separate type for sub-parties (#1510)
Browse files Browse the repository at this point in the history
<!--- Provide a general summary of your changes in the Title above -->

## Description

<!--- Describe your changes in detail -->

## Related Issue(s)

- #1226 

## Verification

- [ ] **Your** code builds clean without any errors or warnings
- [ ] Manual testing done (required)
- [ ] Relevant automated test added (if you find this hard, leave it and
we'll help out)

## Documentation

- [ ] Documentation is updated (either in `docs`-directory, Altinnpedia
or a separate linked PR in
[altinn-studio-docs.](https://github.com/Altinn/altinn-studio-docs), if
applicable)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced new fields in the `AuthorizedParty` and
`AuthorizedSubParty` types to enhance user representation and
relationships.
- Added a new type `AuthorizedSubParty` to support nested party
structures.

- **Bug Fixes**
- Improved the `GetAuthorizedParties` method to return a more complex
structure, including nested sub-party information.

- **Refactor**
- Updated class structure and inheritance for `AuthorizedParty` and
`AuthorizedSubParty` to facilitate better organization and
relationships.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
oskogstad authored Nov 22, 2024
1 parent d18bb76 commit 9c75f11
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
14 changes: 13 additions & 1 deletion docs/schema/V1/schema.verified.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ type AttachmentUrl {
}

type AuthorizedParty {
subParties: [AuthorizedSubParty!]
party: String!
name: String!
partyType: String!
isDeleted: Boolean!
hasKeyRole: Boolean!
isCurrentEndUser: Boolean!
isMainAdministrator: Boolean!
isAccessManager: Boolean!
hasOnlyAccessToSubParties: Boolean!
}

type AuthorizedSubParty {
party: String!
name: String!
partyType: String!
Expand All @@ -75,7 +88,6 @@ type AuthorizedParty {
isMainAdministrator: Boolean!
isAccessManager: Boolean!
hasOnlyAccessToSubParties: Boolean!
subParties: [AuthorizedParty!]
}

type Content {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ public sealed class MappingProfile : Profile
public MappingProfile()
{
CreateMap<AuthorizedPartyDto, AuthorizedParty>();
CreateMap<AuthorizedPartyDto, AuthorizedSubParty>();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Digdir.Domain.Dialogporten.GraphQL.EndUser.Parties;

public sealed class AuthorizedParty
public class AuthorizedPartyBase
{
public string Party { get; init; } = null!;
public string Name { get; init; } = null!;
Expand All @@ -11,5 +11,11 @@ public sealed class AuthorizedParty
public bool IsMainAdministrator { get; init; }
public bool IsAccessManager { get; init; }
public bool HasOnlyAccessToSubParties { get; init; }
public List<AuthorizedParty>? SubParties { get; init; }
}

public sealed class AuthorizedParty : AuthorizedPartyBase
{
public List<AuthorizedSubParty>? SubParties { get; init; }
}

public sealed class AuthorizedSubParty : AuthorizedPartyBase;
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Digdir.Domain.Dialogporten.Application.Externals;
using Digdir.Domain.Dialogporten.Application.Externals.AltinnAuthorization;
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities;
using Digdir.Domain.Dialogporten.Domain.Parties;
using Digdir.Domain.Dialogporten.Domain.Parties.Abstractions;
using Microsoft.EntityFrameworkCore;

Expand Down Expand Up @@ -53,7 +54,23 @@ public async Task<DialogSearchAuthorizationResult> GetAuthorizedResourcesForSear

[SuppressMessage("Performance", "CA1822:Mark members as static")]
public async Task<AuthorizedPartiesResult> GetAuthorizedParties(IPartyIdentifier authenticatedParty, bool _ = false, CancellationToken __ = default)
=> await Task.FromResult(new AuthorizedPartiesResult { AuthorizedParties = [new() { Name = "Local Party", Party = authenticatedParty.FullId, IsCurrentEndUser = true }] });
=> await Task.FromResult(new AuthorizedPartiesResult
{
AuthorizedParties = [new()
{
Name = "Local Party",
Party = authenticatedParty.FullId,
IsCurrentEndUser = true,
SubParties = [
new()
{
Name = "Local Sub Party",
Party = NorwegianOrganizationIdentifier.PrefixWithSeparator + "123456789",
IsCurrentEndUser = true
}
]
}]
});

public Task<bool> HasListAuthorizationForDialog(DialogEntity dialog, CancellationToken cancellationToken) => Task.FromResult(true);
}

0 comments on commit 9c75f11

Please sign in to comment.