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(j-s): Allow district court assistant to act as registrar in R cases #17772

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

unakb
Copy link
Member

@unakb unakb commented Jan 31, 2025

Asana

What

Allow district court assistant to see and work on request cases in the same way a registrar can.

Why

Because they are supposed to be able to assist with performing the same actions as registrars.

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

Release Notes

  • New Features

    • Expanded role-based access for district court assistants in case management
    • More flexible registrar selection for request cases
  • Improvements

    • Simplified user role validation for case updates
    • Enhanced case filtering logic for district court users
    • Streamlined test cases for court user roles
  • Access Control

    • Updated permissions for district court assistants to view and manage cases
    • Removed specific role restrictions in case filtering mechanisms

@unakb unakb requested a review from a team as a code owner January 31, 2025 16:27
Copy link
Contributor

coderabbitai bot commented Jan 31, 2025

Walkthrough

This pull request introduces modifications to the judicial system's backend and web applications, focusing on expanding user role validation and access criteria. The changes primarily affect how district court users, particularly assistants and registrars, can interact with cases. The modifications simplify role-based access logic, broaden the eligibility for case assignments, and adjust filtering mechanisms across multiple components of the judicial system application.

Changes

File Change Summary
apps/judicial-system/backend/src/app/modules/case/case.controller.ts Expanded role validation for registrarId, now including DISTRICT_COURT_ASSISTANT alongside DISTRICT_COURT_REGISTRAR
apps/judicial-system/backend/src/app/modules/case/filters/case.filter.ts Removed role-specific access check for district court users, allowing broader case access
apps/judicial-system/backend/src/app/modules/case/filters/cases.filter.ts Refactored query filter logic to consolidate and simplify case access conditions
apps/judicial-system/backend/src/app/modules/case/filters/test/districtCourtUserFilter.spec.ts Updated test suite to use dynamic role imports and remove manual role filtering
apps/judicial-system/web/src/routes/Court/components/ReceptionAndAssignment/SelectCourtOfficials/SelectCourtOfficials.tsx Added isRequestCase import to expand registrar selection criteria
apps/judicial-system/web/src/routes/Shared/Cases/useFilter.tsx Simplified filter options logic by removing DISTRICT_COURT_ASSISTANT role check

Possibly related PRs

Suggested Labels

automerge

Suggested Reviewers

  • oddsson
  • thorhildurt
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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

nx-cloud bot commented Jan 31, 2025

View your CI Pipeline Execution ↗ for commit 9ef5772.

Command Status Duration Result
nx run-many --projects judicial-system-backend ... ❌ Failed 25m 38s View ↗
nx run-many --projects judicial-system-web --ta... ❌ Failed 1m 47s View ↗
nx run-many --target=build --projects=judicial-... ✅ Succeeded 2m 56s View ↗
nx run-many --target=lint --projects=judicial-s... ✅ Succeeded 18s View ↗
nx run-many --target=codegen/frontend-client --... ✅ Succeeded 12s View ↗
nx run-many --target=codegen/backend-schema --a... ✅ Succeeded 22s View ↗
nx run-many --target=build --projects=judicial-... ✅ Succeeded 17s View ↗

☁️ Nx Cloud last updated this comment at 2025-02-03 12:05:56 UTC

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

🧹 Nitpick comments (1)
apps/judicial-system/backend/src/app/modules/case/filters/cases.filter.ts (1)

111-142: LGTM! Query filter logic simplified.

The consolidation of query options improves code maintainability. Consider extracting the state arrays into constants for better reusability.

+const RESTRICTION_INVESTIGATION_STATES = [
+  CaseState.DRAFT,
+  CaseState.SUBMITTED,
+  CaseState.RECEIVED,
+  CaseState.ACCEPTED,
+  CaseState.REJECTED,
+  CaseState.DISMISSED,
+]
+
+const INDICTMENT_STATES = [
+  CaseState.SUBMITTED,
+  CaseState.WAITING_FOR_CANCELLATION,
+  CaseState.RECEIVED,
+  CaseState.COMPLETED,
+]

 options.push({
   [Op.or]: [
     {
       [Op.and]: [
         { type: [...restrictionCases, ...investigationCases] },
         {
-          state: [
-            CaseState.DRAFT,
-            CaseState.SUBMITTED,
-            CaseState.RECEIVED,
-            CaseState.ACCEPTED,
-            CaseState.REJECTED,
-            CaseState.DISMISSED,
-          ],
+          state: RESTRICTION_INVESTIGATION_STATES,
         },
       ],
     },
     {
       [Op.and]: [
         { type: indictmentCases },
         {
-          state: [
-            CaseState.SUBMITTED,
-            CaseState.WAITING_FOR_CANCELLATION,
-            CaseState.RECEIVED,
-            CaseState.COMPLETED,
-          ],
+          state: INDICTMENT_STATES,
         },
       ],
     },
   ],
 })
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 80377e1 and c34fc04.

📒 Files selected for processing (6)
  • apps/judicial-system/backend/src/app/modules/case/case.controller.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/filters/case.filter.ts (0 hunks)
  • apps/judicial-system/backend/src/app/modules/case/filters/cases.filter.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/case/filters/test/districtCourtUserFilter.spec.ts (1 hunks)
  • apps/judicial-system/web/src/routes/Court/components/ReceptionAndAssignment/SelectCourtOfficials/SelectCourtOfficials.tsx (2 hunks)
  • apps/judicial-system/web/src/routes/Shared/Cases/useFilter.tsx (1 hunks)
💤 Files with no reviewable changes (1)
  • apps/judicial-system/backend/src/app/modules/case/filters/case.filter.ts
🧰 Additional context used
📓 Path-based instructions (5)
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."
apps/judicial-system/web/src/routes/Shared/Cases/useFilter.tsx (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/filters/test/districtCourtUserFilter.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/web/src/routes/Court/components/ReceptionAndAssignment/SelectCourtOfficials/SelectCourtOfficials.tsx (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/filters/cases.filter.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 (1)
apps/judicial-system/backend/src/app/modules/case/filters/test/districtCourtUserFilter.spec.ts (1)
Learnt from: gudjong
PR: island-is/island.is#16389
File: apps/judicial-system/backend/src/app/modules/case/test/limitedAccessCaseController/getCaseFilesRecordPdfRolesRules.spec.ts:1-1
Timestamp: 2024-11-12T15:15:20.157Z
Learning: The usage of `defenderRule` in the following test files is intentional and should remain unchanged:

- `apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/createPresignedPostRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/deleteCaseFileRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/createCaseFileRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/getCaseFileSignedUrlRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/case/test/limitedAccessCaseController/getRulingPdfRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/case/test/limitedAccessCaseController/getRequestPdfRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/case/test/limitedAccessCaseController/getCourtRecordPdfRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/case/test/limitedAccessCaseController/getByIdRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/case/test/limitedAccessCaseController/getAllFilesZipRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/case/test/caseController/getAllRolesRules.spec.ts`
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: tests (judicial-system-backend)
🔇 Additional comments (5)
apps/judicial-system/backend/src/app/modules/case/filters/test/districtCourtUserFilter.spec.ts (1)

65-65: Great improvement in test coverage!

Using districtCourtRoles instead of hardcoded roles enhances maintainability and ensures comprehensive testing across all district court roles.

apps/judicial-system/web/src/routes/Shared/Cases/useFilter.tsx (1)

82-82: LGTM! Aligns with PR objectives.

The change correctly removes filter restrictions for district court assistants while maintaining necessary restrictions for prosecutor representatives.

Run this script to verify the impact:

✅ Verification successful

Verification successful: District court assistants have unrestricted access

The code correctly implements the intended changes:

  • No filtering restrictions exist for district court assistants
  • Only prosecutor representatives have specific filtering limitations
  • The default behavior grants full access to all case types
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that district court assistants have access to all case types
# Test: Search for any remaining restrictions on DISTRICT_COURT_ASSISTANT
rg -A 5 "DISTRICT_COURT_ASSISTANT.*INVESTIGATION|DISTRICT_COURT_ASSISTANT.*INDICTMENT"

Length of output: 88


Script:

#!/bin/bash
# Get the complete useFilter.tsx file
echo "=== useFilter.tsx content ==="
cat apps/judicial-system/web/src/routes/Shared/Cases/useFilter.tsx

echo -e "\n=== Searching for UserRole-based filtering ==="
rg "UserRole\." -A 3 apps/judicial-system/web/src/routes/Shared/Cases/

echo -e "\n=== Searching for DISTRICT_COURT_ASSISTANT usage ==="
rg "DISTRICT_COURT_ASSISTANT" -A 3

Length of output: 16570

apps/judicial-system/web/src/routes/Court/components/ReceptionAndAssignment/SelectCourtOfficials/SelectCourtOfficials.tsx (2)

5-5: LGTM! Proper import added.

The isRequestCase import is correctly added to support the new role validation logic.


77-79: LGTM! Role validation enhanced.

The condition correctly allows district court assistants to act as registrars in request cases while maintaining existing functionality.

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

203-203: LGTM! The role expansion aligns with the PR objective.

The addition of UserRole.DISTRICT_COURT_ASSISTANT to the list of allowed roles for registrar assignments is consistent with the goal of enabling district court assistants to act as registrars in R cases. The implementation maintains type safety and follows NestJS best practices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants