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): Stepper on subarticles #16541

Merged
merged 8 commits into from
Oct 24, 2024
Merged

Conversation

RunarVestmann
Copy link
Member

@RunarVestmann RunarVestmann commented Oct 23, 2024

Stepper on subarticles

What

  • Allow stepper on sub articles (change styles accordingly for when the sub article is in the "stepper view")
  • Change the key for each breadcrumb item due to re-rendering breadcrumbitems with different props leads to focus staying on element I just clicked on (because the key was the index)

Screenshots / Gifs

Screen.Recording.2024-10-24.at.10.55.38.mov

Before breadcrumb key change

Screen.Recording.2024-10-24.at.11.13.41.mov

After breadcrumb key change

Screen.Recording.2024-10-24.at.11.14.13.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

Summary by CodeRabbit

  • New Features

    • Enhanced article navigation with the addition of a stepper for sub-articles, providing detailed breakdowns of steps.
    • Improved breadcrumb structure for better clarity and maintainability.
  • Bug Fixes

    • Adjusted rendering logic to ensure components respond correctly to updated states and props.
  • Refactor

    • Streamlined the ArticleScreen component for better readability and functionality.
    • Updated key assignment in the Breadcrumbs component for improved performance.

Copy link

codecov bot commented Oct 23, 2024

Codecov Report

Attention: Patch coverage is 6.25000% with 30 lines in your changes missing coverage. Please review.

Project coverage is 36.77%. Comparing base (af6f6e9) to head (767e624).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
apps/web/screens/Article/Article.tsx 0.00% 27 Missing ⚠️
libs/cms/src/lib/models/subArticle.model.ts 50.00% 2 Missing ⚠️
.../lib/search/importers/manualChapterItem.service.ts 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16541      +/-   ##
==========================================
- Coverage   36.78%   36.77%   -0.01%     
==========================================
  Files        6853     6853              
  Lines      142166   142181      +15     
  Branches    40552    40563      +11     
==========================================
- Hits        52290    52288       -2     
- Misses      89876    89893      +17     
Flag Coverage Δ
air-discount-scheme-backend 54.08% <ø> (ø)
air-discount-scheme-web 0.00% <ø> (ø)
api 3.37% <ø> (ø)
api-domains-air-discount-scheme 36.93% <ø> (ø)
api-domains-assets 26.71% <ø> (ø)
api-domains-auth-admin 48.48% <ø> (ø)
api-domains-communications 39.91% <40.00%> (+<0.01%) ⬆️
api-domains-criminal-record 48.00% <ø> (ø)
api-domains-driving-license 44.48% <ø> (ø)
api-domains-education 31.58% <ø> (ø)
api-domains-health-insurance 34.77% <ø> (ø)
api-domains-mortgage-certificate 34.98% <ø> (ø)
api-domains-payment-schedule 41.16% <ø> (ø)
application-api-files 56.76% <ø> (ø)
application-core 71.64% <ø> (+0.32%) ⬆️
application-system-api 41.37% <40.00%> (+<0.01%) ⬆️
application-template-api-modules 27.81% <40.00%> (+<0.01%) ⬆️
application-templates-accident-notification 29.27% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 26.34% <ø> (ø)
application-templates-driving-license 18.34% <ø> (ø)
application-templates-estate 12.31% <ø> (ø)
application-templates-example-payment 25.14% <ø> (ø)
application-templates-financial-aid 15.49% <ø> (ø)
application-templates-general-petition 23.44% <ø> (ø)
application-templates-inheritance-report 6.49% <ø> (ø)
application-templates-marriage-conditions 15.17% <ø> (ø)
application-templates-mortgage-certificate 43.59% <ø> (ø)
application-templates-parental-leave 29.96% <ø> (ø)
application-types 6.63% <ø> (ø)
application-ui-components 1.28% <ø> (ø)
application-ui-shell 21.36% <ø> (ø)
auth-nest-tools 30.02% <ø> (ø)
auth-react 22.81% <ø> (ø)
clients-charge-fjs-v2 24.11% <ø> (ø)
clients-driving-license 40.67% <ø> (ø)
clients-driving-license-book 43.80% <ø> (ø)
clients-financial-statements-inao 49.32% <ø> (ø)
clients-license-client 1.83% <ø> (ø)
clients-middlewares 72.86% <ø> (-0.26%) ⬇️
clients-regulations 42.80% <ø> (ø)
clients-rsk-company-registry 29.76% <ø> (ø)
clients-syslumenn 49.49% <ø> (ø)
cms 0.42% <0.00%> (-0.01%) ⬇️
cms-translations 39.04% <40.00%> (+<0.01%) ⬆️
content-search-index-manager 95.65% <ø> (ø)
content-search-toolkit 8.16% <ø> (ø)
contentful-apps 5.44% <ø> (ø)
download-service 44.22% <ø> (ø)
financial-aid-backend 56.25% <ø> (ø)
financial-aid-shared 18.94% <ø> (ø)
icelandic-names-registry-backend 53.97% <ø> (ø)
island-ui-core 28.44% <ø> (ø)
judicial-system-api 18.38% <ø> (ø)
judicial-system-backend 55.16% <40.00%> (-0.01%) ⬇️
judicial-system-web 27.80% <ø> (ø)
license-api 42.53% <ø> (ø)
localization 10.15% <ø> (ø)
nest-audit 68.20% <ø> (ø)
nest-core 43.54% <ø> (ø)
nest-feature-flags 51.52% <ø> (+0.63%) ⬆️
nest-problem 45.85% <ø> (ø)
nest-swagger 51.71% <ø> (ø)
portals-admin-regulations-admin 1.85% <ø> (ø)
portals-core 16.14% <ø> (ø)
reference-backend 49.79% <ø> (ø)
services-auth-admin-api 51.89% <ø> (ø)
services-auth-delegation-api 57.45% <ø> (-0.07%) ⬇️
services-auth-ids-api 51.43% <ø> (-0.04%) ⬇️
services-auth-personal-representative 45.12% <ø> (ø)
services-auth-personal-representative-public 41.25% <ø> (ø)
services-auth-public-api 48.95% <ø> (ø)
services-documents 60.58% <ø> (ø)
services-endorsements-api 53.59% <ø> (ø)
services-sessions 65.39% <ø> (+0.04%) ⬆️
services-university-gateway 48.42% <ø> (ø)
services-user-notification 46.93% <40.00%> (+<0.01%) ⬆️
services-user-profile 61.84% <ø> (+0.09%) ⬆️
shared-components 27.70% <ø> (ø)
shared-form-fields 31.57% <ø> (ø)
shared-problem 87.50% <ø> (ø)
shared-utils 27.69% <ø> (ø)
skilavottord-ws 24.18% <ø> (ø)
web 1.80% <0.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
apps/web/screens/queries/Article.ts 0.00% <ø> (ø)
...island-ui/core/src/lib/Breadcrumbs/Breadcrumbs.tsx 100.00% <ø> (ø)
.../lib/search/importers/manualChapterItem.service.ts 17.14% <0.00%> (ø)
libs/cms/src/lib/models/subArticle.model.ts 47.05% <50.00%> (+0.39%) ⬆️
apps/web/screens/Article/Article.tsx 0.00% <0.00%> (ø)

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update af6f6e9...767e624. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 23, 2024

Datadog Report

All test runs ec2c682 🔗

81 Total Test Services: 0 Failed, 78 Passed
🔻 Test Sessions change in coverage: 2 decreased, 5 increased, 193 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 81 0 27.57s N/A Link
air-discount-scheme-web 0 0 0 2 0 8.85s 1 no change Link
api 0 0 0 4 0 2.82s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 19.65s 1 no change Link
api-domains-assets 0 0 0 3 0 12.8s N/A Link
api-domains-auth-admin 0 0 0 18 0 14.12s 1 no change Link
api-domains-communications 0 0 0 5 0 33.49s 1 increased (+0.01%) Link
api-domains-criminal-record 0 0 0 5 0 10.45s N/A Link
api-domains-driving-license 0 0 0 23 0 33.54s 1 no change Link
api-domains-education 0 0 0 8 0 20.68s N/A Link

🔻 Code Coverage Decreases vs Default Branch (2)

  • services-auth-delegation-api - jest 51.35% (-0.19%) - Details
  • clients-middlewares - jest 75.6% (-0.1%) - Details

@RunarVestmann RunarVestmann marked this pull request as ready for review October 24, 2024 10:52
@RunarVestmann RunarVestmann requested review from a team as code owners October 24, 2024 10:52
@RunarVestmann RunarVestmann requested a review from oddsson October 24, 2024 10:52
Copy link
Contributor

coderabbitai bot commented Oct 24, 2024

Walkthrough

The pull request introduces several modifications across multiple files, primarily focusing on the ArticleScreen component and its associated logic. Key changes include updates to type declarations, the addition of a stepper field in GraphQL queries, and enhancements to the SubArticle model. The breadcrumb generation logic has been refactored for clarity, and error handling improvements have been made in the ManualChapterItemSyncService. These changes collectively enhance type safety, data handling, and component rendering within the application.

Changes

File Path Change Summary
apps/web/screens/Article/Article.tsx - Reorganized imports and updated ArticleProps interface: namespace type changed to Record<string, string>.
- Modified inStepperView logic and breadcrumb generation for clarity.
- Adjusted rendering of ArticleNavigation based on inStepperView.
- Refined content variable structure for better organization.
apps/web/screens/queries/Article.ts - Updated GET_ARTICLE_QUERY to include a new stepper field in the subArticles section with nested properties.
libs/cms/src/lib/models/subArticle.model.ts - Added optional stepper field to SubArticle class and updated mapSubArticle function for mapping this field.
libs/cms/src/lib/search/importers/manualChapterItem.service.ts - Updated processSyncData method to use optional chaining for chapter checks.
- Added console logs for debugging in doMapping method.
libs/island-ui/core/src/lib/Breadcrumbs/Breadcrumbs.tsx - Changed key prop in breadcrumb mapping from index-based to a combination of item title and index for uniqueness.

Possibly related PRs

Suggested reviewers

  • mannipje

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.

@RunarVestmann RunarVestmann added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Oct 24, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (2)
apps/web/screens/queries/Article.ts (1)

136-150: LGTM! Consider documenting the stepper configuration.

The stepper field structure is well-organized and follows GraphQL best practices. However, please consider adding documentation comments to explain:

  • The purpose and structure of the config field at both stepper and step levels
  • The possible values for the stepType field
apps/web/screens/Article/Article.tsx (1)

Line range hint 807-812: Maintain consistent heading levels for better accessibility.

Rendering the sub-article title as an h2 may affect the document outline and accessibility. Ensure that heading levels (h1, h2, h3, etc.) are used sequentially to provide a clear structure for users and assistive technologies.

Consider adjusting the heading levels based on the context:

-    <Text variant="h2" as="h2" paddingTop={7}>
+    <Text variant="h3" as="h3" paddingTop={7}>

Or adjust surrounding headings to maintain a consistent hierarchy.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4919948 and 34c5044.

⛔ 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/screens/Article/Article.tsx (9 hunks)
  • apps/web/screens/queries/Article.ts (1 hunks)
  • libs/cms/src/lib/models/subArticle.model.ts (3 hunks)
  • libs/island-ui/core/src/lib/Breadcrumbs/Breadcrumbs.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
apps/web/screens/Article/Article.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/Article.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/models/subArticle.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/island-ui/core/src/lib/Breadcrumbs/Breadcrumbs.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."
🔇 Additional comments (7)
libs/cms/src/lib/models/subArticle.model.ts (4)

8-8: LGTM: Clean import declaration

The import follows the established pattern and properly imports both the type and mapping function.


33-34: LGTM: Well-structured field declaration

The field declaration follows best practices:

  • Uses @CacheField decorator consistently with other fields
  • Proper TypeScript nullable type definition
  • Maintains the same pattern as other optional fields in the class

59-59: LGTM: Consistent mapping implementation

The mapping implementation:

  • Follows the null-safe pattern used throughout the file
  • Uses the imported mapStepper function consistently
  • Maintains the same structure as other optional field mappings

Line range hint 1-61: Verify the stepper integration across the application

Since this is a model change in a shared library, we should verify its usage across the application.

✅ Verification successful

Let me generate new shell scripts to better verify the stepper integration.

The previous attempt failed because of file type restrictions. Let's try a broader search to find all relevant usages.


Based on the comprehensive search results, I can now provide a final response about the stepper integration:

Stepper integration is well-established and properly integrated across the application

The stepper field in SubArticle model is properly integrated and used throughout the application:

  • It's used in multiple core models:

    • SubArticle model (libs/cms/src/lib/models/subArticle.model.ts)
    • Article model (libs/cms/src/lib/models/article.model.ts)
    • ProjectPage model (libs/cms/src/lib/models/projectPage.model.ts)
  • The integration is complete with:

    • GraphQL schema definitions in libs/clients/cms/schema.graphql
    • Proper imports and mapping functions in all relevant models
    • Full UI implementation in apps/web/components/Stepper
    • Usage in article and project screens (apps/web/screens/Article and apps/web/screens/Project)

The stepper field is properly consumed by the application with all necessary type definitions, mappings, and UI components in place.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the stepper field usage in GraphQL queries and components

# Check for GraphQL queries using the stepper field
echo "Checking GraphQL queries using the stepper field..."
rg -t graphql "stepper" -A 5

# Check for React components that might be consuming the stepper field
echo "Checking React components using the stepper field..."
rg -t typescript -t tsx "stepper.*SubArticle" -A 5

Length of output: 376


Script:

#!/bin/bash
# Search for stepper-related code across all files
echo "Searching for stepper field usage..."
rg "stepper" -A 5

# Search for SubArticle query fragments
echo "Searching for SubArticle query fragments..."
rg "fragment.*SubArticle" -A 10

# Search for stepper model imports
echo "Searching for stepper model imports..."
rg "import.*stepper\.model"

# Search for files that might be using the stepper field
echo "Searching for potential stepper consumers..."
fd -e ts -e tsx -e graphql . | xargs rg "stepper"

Length of output: 71643

libs/island-ui/core/src/lib/Breadcrumbs/Breadcrumbs.tsx (1)

Line range hint 1-99: Well-structured reusable component.

The component follows best practices for reusability and maintainability:

  • Proper TypeScript types and interfaces
  • Flexible customization through props
  • Clean separation of concerns
  • Effective tree-shaking support
apps/web/screens/Article/Article.tsx (2)

768-777: Ensure 'ArticleNavigation' renders correctly in all views.

When inStepperView is false, you conditionally render ArticleNavigation. Verify that this component displays appropriately across different devices and screen sizes, and that the navigation links function as intended.


427-477: Verify breadcrumb items for accurate navigation paths.

In the breadcrumbItems construction, ensure that the URLs and titles are correctly generated, especially when inStepperView is true. This will help users navigate accurately through articles and sub-articles.

Run the following script to check the breadcrumb items:

✅ Verification successful

Let me try a different approach to verify the breadcrumb implementation.

Let's analyze the implementation details and usage patterns to verify the breadcrumb construction.


Let me try one more search to understand the BreadCrumbItem type definition and its usage in the Breadcrumbs component.

This will help us verify the breadcrumb structure and navigation paths.


Based on the gathered information, I can now provide a final response about the breadcrumb implementation.

Breadcrumb implementation is correctly handling navigation paths

The breadcrumb implementation in Article.tsx follows the correct structure and best practices:

  1. The BreadCrumbItem interface is properly defined with all necessary fields:

    • title: string (display text)
    • href: string (optional direct URL)
    • slug: string[] (for dynamic path construction)
    • typename: string (for type-specific routing)
    • isTag: boolean (for special rendering)
  2. The breadcrumb construction logic correctly handles both scenarios:

    • In stepper view: Shows article and sub-article hierarchy
    • In regular view: Shows full path including homepage, category, and group tags
  3. The slug handling is consistent with the application's routing patterns, using arrays for multi-segment paths and proper concatenation for group slugs.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify breadcrumb items and their URLs.

# Test: Output breadcrumb items. Expect: Correct titles and URLs.
ast-grep --pattern $'breadcrumbItems = $_' --typescript "apps/web/screens/Article/Article.tsx"

Length of output: 291


Script:

#!/bin/bash
# Search for breadcrumb-related code and imports
rg -A 5 "BreadCrumbItem" apps/web/screens/Article/Article.tsx

# Look for any tests related to breadcrumbs
fd -e test.tsx -e spec.tsx -X rg -l "breadcrumb"

# Check for BreadCrumbItem type definition
rg -A 5 "type BreadCrumbItem"

# Look for any usage of breadcrumbs in components
rg -A 2 "breadcrumbItems" 

Length of output: 16511


Script:

#!/bin/bash
# Search for BreadCrumbItem type definition and Breadcrumbs component usage
rg -A 10 "interface BreadCrumbItem|type BreadCrumbItem"

# Look for Breadcrumbs component implementation
fd -e tsx -e ts -X rg -l "export.*Breadcrumbs"

# Check how slugs are used in breadcrumb navigation
rg -A 3 "slug.*=.*\[.*\]" 

Length of output: 7891

libs/island-ui/core/src/lib/Breadcrumbs/Breadcrumbs.tsx Outdated Show resolved Hide resolved
apps/web/screens/queries/Article.ts Show resolved Hide resolved
apps/web/screens/Article/Article.tsx Show resolved Hide resolved
apps/web/screens/Article/Article.tsx Show resolved Hide resolved
apps/web/screens/Article/Article.tsx Show resolved Hide resolved
RunarVestmann and others added 2 commits October 24, 2024 10:59
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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 (3)
libs/cms/src/lib/models/subArticle.model.ts (1)

59-59: LGTM: Mapping implementation is type-safe

The stepper mapping follows the established pattern and includes proper null checking. However, since this is a new field, we should ensure it's covered by tests.

Consider adding test cases for:

  • Mapping with stepper field present
  • Mapping with stepper field undefined
  • Mapping with stepper field null

Would you like me to help generate these test cases?

libs/island-ui/core/src/lib/Breadcrumbs/Breadcrumbs.tsx (1)

62-66: Consider adding aria-label to improve accessibility.

While the breadcrumb navigation is already accessible, you could enhance it by adding an aria-label to each item to provide more context.

 <Box
   key={`${item.title}-${index}`}
   display={'inlineFlex'}
   alignItems={'center'}
+  aria-label={`Breadcrumb ${index + 1} of ${visibleItems.length}: ${item.title}`}
 >
apps/web/screens/queries/Article.ts (1)

136-150: Consider adding TypeScript types for stepper-related fields.

The stepper structure is well-organized, but would benefit from explicit TypeScript types for better type safety and developer experience.

Consider creating the following types:

interface StepperConfig {
  // Define configuration options
}

interface Step {
  id: string
  title: string
  slug: string
  stepType: string
  subtitle: AllSlices
  config: Record<string, unknown>
}

interface Stepper {
  id: string
  title: string
  steps: Step[]
  config: StepperConfig
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4919948 and 0aec184.

⛔ Files ignored due to path filters (1)
  • libs/cms/src/lib/generated/contentfulTypes.d.ts is excluded by !**/generated/**
📒 Files selected for processing (5)
  • apps/web/screens/Article/Article.tsx (9 hunks)
  • apps/web/screens/queries/Article.ts (1 hunks)
  • libs/cms/src/lib/models/subArticle.model.ts (3 hunks)
  • libs/cms/src/lib/search/importers/manualChapterItem.service.ts (2 hunks)
  • libs/island-ui/core/src/lib/Breadcrumbs/Breadcrumbs.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
apps/web/screens/Article/Article.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/Article.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/models/subArticle.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/manualChapterItem.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/island-ui/core/src/lib/Breadcrumbs/Breadcrumbs.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."
🔇 Additional comments (8)
libs/cms/src/lib/models/subArticle.model.ts (2)

8-8: LGTM: Import follows established patterns

The import statement follows the existing pattern and properly imports both the mapping function and type definition.


32-34: LGTM: Field declaration follows best practices

The stepper field declaration:

  • Uses proper TypeScript optional types
  • Follows the established pattern with @CacheField decorator
  • Maintains consistency with similar optional fields in the model

Let's verify the Stepper type definition exists:

✅ Verification successful

Let me try a different search strategy to locate the Stepper type definition.

This comprehensive search should help us locate the Stepper type definition or understand how it's being imported and used in the codebase.


Let me check the stepper.model.ts file since it appears to be the source of the Stepper type used in subArticle.model.ts.


Stepper type is properly defined and used correctly

The verification confirms that:

  • The Stepper class is properly defined in libs/cms/src/lib/models/stepper.model.ts
  • It's correctly imported in subArticle.model.ts
  • The type has all necessary fields and decorators for GraphQL schema generation
  • It maps to a valid Contentful interface IStepper

The optional stepper field in subArticle.model.ts is therefore correctly typed and follows the established patterns in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the Stepper type definition
ast-grep --pattern 'export class Stepper {
  $$$
}'

Length of output: 53


Script:

#!/bin/bash
# Search for Stepper type definition using multiple approaches
echo "=== Searching for Stepper class definition ==="
ast-grep --pattern 'class Stepper'

echo -e "\n=== Searching for Stepper type/interface definition ==="
ast-grep --pattern 'type Stepper'
ast-grep --pattern 'interface Stepper'

echo -e "\n=== Searching for Stepper import statements ==="
rg "import.*Stepper" -A 1

echo -e "\n=== Searching for files containing Stepper ==="
fd -t f "Stepper"

Length of output: 6961


Script:

#!/bin/bash
# Check the stepper model definition
echo "=== Checking stepper.model.ts content ==="
cat libs/cms/src/lib/models/stepper.model.ts

echo -e "\n=== Checking the interface definition from contentfulTypes ==="
rg "interface IStepper" -A 10

Length of output: 2561

libs/island-ui/core/src/lib/Breadcrumbs/Breadcrumbs.tsx (1)

62-66: LGTM: Key implementation addresses focus retention issues.

The combination of title and index creates a more stable key that should resolve the focus retention problems mentioned in the PR objectives. This is a good improvement over using just the index.

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

144-146: Verify AllSlices fragment compatibility.

The subtitle field uses the AllSlices fragment. Ensure that all slice types are appropriate for the subtitle context.

libs/cms/src/lib/search/importers/manualChapterItem.service.ts (1)

25-25: LGTM: Improved error handling with optional chaining

The addition of optional chaining operator (?.) is a good defensive programming practice that prevents runtime errors when chapters is undefined.

apps/web/screens/Article/Article.tsx (3)

Line range hint 323-327: Consider specifying explicit types instead of 'any'

In the ArticleProps interface, the stepOptionsFromNamespace property uses any in Record<string, any>[]. Using any diminishes type safety and can lead to potential errors. Defining explicit types for the expected data structure enhances type checking and maintainability.


422-424: Ensure 'query.stepper' comparison accounts for boolean values

In the inStepperView computation, you're comparing query.stepper to the string 'true'. If query.stepper can also be a boolean, consider adjusting the comparison to handle both string and boolean representations of true to prevent unexpected behavior.


705-709: Avoid unnecessary type assertion with 'as StepperSchema'

In the Stepper component, you're using a type assertion to cast (subArticle ? subArticle.stepper : article?.stepper) to StepperSchema. Refining the types of article.stepper and subArticle.stepper to match StepperSchema can eliminate the need for type assertions and improve type safety.

apps/web/screens/Article/Article.tsx Show resolved Hide resolved
@kodiakhq kodiakhq bot merged commit 3288149 into main Oct 24, 2024
211 checks passed
@kodiakhq kodiakhq bot deleted the feature/web-stepper-on-subarticles branch October 24, 2024 16:53
@coderabbitai coderabbitai bot mentioned this pull request Nov 2, 2024
6 tasks
@coderabbitai coderabbitai bot mentioned this pull request Jan 7, 2025
6 tasks
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.

3 participants