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(ui-fields): Add max rows to TableRepeaterFormField #15000

Merged
merged 6 commits into from
May 29, 2024

Conversation

veronikasif
Copy link
Member

@veronikasif veronikasif commented May 29, 2024

What

Add max rows to TableRepeaterFormField

Why

To be able to limit the number of rows that can be added to the table. When the maximum is reached, the button to add a new row is disabled.
This is optional and is set using maxRows: number, e.g. maxRows: 2 allows the applicant to add two rows ​​to the table.

Screenshots / Gifs

image

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 maxValues and maxRows parameters to limit the number of values and rows in table repeaters.
  • Enhancements

    • Updated the table repeater component to disable the "Add Item" button when the maximum number of values or rows is reached.

@veronikasif veronikasif requested a review from a team as a code owner May 29, 2024 13:46
Copy link
Contributor

coderabbitai bot commented May 29, 2024

Walkthrough

The recent changes introduce new parameters maxValues and maxRows to the buildTableRepeaterField function and the TableRepeaterField type. These parameters control the maximum number of values and rows that can be added to a table, respectively. The TableRepeaterFormField component has been updated to utilize these parameters, ensuring that the "Add Item" button is disabled when the maximum limits are reached.

Changes

File Path Change Summary
.../fieldBuilders.ts Added maxValues and maxRows parameters to the buildTableRepeaterField function.
.../Fields.ts Introduced the maxValues property to the TableRepeaterField type.
.../TableRepeaterFormField.tsx Updated TableRepeaterFormField component to include maxValues and maxRows properties, and control the "Add Item" button's state based on these limits.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant TableRepeaterFormField
    participant FieldBuilders
    participant ApplicationTypes

    User->>TableRepeaterFormField: Click "Add Item"
    TableRepeaterFormField->>TableRepeaterFormField: Check maxValues and maxRows
    alt Can Add Item
        TableRepeaterFormField->>FieldBuilders: Add new item
    else Cannot Add Item
        TableRepeaterFormField->>User: Disable "Add Item" button
    end
Loading

This diagram illustrates the interaction between the user and the TableRepeaterFormField component, showing how the new parameters maxValues and maxRows control the ability to add new items.


Tip

Early Access Features
  • gpt-4o model for chat

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

CodeRabbit Configration File (.coderabbit.yaml)

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

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (4)
libs/application/ui-fields/src/lib/TableRepeaterFormField/TableRepeaterFormField.tsx (4)

63-63: Ensure proper documentation for the maxValues property in the component's prop description.


Line range hint 149-149: JSX elements without children should be self-closing for cleaner code.

- <T.HeadData></T.HeadData>
+ <T.HeadData />

Line range hint 161-161: JSX elements without children should be self-closing for cleaner code.

- <T.Data></T.Data>
+ <T.Data />

Line range hint 268-268: Prefer template literals over string concatenation for consistency and readability.

- id + 'title'
+ `${id}title`
Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 6234b82 and 2fb4f80.
Files selected for processing (3)
  • libs/application/core/src/lib/fieldBuilders.ts (2 hunks)
  • libs/application/types/src/lib/Fields.ts (1 hunks)
  • libs/application/ui-fields/src/lib/TableRepeaterFormField/TableRepeaterFormField.tsx (3 hunks)
Additional Context Used
Biome (26)
libs/application/core/src/lib/fieldBuilders.ts (3)

1-44: Some named imports are only used as types.


45-46: All these imports are only used as types.


46-47: All these imports are only used as types.

libs/application/types/src/lib/Fields.ts (13)

320-320: Unexpected any. Specify a different type.


334-334: Unexpected any. Specify a different type.


10-11: All these imports are only used as types.


11-12: All these imports are only used as types.


12-13: All these imports are only used as types.


13-14: All these imports are only used as types.


14-15: All these imports are only used as types.


15-16: All these imports are only used as types.


16-17: All these imports are only used as types.


17-18: All these imports are only used as types.


18-19: All these imports are only used as types.


19-20: All these imports are only used as types.


20-21: All these imports are only used as types.

libs/application/ui-fields/src/lib/TableRepeaterFormField/TableRepeaterFormField.tsx (10)

149-149: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.


158-168: Change to an optional chain.


161-161: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.


268-268: Template literals are preferred over string concatenation.


1-5: All these imports are only used as types.


26-27: Some named imports are only used as types.


151-151: Avoid using the index of an array as key property in an element.


160-160: Avoid using the index of an array as key property in an element.


163-163: Avoid using the index of an array as key property in an element.


218-218: Avoid using the index of an array as key property in an element.

Path-based Instructions (3)
libs/application/ui-fields/src/lib/TableRepeaterFormField/TableRepeaterFormField.tsx (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/types/src/lib/Fields.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/core/src/lib/fieldBuilders.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 (4)
libs/application/ui-fields/src/lib/TableRepeaterFormField/TableRepeaterFormField.tsx (2)

316-316: The logic to disable the "Add Item" button based on maxValues is correctly implemented and integrated into the JSX structure.


86-86: The logic to disable the "Add Item" button based on maxValues is correctly implemented. However, consider adding a unit test to verify this behavior.

libs/application/types/src/lib/Fields.ts (1)

509-513: The addition of the maxValues property to the TableRepeaterField interface is well-documented and aligns with the PR's objectives to limit the number of items in a table.

libs/application/core/src/lib/fieldBuilders.ts (1)

Line range hint 748-768: The buildTableRepeaterField function correctly integrates the maxValues parameter, allowing it to be set when building a TableRepeaterField. This change is consistent with the PR's objectives and the updates in other files.

@veronikasif veronikasif added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label May 29, 2024
@datadog-island-is
Copy link

datadog-island-is bot commented May 29, 2024

Datadog Report

Branch report: feat/table-repeater-add-max-values
Commit report: a0001e5
Test service: judicial-system-web

✅ 0 Failed, 312 Passed, 0 Skipped, 1m 6.99s Total Time
➡️ Test Sessions change in coverage: 1 no change

Copy link

codecov bot commented May 29, 2024

Codecov Report

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

Project coverage is 37.08%. Comparing base (cf2f7ea) to head (092c1ec).
Report is 1 commits behind head on main.

Current head 092c1ec differs from pull request most recent head 1420115

Please upload reports for the commit 1420115 to get more accurate results.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15000      +/-   ##
==========================================
- Coverage   37.08%   37.08%   -0.01%     
==========================================
  Files        6393     6393              
  Lines      130145   130146       +1     
  Branches    37124    37125       +1     
==========================================
  Hits        48270    48270              
- Misses      81875    81876       +1     
Flag Coverage Δ
air-discount-scheme-web 0.00% <ø> (ø)
api 3.46% <ø> (ø)
application-api-files 56.40% <ø> (ø)
application-core 71.72% <ø> (+0.26%) ⬆️
application-system-api 41.98% <ø> (ø)
application-template-api-modules 24.29% <ø> (ø)
application-templates-accident-notification 19.67% <ø> (ø)
application-templates-car-recycling 4.23% <ø> (ø)
application-templates-criminal-record 21.84% <ø> (ø)
application-templates-driving-license 16.47% <ø> (ø)
application-templates-estate 11.75% <ø> (ø)
application-templates-example-payment 20.49% <ø> (ø)
application-templates-financial-aid 11.92% <ø> (ø)
application-templates-general-petition 19.14% <ø> (ø)
application-templates-health-insurance 23.10% <ø> (ø)
application-templates-inheritance-report 3.96% <ø> (ø)
application-templates-marriage-conditions 10.07% <ø> (ø)
application-templates-parental-leave 28.43% <ø> (ø)
application-types 7.39% <ø> (ø)
application-ui-components 1.44% <ø> (ø)
application-ui-shell 21.70% <0.00%> (-0.01%) ⬇️
clients-charge-fjs-v2 22.58% <ø> (ø)
judicial-system-api 17.65% <ø> (ø)
judicial-system-backend 55.91% <ø> (ø)
judicial-system-formatters 81.29% <ø> (ø)
judicial-system-message 65.65% <ø> (ø)
judicial-system-types 48.92% <ø> (ø)
judicial-system-web 28.03% <ø> (ø)
web 1.91% <ø> (ø)

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

Files Coverage Δ
libs/application/core/src/lib/fieldBuilders.ts 37.01% <ø> (ø)
libs/application/types/src/lib/Fields.ts 100.00% <ø> (ø)
.../TableRepeaterFormField/TableRepeaterFormField.tsx 2.08% <0.00%> (-0.03%) ⬇️

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 302a1c0...1420115. Read the comment docs.

Copy link
Member

@Toti91 Toti91 left a comment

Choose a reason for hiding this comment

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

Nice feature!

Maybe maxValues could be more descriptive if renamed to maxRows?

@veronikasif veronikasif requested a review from Toti91 May 29, 2024 15:14
@veronikasif veronikasif changed the title feat(ui-fields): Add max values to TableRepeaterFormField feat(ui-fields): Add max rows to TableRepeaterFormField May 29, 2024
Copy link
Member

@Toti91 Toti91 left a comment

Choose a reason for hiding this comment

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

Nice

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 (3)
libs/application/ui-fields/src/lib/TableRepeaterFormField/TableRepeaterFormField.tsx (3)

Line range hint 149-149: JSX elements without children should be self-closing for consistency and readability.

- <T.HeadData></T.HeadData>
+ <T.HeadData />

Line range hint 161-161: JSX elements without children should be self-closing for consistency and readability.

- <T.Data></T.Data>
+ <T.Data />

Line range hint 268-268: Use template literals for string concatenation to improve readability.

- id + 'title'
+ `${id}title`
Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 2fb4f80 and 1420115.
Files selected for processing (3)
  • libs/application/core/src/lib/fieldBuilders.ts (2 hunks)
  • libs/application/types/src/lib/Fields.ts (1 hunks)
  • libs/application/ui-fields/src/lib/TableRepeaterFormField/TableRepeaterFormField.tsx (3 hunks)
Additional Context Used
Biome (26)
libs/application/core/src/lib/fieldBuilders.ts (3)

1-44: Some named imports are only used as types.


45-46: All these imports are only used as types.


46-47: All these imports are only used as types.

libs/application/types/src/lib/Fields.ts (13)

320-320: Unexpected any. Specify a different type.


334-334: Unexpected any. Specify a different type.


10-11: All these imports are only used as types.


11-12: All these imports are only used as types.


12-13: All these imports are only used as types.


13-14: All these imports are only used as types.


14-15: All these imports are only used as types.


15-16: All these imports are only used as types.


16-17: All these imports are only used as types.


17-18: All these imports are only used as types.


18-19: All these imports are only used as types.


19-20: All these imports are only used as types.


20-21: All these imports are only used as types.

libs/application/ui-fields/src/lib/TableRepeaterFormField/TableRepeaterFormField.tsx (10)

149-149: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.


158-168: Change to an optional chain.


161-161: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.


268-268: Template literals are preferred over string concatenation.


1-5: All these imports are only used as types.


26-27: Some named imports are only used as types.


151-151: Avoid using the index of an array as key property in an element.


160-160: Avoid using the index of an array as key property in an element.


163-163: Avoid using the index of an array as key property in an element.


218-218: Avoid using the index of an array as key property in an element.

Path-based Instructions (3)
libs/application/ui-fields/src/lib/TableRepeaterFormField/TableRepeaterFormField.tsx (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/types/src/lib/Fields.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/core/src/lib/fieldBuilders.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 (4)
libs/application/ui-fields/src/lib/TableRepeaterFormField/TableRepeaterFormField.tsx (2)

86-86: The logic for disabling the "Add Item" button based on maxRows is correctly implemented.


316-316: The logic to disable the "Add Item" button based on the canAddItem condition is correctly implemented.

libs/application/types/src/lib/Fields.ts (1)

509-513: The maxRows property is well-documented, clearly explaining its purpose and effect.

libs/application/core/src/lib/fieldBuilders.ts (1)

Line range hint 748-768: The buildTableRepeaterField function correctly integrates the maxRows parameter, ensuring it is passed along to the TableRepeaterField type.

@kodiakhq kodiakhq bot merged commit 3bf1b64 into main May 29, 2024
24 checks passed
@kodiakhq kodiakhq bot deleted the feat/table-repeater-add-max-values branch May 29, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated:automerge (Disabled) Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants