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(auth-admin): Allow non super admin to change Legal Representative Delegation type #17107

Merged
merged 2 commits into from
Dec 3, 2024

Conversation

GunnlaugurG
Copy link
Member

@GunnlaugurG GunnlaugurG commented Dec 3, 2024

What

☝️

Why

So non super admins can update Legal Representative in IDS admin

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 visibility of delegation providers for non-super admin users, allowing access to the DistrictCommissionersRegistry.
  • Bug Fixes

    • Simplified conditional rendering logic for delegation providers based on user roles.

@GunnlaugurG GunnlaugurG requested a review from a team as a code owner December 3, 2024 09:58
Copy link
Contributor

coderabbitai bot commented Dec 3, 2024

Walkthrough

The changes in the PermissionDelegations.tsx file focus on the conditional rendering logic for delegation providers based on user roles. The exclusion of PersonalRepresentativeRegistry for non-super admins has been simplified, while DistrictCommissionersRegistry is now always displayed. The structure of the component remains unchanged, and the state management related to delegation types continues as before. No new error handling mechanisms were introduced, and the overall functionality remains focused on managing permission delegations.

Changes

File Path Change Summary
libs/portals/admin/ids-admin/src/screens/Permission/components/PermissionDelegations.tsx Modified conditional rendering logic to simplify exclusions for delegation providers based on user roles.

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • Herdismaria

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.

@datadog-island-is
Copy link

Datadog Report

Branch report: feat/standard-user-pers-rep
Commit report: 83df28a
Test service: portals-admin-ids-admin

✅ 0 Failed, 2 Passed, 0 Skipped, 6.93s Total Time
➡️ Test Sessions change in coverage: 1 no change

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/admin/ids-admin/src/screens/Permission/components/PermissionDelegations.tsx (1)

Line range hint 1-150: Add explicit type annotations for better type safety.

While the component follows good practices for reusability and tree-shaking, it could benefit from explicit type annotations:

Consider adding these TypeScript improvements:

- const toggleDelegationType = (field: string, checked: boolean) => {
+ const toggleDelegationType = (field: string, checked: boolean): void => {

- const providers = delegationProviders.map(
+ const providers: Array<ReturnType<typeof getDelegationProviderTranslations>> = delegationProviders.map(

- const [inputValues, setInputValues] = useEnvironmentState<{
+ interface DelegationState {
+   isAccessControlled: boolean
+   grantToAuthenticatedUser: boolean
+   supportedDelegationTypes: string[]
+   addedDelegationTypes: string[]
+   removedDelegationTypes: string[]
+ }
+ const [inputValues, setInputValues] = useEnvironmentState<DelegationState>({
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a621cbe and df3a384.

📒 Files selected for processing (1)
  • libs/portals/admin/ids-admin/src/screens/Permission/components/PermissionDelegations.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/portals/admin/ids-admin/src/screens/Permission/components/PermissionDelegations.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/admin/ids-admin/src/screens/Permission/components/PermissionDelegations.tsx (1)

121-122: LGTM, but verify security implications.

The changes align with the PR objective to allow non-super admins to change Legal Representative Delegation type. The code correctly excludes only PersonalRepresentativeRegistry for non-super admins.

Let's verify that proper access controls are in place for DistrictCommissionersRegistry:

✅ Verification successful

Security implications verified, changes are safe

The code changes are safe because:

  1. The isSuperAdmin check is still in place, ensuring only super admins can access PersonalRepresentativeRegistry
  2. The DistrictCommissionersRegistry (Legal Representative) access is controlled through the standard delegation type system as shown in the AuthDelegationType enum
  3. The component properly handles delegation type toggling with addedDelegationTypes and removedDelegationTypes tracking
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for access control implementations related to DistrictCommissionersRegistry

# Search for access control checks
rg -A 5 "DistrictCommissionersRegistry" --type typescript

# Search for related permission checks
ast-grep --pattern 'if ($CHECK && $AUTH) {
  $$$
  DistrictCommissionersRegistry
  $$$
}'

Length of output: 184


Script:

#!/bin/bash
# Search for access control checks with proper file extension
rg -A 5 "DistrictCommissionersRegistry" --type ts --type tsx

# Search for permission-related imports and usage
rg "import.*AuthDelegationProvider" --type ts --type tsx -A 3

# Search for any security or permission checks in the same directory
fd . "libs/portals/admin/ids-admin/src/screens/Permission" -e ts -e tsx --exec rg -l "hasPermission|isAuthorized|canAccess|isSuperAdmin"

Length of output: 497


Script:

#!/bin/bash
# Check the content of the permission-related files
cat libs/portals/admin/ids-admin/src/screens/Permission/components/PermissionAccessControl.tsx
cat libs/portals/admin/ids-admin/src/screens/Permission/components/PermissionDelegations.tsx

# Search for enums and types related to delegation providers
rg -g "*.{ts,tsx}" "enum.*AuthDelegationProvider|type.*AuthDelegationProvider"

Length of output: 9968


Script:

#!/bin/bash
# Check the enum definition and its usage
cat libs/shared/types/src/lib/delegation.ts

# Check for any additional permission checks in the context hooks
cat libs/portals/admin/ids-admin/src/hooks/useSuperAdmin.ts

Length of output: 753

@GunnlaugurG GunnlaugurG added the automerge Merge this PR as soon as all checks pass label Dec 3, 2024
Copy link

codecov bot commented Dec 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.68%. Comparing base (a621cbe) to head (09db6d5).
Report is 11 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #17107   +/-   ##
=======================================
  Coverage   35.68%   35.68%           
=======================================
  Files        6946     6946           
  Lines      147401   147401           
  Branches    41904    41904           
=======================================
+ Hits        52600    52601    +1     
+ Misses      94801    94800    -1     
Flag Coverage Δ
air-discount-scheme-backend 48.02% <ø> (ø)
air-discount-scheme-web 0.00% <ø> (ø)
api 3.34% <ø> (ø)
api-catalogue-services 77.85% <ø> (ø)
api-domains-air-discount-scheme 37.39% <ø> (ø)
api-domains-assets 26.71% <ø> (ø)
api-domains-auth-admin 48.49% <ø> (ø)
api-domains-communications 39.53% <ø> (ø)
api-domains-criminal-record 47.38% <ø> (ø)
api-domains-driving-license 44.58% <ø> (ø)
api-domains-education 30.61% <ø> (ø)
api-domains-health-insurance 34.48% <ø> (ø)
api-domains-mortgage-certificate 34.68% <ø> (ø)
api-domains-payment-schedule 41.59% <ø> (ø)
application-api-files 62.14% <ø> (ø)
application-core 75.81% <ø> (ø)
application-system-api 38.73% <ø> (-0.01%) ⬇️
application-template-api-modules 27.78% <ø> (-0.02%) ⬇️
application-templates-accident-notification 28.97% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 25.86% <ø> (ø)
application-templates-driving-license 18.18% <ø> (ø)
application-templates-estate 13.87% <ø> (ø)
application-templates-example-payment 24.80% <ø> (ø)
application-templates-financial-aid 15.83% <ø> (ø)
application-templates-general-petition 23.09% <ø> (ø)
application-templates-inheritance-report 6.57% <ø> (ø)
application-templates-marriage-conditions 15.12% <ø> (ø)
application-templates-mortgage-certificate 43.27% <ø> (ø)
application-templates-parental-leave 29.93% <ø> (ø)
application-types 6.51% <ø> (ø)
application-ui-components 1.27% <ø> (ø)
application-ui-shell 22.56% <ø> (ø)
auth-admin-web 2.43% <ø> (ø)
auth-nest-tools 31.10% <ø> (ø)
auth-react 24.50% <ø> (ø)
auth-shared 75.00% <ø> (ø)
clients-charge-fjs-v2 24.11% <ø> (ø)
clients-driving-license 40.16% <ø> (ø)
clients-driving-license-book 43.39% <ø> (ø)
clients-financial-statements-inao 49.10% <ø> (ø)
clients-license-client 1.26% <ø> (ø)
clients-middlewares 73.00% <ø> (ø)
clients-regulations 42.21% <ø> (ø)
clients-rsk-company-registry 29.76% <ø> (ø)
clients-rsk-personal-tax-return 38.00% <ø> (ø)
clients-smartsolutions 12.77% <ø> (ø)
clients-syslumenn 49.13% <ø> (ø)
clients-zendesk 50.73% <ø> (ø)
cms 0.40% <ø> (ø)
cms-translations 38.86% <ø> (ø)
content-search-index-manager 95.65% <ø> (ø)
content-search-toolkit 8.20% <ø> (ø)
contentful-apps 4.73% <ø> (ø)
dokobit-signing 62.85% <ø> (ø)
email-service 60.65% <ø> (ø)
feature-flags 90.69% <ø> (ø)
file-storage 45.91% <ø> (ø)
financial-aid-backend 51.41% <ø> (ø)
financial-aid-shared 17.81% <ø> (ø)
icelandic-names-registry-backend 54.66% <ø> (ø)
infra-nest-server 48.37% <ø> (ø)
infra-tracing 43.24% <ø> (ø)
island-ui-core 30.94% <ø> (ø)
judicial-system-api 19.99% <ø> (ø)
judicial-system-audit-trail 68.94% <ø> (ø)
judicial-system-backend 55.66% <ø> (ø)
judicial-system-formatters 79.58% <ø> (ø)
judicial-system-message 67.12% <ø> (ø)
judicial-system-message-handler 48.17% <ø> (ø)
judicial-system-scheduler 71.10% <ø> (ø)
judicial-system-types 42.79% <ø> (ø)
judicial-system-web 27.95% <ø> (ø)
license-api 42.69% <ø> (ø)
localization 10.15% <ø> (ø)
logging 48.43% <ø> (ø)
message-queue 68.13% <ø> (-0.74%) ⬇️
nest-audit 68.20% <ø> (ø)
nest-aws 53.04% <ø> (ø)
nest-config 78.07% <ø> (ø)
nest-core 43.54% <ø> (ø)
nest-feature-flags 51.15% <ø> (ø)
nest-problem 45.82% <ø> (ø)
nest-sequelize 94.44% <ø> (ø)
nest-swagger 51.71% <ø> (ø)
nova-sms 62.18% <ø> (ø)
portals-admin-regulations-admin 1.80% <ø> (ø)
portals-core 19.80% <ø> (ø)
regulations 16.78% <ø> (ø)
residence-history 85.00% <ø> (ø)
services-auth-admin-api 52.57% <ø> (ø)
services-auth-delegation-api 58.50% <ø> (-0.09%) ⬇️
services-auth-ids-api 52.33% <ø> (+0.04%) ⬆️
services-auth-public-api 49.29% <ø> (ø)
services-user-profile 56.90% <ø> (+0.06%) ⬆️
shared-components 30.22% <ø> (ø)
shared-form-fields 33.88% <ø> (ø)
shared-mocking 58.64% <ø> (ø)
shared-pii 92.85% <ø> (ø)
shared-problem 87.50% <ø> (ø)
shared-utils 27.69% <ø> (ø)
skilavottord-ws 24.14% <ø> (ø)
web 2.44% <ø> (ø)

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

see 3 files 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 a621cbe...09db6d5. Read the comment docs.

@kodiakhq kodiakhq bot merged commit ebd9b8f into main Dec 3, 2024
266 of 267 checks passed
@kodiakhq kodiakhq bot deleted the feat/standard-user-pers-rep branch December 3, 2024 10:37
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