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(signature-collection): Sign parliamentary list hooked up #15927

Merged
merged 9 commits into from
Sep 11, 2024

Conversation

juni-haukur
Copy link
Member

@juni-haukur juni-haukur commented Sep 9, 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

    • Introduced a new optional field for party ballot letter in the signature collection candidate model.
    • Added functionality for parliamentary list signing with a new module and service.
    • Enhanced forms to dynamically retrieve and display relevant data based on user input.
    • Integrated new APIs for checking signing eligibility and retrieving lists.
    • Added support for different list types and improved slug generation.
  • Bug Fixes

    • Improved error handling and validation logic in the signing process.
  • Documentation

    • Updated messages to include dynamic content for better user context.
  • Chores

    • Refined data schema to accommodate additional properties for list management.

@juni-haukur juni-haukur requested review from a team as code owners September 9, 2024 15:12
Copy link
Contributor

coderabbitai bot commented Sep 9, 2024

Warning

Rate limit exceeded

@juni-haukur has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 6 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 48f30d9 and 232f370.

Walkthrough

This pull request introduces enhancements to the signature collection functionality within the application. Key changes include the addition of a new optional field in the SignatureCollectionCandidate class, the introduction of the ParliamentaryListSigningModule and ParliamentaryListSigningService, and the integration of new APIs for checking signing eligibility and retrieving lists. Various forms were updated to improve data handling and user interaction, alongside modifications to the data schema and messages for better context and validation. Additionally, updates were made to the list.dto.ts file to support different list types and slug generation.

Changes

File Change Summary
libs/api/domains/signature-collection/src/lib/models/candidate.model.ts Added an optional field partyBallotLetter to the SignatureCollectionCandidate class.
libs/application/template-api-modules/src/lib/modules/templates/index.ts Added ParliamentaryListSigningModule and ParliamentaryListSigningService to exports.
libs/application/template-api-modules/src/lib/modules/templates/signature-collection/parliamentary-list-signing/parliamentary-list-signing.module.ts Defined the ParliamentaryListSigningModule, including a register method for configuration and importing necessary modules.
libs/application/template-api-modules/src/lib/modules/templates/signature-collection/parliamentary-list-signing/parliamentary-list-signing.service.ts Introduced ParliamentaryListSigningService with methods for signing lists, checking eligibility, and retrieving lists.
libs/application/templates/signature-collection/parliamentary-list-signing/src/dataProviders/index.ts Added CanSignApi and GetListApi for user permissions and data retrieval.
libs/application/templates/signature-collection/parliamentary-list-signing/src/forms/Done.ts Modified description to be dynamic, incorporating values from the Application object.
libs/application/templates/signature-collection/parliamentary-list-signing/src/forms/Draft.ts Added a hidden input field listId and modified existing fields to retrieve dynamic values based on external data.
libs/application/templates/signature-collection/parliamentary-list-signing/src/forms/Prerequisites.ts Integrated CanSignApi and GetListApi into the form's data provider list.
libs/application/templates/signature-collection/parliamentary-list-signing/src/lib/dataSchema.ts Added new fields listId and list to the dataSchema for enhanced data validation.
libs/application/templates/signature-collection/parliamentary-list-signing/src/lib/messages.ts Modified listSignedDescription message to support dynamic content and markdown formatting.
libs/application/templates/signature-collection/parliamentary-list-signing/src/lib/signListTemplate.ts Added initialQueryParameter and updated the API array to include new APIs while uncommenting the onEntry function call.
libs/clients/signature-collection/src/lib/types/list.dto.ts Added ListType enum and modified getSlug function to handle different list types for slug generation.
libs/clients/signature-collection/src/lib/signature-collection.service.spec.ts Modified expected output of a test case to remove trailing slash in the slug property of the result.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Frontend
    participant ParliamentaryListSigningService
    participant SignatureCollectionClientService

    User->>Frontend: Initiates signing process
    Frontend->>ParliamentaryListSigningService: Calls signList()
    ParliamentaryListSigningService->>SignatureCollectionClientService: Sign list with ID
    SignatureCollectionClientService-->>ParliamentaryListSigningService: Returns signature result
    ParliamentaryListSigningService-->>Frontend: Returns success or error
    Frontend-->>User: Displays result
Loading

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

Outside diff range, codebase verification and nitpick comments (1)
libs/application/template-api-modules/src/lib/modules/templates/signature-collection/parliamentary-list-signing/parliamentary-list-signing.service.ts (1)

37-67: Review TypeScript type definitions and consider removing redundant comments.

The method canSign includes a comment about TypeScript checking which might be redundant if the types are defined correctly. Ensure that the types for canSignInfo are properly defined to make this comment unnecessary.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d652bf1 and 9dac87c.

Files selected for processing (11)
  • libs/api/domains/signature-collection/src/lib/models/candidate.model.ts (1 hunks)
  • libs/application/template-api-modules/src/lib/modules/templates/index.ts (3 hunks)
  • libs/application/template-api-modules/src/lib/modules/templates/signature-collection/parliamentary-list-signing/parliamentary-list-signing.module.ts (1 hunks)
  • libs/application/template-api-modules/src/lib/modules/templates/signature-collection/parliamentary-list-signing/parliamentary-list-signing.service.ts (1 hunks)
  • libs/application/templates/signature-collection/parliamentary-list-signing/src/dataProviders/index.ts (1 hunks)
  • libs/application/templates/signature-collection/parliamentary-list-signing/src/forms/Done.ts (2 hunks)
  • libs/application/templates/signature-collection/parliamentary-list-signing/src/forms/Draft.ts (2 hunks)
  • libs/application/templates/signature-collection/parliamentary-list-signing/src/forms/Prerequisites.ts (2 hunks)
  • libs/application/templates/signature-collection/parliamentary-list-signing/src/lib/dataSchema.ts (1 hunks)
  • libs/application/templates/signature-collection/parliamentary-list-signing/src/lib/messages.ts (1 hunks)
  • libs/application/templates/signature-collection/parliamentary-list-signing/src/lib/signListTemplate.ts (4 hunks)
Files not reviewed due to server errors (2)
  • libs/application/templates/signature-collection/parliamentary-list-signing/src/lib/signListTemplate.ts
  • libs/application/templates/signature-collection/parliamentary-list-signing/src/forms/Draft.ts
Additional context used
Path-based instructions (11)
libs/application/templates/signature-collection/parliamentary-list-signing/src/lib/dataSchema.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/api/domains/signature-collection/src/lib/models/candidate.model.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/application/templates/signature-collection/parliamentary-list-signing/src/dataProviders/index.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/application/template-api-modules/src/lib/modules/templates/signature-collection/parliamentary-list-signing/parliamentary-list-signing.module.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/application/templates/signature-collection/parliamentary-list-signing/src/forms/Done.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/application/templates/signature-collection/parliamentary-list-signing/src/forms/Prerequisites.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/application/template-api-modules/src/lib/modules/templates/signature-collection/parliamentary-list-signing/parliamentary-list-signing.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/application/templates/signature-collection/parliamentary-list-signing/src/lib/signListTemplate.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/application/templates/signature-collection/parliamentary-list-signing/src/forms/Draft.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/application/templates/signature-collection/parliamentary-list-signing/src/lib/messages.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/application/template-api-modules/src/lib/modules/templates/index.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."
Biome
libs/application/template-api-modules/src/lib/modules/templates/signature-collection/parliamentary-list-signing/parliamentary-list-signing.module.ts

[error] 14-26: Avoid classes that contain only static members.

Prefer using simple functions instead of classes with only static members.

(lint/complexity/noStaticOnlyClass)

Additional comments not posted (5)
libs/application/template-api-modules/src/lib/modules/templates/signature-collection/parliamentary-list-signing/parliamentary-list-signing.module.ts (1)

14-26: Justification for using a static method in NestJS module configuration.

The use of a static method here is typical for NestJS modules, which often utilize static methods for configuration purposes. This pattern is well-suited for setting up modules dynamically based on passed configurations and is a common practice in NestJS applications.

Despite the static analysis tool's suggestion to avoid classes with only static members, in this context, it aligns with NestJS's design patterns and is necessary for the modular architecture of the application.

Tools
Biome

[error] 14-26: Avoid classes that contain only static members.

Prefer using simple functions instead of classes with only static members.

(lint/complexity/noStaticOnlyClass)

libs/application/templates/signature-collection/parliamentary-list-signing/src/forms/Done.ts (1)

35-40: Enhancement in user experience through dynamic description.

The implementation of a dynamic description function in the Done form is a significant enhancement. It uses the Application object to personalize the completion message based on user input, which improves user interaction and satisfaction.

This change not only makes the form more responsive but also demonstrates effective use of dynamic data within the application's forms.

libs/application/templates/signature-collection/parliamentary-list-signing/src/forms/Prerequisites.ts (1)

80-89: Proper integration of new data providers enhances form functionality.

The addition of CanSignApi and GetListApi to the Prerequisites form is a crucial enhancement that allows the form to interact with external APIs to check signing eligibility and retrieve lists. This integration significantly enhances the form's capabilities and aligns with the objectives of expanding its functionality.

While the implementation appears correct, it is recommended to verify the proper integration and functionality of these APIs through testing.

Run the following script to verify the API integration:

Verification successful

Integration of CanSignApi and GetListApi is confirmed.

The CanSignApi and GetListApi are properly integrated into the Prerequisites form and other components, as evidenced by their usage and definition in the codebase. They are set up as template APIs with specific actions, indicating their role in enhancing the form's functionality.

To ensure these APIs function as intended, it is recommended to conduct runtime testing to verify their interactions and responses.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `CanSignApi` and `GetListApi`.

# Test: Search for API usage in the application. Expect: Proper handling and responses.
rg --type typescript -A 5 $'CanSignApi|GetListApi'

Length of output: 86


Script:

#!/bin/bash
# Description: Verify the integration of `CanSignApi` and `GetListApi`.

# Test: Search for API usage in the application. Expect: Proper handling and responses.
rg --type ts -A 5 $'CanSignApi|GetListApi'

Length of output: 10159

libs/application/templates/signature-collection/parliamentary-list-signing/src/lib/messages.ts (1)

152-153: Approved changes with suggestions for verification.

The updates to the listSignedDescription message enhance its functionality by supporting markdown and dynamic content. Ensure that the application correctly renders markdown and integrates dynamic data where {name} is used.

Run the following script to verify markdown rendering and data integration:

libs/application/template-api-modules/src/lib/modules/templates/index.ts (1)

145-146: Approved additions with suggestions for verification.

The addition of ParliamentaryListSigningModule and ParliamentaryListSigningService expands the application's capabilities in handling parliamentary list signing. Ensure that these new entities are correctly integrated and used appropriately within the application.

Run the following script to verify the integration and usage of the new module and service:

Also applies to: 218-218, 291-291

Verification successful

Integration and Usage Verified

The ParliamentaryListSigningModule and ParliamentaryListSigningService are correctly integrated and used within the application. They are properly imported, exported, and defined, with no conflicts or issues identified in the existing functionality.

  • ParliamentaryListSigningModule and ParliamentaryListSigningService are imported and exported in libs/application/template-api-modules/src/lib/modules/templates/index.ts.
  • ParliamentaryListSigningService extends BaseTemplateApiService and is provided and exported by ParliamentaryListSigningModule.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration and usage of `ParliamentaryListSigningModule` and `ParliamentaryListSigningService`.

# Test: Search for the usage of these entities in the application. Expect: Correct integration and no conflicts with existing functionality.
rg --type typescript -A 5 $'ParliamentaryListSigningModule|ParliamentaryListSigningService'

Length of output: 127


Script:

#!/bin/bash
# Description: Verify the integration and usage of `ParliamentaryListSigningModule` and `ParliamentaryListSigningService`.

# Test: Search for the usage of these entities in the application. Expect: Correct integration and no conflicts with existing functionality.
rg --type ts -A 5 $'ParliamentaryListSigningModule|ParliamentaryListSigningService'

Length of output: 5844

Copy link
Member

@albinagu albinagu left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link

codecov bot commented Sep 9, 2024

Codecov Report

Attention: Patch coverage is 32.50000% with 54 lines in your changes missing coverage. Please review.

Project coverage is 36.84%. Comparing base (900c342) to head (232f370).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...list-signing/parliamentary-list-signing.service.ts 15.51% 49 Missing ⚠️
...nts/signature-collection/src/lib/types/list.dto.ts 44.44% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##             main   #15927    +/-   ##
========================================
  Coverage   36.83%   36.84%            
========================================
  Files        6693     6702     +9     
  Lines      137256   137374   +118     
  Branches    39041    39070    +29     
========================================
+ Hits        50562    50615    +53     
- Misses      86694    86759    +65     
Flag Coverage Δ
api 3.39% <ø> (ø)
application-system-api 41.69% <32.50%> (+<0.01%) ⬆️
application-template-api-modules 23.46% <0.00%> (-0.09%) ⬇️
application-ui-shell 21.08% <ø> (ø)

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

Files with missing lines Coverage Δ
...ate-api-modules/src/lib/modules/templates/index.ts 100.00% <100.00%> (ø)
...-list-signing/parliamentary-list-signing.module.ts 100.00% <100.00%> (ø)
...liamentary-list-signing/src/dataProviders/index.ts 100.00% <100.00%> (ø)
...n/parliamentary-list-signing/src/lib/dataSchema.ts 66.66% <ø> (ø)
...ction/parliamentary-list-signing/src/lib/errors.ts 100.00% <ø> (ø)
...ion/parliamentary-list-signing/src/lib/messages.ts 100.00% <ø> (ø)
...iamentary-list-signing/src/lib/signListTemplate.ts 47.61% <100.00%> (ø)
libs/clients/signature-collection/src/index.ts 100.00% <100.00%> (ø)
...nts/signature-collection/src/lib/types/list.dto.ts 28.30% <44.44%> (+2.21%) ⬆️
...list-signing/parliamentary-list-signing.service.ts 15.51% <15.51%> (ø)

... and 2 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 900c342...232f370. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Sep 9, 2024

Datadog Report

All test runs f236212 🔗

4 Total Test Services: 0 Failed, 4 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.06%), 2 increased, 8 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 3.08s 1 no change Link
application-system-api 0 0 0 111 2 3m 18.65s 1 increased (+0.02%) Link
application-template-api-modules 0 0 0 109 0 1m 54.61s 1 decreased (-0.06%) Link
application-ui-shell 0 0 0 74 0 36.65s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • application-template-api-modules - jest 25.55% (-0.06%) - Details

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, codebase verification and nitpick comments (1)
libs/clients/signature-collection/src/lib/types/list.dto.ts (1)

56-63: LGTM, but remove the console.log statement.

The code changes are approved.

However, please remove the console.log statement at line 57 as it is not necessary.

Apply this diff to remove the console.log statement:

-  console.log(type)
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e76ae0d and ac2eb1f.

Files selected for processing (1)
  • libs/clients/signature-collection/src/lib/types/list.dto.ts (4 hunks)
Additional context used
Path-based instructions (1)
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."
Additional comments not posted (3)
libs/clients/signature-collection/src/lib/types/list.dto.ts (3)

10-10: LGTM!

The code changes are approved.


20-23: LGTM!

The code changes are approved.


130-130: LGTM!

The code changes are approved.

@juni-haukur juni-haukur added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Sep 11, 2024
@kodiakhq kodiakhq bot merged commit 9225400 into main Sep 11, 2024
38 checks passed
@kodiakhq kodiakhq bot deleted the feat/sign-parliamentary-list branch September 11, 2024 10:12
@coderabbitai coderabbitai bot mentioned this pull request Sep 12, 2024
6 tasks
jonnigs pushed a commit that referenced this pull request Sep 12, 2024
* sign parliamentary list hooked up

* update errors

* fix type from feedback

* Answers as a type

* update slug

* fix test after update

* remove debug

---------

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.

4 participants