Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(delegation-api): Add GeneralMandate delegations to accessControl #16170

Merged
merged 6 commits into from
Sep 27, 2024

Conversation

GunnlaugurG
Copy link
Member

@GunnlaugurG GunnlaugurG commented Sep 26, 2024

What

Add general mandate delegations to the access control->From tab since it is missing there

Why

So users can see GeneralMandate delegations that they have given

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Enhanced delegation retrieval based on user national ID, now including specific delegation types and validity checks.
    • Improved rendering logic in the Access Card component to display delegation types more accurately.
  • Bug Fixes

    • Adjusted conditions for rendering delegation type labels to ensure correct display based on delegation type.
  • Chores

    • Swapped values of delegation reference ID constants for better clarity.

@GunnlaugurG GunnlaugurG requested review from a team as code owners September 26, 2024 11:48
Copy link
Contributor

coderabbitai bot commented Sep 26, 2024

Walkthrough

The pull request enhances the DelegationsOutgoingService class by modifying the findAll method to retrieve delegations based on a user's national ID while filtering for valid delegation types. The AccessCard component is updated to improve conditional rendering based on delegation types. Additionally, constant declarations in the zendesk.ts file have been swapped.

Changes

File Change Summary
libs/auth-api-lib/src/lib/delegations/delegations-outgoing.service.ts Modified the findAll method to concurrently retrieve delegations of type AuthDelegationType.GeneralMandate, filtering for valid delegations and transforming results into DTO format.
libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx Reordered import statements and enhanced the conditional rendering logic to include a check for delegation.type === AuthDelegationType.GeneralMandate, affecting how delegation type labels are displayed.
libs/auth-api-lib/src/lib/delegations/constants/zendesk.ts Swapped the values of DelegationFromReferenceId and DelegationToReferenceId constants.

Possibly related PRs

Suggested labels

high priority

Suggested reviewers

  • Herdismaria
  • saevarma

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 11da3fe and a37c337.

📒 Files selected for processing (1)
  • libs/auth-api-lib/src/lib/delegations/delegations-outgoing.service.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • libs/auth-api-lib/src/lib/delegations/delegations-outgoing.service.ts

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (1)
libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx (1)

185-187: LGTM: Conditional rendering updated to include GeneralMandate type.

The addition of delegation.type === AuthDelegationType.GeneralMandate to the conditional rendering logic aligns with the PR objective to incorporate general mandate delegations. This change correctly extends the cases where the delegation type label is rendered.

Consider extracting the condition into a separate variable for improved readability:

const shouldRenderDelegationTypeLabel = 
  isAdminView || 
  !isOutgoing || 
  delegation.type === AuthDelegationType.GeneralMandate;

{shouldRenderDelegationTypeLabel && (
  // ... existing code
)}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b78609d and 18f03fc.

📒 Files selected for processing (2)
  • libs/auth-api-lib/src/lib/delegations/delegations-outgoing.service.ts (2 hunks)
  • libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
libs/auth-api-lib/src/lib/delegations/delegations-outgoing.service.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🔇 Additional comments (5)
libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx (2)

8-14: LGTM: Import statements reorganized and new components added.

The reordering of import statements and addition of new component imports (Inline, Stack, Tag, and Text) improve code organization and indicate the use of these components in the file. This change adheres to the coding guideline for effective tree-shaking and bundling practices.


Line range hint 1-324: LGTM: Component adheres to coding guidelines for libs/**/*.

The AccessCard component follows the coding guidelines for the libs/**/* pattern:

  1. It's a reusable React component that can be used across different NextJS apps.
  2. TypeScript is used for defining props (AccessCardProps interface).
  3. The component structure supports effective tree-shaking and bundling practices.
libs/auth-api-lib/src/lib/delegations/delegations-outgoing.service.ts (3)

42-43: LGTM: New import added correctly

The new import for DelegationDelegationType is correctly placed and follows the existing import style. Both this and the AuthDelegationType import are necessary for the new functionality in the findAll method.


108-135: LGTM: TypeScript usage and reusability

The new code maintains consistent TypeScript usage, leveraging type inference and existing model types. The changes are well-integrated into the DelegationsOutgoingService class without introducing any reusability issues across different NextJS apps.

The modifications are specific to this service and align well with the existing codebase structure. No additional types need to be exported, preserving the current level of modularity.


Line range hint 42-135: Summary: Successfully implemented GeneralMandate delegations

The changes in this file successfully implement the feature to incorporate general mandate delegations into the access control section, specifically within the "From" tab. The modifications allow users to view their GeneralMandate delegations, aligning well with the PR objectives.

Key points:

  1. New imports added correctly.
  2. The findAll method now includes GeneralMandate delegations.
  3. TypeScript usage is consistent and doesn't introduce reusability issues.

The implementation enhances the access control functionality as intended, improving the overall usability of the system. A minor optimization using Promise.all was suggested to potentially improve performance.

Copy link

codecov bot commented Sep 26, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Project coverage is 36.69%. Comparing base (55d69bb) to head (a37c337).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...rc/lib/delegations/delegations-outgoing.service.ts 88.88% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #16170   +/-   ##
=======================================
  Coverage   36.69%   36.69%           
=======================================
  Files        6776     6776           
  Lines      139586   139592    +6     
  Branches    39680    39680           
=======================================
+ Hits        51222    51227    +5     
- Misses      88364    88365    +1     
Flag Coverage Δ
api 3.39% <ø> (ø)
api-domains-auth-admin 48.77% <ø> (ø)
application-system-api 41.63% <ø> (ø)
application-template-api-modules 23.68% <ø> (-0.04%) ⬇️
services-auth-admin-api 51.96% <33.33%> (-0.01%) ⬇️
services-auth-delegation-api 57.85% <88.88%> (+0.01%) ⬆️
services-auth-ids-api 51.84% <33.33%> (-0.01%) ⬇️
services-auth-personal-representative 45.50% <33.33%> (+<0.01%) ⬆️
services-auth-personal-representative-public 41.58% <33.33%> (+0.03%) ⬆️
services-auth-public-api 49.22% <33.33%> (+<0.01%) ⬆️
services-user-notification 47.14% <ø> (ø)
services-user-profile 62.28% <ø> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...h-api-lib/src/lib/delegations/constants/zendesk.ts 100.00% <ø> (ø)
...rc/lib/delegations/delegations-outgoing.service.ts 95.23% <88.88%> (-0.51%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 55d69bb...a37c337. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Sep 26, 2024

Datadog Report

All test runs 84cbdfd 🔗

13 Total Test Services: 0 Failed, 13 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.01%), 2 increased, 25 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 2.66s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 12.08s 1 no change Link
application-system-api 0 0 0 111 2 3m 4.03s 1 increased (+0.02%) Link
application-template-api-modules 0 0 0 109 0 1m 54s 1 decreased (-0.01%) Link
auth-api-lib 0 0 0 20 0 34.41s 1 no change Link
services-auth-admin-api 0 0 0 125 0 3m 2.71s 1 no change Link
services-auth-delegation-api 0 0 0 256 0 3m 9.56s 1 no change Link
services-auth-ids-api 0 0 0 152 0 58.18s 1 no change Link
services-auth-personal-representative 0 0 0 59 0 1m 25.45s 1 no change Link
services-auth-personal-representative-public 0 0 0 10 0 26.64s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • application-template-api-modules - jest 25.7% (-0.01%) - Details

@GunnlaugurG GunnlaugurG added the automerge Merge this PR as soon as all checks pass label Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants