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(new button in form): Add possibility to render ServicePortal button in form footer #17433

Closed

Conversation

johannaagma
Copy link
Member

@johannaagma johannaagma commented Jan 7, 2025

What

In the application SecondarySchool, we have an overview page after application has been submitted to MMS. We need to add a back button on that screen, but since there is no steps to go back to, it should just open minar-sidur. If using the built in buildMessageWithLinkButtonField to display button for minar-sidur, then the page looks weird with both "Breyta umsókn" and this blue box

Screenshots / Gifs

Before (using buildMessageWithLinkButtonField):

image

After (using renderLastScreenServicePortalButton on form):

image

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

Release Notes

  • New Features

    • Added a service portal button option for the last screen of forms
    • Introduced new configuration to conditionally render a "Back to My Pages" button
  • Improvements

    • Enhanced form navigation with a new optional service portal button
    • Increased flexibility in screen footer rendering

The update provides users with an additional navigation option, allowing them to easily return to their personal service portal from the last screen of forms.

Copy link
Contributor

coderabbitai bot commented Jan 7, 2025

Walkthrough

This pull request introduces a new feature for rendering a service portal button in the application's form flow. The changes span multiple libraries, adding a new message entry, extending the Form interface, and updating components like Screen, ScreenFooter, and FormShell to support conditional rendering of a service portal button. The implementation allows for flexible navigation, particularly on the last screen of a form, with the ability to return to the user's personal pages.

Changes

File Change Summary
libs/application/core/src/lib/messages.ts Added new message entry buttonServicePortal with ID application.system:button.buttonServicePortal and default message "Til baka á mínar síður"
libs/application/types/src/lib/Form.ts Added optional boolean property renderLastScreenServicePortalButton to Form interface
libs/application/ui-shell/src/components/Screen.tsx Updated ScreenProps type and component to include renderLastScreenServicePortalButton prop
libs/application/ui-shell/src/components/ScreenFooter.tsx Added logic to conditionally render service portal button based on new prop
libs/application/ui-shell/src/lib/FormShell.tsx Integrated renderLastScreenServicePortalButton prop into component's rendering logic

Sequence Diagram

sequenceDiagram
    participant FormShell
    participant Screen
    participant ScreenFooter
    
    FormShell->>Screen: Pass renderLastScreenServicePortalButton
    Screen->>ScreenFooter: Forward renderLastScreenServicePortalButton
    alt renderLastScreenServicePortalButton is true
        ScreenFooter->>ScreenFooter: Render Service Portal Button
    end
Loading

Possibly related PRs

Suggested labels

automerge, deploy-feature

Suggested reviewers

  • thorkellmani
  • 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.

Copy link

codecov bot commented Jan 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.64%. Comparing base (6a1bc3b) to head (b06ffd1).
Report is 18 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #17433   +/-   ##
=======================================
  Coverage   35.64%   35.64%           
=======================================
  Files        6939     6939           
  Lines      149134   149134           
  Branches    42647    42647           
=======================================
  Hits        53165    53165           
  Misses      95969    95969           
Flag Coverage Δ
air-discount-scheme-web 0.00% <ø> (ø)
api 3.33% <ø> (ø)
application-api-files 61.97% <ø> (ø)
application-core 75.60% <ø> (ø)
application-system-api 38.74% <ø> (ø)
application-template-api-modules 27.72% <ø> (+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.70% <ø> (ø)
application-templates-parental-leave 29.92% <ø> (+0.11%) ⬆️
application-types 6.48% <ø> (ø)
application-ui-components 1.22% <ø> (ø)
clients-charge-fjs-v2 28.88% <ø> (ø)
web 2.39% <ø> (ø)

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

Files with missing lines Coverage Δ
libs/application/core/src/lib/messages.ts 100.00% <ø> (ø)
libs/application/types/src/lib/Form.ts 100.00% <ø> (ø)
...ibs/application/ui-shell/src/components/Screen.tsx 42.99% <ø> (ø)
...plication/ui-shell/src/components/ScreenFooter.tsx 26.19% <ø> (ø)
libs/application/ui-shell/src/lib/FormShell.tsx 69.44% <ø> (ø)

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 6a1bc3b...b06ffd1. Read the comment docs.

@datadog-island-is
Copy link

Datadog Report

All test runs a7acd50 🔗

10 Total Test Services: 0 Failed, 10 Passed
⬆️ Test Sessions change in coverage: 2 increased, 91 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-web 0 0 0 2 0 6.64s 1 no change Link
api 0 0 0 4 0 2.39s 1 no change Link
application-api-files 0 0 0 2 0 4.28s 1 no change Link
application-core 0 0 0 97 0 14.84s 1 no change Link
application-system-api 0 0 0 46 0 2m 15.59s 1 no change Link
application-template-api-modules 0 0 0 118 0 2m 4.16s 1 no change Link
application-templates-accident-notification 0 0 0 140 0 13.26s 1 no change Link
application-templates-criminal-record 0 0 0 2 0 9.46s 1 no change Link
application-templates-driving-license 0 0 0 13 0 12.95s 1 no change Link
application-templates-example-payment 0 0 0 2 0 9.99s 1 no change Link

@johannaagma johannaagma changed the title feat(form footer): Add renderLastScreenServicePortalButton feat(new button in form): Add possibility to render ServicePortal button in form footer Jan 7, 2025
@johannaagma johannaagma marked this pull request as ready for review January 8, 2025 13:18
@johannaagma johannaagma requested a review from a team as a code owner January 8, 2025 13:18
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)
libs/application/ui-shell/src/components/ScreenFooter.tsx (2)

199-211: Consider extracting duplicated button logic.

The service portal button implementation is duplicated between desktop and mobile views. Consider extracting this into a reusable component or shared function.

+ const ServicePortalButton = ({ isMobile, ...props }) => (
+   <Button
+     {...props}
+     variant="ghost"
+     data-testid="step-back"
+     onClick={() => {
+       window.open(servicePortalUrl, '_self')
+     }}
+     disabled={!canProceed || loading}
+     {...(isMobile ? {
+       circle: true,
+       icon: "arrowBack"
+     } : {})}
+   >
+     {!isMobile && formatMessage(coreMessages.buttonServicePortal)}
+   </Button>
+ )

  {showOpenServicePortal && (
-   <Button
-     variant="ghost"
-     data-testid="step-back"
-     onClick={() => {
-       window.open(servicePortalUrl, '_self')
-     }}
-     disabled={!canProceed || loading}
-   >
-     {formatMessage(coreMessages.buttonServicePortal)}
-   </Button>
+   <ServicePortalButton isMobile={false} />
  )}

  // Mobile view
  {showOpenServicePortal && (
-   <Button
-     circle
-     data-testid="step-back"
-     variant="ghost"
-     icon="arrowBack"
-     onClick={() => {
-       window.open(servicePortalUrl, '_self')
-     }}
-     disabled={!canProceed || loading}
-   />
+   <ServicePortalButton isMobile={true} />
  )}

Also applies to: 224-236


84-84: Consider making the service portal URL configurable.

The URL construction could be made more configurable by moving it to a configuration file or accepting it as a prop.

+ interface FooterProps {
+   // ... existing props
+   servicePortalBaseUrl?: string
+ }

- const servicePortalUrl = `/minarsidur/umsoknir#${application.id}`
+ const servicePortalUrl = `${props.servicePortalBaseUrl ?? '/minarsidur/umsoknir'}#${application.id}`
libs/application/core/src/lib/messages.ts (1)

14-18: Consider enhancing the description for better reusability.

The implementation follows the established pattern and naming conventions. However, to improve reusability across different NextJS apps, consider making the description more detailed to help other developers understand the specific use case and context.

Apply this diff to enhance the description:

   buttonServicePortal: {
     id: 'application.system:button.buttonServicePortal',
     defaultMessage: 'Til baka á mínar síður',
-    description: 'Service portal',
+    description: 'Button to navigate back to the service portal (mínar síður) from the overview page',
   },
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6a1bc3b and b06ffd1.

📒 Files selected for processing (5)
  • libs/application/core/src/lib/messages.ts (1 hunks)
  • libs/application/types/src/lib/Form.ts (1 hunks)
  • libs/application/ui-shell/src/components/Screen.tsx (3 hunks)
  • libs/application/ui-shell/src/components/ScreenFooter.tsx (5 hunks)
  • libs/application/ui-shell/src/lib/FormShell.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
libs/application/types/src/lib/Form.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/application/ui-shell/src/components/ScreenFooter.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."
libs/application/ui-shell/src/lib/FormShell.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."
libs/application/ui-shell/src/components/Screen.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."
libs/application/core/src/lib/messages.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)
libs/application/types/src/lib/Form.ts (1)

85-85: LGTM! Type definition follows best practices.

The new optional boolean property is well-typed and follows the existing naming pattern for similar properties.

libs/application/ui-shell/src/lib/FormShell.tsx (1)

68-68: LGTM! Clean prop drilling implementation.

The property is correctly extracted from state and properly passed down to the Screen component, following the established pattern.

Also applies to: 154-156

libs/application/ui-shell/src/components/ScreenFooter.tsx (1)

81-84: LGTM! Clean conditional rendering logic.

The showOpenServicePortal condition is well-structured and follows the existing pattern.

libs/application/ui-shell/src/components/Screen.tsx (1)

77-77: LGTM! Clean prop drilling implementation.

The property is correctly typed in ScreenProps and properly passed down to the ScreenFooter component.

Also applies to: 419-421

@johannaagma johannaagma closed this Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant