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): add support links to grants #17189

Merged
merged 5 commits into from
Dec 12, 2024
Merged

feat(web): add support links to grants #17189

merged 5 commits into from
Dec 12, 2024

Conversation

thorkellmani
Copy link
Member

@thorkellmani thorkellmani commented Dec 10, 2024

What

  • Support link panel in grant sidebar

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Introduced a new panel in the Grant sidebar for support links, enhancing user navigation.
    • Added support links to the grant details, providing additional resources for users.
  • Bug Fixes

    • Improved the rendering logic in the Grant sidebar for better performance and maintainability.
  • Documentation

    • Updated GraphQL queries to include new support links field, enriching the data returned for grants.

@thorkellmani thorkellmani requested review from a team as code owners December 10, 2024 11:14
Copy link
Contributor

coderabbitai bot commented Dec 10, 2024

Walkthrough

The changes involve modifications to the GrantSidebar.tsx component, the GraphQL query in Grants.ts, and the Grant model in grant.model.ts. A new helper function, generateSidebarPanel, is introduced to streamline the rendering of sidebar panels in the UI. Additionally, a new field supportLinks is added to the GraphQL query and the Grant model, enhancing the data structure without altering existing fields. The overall structure and control flow remain similar, focusing on improved modularity and data handling.

Changes

File Path Change Summary
apps/web/screens/Grants/Grant/GrantSidebar.tsx Added generateSidebarPanel function for rendering sidebar panels and refactored existing panel logic. Introduced supportLinksPanelData for rendering support links. Updated import statements for BoxProps.
apps/web/screens/queries/Grants.ts Added supportLinks field to GET_GRANT_QUERY with subfields id, text, url, and date.
libs/cms/src/lib/models/grant.model.ts Added optional supportLinks field to Grant class and updated mapGrant function to include support links mapping.

Suggested labels

automerge, autoupdate

Suggested reviewers

  • birkirkristmunds

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. (Experiment)
  • @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

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 12.50000% with 14 lines in your changes missing coverage. Please review.

Project coverage is 35.76%. Comparing base (c561cf8) to head (66c6f84).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
apps/web/screens/Grants/Grant/GrantSidebar.tsx 0.00% 12 Missing ⚠️
libs/cms/src/lib/models/grant.model.ts 50.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17189      +/-   ##
==========================================
- Coverage   35.77%   35.76%   -0.01%     
==========================================
  Files        6931     6931              
  Lines      147962   147974      +12     
  Branches    42169    42171       +2     
==========================================
- Hits        52928    52926       -2     
- Misses      95034    95048      +14     
Flag Coverage Δ
api 3.33% <ø> (ø)
api-domains-auth-admin 48.49% <ø> (ø)
api-domains-communications 39.42% <50.00%> (+<0.01%) ⬆️
application-system-api 38.76% <50.00%> (-0.01%) ⬇️
application-template-api-modules 27.80% <50.00%> (+<0.01%) ⬆️
application-templates-accident-notification 28.93% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-driving-license 18.12% <ø> (ø)
application-templates-estate 13.79% <ø> (ø)
application-templates-financial-aid 14.42% <ø> (ø)
application-templates-general-petition 23.13% <ø> (ø)
application-templates-inheritance-report 6.54% <ø> (ø)
application-templates-marriage-conditions 15.11% <ø> (ø)
application-templates-mortgage-certificate 43.56% <ø> (ø)
application-templates-parental-leave 29.95% <ø> (ø)
application-ui-components 1.24% <ø> (ø)
application-ui-shell 22.47% <ø> (ø)
cms 0.40% <0.00%> (-0.01%) ⬇️
cms-translations 38.76% <50.00%> (+<0.01%) ⬆️
judicial-system-api 20.16% <ø> (ø)
judicial-system-backend 55.88% <50.00%> (-0.01%) ⬇️
portals-admin-regulations-admin 1.80% <ø> (ø)
portals-core 19.83% <ø> (ø)
services-user-notification 46.58% <50.00%> (+<0.01%) ⬆️
shared-components 30.06% <ø> (ø)
shared-form-fields 33.88% <ø> (ø)
web 2.43% <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/Grants.ts 0.00% <ø> (ø)
libs/cms/src/lib/models/grant.model.ts 47.29% <50.00%> (+0.15%) ⬆️
apps/web/screens/Grants/Grant/GrantSidebar.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 c561cf8...66c6f84. Read the comment docs.

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/screens/Grants/Grant/GrantSidebar.tsx (2)

138-165: Consider adding loading state and error handling

While the implementation is solid, consider these improvements:

  1. Add loading state for async link rendering
  2. Handle potential errors when links are invalid
 const supportLinksPanelData = useMemo(
   () =>
     grant.supportLinks
       ?.map((link) => {
         if (!link.url || !link.text || !link.id) {
+          console.warn(`Invalid support link found: ${JSON.stringify(link)}`);
           return null;
         }
+        try {
+          const url = new URL(link.url);
           return (
             <LinkV2
               newTab
               key={link.id}
-              href={link.url}
+              href={url.toString()}
               underlineVisibility="hover"
             >
               <Button
                 size="medium"
                 icon="link"
                 iconType="outline"
                 variant="text"
               >
                 {link.text}
               </Button>
             </LinkV2>
           )
+        } catch (error) {
+          console.error(`Invalid URL in support link: ${link.url}`);
+          return null;
+        }
       })
       .filter(isDefined) ?? [],
   [grant.supportLinks],
 )

3-10: LGTM: Follows NextJS and TypeScript best practices

The component implementation:

  • Uses proper TypeScript types with BoxProps
  • Implements efficient state management with useMemo
  • Follows island-ui/core component patterns
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fcadfe5 and f97b388.

⛔ Files ignored due to path filters (1)
  • libs/cms/src/lib/generated/contentfulTypes.d.ts is excluded by !**/generated/**
📒 Files selected for processing (3)
  • apps/web/screens/Grants/Grant/GrantSidebar.tsx (5 hunks)
  • apps/web/screens/queries/Grants.ts (1 hunks)
  • libs/cms/src/lib/models/grant.model.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
apps/web/screens/queries/Grants.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/grant.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/web/screens/Grants/Grant/GrantSidebar.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 (6)
libs/cms/src/lib/models/grant.model.ts (3)

10-10: LGTM: Import statement is correctly placed

The Link model import is appropriately placed with other model imports.


70-72: LGTM: Field definition follows best practices

The supportLinks field is properly decorated with @CacheField and correctly typed as an optional array of Link.


123-124: LGTM: Mapping function handles edge cases

The mapping function correctly handles null/undefined cases using the nullish coalescing operator.

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

80-85: Verify usage of the date field

While the query structure is correct, the date field is retrieved but not used in the UI component.

Consider removing the date field from the query if it's not being used to optimize the response payload.

apps/web/screens/Grants/Grant/GrantSidebar.tsx (2)

40-52: LGTM: Well-structured helper function

The generateSidebarPanel helper function improves code reusability and maintains consistent styling across panels.


178-180: LGTM: Consistent panel implementation

The implementation maintains visual consistency with other panels through proper background colors and spacing.

@datadog-island-is
Copy link

datadog-island-is bot commented Dec 10, 2024

Datadog Report

All test runs 741b2d7 🔗

11 Total Test Services: 0 Failed, 10 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.01%), 28 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 3.17s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 14.59s 1 no change Link
api-domains-communications 0 0 0 5 0 36.94s 1 no change Link
api-domains-license-service 0 0 0 0 0 484.51ms 1 no change Link
application-system-api 0 0 0 46 0 1m 56.84s 1 no change Link
application-template-api-modules 0 0 0 118 0 2m 7.43s 1 no change Link
cms-translations 0 0 0 3 0 30.32s 1 no change Link
judicial-system-api 0 0 0 61 0 7.38s 1 no change Link
judicial-system-backend 0 0 0 21278 0 24m 12.66s 1 no change Link
services-user-notification 0 0 0 51 0 1m 29.99s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • cms - jest 0.47% (-0.01%) - Details

@thorkellmani thorkellmani added the automerge Merge this PR as soon as all checks pass label Dec 10, 2024
@thorkellmani thorkellmani added automerge Merge this PR as soon as all checks pass and removed automerge Merge this PR as soon as all checks pass labels Dec 10, 2024
Copy link
Member

@disaerna disaerna left a comment

Choose a reason for hiding this comment

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

I would want to revisit the three panel view later on 👀

@oddsson oddsson added automerge Merge this PR as soon as all checks pass and removed automerge Merge this PR as soon as all checks pass labels Dec 11, 2024
@kodiakhq kodiakhq bot merged commit b2c44ee into main Dec 12, 2024
116 checks passed
@kodiakhq kodiakhq bot deleted the feat/add-support-links branch December 12, 2024 11:31
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.

4 participants