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(web): Tag filtering for generic lists #15196

Merged
merged 14 commits into from
Jun 19, 2024

Conversation

RunarVestmann
Copy link
Member

@RunarVestmann RunarVestmann commented Jun 11, 2024

Tag filtering for generic lists

What

  • Allow filtering generic list items by tag

Screenshots / Gifs

Screen.Recording.2024-06-18.at.16.00.51.mov

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

    • Enhanced filtering functionality in the GenericList component, including tag selection and search parameters.
    • Improved UI for filtering with category selection and tag display.
    • Responsive design adjustments based on viewport width.
  • Bug Fixes

    • Improved error handling.
    • Enhanced pagination behavior.
  • Refactor

    • Updated item rendering logic and state management in the GenericList component.

Copy link
Contributor

coderabbitai bot commented Jun 11, 2024

Walkthrough

The updates introduce a comprehensive filtering system across multiple components, allowing users to filter lists using tags. Major additions include new state management in GenericList for handling tag filters, updated GraphQL queries to support tag-based filtering, and backend adjustments to process these filters. Error handling, pagination, and responsive design improvements were also made to enhance the user experience.

Changes

Files Summarized Changes
apps/web/components/GenericList/GenericList.tsx Added imports, declarations; updated GenericList component for filtering, tag selection, search parameters, item rendering, state management, API querying, responsive design UI.
apps/web/components/Organization/Slice/SliceMachine.tsx Modified the renderSlice function to include filterTags prop and remove firstPageItemResponse in GenericList component.
apps/web/screens/queries/GenericList.ts Updated GET_GENERIC_LIST_ITEMS_QUERY to include input tags and filterTags fields in items.
apps/web/screens/queries/fragments.ts Replaced firstPageListItemResponse with filterTags in the GraphQL query export.
apps/web/utils/richText.tsx Updated GenericList rendering logic by removing firstPageItemResponse and adding filterTags prop.
libs/cms/src/lib/cms.elasticsearch.service.ts Changed must variable from const to let and added logic to concatenate queries based on tags and tagGroups inputs.
libs/cms/src/lib/cms.module.ts Removed GenericListResolver from imports and providers list.
libs/cms/src/lib/cms.resolver.ts Removed GenericListResolver class and its associated decorators and methods.
libs/cms/src/lib/dto/getGenericListItems.input.ts Added tags and tagGroups fields with string[] and Record<string, string[]> types respectively.
libs/cms/src/lib/generated/contentfulTypes.d.ts Added filterTags property to IGenericListFields interface and slug property to IGenericListItemFields interface.
libs/cms/src/lib/models/genericList.model.ts Modified GenericList class to include filterTags field, added mapping function for it.
libs/cms/src/lib/models/genericListItem.model.ts Added filterTags field and mapping logic in GenericListItem model. Updated imports accordingly.
libs/cms/src/lib/search/importers/genericListItem.service.ts Modified initialization of tags field in GenericListItemSyncService, added new object based on tag data, used nullish coalescing operator for handling null/undefined values.

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

codecov bot commented Jun 11, 2024

Codecov Report

Attention: Patch coverage is 6.77966% with 110 lines in your changes missing coverage. Please review.

Project coverage is 37.15%. Comparing base (ba8bf43) to head (2dc490c).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15196      +/-   ##
==========================================
- Coverage   37.17%   37.15%   -0.03%     
==========================================
  Files        6474     6474              
  Lines      131745   131820      +75     
  Branches    37643    37686      +43     
==========================================
- Hits        48974    48973       -1     
- Misses      82771    82847      +76     
Flag Coverage Δ
api 3.48% <ø> (ø)
api-domains-communications 40.65% <38.88%> (-0.03%) ⬇️
application-system-api 42.10% <42.10%> (-0.01%) ⬇️
application-template-api-modules 24.24% <ø> (+0.01%) ⬆️
cms 0.44% <0.00%> (-0.01%) ⬇️
cms-translations 39.76% <38.88%> (-0.02%) ⬇️
judicial-system-api 18.20% <ø> (ø)
services-user-notification 48.18% <42.10%> (-0.07%) ⬇️
web 1.92% <0.00%> (-0.01%) ⬇️

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

Files Coverage Δ
...web/components/Organization/Slice/SliceMachine.tsx 0.00% <ø> (ø)
apps/web/screens/queries/GenericList.ts 0.00% <ø> (ø)
apps/web/screens/queries/fragments.ts 0.00% <ø> (ø)
apps/web/utils/richText.tsx 0.00% <ø> (ø)
libs/cms/src/lib/cms.module.ts 100.00% <ø> (ø)
libs/cms/src/lib/cms.resolver.ts 66.87% <ø> (-0.07%) ⬇️
libs/cms/src/lib/dto/getGenericListItems.input.ts 63.15% <66.66%> (-1.13%) ⬇️
libs/cms/src/lib/models/genericList.model.ts 60.86% <50.00%> (-1.64%) ⬇️
libs/cms/src/lib/models/genericListItem.model.ts 46.87% <50.00%> (+0.44%) ⬆️
...rc/lib/search/importers/genericListItem.service.ts 17.85% <0.00%> (-0.67%) ⬇️
... and 2 more

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 ba8bf43...2dc490c. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Jun 11, 2024

Datadog Report

All test runs 0f0bbb3 🔗

12 Total Test Services: 0 Failed, 11 Passed
🔻 Test Sessions change in coverage: 4 decreased, 24 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
api 0 0 0 4 0 4.47s 1 no change Link
api-domains-communications 0 0 0 5 0 37.6s 1 decreased (-0.03%) Link
api-domains-license-service 0 0 0 0 0 1.08s 1 no change Link
application-system-api 0 0 0 111 2 2m 26.26s 1 no change Link
application-template-api-modules 0 0 0 109 0 1m 50.44s 1 no change Link
cms-translations 0 0 0 3 0 48.35s 1 decreased (-0.02%) Link
judicial-system-api 0 0 0 54 0 12.99s 1 no change Link
judicial-system-backend 0 0 0 20150 0 17m 41.5s 1 no change Link
judicial-system-message 0 0 0 31 0 17.52s 1 no change Link
judicial-system-message-handler 0 0 0 3 0 12.31s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (4)

  • api-domains-communications - jest 50.09% (-0.03%) - Details
  • services-user-notification - jest 71.32% (-0.02%) - Details
  • cms-translations - jest 49.54% (-0.02%) - Details
  • web - jest 2.63% (-0.01%) - Details

@RunarVestmann RunarVestmann force-pushed the feature/web-generic-list-tag-filtering branch from b20e9f7 to a1524f0 Compare June 12, 2024 10:27
@RunarVestmann RunarVestmann added the automerge Merge this PR as soon as all checks pass label Jun 18, 2024
@RunarVestmann RunarVestmann marked this pull request as ready for review June 18, 2024 16:06
@RunarVestmann RunarVestmann requested review from a team as code owners June 18, 2024 16:06
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

Outside diff range and nitpick comments (2)
libs/cms/src/lib/cms.resolver.ts (2)

Line range hint 133-133: Incorrect use of decorators on method parameters.

Decorators in TypeScript are not valid on method parameters unless explicitly enabled in the TypeScript configuration. This is a common source of errors and can lead to unexpected behavior. Here's a suggested fix:

- @CacheControl(defaultCache)
+ // Decorator removed due to invalid usage on method parameters.

Please verify if the decorator is necessary and if so, consider enabling parameter decorators in your TypeScript configuration or use decorators correctly on class methods or properties.


Line range hint 145-145: Multiple instances of incorrect decorator usage on method parameters.

Decorators are consistently misused across various methods in this file, applied incorrectly on method parameters. This misuse can lead to compile-time errors or unexpected behavior at runtime. Here's a general suggestion for all occurrences:

- @CacheControl(defaultCache)
+ // Decorator removed due to invalid usage on method parameters.

Please review all instances where decorators are applied to method parameters, and either adjust the TypeScript configuration to allow this pattern or correct the decorator placement.

Also applies to: 153-153, 161-161, 169-169, 177-177, 185-185, 196-196, 204-204, 212-212, 220-220, 232-232, 243-243, 254-254, 265-265, 276-276, 288-288, 295-295, 303-303, 311-311

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4862a0a and 104bae9.

Files selected for processing (13)
  • apps/web/components/GenericList/GenericList.tsx (9 hunks)
  • apps/web/components/Organization/Slice/SliceMachine.tsx (1 hunks)
  • apps/web/screens/queries/GenericList.ts (2 hunks)
  • apps/web/screens/queries/fragments.ts (1 hunks)
  • apps/web/utils/richText.tsx (1 hunks)
  • libs/cms/src/lib/cms.elasticsearch.service.ts (2 hunks)
  • libs/cms/src/lib/cms.module.ts (2 hunks)
  • libs/cms/src/lib/cms.resolver.ts (1 hunks)
  • libs/cms/src/lib/dto/getGenericListItems.input.ts (2 hunks)
  • libs/cms/src/lib/generated/contentfulTypes.d.ts (2 hunks)
  • libs/cms/src/lib/models/genericList.model.ts (3 hunks)
  • libs/cms/src/lib/models/genericListItem.model.ts (3 hunks)
  • libs/cms/src/lib/search/importers/genericListItem.service.ts (1 hunks)
Files not reviewed due to errors (1)
  • apps/web/screens/queries/fragments.ts (no review received)
Additional context used
Path-based instructions (13)
apps/web/screens/queries/GenericList.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
libs/cms/src/lib/dto/getGenericListItems.input.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/cms/src/lib/models/genericList.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/cms/src/lib/models/genericListItem.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/cms/src/lib/search/importers/genericListItem.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/cms/src/lib/cms.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."
apps/web/components/Organization/Slice/SliceMachine.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/web/utils/richText.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/web/screens/queries/fragments.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/web/components/GenericList/GenericList.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."
libs/cms/src/lib/cms.elasticsearch.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/cms/src/lib/cms.resolver.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/cms/src/lib/generated/contentfulTypes.d.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
apps/web/components/GenericList/GenericList.tsx

[error] 446-460: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)

The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset

libs/cms/src/lib/cms.elasticsearch.service.ts

[error] 302-304: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.

libs/cms/src/lib/cms.resolver.ts

[error] 133-133: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 145-145: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 153-153: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 161-161: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 169-169: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 177-177: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 185-185: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 196-196: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 204-204: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 212-212: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 220-220: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 232-232: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 243-243: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 254-254: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 265-265: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 276-276: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 288-288: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 295-295: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 303-303: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.


[error] 311-311: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.

Additional comments not posted (18)
apps/web/screens/queries/GenericList.ts (2)

11-11: Added tags to the input object for the GraphQL query.

This addition aligns with the PR's objective to enable tag-based filtering for generic lists.


20-24: Added filterTags block to the items object in the GraphQL query.

This will allow the front-end to display tags associated with each item, enhancing the filtering capabilities. Make sure the backend appropriately handles these new fields.

libs/cms/src/lib/dto/getGenericListItems.input.ts (2)

3-4: Imported GraphQLJSON and related utilities.

This is necessary for handling complex JSON types in GraphQL, such as the new tagGroups field.


32-36: Added fields tags and tagGroups to the DTO.

These additions support the new functionality of tag-based filtering and grouping. Ensure that these fields are properly validated and sanitized in the backend to prevent security issues.

libs/cms/src/lib/models/genericList.model.ts (3)

5-5: Imported GenericTag and related mapping function.

This is essential for handling the new filterTags field in the GenericList model.


27-28: Added filterTags field to the GenericList model.

This field will store tags related to each list, which is crucial for the new filtering feature. Consider adding null checks or default values to handle cases where filterTags might be undefined.


44-44: Updated mapGenericList function to handle filterTags.

Properly maps filterTags using the imported mapping function, ensuring data consistency and structure.

libs/cms/src/lib/models/genericListItem.model.ts (3)

6-6: Imported GenericTag and related mapping function.

This ensures that the GenericListItem model can handle the new filterTags field effectively.


31-32: Added filterTags field to the GenericListItem model.

This addition is crucial for linking tags directly to individual list items, enhancing the granularity of the tagging system.


52-52: Updated mapGenericListItem function to handle filterTags.

This ensures that filterTags are correctly mapped and integrated into the GenericListItem model, maintaining data integrity and structure.

libs/cms/src/lib/cms.module.ts (1)

Line range hint 1-1: Ensure that all necessary providers and services are correctly registered in the CmsModule.

Verification successful

The verification script has successfully identified the usage of all the providers and services mentioned in the CmsModule. The relevant imports and usage are confirmed within the codebase.

  • CmsResolver, ArticleResolver, ElasticService, CmsContentfulService, CmsElasticsearchService, ContentfulRepository, and CmsHealthIndicator are all correctly imported and utilized in various parts of the project.

This confirms that the CmsModule is correctly configured with the necessary providers and services.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all providers and services used in the CmsModule are correctly imported and utilized.

# Test: Search for the usage of the providers and services within the project.
rg --type typescript $'CmsResolver|ArticleResolver|ElasticService|CmsContentfulService|CmsElasticsearchService|ContentfulRepository|CmsHealthIndicator'

Length of output: 187



Script:

#!/bin/bash
# Description: Verify that all providers and services used in the CmsModule are correctly imported and utilized.

# Test: Search for the usage of the providers and services within the project.
rg --type ts $'CmsResolver|ArticleResolver|ElasticService|CmsContentfulService|CmsElasticsearchService|ContentfulRepository|CmsHealthIndicator'

Length of output: 14898

apps/web/components/Organization/Slice/SliceMachine.tsx (1)

192-192: Ensure the filterTags prop is correctly utilized within the GenericList component.

apps/web/utils/richText.tsx (1)

196-196: Confirm that the filterTags prop is properly integrated and handled within the GenericList component.

apps/web/components/GenericList/GenericList.tsx (1)

1-6: The imports and utility functions are well-organized and relevant to the functionality of the GenericList component. Good use of hooks and utilities from next-usequerystate and @apollo/client for state management and data fetching.

Also applies to: 12-14, 22-22, 29-29, 36-40, 44-44

libs/cms/src/lib/cms.elasticsearch.service.ts (1)

Line range hint 457-524: The modifications to the Elasticsearch query logic in getGenericListItems to support filtering by tags and tag groups are correctly implemented. Ensure that the corresponding Elasticsearch mappings and settings are configured to support these queries, especially for the nested and simple_query_string queries used here.

libs/cms/src/lib/generated/contentfulTypes.d.ts (3)

1552-1553: Added filterTags field to IGenericListFields interface.

This addition aligns with the PR's focus on enhancing tag-based filtering capabilities for lists. It looks well-implemented and should facilitate the new feature's requirements effectively.


1591-1593: Added slug field to IGenericListItemFields interface.

The addition of a slug field is a good practice for item identification and URL generation, which can enhance SEO and user navigation. This change is appropriate and well-defined.


1597-1598: Added filterTags field to IGenericListItemFields interface.

This addition supports the new functionality of tag-based filtering at the item level within generic lists. It's a necessary update to accommodate the feature described in the PR.

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 (2)
apps/web/components/GenericList/GenericList.tsx (2)

Line range hint 159-240: The main component function GenericList is well-structured and makes good use of React hooks for state and effect management. However, consider simplifying the complex state logic related to filterCategories and parameters to improve maintainability.


Line range hint 470-484: Provide an explicit type prop for the button element to avoid unintended form submissions.

- <button onClick={() => {
+ <button type="button" onClick={() => {

This change prevents the button from submitting a form unintentionally, which is the default behavior when the type attribute is not specified.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 104bae9 and a85baf9.

Files selected for processing (1)
  • apps/web/components/GenericList/GenericList.tsx (9 hunks)
Additional context used
Path-based instructions (1)
apps/web/components/GenericList/GenericList.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."
Biome
apps/web/components/GenericList/GenericList.tsx

[error] 470-484: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)

The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset

Additional comments not posted (2)
apps/web/components/GenericList/GenericList.tsx (2)

1-6: Ensure proper use of imports and check for any unused imports to keep the code clean and efficient.


152-152: The filterTags prop is appropriately typed to accept an array of GenericTag or null, which aligns well with TypeScript's strict type safety features.

@kodiakhq kodiakhq bot merged commit af0efbd into main Jun 19, 2024
61 checks passed
@kodiakhq kodiakhq bot deleted the feature/web-generic-list-tag-filtering branch June 19, 2024 11:22
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.

3 participants