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(j-s): Roles Rules #15416

Merged
merged 3 commits into from
Jul 3, 2024
Merged

Conversation

gudjong
Copy link
Member

@gudjong gudjong commented Jul 2, 2024

Roles Rules

Fulltrúi hjá sækjanda - yfirfara réttindi hlutverks

What

  • Gives prosecutor representatives permission to cancel indictments.
  • Moves some user specific checks from the case controller to appropriate roles rules.

Why

  • Prosecutor representatives should be able to cancel indictments.
  • User check are better handled in roles rules.

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

    • Introduced a new rule for district court judges to sign rulings.
    • Added various case types and user roles for enhanced role-based access control.
  • Bug Fixes

    • Removed redundant permission checks for confirming and denying indictments.
  • Tests

    • Updated test cases to reflect new rules and removed unnecessary imports and checks.

@gudjong gudjong requested a review from a team as a code owner July 2, 2024 12:55
Copy link
Contributor

coderabbitai bot commented Jul 2, 2024

Walkthrough

The updates to the judicial-system backend primarily enhance the authorization logic for district court judges by introducing the districtCourtJudgeSignRulingRule, and modifying how indictments are managed, specifically removing permission checks for confirming and denying indictments. Test files and logic in various modules are updated accordingly to reflect these changes, optimizing the handling of indictment-related transitions and ensuring the correct application of roles and permissions.

Changes

File Path Change Summary
…/backend/src/app/modules/case/case.controller.ts Replaced districtCourtJudgeRule with districtCourtJudgeSignRulingRule; removed permission checks for confirming and denying indictments.
…/backend/src/app/modules/case/guards/rolesRules.ts Introduced districtCourtJudgeSignRulingRule; updated prosecutorTransitionRule and defenderTransitionRule logic; added CaseType, User, CaseTransition.DENY_INDICTMENT.
…/case/test/caseController/getRulingSignatureConfirmation.spec.ts Removed ForbiddenException import; deleted a test case for an unassigned judge.
…/case/test/caseController/getRulingSignatureConfirmationRolesRules.spec.ts Swapped districtCourtJudgeRule with districtCourtJudgeSignRulingRule in imports and tests.
…/case/test/caseController/requestRulingSignature.spec.ts Renamed and adjusted a test case from checking the assigned judge to verifying signature requests; removed ForbiddenException import.

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2d1878f and b4285a7.

Files selected for processing (6)
  • apps/judicial-system/backend/src/app/modules/case/case.controller.ts (7 hunks)
  • apps/judicial-system/backend/src/app/modules/case/guards/rolesRules.ts (8 hunks)
  • apps/judicial-system/backend/src/app/modules/case/test/caseController/getRulingSignatureConfirmation.spec.ts (2 hunks)
  • apps/judicial-system/backend/src/app/modules/case/test/caseController/getRulingSignatureConfirmationRolesRules.spec.ts (2 hunks)
  • apps/judicial-system/backend/src/app/modules/case/test/caseController/requestRulingSignature.spec.ts (3 hunks)
  • apps/judicial-system/backend/src/app/modules/case/test/caseController/requestRulingSignatureRolesRules.spec.ts (2 hunks)
Files skipped from review due to trivial changes (2)
  • apps/judicial-system/backend/src/app/modules/case/test/caseController/getRulingSignatureConfirmation.spec.ts
  • apps/judicial-system/backend/src/app/modules/case/test/caseController/requestRulingSignature.spec.ts
Additional context used
Path-based instructions (4)
apps/judicial-system/backend/src/app/modules/case/test/caseController/requestRulingSignatureRolesRules.spec.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/case/test/caseController/getRulingSignatureConfirmationRolesRules.spec.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/case/guards/rolesRules.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/case/case.controller.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
Learnings (3)
apps/judicial-system/backend/src/app/modules/case/test/caseController/requestRulingSignatureRolesRules.spec.ts (1)
Learnt from: gudjong
PR: island-is/island.is#15241
File: apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverSignedRulingToPolice.spec.ts:41-42
Timestamp: 2024-06-14T15:09:49.085Z
Learning: User gudjong prefers not to make changes to error handling messages in test setups at this time.
apps/judicial-system/backend/src/app/modules/case/test/caseController/getRulingSignatureConfirmationRolesRules.spec.ts (1)
Learnt from: gudjong
PR: island-is/island.is#15241
File: apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverSignedRulingToPolice.spec.ts:41-42
Timestamp: 2024-06-14T15:09:49.085Z
Learning: User gudjong prefers not to make changes to error handling messages in test setups at this time.
apps/judicial-system/backend/src/app/modules/case/case.controller.ts (2)
Learnt from: unakb
PR: island-is/island.is#15378
File: apps/judicial-system/web/src/routes/Court/Indictments/Summary/Summary.tsx:86-100
Timestamp: 2024-06-27T14:37:07.823Z
Learning: User unakb prefers explicit case handling in switch statements for key functionalities like `getRulingDecisionTagColor` to ensure clarity and avoid assumptions that a case was overlooked.
Learnt from: gudjong
PR: island-is/island.is#15393
File: apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts:28-28
Timestamp: 2024-07-01T13:14:45.714Z
Learning: The `DeliverCancellationNoticeDto` import in `apps/judicial-system/backend/src/app/modules/case/internalCase.controller.ts` is used in the `deliverIndictmentCancellationNoticeToCourt` method.
Additional comments not posted (9)
apps/judicial-system/backend/src/app/modules/case/test/caseController/requestRulingSignatureRolesRules.spec.ts (1)

2-2: Import change is correct.

The import of districtCourtJudgeSignRulingRule aligns with the PR objective.

apps/judicial-system/backend/src/app/modules/case/test/caseController/getRulingSignatureConfirmationRolesRules.spec.ts (1)

2-2: Import change is correct.

The import of districtCourtJudgeSignRulingRule aligns with the PR objective.

apps/judicial-system/backend/src/app/modules/case/guards/rolesRules.ts (5)

2-7: New entities and imports are correct.

The addition of CaseTransition, CaseType, User, and UserRole aligns with the PR objective.


198-229: Updates to prosecutorTransitionRule are correct.

The updates to include CaseTransition.DENY_INDICTMENT and the logic for handling transitions align with the PR objective.


240-244: Updates to prosecutorRepresentativeTransitionRule are correct.

The updates to allow prosecutor representatives to ask for confirmation, cancellation, and delete align with the PR objective.


254-266: Updates to defenderTransitionRule are correct.

The updates to handle the withdrawal of appeals align with the PR objective.


347-363: Introduction of districtCourtJudgeSignRulingRule is correct.

The new rule to allow district court judges to sign rulings aligns with the PR objective.

apps/judicial-system/backend/src/app/modules/case/case.controller.ts (2)

768-768: Change to use districtCourtJudgeSignRulingRule is correct.

The update aligns with the PR objective of allowing district court judges to sign rulings.


805-805: Change to use districtCourtJudgeSignRulingRule is correct.

The update aligns with the PR objective of allowing district court judges to sign rulings.

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b4285a7 and e1f01f1.

Files selected for processing (1)
  • apps/judicial-system/backend/src/app/modules/case/guards/rolesRules.ts (8 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/judicial-system/backend/src/app/modules/case/guards/rolesRules.ts

@datadog-island-is
Copy link

Datadog Report

Branch report: j-s/fix-prosecutor-representative-permissions
Commit report: 6a39114
Test service: judicial-system-backend

✅ 0 Failed, 19817 Passed, 0 Skipped, 18m 23.25s Total Time
🔻 Test Sessions change in coverage: 1 decreased (-0.05%)

🔻 Code Coverage Decreases vs Default Branch (1)

Copy link

codecov bot commented Jul 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.02%. Comparing base (38fe437) to head (a34ea47).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15416      +/-   ##
==========================================
- Coverage   37.02%   37.02%   -0.01%     
==========================================
  Files        6541     6541              
  Lines      133684   133664      -20     
  Branches    38240    38231       -9     
==========================================
- Hits        49501    49487      -14     
+ Misses      84183    84177       -6     
Flag Coverage Δ
api 3.44% <ø> (ø)
application-templates-accident-notification 19.93% <ø> (ø)
feature-flags 90.16% <ø> (ø)
file-storage 52.17% <ø> (ø)
financial-aid-shared 19.03% <ø> (ø)
judicial-system-formatters 80.41% <ø> (ø)
judicial-system-scheduler 58.04% <ø> (ø)
nest-feature-flags 51.46% <ø> (ø)
services-auth-admin-api 51.11% <ø> (ø)
services-auth-delegation-api 61.61% <ø> (ø)
services-auth-ids-api 54.67% <ø> (ø)
services-auth-personal-representative 48.28% <ø> (ø)
services-auth-personal-representative-public 44.14% <ø> (ø)
services-auth-public-api 51.08% <ø> (ø)
services-sessions 65.37% <ø> (-0.05%) ⬇️
services-university-gateway 48.56% <ø> (+0.11%) ⬆️
services-user-notification 48.04% <ø> (ø)
shared-mocking 64.62% <ø> (ø)
shared-problem 87.50% <ø> (ø)

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

Files Coverage Δ
...em/backend/src/app/modules/case/case.controller.ts 84.15% <ø> (+0.15%) ⬆️
.../backend/src/app/modules/case/guards/rolesRules.ts 64.10% <ø> (+5.01%) ⬆️

... and 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 38fe437...a34ea47. Read the comment docs.

Copy link
Member

@unakb unakb left a comment

Choose a reason for hiding this comment

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

Nice, love the explanatory comments on the PR as well 🙏😁

@gudjong gudjong added deprecated:automerge (Disabled) Merge this PR as soon as all checks pass labels Jul 3, 2024
@kodiakhq kodiakhq bot merged commit dc2ec0a into main Jul 3, 2024
245 checks passed
@kodiakhq kodiakhq bot deleted the j-s/fix-prosecutor-representative-permissions branch July 3, 2024 21:09
oskarjs pushed a commit that referenced this pull request Aug 20, 2024
* Fixes and improves roles rules logic

* Fixes typo

---------

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
deprecated:automerge (Disabled) Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants