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): Featured link slice #17416

Merged
merged 9 commits into from
Jan 8, 2025
Merged

feat(web): Featured link slice #17416

merged 9 commits into from
Jan 8, 2025

Conversation

RunarVestmann
Copy link
Member

@RunarVestmann RunarVestmann commented Jan 6, 2025

Featured link slice

  • Featured links on the frontpage have now been moved into a reusable component
  • New content type "Featured links" in contentful which allows us to display links on top of organization pages

Organization page slice

Screenshot 2025-01-07 at 12 12 18

Frontpage

Screenshot 2025-01-07 at 12 52 16

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

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new FeaturedLinks component for displaying featured links.
    • Added a FeaturedLinksSlice component for rendering featured links within slices.
    • Enhanced the SearchSection to utilize the new FeaturedLinks component.
  • Improvements

    • Updated GraphQL fragments to support featured links.
    • Implemented dynamic loading for the FeaturedLinksSlice component.
  • Technical Updates

    • Expanded component exports to include new featured links components.
    • Updated slice rendering mechanisms to accommodate the new featured links structure.

The changes improve link presentation and provide more flexible content rendering across the application.

Copy link
Contributor

coderabbitai bot commented Jan 6, 2025

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 a new FeaturedLinks component and related infrastructure for rendering featured links across the web application. This includes the creation of the FeaturedLinks and FeaturedLinksSlice components, updates to the slice machine for dynamic imports, and modifications to existing components like SearchSection to utilize the new FeaturedLinks component. Additionally, new GraphQL fragments and models are defined to support this functionality, allowing for flexible rendering of featured links with URL resolution.

Changes

File Change Summary
apps/web/components/FeaturedLinks/FeaturedLinks.tsx New component for rendering featured links with URL resolution and custom rendering.
apps/web/components/Organization/Slice/FeaturedLinksSlice/FeaturedLinksSlice.tsx New slice component for rendering featured links with title.
apps/web/components/Organization/Slice/SliceMachine.tsx Added dynamic import and rendering support for FeaturedLinksSlice.
apps/web/components/SearchSection/SearchSection.tsx Replaced existing link rendering with new FeaturedLinks component.
apps/web/components/real.ts Added exports for new FeaturedLinks and FeaturedLinksSlice components.
apps/web/screens/queries/fragments.ts Added GraphQL fragment for FeaturedLinksFields.
libs/cms/src/lib/models/featuredLinks.model.ts New model for FeaturedLinks with mapping function.
libs/cms/src/lib/unions/slice.union.ts Updated slice types and mapping to include FeaturedLinks.

Sequence Diagram

sequenceDiagram
    participant User
    participant SliceMachine
    participant FeaturedLinksSlice
    participant FeaturedLinks
    participant LinkResolver

    User->>SliceMachine: Request page with slice
    SliceMachine->>FeaturedLinksSlice: Render slice
    FeaturedLinksSlice->>FeaturedLinks: Pass featured links
    FeaturedLinks->>LinkResolver: Resolve link URLs
    LinkResolver-->>FeaturedLinks: Return resolved URLs
    FeaturedLinks->>User: Render featured links
Loading

Possibly related PRs

Suggested labels

deploy-feature

Suggested reviewers

  • mannipje
  • Toti91

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@datadog-island-is
Copy link

datadog-island-is bot commented Jan 6, 2025

Datadog Report

All test runs 9aca84f 🔗

10 Total Test Services: 0 Failed, 10 Passed
⬆️ Test Sessions change in coverage: 2 increased, 198 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-backend 0 0 0 63 0 22.2s N/A Link
air-discount-scheme-web 0 0 0 2 0 6.45s N/A Link
api 0 0 0 4 0 2.78s N/A Link
api-catalogue-services 0 0 0 23 0 9.01s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 16.28s N/A Link
api-domains-assets 0 0 0 3 0 9.59s N/A Link
api-domains-auth-admin 0 0 0 18 0 10.21s 1 no change Link
api-domains-communications 0 0 0 5 0 30.96s N/A Link
api-domains-criminal-record 0 0 0 5 0 8.65s N/A Link
api-domains-driving-license 0 0 0 23 0 30.97s N/A Link

Copy link

codecov bot commented Jan 6, 2025

Codecov Report

Attention: Patch coverage is 25.00000% with 27 lines in your changes missing coverage. Please review.

Project coverage is 35.67%. Comparing base (e2ecff6) to head (10e3981).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...pps/web/components/FeaturedLinks/FeaturedLinks.tsx 0.00% 13 Missing ⚠️
libs/cms/src/lib/models/featuredLinks.model.ts 61.53% 5 Missing ⚠️
...web/components/Organization/Slice/SliceMachine.tsx 0.00% 4 Missing ⚠️
...on/Slice/FeaturedLinksSlice/FeaturedLinksSlice.tsx 0.00% 3 Missing ⚠️
libs/cms/src/lib/unions/slice.union.ts 33.33% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #17416   +/-   ##
=======================================
  Coverage   35.67%   35.67%           
=======================================
  Files        6938     6941    +3     
  Lines      149103   149131   +28     
  Branches    42636    42640    +4     
=======================================
+ Hits        53187    53197   +10     
- Misses      95916    95934   +18     
Flag Coverage Δ
air-discount-scheme-backend 48.24% <ø> (ø)
air-discount-scheme-web 0.00% <ø> (ø)
api 3.35% <ø> (ø)
api-catalogue-services 75.81% <ø> (ø)
api-domains-air-discount-scheme 37.99% <ø> (ø)
api-domains-assets 26.71% <ø> (ø)
api-domains-auth-admin 48.49% <ø> (ø)
api-domains-communications 39.47% <56.25%> (+0.02%) ⬆️
api-domains-criminal-record 48.03% <ø> (ø)
api-domains-driving-license 44.86% <ø> (ø)
api-domains-education 31.27% <ø> (ø)
api-domains-health-insurance 35.47% <ø> (ø)
api-domains-mortgage-certificate 35.24% <ø> (ø)
api-domains-payment-schedule 42.12% <ø> (ø)
application-api-files 61.97% <ø> (ø)
application-core 75.60% <ø> (ø)
application-system-api 38.74% <56.25%> (-0.02%) ⬇️
application-template-api-modules 27.72% <56.25%> (+<0.01%) ⬆️
application-templates-accident-notification 27.60% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 25.82% <ø> (ø)
application-templates-driving-license 18.17% <ø> (ø)
application-templates-estate 13.67% <ø> (ø)
application-templates-example-payment 24.69% <ø> (ø)
application-templates-financial-aid 14.47% <ø> (ø)
application-templates-general-petition 23.13% <ø> (ø)
application-templates-inheritance-report 6.59% <ø> (ø)
application-templates-marriage-conditions 15.21% <ø> (ø)
application-templates-mortgage-certificate 43.73% <ø> (ø)
application-templates-parental-leave 29.92% <ø> (ø)
application-types 6.48% <ø> (ø)
application-ui-components 1.22% <ø> (ø)
application-ui-shell 22.25% <ø> (ø)
auth-admin-web 2.43% <ø> (ø)
auth-nest-tools 31.69% <ø> (ø)
auth-shared 75.00% <ø> (ø)
clients-charge-fjs-v2 28.88% <ø> (ø)
clients-driving-license 40.91% <ø> (ø)
clients-driving-license-book 43.92% <ø> (ø)
clients-financial-statements-inao 49.70% <ø> (ø)
clients-license-client 1.26% <ø> (ø)
clients-middlewares 73.20% <ø> (+0.24%) ⬆️
clients-regulations 43.00% <ø> (ø)
clients-rsk-company-registry 31.18% <ø> (ø)
clients-rsk-personal-tax-return 38.32% <ø> (ø)
clients-smartsolutions 12.77% <ø> (ø)
clients-syslumenn 49.47% <ø> (ø)
clients-zendesk 50.58% <ø> (ø)
cms 0.39% <0.00%> (-0.01%) ⬇️
cms-translations 38.80% <56.25%> (+0.02%) ⬆️
content-search-index-manager 95.65% <ø> (ø)
content-search-toolkit 8.16% <ø> (ø)
contentful-apps 4.69% <ø> (ø)
dokobit-signing 62.18% <ø> (ø)
email-service 60.15% <ø> (ø)
feature-flags 90.83% <ø> (ø)
file-storage 45.97% <ø> (ø)
financial-aid-backend 51.42% <ø> (ø)
financial-aid-shared 17.88% <ø> (ø)
icelandic-names-registry-backend 54.33% <ø> (ø)
infra-nest-server 48.06% <ø> (ø)
infra-tracing 69.94% <ø> (ø)
island-ui-core 30.34% <ø> (ø)
judicial-system-api 20.23% <ø> (ø)
judicial-system-audit-trail 69.02% <ø> (ø)
judicial-system-backend 55.88% <56.25%> (+<0.01%) ⬆️
judicial-system-formatters 78.52% <ø> (ø)
judicial-system-message 66.66% <ø> (ø)
judicial-system-message-handler 48.41% <ø> (ø)
judicial-system-scheduler 71.20% <ø> (ø)
judicial-system-types 41.54% <ø> (ø)
judicial-system-web 27.76% <ø> (ø)
license-api 42.94% <ø> (+0.07%) ⬆️
localization 10.15% <ø> (ø)
logging 58.02% <ø> (ø)
message-queue 67.76% <ø> (ø)
nest-audit 65.78% <ø> (ø)
nest-aws 51.93% <ø> (ø)
nest-config 76.45% <ø> (ø)
nest-core 53.16% <ø> (ø)
nest-feature-flags 51.06% <ø> (ø)
nest-problem 45.64% <ø> (ø)
nest-sequelize 94.44% <ø> (ø)
nest-swagger 51.13% <ø> (ø)
nova-sms 61.52% <ø> (ø)
portals-admin-regulations-admin 1.80% <ø> (ø)
portals-core 19.58% <ø> (ø)
regulations 16.78% <ø> (ø)
residence-history 85.00% <ø> (ø)
services-auth-admin-api 52.54% <ø> (ø)
services-auth-delegation-api 58.56% <ø> (ø)
services-auth-ids-api 52.59% <ø> (ø)
services-auth-public-api 49.43% <ø> (+<0.01%) ⬆️
services-sessions 65.33% <ø> (ø)
services-university-gateway 49.58% <ø> (+0.02%) ⬆️
services-user-notification 46.54% <56.25%> (+0.01%) ⬆️
services-user-profile 56.97% <ø> (ø)
shared-components 29.49% <ø> (ø)
shared-form-fields 33.37% <ø> (ø)
shared-mocking 58.64% <ø> (ø)
shared-pii 92.85% <ø> (ø)
shared-problem 87.50% <ø> (ø)
shared-utils 27.69% <ø> (ø)
skilavottord-ws 24.26% <ø> (ø)
web 2.39% <0.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
...pps/web/components/SearchSection/SearchSection.tsx 0.00% <ø> (ø)
apps/web/screens/queries/fragments.ts 0.00% <ø> (ø)
libs/cms/src/lib/unions/slice.union.ts 31.38% <33.33%> (+0.03%) ⬆️
...on/Slice/FeaturedLinksSlice/FeaturedLinksSlice.tsx 0.00% <0.00%> (ø)
...web/components/Organization/Slice/SliceMachine.tsx 0.00% <0.00%> (ø)
libs/cms/src/lib/models/featuredLinks.model.ts 61.53% <61.53%> (ø)
...pps/web/components/FeaturedLinks/FeaturedLinks.tsx 0.00% <0.00%> (ø)

... and 1 file 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 e2ecff6...10e3981. Read the comment docs.

@RunarVestmann RunarVestmann added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Jan 7, 2025
@RunarVestmann RunarVestmann marked this pull request as ready for review January 7, 2025 12:13
@RunarVestmann RunarVestmann requested review from a team as code owners January 7, 2025 12:13
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 comments (1)
apps/web/components/SearchSection/SearchSection.tsx (1)

Line range hint 41-49: Remove ts-ignore comments by fixing type definitions.

There are multiple ts-ignore comments in the code. Consider fixing the underlying type issues by:

  1. Properly typing the page prop
  2. Adding proper type definitions for featured, heading, image, etc.
-// eslint-disable-next-line @typescript-eslint/ban-ts-comment
-// @ts-ignore make web strict
-featured,
+featured?: Featured[],
🧹 Nitpick comments (3)
apps/web/components/Organization/Slice/FeaturedLinksSlice/FeaturedLinksSlice.tsx (1)

9-17: Consider memoizing the component for performance optimization.

The component is well-structured, but since it's likely to be rendered frequently in a list, consider wrapping it with React.memo to prevent unnecessary re-renders.

-export const FeaturedLinksSlice = ({ slice }: FeaturedLinksSliceProps) => {
+export const FeaturedLinksSlice = React.memo(({ slice }: FeaturedLinksSliceProps) => {
   if (!slice.featuredLinks?.length) return null
   return (
     <Stack space={2}>
       <Text variant="h4">{slice.title}</Text>
       <FeaturedLinks links={slice.featuredLinks} />
     </Stack>
   )
-}
+})
libs/cms/src/lib/models/featuredLinks.model.ts (1)

19-27: Consider adding input validation in the mapping function.

While the mapping function handles null cases, it might benefit from additional validation for the input fields.

 export const mapFeaturedLinks = ({
   fields,
   sys,
 }: IFeaturedLinks): SystemMetadata<FeaturedLinks> => ({
   typename: 'FeaturedLinks',
   id: sys.id,
-  title: fields.displayedTitle ?? '',
+  title: fields.displayedTitle?.trim() ?? '',
   featuredLinks: fields.links?.filter(Boolean).map(mapFeatured) ?? [],
 })
apps/web/components/FeaturedLinks/FeaturedLinks.tsx (1)

22-31: Extract CustomLink component for better maintainability.

The inline CustomLink component definition could be moved outside the render method to improve readability and prevent unnecessary recreations.

+const CustomLink = ({ children, title, ...props }) => (
+  <LinkV2 {...props} dataTestId="featured-link">
+    {children}
+  </LinkV2>
+)

 export const FeaturedLinks = ({ links }: FeaturedLinksProps) => {
   // ... rest of the component
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 550571d and 44a08a3.

⛔ Files ignored due to path filters (1)
  • libs/cms/src/lib/generated/contentfulTypes.d.ts is excluded by !**/generated/**
📒 Files selected for processing (8)
  • apps/web/components/FeaturedLinks/FeaturedLinks.tsx (1 hunks)
  • apps/web/components/Organization/Slice/FeaturedLinksSlice/FeaturedLinksSlice.tsx (1 hunks)
  • apps/web/components/Organization/Slice/SliceMachine.tsx (2 hunks)
  • apps/web/components/SearchSection/SearchSection.tsx (2 hunks)
  • apps/web/components/real.ts (1 hunks)
  • apps/web/screens/queries/fragments.ts (2 hunks)
  • libs/cms/src/lib/models/featuredLinks.model.ts (1 hunks)
  • libs/cms/src/lib/unions/slice.union.ts (5 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
apps/web/components/real.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/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/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/Organization/Slice/FeaturedLinksSlice/FeaturedLinksSlice.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/components/FeaturedLinks/FeaturedLinks.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/components/SearchSection/SearchSection.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/models/featuredLinks.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/unions/slice.union.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 (6)
apps/web/components/Organization/Slice/FeaturedLinksSlice/FeaturedLinksSlice.tsx (1)

5-7: LGTM! Well-defined TypeScript interface.

The interface is properly typed with the GraphQL schema type, ensuring type safety throughout the component.

libs/cms/src/lib/models/featuredLinks.model.ts (1)

8-17: LGTM! Well-structured GraphQL object type.

The class is properly decorated with GraphQL decorators and includes appropriate field types and nullability checks.

apps/web/components/real.ts (1)

99-100: LGTM! Exports follow the established pattern.

The new exports maintain consistency with the existing barrel file structure and documentation guidelines.

libs/cms/src/lib/unions/slice.union.ts (1)

51-51: Integration of FeaturedLinks follows established patterns!

The addition of the FeaturedLinks type and its mapping function is well-structured and maintains consistency with the existing type system.

Also applies to: 197-197, 250-250, 348-349

apps/web/screens/queries/fragments.ts (1)

924-936: Please clarify the purpose of the attention field.

The FeaturedLinksFields fragment is well-structured, but the purpose of the attention field in featuredLinks is not immediately clear. Consider adding a comment or documentation to explain its usage.

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

110-112: Implementation follows NextJS best practices!

The dynamic import and slice rendering implementation for FeaturedLinks follows the established patterns and NextJS best practices for code splitting.

Also applies to: 227-228

apps/web/components/FeaturedLinks/FeaturedLinks.tsx Outdated Show resolved Hide resolved
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

🧹 Nitpick comments (3)
apps/web/components/Organization/Slice/SliceMachine.tsx (2)

228-229: Consider improving type safety

While the implementation is correct, the function uses multiple @ts-ignore comments. Consider improving type safety by:

  1. Properly typing the slice parameter
  2. Using a discriminated union type for different slice types
  3. Removing the need for @ts-ignore comments

Example type improvement:

type SliceUnion = 
  | { __typename: 'FeaturedLinks'; /* ... other props */ }
  | { __typename: 'HeadingSlice'; /* ... other props */ }
  // ... other slice types

function renderSlice(slice: SliceUnion, namespace: Record<string, string>, slug: string, params: unknown) {
  switch (slice.__typename) {
    // ... cases
  }
}

Line range hint 1-290: Consider restructuring for better maintainability

The file has grown to handle many slice types and could benefit from restructuring:

  1. Group related slices into separate modules
  2. Create a registry pattern for slice types
  3. Move slice type definitions to a separate file

Example restructure:

// sliceRegistry.ts
const sliceRegistry = {
  content: {
    HeadingSlice: () => import('./slices/content/HeadingSlice'),
    OneColumnTextSlice: () => import('./slices/content/OneColumnTextSlice'),
    // ...
  },
  features: {
    FeaturedLinksSlice: () => import('./slices/features/FeaturedLinksSlice'),
    FeaturedArticlesSlice: () => import('./slices/features/FeaturedArticlesSlice'),
    // ...
  }
};

// This would simplify SliceMachine.tsx and make it more maintainable
libs/cms/src/lib/unions/slice.union.ts (1)

51-51: Well-structured changes maintaining library guidelines.

The changes follow best practices for library code:

  • Proper TypeScript type definitions ensuring type safety
  • Clean integration with the CMS type system
  • Maintains reusability across NextJS apps
  • Supports tree-shaking through specific exports

Also applies to: 150-150, 203-203, 256-257, 355-356

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 44a08a3 and 38f26c3.

⛔ Files ignored due to path filters (1)
  • libs/cms/src/lib/generated/contentfulTypes.d.ts is excluded by !**/generated/**
📒 Files selected for processing (4)
  • apps/web/components/FeaturedLinks/FeaturedLinks.tsx (1 hunks)
  • apps/web/components/Organization/Slice/SliceMachine.tsx (2 hunks)
  • apps/web/screens/queries/fragments.ts (2 hunks)
  • libs/cms/src/lib/unions/slice.union.ts (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/web/screens/queries/fragments.ts
  • apps/web/components/FeaturedLinks/FeaturedLinks.tsx
🧰 Additional context used
📓 Path-based instructions (2)
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."
libs/cms/src/lib/unions/slice.union.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 (4)
apps/web/components/Organization/Slice/SliceMachine.tsx (1)

110-112: LGTM! Dynamic import follows best practices

The dynamic import implementation follows NextJS best practices for code splitting and maintains consistency with existing patterns.

libs/cms/src/lib/unions/slice.union.ts (3)

51-51: LGTM! Type definitions and imports are well-organized.

The new FeaturedLinks related imports and type definitions are properly integrated, maintaining consistency with existing patterns.

Also applies to: 150-150, 203-203


256-257: LGTM! Union type integration is correct.

The FeaturedLinks type is properly added to the SliceUnion array, maintaining the type system integrity.


355-356: Verify the FeaturedLinks mapping implementation.

The mapping case is correctly added. Let's verify the implementation of the imported mapFeaturedLinks function.

Run this script to check the mapping function implementation:

✅ Verification successful

✓ FeaturedLinks mapping implementation is correct

The mapFeaturedLinks function properly transforms IFeaturedLinks into SystemMetadata<FeaturedLinks> with appropriate field mapping and null handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the FeaturedLinks mapping implementation
# Expected: Find the mapFeaturedLinks function implementation that converts IFeaturedLinks to SystemMetadata<FeaturedLinks>

ast-grep --pattern 'export const mapFeaturedLinks = (slice: IFeaturedLinks)' 

Length of output: 78


Script:

#!/bin/bash
# Search for any mentions of mapFeaturedLinks
rg "mapFeaturedLinks" -A 2

# Find files related to FeaturedLinks
fd -t f "FeaturedLinks"

# Look for import statements containing mapFeaturedLinks
rg "import.*mapFeaturedLinks"

Length of output: 1013


Script:

#!/bin/bash
# Get the complete implementation of mapFeaturedLinks
cat libs/cms/src/lib/models/featuredLinks.model.ts

Length of output: 795

@kodiakhq kodiakhq bot merged commit b3202f5 into main Jan 8, 2025
265 checks passed
@kodiakhq kodiakhq bot deleted the feature/web-featured-links branch January 8, 2025 12:28
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