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

fix(delegations): Fix delete for GeneralMandate delegations #16212

Merged
merged 4 commits into from
Oct 1, 2024

Conversation

GunnlaugurG
Copy link
Member

@GunnlaugurG GunnlaugurG commented Sep 30, 2024

What

Fix the AccessDeleteModal to handle general mandate delegations

Why

So all type of delegations can be deleted

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 handling of delegation types in the Access Delete Modal for improved user experience.
    • Conditional rendering of domain information based on delegation type, providing clearer context for users.
  • Bug Fixes

    • Improved robustness when dealing with potentially missing delegation data, ensuring users see relevant information.
    • Retained error handling to communicate issues during the deletion process effectively.

@GunnlaugurG GunnlaugurG requested a review from a team as a code owner September 30, 2024 14:14
Copy link
Contributor

coderabbitai bot commented Sep 30, 2024

Walkthrough

The changes in the pull request focus on the AccessDeleteModal.tsx component, enhancing its handling of domain names and delegation types. Key modifications include improved domain name validation, conditional rendering based on delegation type, and streamlined logic, which collectively enhance the component's functionality and clarity.

Changes

File Change Summary
libs/portals/shared-modules/delegations/src/components/access/AccessDeleteModal/AccessDeleteModal.tsx - Enhanced domain name handling with nullish coalescing operator.
- Conditional rendering based on delegation type, specifically for 'GeneralMandate'.
- Removed redundant unconditional rendering of AccessListContainer.

Possibly related PRs

Suggested labels

high priority


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.

@GunnlaugurG GunnlaugurG added the automerge Merge this PR as soon as all checks pass label Sep 30, 2024
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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between efbef76 and 20cf66b.

📒 Files selected for processing (1)
  • libs/portals/shared-modules/delegations/src/components/access/AccessDeleteModal/AccessDeleteModal.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/portals/shared-modules/delegations/src/components/access/AccessDeleteModal/AccessDeleteModal.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 (1)
libs/portals/shared-modules/delegations/src/components/access/AccessDeleteModal/AccessDeleteModal.tsx (1)

45-45: Robust handling of undefined delegation domain

Good use of the nullish coalescing operator to handle cases where delegation.domain might be undefined, ensuring that domain is set to null when necessary.

Copy link

codecov bot commented Sep 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.76%. Comparing base (9ef986b) to head (ae9c76d).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #16212   +/-   ##
=======================================
  Coverage   36.76%   36.76%           
=======================================
  Files        6785     6785           
  Lines      139900   139904    +4     
  Branches    39772    39776    +4     
=======================================
+ Hits        51435    51438    +3     
- Misses      88465    88466    +1     
Flag Coverage Δ
air-discount-scheme-backend 54.23% <ø> (ø)
air-discount-scheme-web 0.00% <ø> (ø)
api 3.39% <ø> (ø)
api-domains-air-discount-scheme 36.91% <ø> (ø)
api-domains-assets 26.71% <ø> (ø)
api-domains-auth-admin 48.77% <ø> (ø)
api-domains-communications 39.92% <ø> (ø)
api-domains-criminal-record 47.85% <ø> (ø)
api-domains-driving-license 44.47% <ø> (ø)
api-domains-education 31.67% <ø> (ø)
api-domains-health-insurance 34.68% <ø> (ø)
api-domains-mortgage-certificate 35.70% <ø> (ø)
api-domains-payment-schedule 41.20% <ø> (ø)
application-api-files 57.86% <ø> (ø)
application-core 71.54% <ø> (-0.09%) ⬇️
application-system-api 41.62% <ø> (ø)
application-template-api-modules 23.73% <ø> (ø)
application-templates-accident-notification 22.14% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 26.63% <ø> (ø)
application-templates-driving-license 18.70% <ø> (ø)
application-templates-estate 12.34% <ø> (ø)
application-templates-example-payment 25.41% <ø> (ø)
application-templates-financial-aid 14.34% <ø> (ø)
application-templates-general-petition 23.68% <ø> (ø)
application-templates-health-insurance 26.62% <ø> (ø)
application-templates-inheritance-report 6.45% <ø> (ø)
application-templates-marriage-conditions 15.23% <ø> (ø)
application-templates-mortgage-certificate 43.96% <ø> (ø)
application-templates-parental-leave 30.15% <ø> (ø)
application-types 6.71% <ø> (ø)
application-ui-components 1.28% <ø> (ø)
application-ui-shell 21.29% <ø> (ø)
auth-react 22.80% <ø> (ø)
clients-charge-fjs-v2 24.11% <ø> (ø)
clients-driving-license 40.65% <ø> (ø)
clients-driving-license-book 43.91% <ø> (ø)
clients-financial-statements-inao 49.17% <ø> (ø)
clients-license-client 1.83% <ø> (ø)
clients-middlewares 73.11% <ø> (+0.33%) ⬆️
clients-regulations 42.63% <ø> (ø)
clients-rsk-company-registry 29.76% <ø> (ø)
clients-syslumenn 49.66% <ø> (ø)
cms 0.43% <ø> (ø)
cms-translations 39.05% <ø> (ø)
content-search-toolkit 8.16% <ø> (ø)
contentful-apps 5.76% <ø> (ø)
download-service 44.75% <ø> (ø)
financial-aid-backend 56.54% <ø> (ø)
financial-aid-shared 19.03% <ø> (ø)
island-ui-core 28.47% <ø> (ø)
judicial-system-api 18.30% <ø> (ø)
judicial-system-backend 55.30% <ø> (ø)
judicial-system-message 66.99% <ø> (ø)
judicial-system-message-handler 47.99% <ø> (+0.18%) ⬆️
judicial-system-scheduler 69.12% <ø> (ø)
judicial-system-web 28.11% <ø> (ø)
license-api 42.69% <ø> (+0.01%) ⬆️
portals-admin-regulations-admin 1.88% <ø> (ø)
portals-core 16.17% <ø> (ø)
services-auth-admin-api 51.98% <ø> (ø)
services-auth-delegation-api 57.87% <ø> (-0.07%) ⬇️
services-auth-ids-api 51.88% <ø> (ø)
services-auth-personal-representative 45.55% <ø> (+0.02%) ⬆️
services-auth-personal-representative-public 41.59% <ø> (ø)
services-auth-public-api 49.37% <ø> (ø)
services-endorsements-api 55.23% <ø> (ø)
services-university-gateway 48.54% <ø> (+0.11%) ⬆️
services-user-notification 47.07% <ø> (ø)
services-user-profile 62.37% <ø> (ø)
shared-components 27.68% <ø> (ø)
shared-form-fields 31.61% <ø> (ø)
shared-utils 28.01% <ø> (ø)
web 1.83% <ø> (ø)

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

see 1 file with indirect coverage changes


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 9ef986b...ae9c76d. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Sep 30, 2024

Datadog Report

All test runs c1e0d20 🔗

68 Total Test Services: 1 Failed, 65 Passed
🔻 Test Sessions change in coverage: 2 decreased, 3 increased, 195 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
services-auth-admin-api 1 0 0 0 0 0s N/A Link
air-discount-scheme-backend 0 0 0 81 0 26.8s N/A Link
air-discount-scheme-web 0 0 0 2 0 8.7s N/A Link
api 0 0 0 4 0 2.95s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 19.44s N/A Link
api-domains-assets 0 0 0 3 0 12.34s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 13.46s N/A Link
api-domains-communications 0 0 0 5 0 33.05s N/A Link
api-domains-criminal-record 0 0 0 5 0 10.21s 1 no change Link
api-domains-driving-license 0 0 0 23 0 31.57s N/A Link

❌ Failed Tests (1)

  • MeClientsController with auth with tenant id that user does not own GET /v2/me/tenants/@test.is/clients should return 204 No Content - apps/services/auth/admin-api/src/app/v2/clients/test/me-clients.spec.ts - Details

    Expand for error
     connect ECONNREFUSED 172.17.0.1:55450
    

🔻 Code Coverage Decreases vs Default Branch (2)

  • services-auth-delegation-api - jest 51.31% (-0.19%) - Details
  • application-core - jest 79.46% (-0.11%) - Details

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: 0

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

Line range hint 43-50: Improve null safety in useEffect condition

The condition for fetching the auth scope tree has been improved, but we can further enhance it using optional chaining for better null safety.

Apply this diff to improve the condition:

-    if (delegation && delegation.domain?.name) {
+    if (delegation?.domain?.name) {
      getAuthScopeTree({
        variables: {
          input: {
            domain: delegation.domain.name,
            lang,
          },
        },
      })
    }

This change ensures that we safely access the domain property of delegation using optional chaining, making the code more robust against potential null or undefined values.

🧰 Tools
🪛 Biome

[error] 43-43: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 482841d and f6e0e7f.

📒 Files selected for processing (1)
  • libs/portals/shared-modules/delegations/src/components/access/AccessDeleteModal/AccessDeleteModal.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/portals/shared-modules/delegations/src/components/access/AccessDeleteModal/AccessDeleteModal.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."
🪛 Biome
libs/portals/shared-modules/delegations/src/components/access/AccessDeleteModal/AccessDeleteModal.tsx

[error] 43-43: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (4)
libs/portals/shared-modules/delegations/src/components/access/AccessDeleteModal/AccessDeleteModal.tsx (4)

Line range hint 1-20: LGTM: Import statements are correctly updated and ordered.

The addition of AuthDelegationType import is appropriate for the changes made in the component. The import order follows the coding guidelines.


138-160: LGTM: Improved rendering logic for different delegation types

The changes effectively address the need to handle different delegation types, particularly distinguishing between GeneralMandate and other types. This aligns well with the PR objectives to fix deletion for GeneralMandate delegations.

The conditional rendering is clear, concise, and follows React best practices. Good job on improving the component's flexibility and accuracy in displaying delegation information.


138-138: LGTM: Correct usage of AuthDelegationType enum

The change from string literal to AuthDelegationType.GeneralMandate for type comparison is excellent. This ensures type safety and maintains consistency throughout the codebase.


Line range hint 1-179: LGTM: Overall improvements to AccessDeleteModal component

The changes in this file successfully address the PR objectives and previous review comments. Key improvements include:

  1. Correct handling of different delegation types, especially GeneralMandate.
  2. Enhanced conditional rendering based on delegation type.
  3. Improved null safety in the useEffect hook (with a suggested further improvement).
  4. Proper use of AuthDelegationType enum for type comparisons.

These changes enhance the component's functionality and maintainability. Great job on the improvements!

Copy link
Member

@saevarma saevarma left a comment

Choose a reason for hiding this comment

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

🚀

@kodiakhq kodiakhq bot merged commit 148403d into main Oct 1, 2024
196 checks passed
@kodiakhq kodiakhq bot deleted the fix/delete-delegation branch October 1, 2024 14:56
thoreyjona pushed a commit that referenced this pull request Oct 2, 2024
* Fix delete

* fix hardcoded value

* fix pr comments

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
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