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(signature-collection): Fix collection and signature active state #16206

Merged
merged 6 commits into from
Sep 30, 2024

Conversation

juni-haukur
Copy link
Member

@juni-haukur juni-haukur commented Sep 30, 2024

...

Attach a link to issue if relevant

What

Specify what you're trying to achieve

Why

Specify why you need to achieve this

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

    • Added optional query parameters shouldToggle and shouldLock to the respective endpoints for enhanced functionality.
    • Introduced new properties urvinnslaLokid and locked in relevant data models to indicate processing and locking status.
  • Bug Fixes

    • Simplified logic for determining if a user can unsign a list, improving clarity and functionality.
  • Documentation

    • Updated API specifications to reflect new parameters, responses, and data model properties.

@juni-haukur juni-haukur requested a review from a team as a code owner September 30, 2024 09:45
Copy link
Contributor

coderabbitai bot commented Sep 30, 2024

Walkthrough

The pull request introduces several updates to the MedmaeliRestAPI, specifically enhancing the /Admin/Medmaelalisti/{ID}/ToggleList and /Admin/Medmaelalisti/{ID}/LockList endpoints by adding optional query parameters and expanding response types. Additionally, it modifies data models to include new properties indicating processing and locking states. Changes in the SignatureCollectionClientService and related DTOs streamline logic regarding signature unsigning and update properties related to list activity and review status.

Changes

File Path Change Summary
libs/clients/signature-collection/src/clientConfig.json Updated OpenAPI specification for /Admin/Medmaelalisti/{ID}/ToggleList and /Admin/Medmaelalisti/{ID}/LockList endpoints, adding optional query parameters and expanding response types.
libs/clients/signature-collection/src/lib/signature-collection.service.ts Modified getSignedList method to consolidate conditions for unsigning a list, clarifying logic related to signature validity and locking.
libs/clients/signature-collection/src/lib/types/list.dto.ts Altered mapList function to change how isActive and reviewed properties are determined, impacting the construction of List objects.
libs/clients/signature-collection/src/lib/types/signature.dto.ts Introduced a new optional locked property in the Signature interface and updated the mapSignature function to include this property in the returned object.
libs/clients/signature-collection/src/lib/signature-collection.service.spec.ts Updated test cases to reflect new properties and logic changes, including checks for locked property and adjustments for methods like getLists, createLists, removeLists, signList, and unsignList.

Possibly related PRs

Suggested reviewers

  • albinagu

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

🧹 Outside diff range and nitpick comments (6)
libs/clients/signature-collection/src/lib/types/signature.dto.ts (2)

17-17: LGTM! Consider adding JSDoc comment for clarity.

The addition of the locked property to the Signature interface is well-implemented and aligns with the PR objectives. It correctly uses TypeScript for type definition, adhering to the coding guidelines.

Consider adding a JSDoc comment to explain the purpose of the locked property. For example:

/** Indicates whether the signature is locked and cannot be modified */
locked: boolean

This would enhance code readability and maintainability.


44-44: LGTM! Consider consistent property ordering.

The update to the mapSignature function correctly handles the new locked property, maintaining consistency with the Signature interface. The use of the nullish coalescing operator is a good practice for providing a default value.

For better code organization and readability, consider ordering the properties in the return object to match the order in the Signature interface. This would mean moving the locked property just before the valid property:

return {
  // ... other properties
  isInitialType,
  locked: signature.locked ?? false,
  valid: signature.valid ?? true,
}

This minor change would enhance consistency between the interface definition and its implementation.

libs/clients/signature-collection/src/clientConfig.json (4)

180-215: Approved: Enhanced endpoint functionality and documentation

The changes to the /Admin/Medmaelalisti/{ID}/ToggleList endpoint are well-implemented:

  1. The new summary clearly describes the endpoint's purpose.
  2. The optional shouldToggle parameter provides more flexibility.
  3. The additional 204 No Content response covers a valid use case.

These improvements enhance both the functionality and the documentation of the API.

Consider adding a brief description for the ID parameter in the path, similar to how you've described the shouldToggle parameter. This would further improve the API documentation.


Line range hint 217-253: Approved: Well-structured new endpoint for locking lists

The new /Admin/Medmaelalisti/{ID}/LockList endpoint is a valuable addition:

  1. It follows a consistent pattern with the ToggleList endpoint, which is good for API usability.
  2. The summary clearly describes the endpoint's purpose.
  3. The optional shouldLock parameter provides flexibility in the locking action.
  4. Appropriate response statuses (200, 204, 400) are included.

For consistency with the ToggleList endpoint, consider adding a brief description for the ID parameter in the path. This would maintain a uniform level of detail across similar endpoints.


2131-2131: Approved: New property added to MedmaelalistiBaseDTO

The addition of the urvinnslaLokid boolean property to the MedmaelalistiBaseDTO schema is appropriate:

  1. It likely represents whether the processing of the list is completed.
  2. The property is consistent with the DTO's purpose of representing basic information about a "Medmaelalisti".
  3. The naming follows the convention of existing properties.

Consider adding a brief description or comment for the urvinnslaLokid property to clarify its purpose and usage. This would enhance the schema's documentation and make it easier for API consumers to understand the property's significance.


2331-2332: Approved: New 'locked' property added to MedmaeliDTO

The addition of the locked boolean property to the MedmaeliDTO schema is a valuable update:

  1. It likely represents whether the "Medmaeli" entry is locked or not.
  2. This new state information could be related to the newly added LockList endpoint, providing a cohesive API design.
  3. The property name follows the convention of existing properties in the schema.

To improve clarity and documentation, consider adding a brief description or comment for the locked property. This would help API consumers understand the property's purpose and its relationship to other API functionalities, such as the new LockList endpoint.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d399cd8 and 3e74898.

📒 Files selected for processing (4)
  • libs/clients/signature-collection/src/clientConfig.json (5 hunks)
  • libs/clients/signature-collection/src/lib/signature-collection.service.ts (1 hunks)
  • libs/clients/signature-collection/src/lib/types/list.dto.ts (1 hunks)
  • libs/clients/signature-collection/src/lib/types/signature.dto.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
libs/clients/signature-collection/src/clientConfig.json (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."
libs/clients/signature-collection/src/lib/signature-collection.service.ts (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."
libs/clients/signature-collection/src/lib/types/list.dto.ts (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."
libs/clients/signature-collection/src/lib/types/signature.dto.ts (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 (5)
libs/clients/signature-collection/src/lib/types/signature.dto.ts (1)

Line range hint 1-44: Overall, the changes look good. Verify usage across the codebase.

The addition of the locked property to the Signature interface and its implementation in the mapSignature function are well-executed. These changes align with the PR objectives and adhere to the coding guidelines for this library.

To ensure the changes are fully integrated, please run the following script to verify the usage of the locked property across the codebase:

This script will help identify any areas in the codebase that might need updates to accommodate the new locked property, ensuring comprehensive integration of the changes.

✅ Verification successful

Verification Successful: locked property is correctly implemented and utilized.
The locked property has been properly added to the Signature interface and is used appropriately within the signature.dto.ts and signature-collection.service.ts files. No further issues detected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new 'locked' property in Signature interface and related functions

# Test 1: Check for any usages of the 'locked' property in Signature interface
echo "Checking for usages of 'locked' property in Signature interface:"
rg --type typescript "Signature.*\{[^}]*locked" libs

# Test 2: Check for any usages of 'locked' property in functions handling Signature objects
echo "Checking for usages of 'locked' property in functions handling Signature objects:"
rg --type typescript "signature\.locked" libs

# Test 3: Check for any TODO comments related to 'locked' property
echo "Checking for any TODO comments related to 'locked' property:"
rg --type typescript "TODO.*locked" libs

Length of output: 711


Script:

#!/bin/bash
# Description: Verify the usage of the new 'locked' property in Signature interface and related functions

# Test 1: Check for any usages of the 'locked' property in Signature interface
echo "Checking for usages of 'locked' property in Signature interface:"
rg -g "*.ts*" "Signature\s*\{[^}]*locked" libs

# Test 2: Check for any usages of 'locked' property in functions handling Signature objects
echo "Checking for usages of 'locked' property in functions handling Signature objects:"
rg -g "*.ts*" "signature\.locked" libs

# Test 3: Check for any TODO comments related to 'locked' property
echo "Checking for any TODO comments related to 'locked' property:"
rg -g "*.ts*" "TODO.*locked" libs

Length of output: 797

libs/clients/signature-collection/src/clientConfig.json (1)

2148-2148: Approved: Consistent update to MedmaelalistiDTO

The addition of the urvinnslaLokid boolean property to the MedmaelalistiDTO schema is appropriate:

  1. It mirrors the change in the MedmaelalistiBaseDTO schema, maintaining consistency between the base and extended DTOs.
  2. The extended DTO correctly includes all properties of the base DTO, following good object-oriented design principles.

This change ensures that the MedmaelalistiDTO remains in sync with its base type, providing a complete representation of a "Medmaelalisti" entity.

libs/clients/signature-collection/src/lib/types/list.dto.ts (3)

112-113: Ensure correct mapping of isActive property.

The assignment const isActive = list.listaLokad ?? false relies on list.listaLokad. Please verify that listaLokad accurately represents the active state of the list. Changing the source of isActive may impact application logic that depends on this property.


114-114: Verify the use of list.urvinnslaLokid for reviewed status.

The reviewed property is now set using list.urvinnslaLokid ?? false. Ensure that urvinnslaLokid correctly reflects whether the list has been reviewed to prevent any unintended behaviors in the application.


Line range hint 66-118: Function mapList adheres to TypeScript best practices.

The mapList function effectively maps the MedmaelalistiDTO to the List interface, utilizing TypeScript types and interfaces appropriately. This enhances type safety and maintainability.

Copy link

codecov bot commented Sep 30, 2024

Codecov Report

Attention: Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.

Project coverage is 36.66%. Comparing base (4db48bd) to head (49bfe61).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...collection/src/lib/signature-collection.service.ts 0.00% 5 Missing ⚠️
...nts/signature-collection/src/lib/types/list.dto.ts 0.00% 2 Missing ⚠️
...ignature-collection/src/lib/types/signature.dto.ts 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16206      +/-   ##
==========================================
- Coverage   36.69%   36.66%   -0.03%     
==========================================
  Files        6778     6778              
  Lines      139671   139654      -17     
  Branches    39719    39710       -9     
==========================================
- Hits        51247    51205      -42     
- Misses      88424    88449      +25     
Flag Coverage Δ
air-discount-scheme-web 0.00% <ø> (ø)
api 3.39% <ø> (ø)
application-api-files 57.65% <ø> (ø)
application-core 71.62% <ø> (ø)
application-system-api 41.63% <0.00%> (ø)
application-template-api-modules 23.72% <ø> (+0.01%) ⬆️
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% <ø> (ø)
contentful-apps 5.76% <ø> (ø)
download-service 44.63% <ø> (ø)
financial-aid-backend 56.54% <ø> (ø)
financial-aid-shared 19.03% <ø> (ø)
island-ui-core 28.47% <ø> (ø)
judicial-system-web 28.16% <ø> (ø)
portals-admin-regulations-admin 1.88% <ø> (ø)
portals-core 16.17% <ø> (ø)
services-auth-personal-representative 45.49% <ø> (-0.03%) ⬇️
shared-components 27.68% <ø> (ø)
shared-form-fields 31.61% <ø> (ø)
web 1.83% <ø> (ø)

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

Files with missing lines Coverage Δ
...ignature-collection/src/lib/types/signature.dto.ts 16.66% <0.00%> (-0.99%) ⬇️
...nts/signature-collection/src/lib/types/list.dto.ts 28.30% <0.00%> (ø)
...collection/src/lib/signature-collection.service.ts 6.94% <0.00%> (+0.03%) ⬆️

... and 8 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 4db48bd...49bfe61. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Sep 30, 2024

Datadog Report

All test runs 342a6db 🔗

35 Total Test Services: 0 Failed, 34 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.22%), 151 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-web 0 0 0 2 0 8.51s 1 no change Link
api 0 0 0 4 0 2.98s 1 no change Link
application-api-files 0 0 0 12 0 6.74s 1 no change Link
application-core 0 0 0 90 0 21.36s 1 no change Link
application-system-api 0 0 0 111 2 3m 19.49s 1 no change Link
application-template-api-modules 0 0 0 109 0 1m 54.28s 1 no change Link
application-templates-accident-notification 0 0 0 98 0 19.97s 1 no change Link
application-templates-criminal-record 0 0 0 2 0 9.79s 1 no change Link
application-templates-driving-license 0 0 0 13 0 15.76s 1 no change Link
application-templates-example-payment 0 0 0 2 0 11.06s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • clients-signature-collection - jest 22.25% (-0.22%) - Details

@albinagu albinagu 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: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 3e74898 and 9b941b5.

📒 Files selected for processing (2)
  • libs/clients/signature-collection/src/lib/signature-collection.service.spec.ts (3 hunks)
  • libs/clients/signature-collection/src/lib/types/list.dto.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • libs/clients/signature-collection/src/lib/types/list.dto.ts
🧰 Additional context used
📓 Path-based instructions (1)
libs/clients/signature-collection/src/lib/signature-collection.service.spec.ts (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."

@kodiakhq kodiakhq bot merged commit ce108c5 into main Sep 30, 2024
126 checks passed
@kodiakhq kodiakhq bot deleted the fix/signature-collection-active branch September 30, 2024 12:28
thoreyjona pushed a commit that referenced this pull request Oct 2, 2024
…16206)

* Fix collection and signature active state

* fix collection isActive

---------

Co-authored-by: albinagu <47886428+albinagu@users.noreply.github.com>
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