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

chore(j-s): Hide laws broken #16477

Merged
merged 2 commits into from
Oct 18, 2024
Merged

chore(j-s): Hide laws broken #16477

merged 2 commits into from
Oct 18, 2024

Conversation

oddsson
Copy link
Member

@oddsson oddsson commented Oct 18, 2024

Hide laws broken

Asana

What

Hide laws broken accordion from indictment cases

Why

The list of laws broken is not complete and does not serve a purpose at the moment. We do however want to keep the code as the list will be complete in the coming days / weeks

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

    • Temporarily hidden display of the IndictmentsLawsBrokenAccordionItem component across various overview routes to indicate incomplete functionality.
    • Adjusted conditions for displaying the InfoCardClosedIndictment component in the PublicProsecutor route.
  • Bug Fixes

    • Preserved core logic and structure of components while implementing temporary visibility changes.

@oddsson oddsson requested a review from a team as a code owner October 18, 2024 15:28
Copy link
Contributor

coderabbitai bot commented Oct 18, 2024

Walkthrough

The changes involve modifications to several Overview.tsx components and the Completed.tsx component within the judicial system application. The primary alteration is the temporary hiding of the IndictmentsLawsBrokenAccordionItem component, now wrapped in a comment block, indicating that its display is incomplete. Additionally, the PublicProsecutor route's InfoCardClosedIndictment component has been adjusted to include a new condition based on workingCase.indictmentRulingDecision. The overall structure and functionality of the components remain unchanged.

Changes

File Path Change Summary
.../Completed/Completed.tsx Commented out the IndictmentsLawsBrokenAccordionItem component, preserving logic for merged cases.
.../Indictments/Overview/Overview.tsx Commented out the IndictmentsLawsBrokenAccordionItem component across multiple routes; adjusted InfoCardClosedIndictment logic in PublicProsecutor.

Possibly related PRs

  • feat(j-s): Completed indictment overview #14780: The changes in the Overview.tsx components across different routes involve temporarily hiding the IndictmentsLawsBrokenAccordionItem, which is directly related to the modifications made in the main PR regarding the same component.
  • fix(j-s): Indictment Post Processing #15077: This PR updates the Completed.tsx file to conditionally render sections based on the indictmentRulingDecision, which aligns with the changes made in the main PR that also involve conditional rendering based on case decisions.
  • fix(j-s): Disable ServiceRequirement rather then hiding it when sent to public prosecutor #15850: The changes in Completed.tsx introduce a new boolean constant isRuling, which refines the conditional rendering logic, similar to the modifications in the main PR that involve conditional display logic based on the hasLawsBroken and hasMergeCases variables.
  • feat(j-s): Civil Claimants Info Card #16113: The introduction of the CivilClaimantInfo component in this PR enhances the display of information related to civil claimants, which may relate to the overall structure and display logic in the Completed.tsx and Overview.tsx components modified in the main PR.

Suggested labels

automerge

Suggested reviewers

  • unakb

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

🧹 Outside diff range and nitpick comments (4)
apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx (2)

114-122: Approved: Temporary hiding of incomplete "laws broken" section

The change aligns with the PR objectives by commenting out the rendering of the IndictmentsLawsBrokenAccordionItem. The explanatory comment is clear and helpful for other developers.

Consider the following suggestions:

  1. Update any related unit tests to account for this temporary change.
  2. Add a TODO comment with a ticket number (if applicable) to track when this section should be re-enabled.
  3. Ensure that any documentation mentioning this feature is updated to reflect its temporary removal.

Line range hint 1-185: Approved: Overall structure and NextJS/TypeScript usage

The component adheres to NextJS best practices and makes good use of TypeScript for type safety. The structure is well-organized and follows React best practices.

For improved type safety, consider adding explicit return types to the component and any internal functions, e.g.:

const IndictmentOverview: React.FC = (): JSX.Element => {
  // ...
}

const handleNavigationTo = useCallback(
  async (destination: string): Promise<void> => {
    // ...
  },
  [router, updateDefendant, workingCase.defendants, workingCase.id],
)
apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx (1)

161-169: Approved: Temporary hiding of IndictmentsLawsBrokenAccordionItem

The change aligns with the PR objective to hide the "laws broken" accordion section. The explanatory comment is clear and helpful.

Consider adding a TODO comment with a ticket number or date for when this should be revisited, to ensure it's not forgotten. For example:

// TODO(TICKET-123): Re-enable this section once the list of laws broken is complete
apps/judicial-system/web/src/routes/Court/Indictments/Completed/Completed.tsx (1)

156-162: LGTM! Consider adding a TODO comment for future reference.

The change aligns with the PR objectives to hide the "laws broken" accordion section. The explanatory comment is clear and helpful. To improve maintainability, consider adding a TODO comment with a ticket number or date for when this should be revisited.

You could add a TODO comment like this:

// TODO: Uncomment this section once the list of laws broken is complete for indictment cases (TICKET-123)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1972eb3 and 34bb008.

📒 Files selected for processing (5)
  • apps/judicial-system/web/src/routes/Court/Indictments/Completed/Completed.tsx (1 hunks)
  • apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx (1 hunks)
  • apps/judicial-system/web/src/routes/Prosecutor/Indictments/Overview/Overview.tsx (1 hunks)
  • apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx (1 hunks)
  • apps/judicial-system/web/src/routes/Shared/IndictmentOverview/IndictmentOverview.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
apps/judicial-system/web/src/routes/Court/Indictments/Completed/Completed.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/web/src/routes/Court/Indictments/Overview/Overview.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/web/src/routes/Prosecutor/Indictments/Overview/Overview.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/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.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/web/src/routes/Shared/IndictmentOverview/IndictmentOverview.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."
📓 Learnings (4)
apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx (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: unakb
PR: island-is/island.is#15378
File: apps/judicial-system/web/src/routes/Court/Indictments/Summary/Summary.tsx:86-100
Timestamp: 2024-10-08T15:39:04.351Z
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.
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Overview/Overview.tsx (3)
Learnt from: unakb
PR: island-is/island.is#14712
File: apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/IndictmentOverview.tsx:0-0
Timestamp: 2024-10-08T15:39:04.351Z
Learning: The judicial system application uses a toaster notification system to handle errors globally.
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: unakb
PR: island-is/island.is#15378
File: apps/judicial-system/web/src/routes/Court/Indictments/Summary/Summary.tsx:86-100
Timestamp: 2024-10-08T15:39:04.351Z
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.
apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx (1)
Learnt from: unakb
PR: island-is/island.is#14712
File: apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/IndictmentOverview.tsx:0-0
Timestamp: 2024-10-08T15:39:04.351Z
Learning: The judicial system application uses a toaster notification system to handle errors globally.
apps/judicial-system/web/src/routes/Shared/IndictmentOverview/IndictmentOverview.tsx (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: unakb
PR: island-is/island.is#15378
File: apps/judicial-system/web/src/routes/Court/Indictments/Summary/Summary.tsx:86-100
Timestamp: 2024-10-08T15:39:04.351Z
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.
🔇 Additional comments (5)
apps/judicial-system/web/src/routes/Shared/IndictmentOverview/IndictmentOverview.tsx (1)

157-163: Approved: Hiding of "laws broken" section aligns with PR objectives.

The commented-out section effectively hides the IndictmentsLawsBrokenAccordionItem as intended. The explanatory comment provides clear context for this change.

Suggestions for improvement:

  1. Consider removing the hasLawsBroken calculation (line 146) if it's not used elsewhere in the component.
  2. Adjust the surrounding conditional logic (line 156) to remove hasLawsBroken:
    {hasMergeCases && (
      <Box marginBottom={5}>
        <Accordion>
          {/* ... */}
        </Accordion>
      </Box>
    )}

To ensure this change doesn't impact other parts of the component, please run:

✅ Verification successful

Verified: Hiding of the "laws broken" section is correctly implemented.

The IndictmentsLawsBrokenAccordionItem component has been successfully commented out as intended. However, the hasLawsBroken variable remains in use within conditional statements, which may no longer be necessary.

Suggestions for improvement:

  1. Remove the hasLawsBroken variable if it isn't used elsewhere in the component.
  2. Adjust the surrounding conditional logic to exclude hasLawsBroken:
    {hasMergeCases && (
      <Box marginBottom={5}>
        <Accordion>
          {/* ... */}
        </Accordion>
      </Box>
    )}
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify usage of hasLawsBroken and IndictmentsLawsBrokenAccordionItem
rg --type typescript 'hasLawsBroken|IndictmentsLawsBrokenAccordionItem' apps/judicial-system/web/src/routes/Shared/IndictmentOverview/

Length of output: 171


Script:

#!/bin/bash
# Verify usage of hasLawsBroken and IndictmentsLawsBrokenAccordionItem
rg --type ts --type tsx 'hasLawsBroken|IndictmentsLawsBrokenAccordionItem' apps/judicial-system/web/src/routes/Shared/IndictmentOverview/

Length of output: 167


Script:

#!/bin/bash
# Verify usage of hasLawsBroken and IndictmentsLawsBrokenAccordionItem
rg 'hasLawsBroken|IndictmentsLawsBrokenAccordionItem' apps/judicial-system/web/src/routes/Shared/IndictmentOverview/ --glob '*.ts' --glob '*.tsx'

Length of output: 812

apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx (2)

Line range hint 89-100: Verify the condition for displaying the verdict button

The new condition workingCase.indictmentRulingDecision === CaseIndictmentRulingDecision.RULING for showing the defendantInfoActionButton looks good. It adds more specificity to when the verdict can be displayed.

Please confirm that this is the intended behavior:

  1. The verdict display button should only be shown when the indictment ruling decision is specifically set to RULING.
  2. For other indictment ruling decisions, the button should not be displayed.

If this is correct, the implementation looks good. If not, please clarify the intended behavior.


Line range hint 1-247: Overall implementation follows best practices

The component structure, use of React hooks, and TypeScript implementation align well with NextJS best practices and coding guidelines. The code demonstrates:

  1. Effective use of TypeScript for type safety.
  2. Proper use of React hooks for state management and side effects.
  3. Correct usage of Next.js's useRouter for navigation.

The overall architecture and implementation of this component are sound and maintainable.

apps/judicial-system/web/src/routes/Court/Indictments/Completed/Completed.tsx (1)

Line range hint 1-385: Great job adhering to NextJS and TypeScript best practices!

The component demonstrates excellent use of NextJS conventions and TypeScript for type safety. It follows modern React patterns with functional components and hooks, and efficiently manages state using React hooks and context. The code structure is clean and well-organized.

apps/judicial-system/web/src/routes/Prosecutor/Indictments/Overview/Overview.tsx (1)

232-238: Approve change and suggest minor improvements

The change aligns with the PR objective of hiding the "laws broken" accordion section. Good job on commenting out the code instead of removing it, as it preserves the implementation for future use.

Consider the following improvements:

  1. Remove the conditional rendering to clean up the code:
-            {/* 
-            NOTE: Temporarily hidden while list of laws broken is not complete in
-            indictment cases
-            
-            {hasLawsBroken && (
-              <IndictmentsLawsBrokenAccordionItem workingCase={workingCase} />
-            )} */}
+            {/* 
+            TODO: Uncomment and implement when the list of laws broken is complete in indictment cases
+            <IndictmentsLawsBrokenAccordionItem workingCase={workingCase} />
+            */}
  1. Verify if any imports related to the IndictmentsLawsBrokenAccordionItem component are now unused and remove them if necessary.
✅ Verification successful

Approve change and suggest minor improvements

The change aligns with the PR objective of hiding the "laws broken" accordion section. Good job on commenting out the code instead of removing it, as it preserves the implementation for future use.

Consider the following improvement:

  1. Remove the conditional rendering to clean up the code:
    -            {/* 
    -            NOTE: Temporarily hidden while list of laws broken is not complete in
    -            indictment cases
    -            
    -            {hasLawsBroken && (
    -              <IndictmentsLawsBrokenAccordionItem workingCase={workingCase} />
    -            )} */}
    +            {/* 
    +            TODO: Uncomment and implement when the list of laws broken is complete in indictment cases
    +            <IndictmentsLawsBrokenAccordionItem workingCase={workingCase} />
    +            */}
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for unused imports
rg --type typescript "import.*IndictmentsLawsBrokenAccordionItem" apps/judicial-system/web/src/routes/Prosecutor/Indictments/Overview/Overview.tsx

Length of output: 183


Script:

#!/bin/bash
# Check for unused imports of IndictmentsLawsBrokenAccordionItem using ast-grep
ast-grep --lang typescript --pattern '
import $_ from ".*IndictmentsLawsBrokenAccordionItem.*";
if (!$_) {
  // IndictmentsLawsBrokenAccordionItem is imported but not used
}' apps/judicial-system/web/src/routes/Prosecutor/Indictments/Overview/Overview.tsx

Length of output: 815


Script:

#!/bin/bash
# Check for import of IndictmentsLawsBrokenAccordionItem
rg "import .*IndictmentsLawsBrokenAccordionItem" apps/judicial-system/web/src/routes/Prosecutor/Indictments/Overview/Overview.tsx

# Check for usage of IndictmentsLawsBrokenAccordionItem
rg "IndictmentsLawsBrokenAccordionItem" apps/judicial-system/web/src/routes/Prosecutor/Indictments/Overview/Overview.tsx

Length of output: 369

Copy link

codecov bot commented Oct 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.76%. Comparing base (81a9fcb) to head (c3cd1c9).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16477      +/-   ##
==========================================
- Coverage   36.76%   36.76%   -0.01%     
==========================================
  Files        6838     6835       -3     
  Lines      141611   141476     -135     
  Branches    40345    40290      -55     
==========================================
- Hits        52069    52017      -52     
+ Misses      89542    89459      -83     
Flag Coverage Δ
api 3.37% <ø> (ø)
application-system-api 41.36% <ø> (ø)
application-template-api-modules 27.85% <ø> (-0.02%) ⬇️
application-ui-shell 21.37% <ø> (ø)
judicial-system-web 27.93% <ø> (+0.01%) ⬆️
web 1.81% <ø> (ø)

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

Files with missing lines Coverage Δ
...c/routes/Court/Indictments/Completed/Completed.tsx 0.00% <ø> (ø)
...src/routes/Court/Indictments/Overview/Overview.tsx 0.00% <ø> (ø)
...outes/Prosecutor/Indictments/Overview/Overview.tsx 0.00% <ø> (ø)
...PublicProsecutor/Indictments/Overview/Overview.tsx 7.93% <ø> (+0.24%) ⬆️
...s/Shared/IndictmentOverview/IndictmentOverview.tsx 0.00% <ø> (ø)

... and 14 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 81a9fcb...c3cd1c9. Read the comment docs.

@datadog-island-is
Copy link

Datadog Report

All test runs 3e69f14 🔗

101 Total Test Services: 0 Failed, 98 Passed
🔻 Test Sessions change in coverage: 2 decreased, 1 increased (+0.2%), 197 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
air-discount-scheme-backend 0 0 0 81 0 23.43s N/A Link
air-discount-scheme-web 0 0 0 2 0 9.03s N/A Link
api 0 0 0 4 0 2.85s N/A Link
api-catalogue-services 0 0 0 23 0 11.78s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 17.48s N/A Link
api-domains-assets 0 0 0 3 0 11.19s N/A Link
api-domains-auth-admin 0 0 0 18 0 12.22s 1 no change Link
api-domains-communications 0 0 0 5 0 30.56s N/A Link
api-domains-criminal-record 0 0 0 5 0 9.16s N/A Link
api-domains-driving-license 0 0 0 23 0 27.38s N/A Link

🔻 Code Coverage Decreases vs Default Branch (2)

  • services-auth-delegation-api - jest 51.22% (-0.19%) - Details
  • application-template-api-modules - jest 30.08% (-0.01%) - Details

@gudjong gudjong added the automerge Merge this PR as soon as all checks pass label Oct 18, 2024
@kodiakhq kodiakhq bot merged commit 5a37233 into main Oct 18, 2024
44 checks passed
@kodiakhq kodiakhq bot deleted the j-s/hide-laws-broken branch October 18, 2024 19:24
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