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(contentful-apps): Add organization parent subpage to link group link field #17143

Conversation

mannipje
Copy link
Member

@mannipje mannipje commented Dec 5, 2024

Add organization parent subpage to link group link field

What

  • Make it possible to set primary and children links in link group as organizationParentSubpage but only on organization page

Screenshots / Gifs

Screencast.from.fim.5.des.2024.13.46.46.webm

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 handling of subpage content types, allowing multiple types to be returned and processed.
    • Introduced a new organization-related link type for improved link management.
  • Bug Fixes

    • Updated logic for fetching and rendering selectable content types to ensure accurate display and functionality.
  • Documentation

    • Updated interface definitions to reflect the changes in content type handling and link processing.

@mannipje mannipje added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Dec 5, 2024
@mannipje mannipje requested review from a team as code owners December 5, 2024 13:52
Copy link
Contributor

coderabbitai bot commented Dec 5, 2024

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • libs/cms/src/lib/generated/contentfulTypes.d.ts is excluded by !**/generated/**

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces significant modifications to the link-group-link-field.tsx file, updating the handling of subpage content types. The function getSubpageContentTypeId is renamed to getSubpageContentTypeIds, returning an array of strings or null. The useSubpageData hook is adjusted to fetch multiple content types, and the SubpageData interface reflects these changes. Additionally, the linkGroup.model.ts file adds a new interface IOrganizationParentSubpage and updates the LinkType definition, enhancing the processing of organization-related subpage links.

Changes

File Path Change Summary
apps/contentful-apps/pages/fields/link-group-link-field.tsx - Renamed getSubpageContentTypeId to getSubpageContentTypeIds, updated return type to `string[]
libs/cms/src/lib/models/linkGroup.model.ts - Added IOrganizationParentSubpage interface.
- Updated LinkType to include IOrganizationParentSubpage.
- Modified mapLinkWrapper function to handle new link types.

Possibly related PRs

Suggested reviewers

  • baering
  • RunarVestmann

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d5d4383 and 3223e09.

⛔ Files ignored due to path filters (1)
  • libs/cms/src/lib/generated/contentfulTypes.d.ts is excluded by !**/generated/**
📒 Files selected for processing (2)
  • apps/contentful-apps/pages/fields/link-group-link-field.tsx (6 hunks)
  • libs/cms/src/lib/models/linkGroup.model.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
libs/cms/src/lib/models/linkGroup.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."
apps/contentful-apps/pages/fields/link-group-link-field.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."
🔇 Additional comments (8)
apps/contentful-apps/pages/fields/link-group-link-field.tsx (6)

17-21: Function getSubpageContentTypeIds updated appropriately

The function now correctly returns an array of content type IDs to handle multiple subpage content types for 'organizationPage' and 'projectPage'.


28-28: Updated subpageContentType to support multiple content types

Changing subpageContentType to an array reflects the need to handle multiple subpage content types, aligning with the updated logic.


165-166: Conditional logic correctly includes new content type

The condition now checks for both organizationSubpage and organizationParentSubpage, ensuring that entries of the new type are handled appropriately.


221-221: Safely retrieving content type IDs with getSubpageContentTypeIds

Using optional chaining when calling getSubpageContentTypeIds ensures that the function handles undefined pageAbove gracefully.


231-232: Correctly configuring content types for entry selection

The contentTypes array now includes both subpage content types and 'link', allowing users to select from all relevant content types.


250-250: Combining subpage content types with link content type for selection

The selectableContentTypes array is properly constructed to include all available content types for selection in the UI.

libs/cms/src/lib/models/linkGroup.model.ts (2)

11-11: Imported IOrganizationParentSubpage interface

Including IOrganizationParentSubpage in the imports ensures that the new content type is recognized within this module.


36-36: Extended LinkType to include IOrganizationParentSubpage

Updating the LinkType union type allows the module to handle entries of the new content type effectively.

libs/cms/src/lib/models/linkGroup.model.ts Outdated Show resolved Hide resolved
Copy link

codecov bot commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 4.16667% with 23 lines in your changes missing coverage. Please review.

Project coverage is 35.71%. Comparing base (083feb4) to head (dd42e88).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...entful-apps/pages/fields/link-group-link-field.tsx 0.00% 16 Missing ⚠️
libs/cms/src/lib/models/linkGroup.model.ts 12.50% 7 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17143      +/-   ##
==========================================
- Coverage   35.73%   35.71%   -0.03%     
==========================================
  Files        6926     6926              
  Lines      147689   147624      -65     
  Branches    42068    42056      -12     
==========================================
- Hits        52776    52722      -54     
+ Misses      94913    94902      -11     
Flag Coverage Δ
api 3.33% <ø> (ø)
api-domains-auth-admin 48.49% <ø> (ø)
api-domains-communications 39.45% <12.50%> (-0.02%) ⬇️
application-system-api 38.76% <12.50%> (-0.01%) ⬇️
application-template-api-modules 27.82% <12.50%> (-0.01%) ⬇️
cms 0.40% <0.00%> (-0.01%) ⬇️
cms-translations 38.79% <12.50%> (-0.02%) ⬇️
judicial-system-api 19.98% <ø> (ø)
judicial-system-backend 55.71% <12.50%> (-0.02%) ⬇️
services-user-notification 46.59% <12.50%> (-0.05%) ⬇️
web 2.43% <ø> (ø)

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

Files with missing lines Coverage Δ
libs/cms/src/lib/models/linkGroup.model.ts 31.70% <12.50%> (-3.43%) ⬇️
...entful-apps/pages/fields/link-group-link-field.tsx 0.00% <0.00%> (ø)

... and 31 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 083feb4...dd42e88. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Dec 6, 2024

Datadog Report

All test runs 2460967 🔗

11 Total Test Services: 0 Failed, 10 Passed
➡️ Test Sessions change in coverage: 29 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 2.99s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 15.09s 1 no change Link
api-domains-communications 0 0 0 5 0 36.64s 1 no change Link
api-domains-license-service 0 0 0 0 0 631.46ms 1 no change Link
application-system-api 0 0 0 46 0 2m 20.08s 1 no change Link
application-template-api-modules 0 0 0 118 0 2m 2.01s 1 no change Link
cms-translations 0 0 0 3 0 25.62s 1 no change Link
judicial-system-api 0 0 0 61 0 5.31s 1 no change Link
judicial-system-backend 0 0 0 20941 0 17m 41.58s 1 no change Link
services-user-notification 0 0 0 51 0 1m 36.63s 1 no change Link

@kodiakhq kodiakhq bot merged commit fb234b4 into main Dec 9, 2024
66 of 67 checks passed
@kodiakhq kodiakhq bot deleted the feature/contentful-apps-add-organization-parent-subpage-to-link-group-link-field branch December 9, 2024 11:42
thorhildurt pushed a commit that referenced this pull request Dec 11, 2024
…link field (#17143)

* Add organizationParentPage as option for organizationPage menu links

* Add organizationParentSubpage to link mapping

* Add generated contentful types

* Fix subpage type when generating organization subpage link

* Minor fix after review

---------

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.

2 participants