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 disclaimer for UTL web chat #16577

Merged
merged 6 commits into from
Oct 28, 2024

Conversation

RunarVestmann
Copy link
Member

@RunarVestmann RunarVestmann commented Oct 25, 2024

Add disclaimer for UTL web chat

Why

  • This was requested by Digital Iceland

Screenshots / Gifs

Screen.Recording.2024-10-28.at.09.37.49.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

Release Notes

  • New Features

    • Introduced an EmbedDisclaimer component to present terms and conditions within the chat interface.
    • Enhanced ChatBubble to conditionally display the disclaimer based on user interactions.
    • Improved Watson chat integration with user feedback options and dynamic disclaimer messaging.
  • Bug Fixes

    • Resolved issues with rendering and state management in the chat components.
  • Styling

    • Added new styles for the EmbedDisclaimer component to improve visual presentation and responsiveness.

Copy link
Contributor

coderabbitai bot commented Oct 25, 2024

Walkthrough

The pull request introduces changes to the ChatBubble and WatsonChatPanel components, enhancing user interactions and disclaimers. A new EmbedDisclaimer component is added to manage user acceptance of terms through a modal interface. The ChatBubble component is updated to include props for the disclaimer, while the WatsonChatPanel integrates logic to conditionally display the disclaimer based on chat configuration. Additionally, new styles are introduced for the disclaimer modal.

Changes

File Change Summary
apps/web/components/ChatPanel/ChatBubble/ChatBubble.tsx - Added embedDisclaimerProps to ChatBubbleProps interface.
- Introduced state and ref for modal handling.
- Updated rendering logic for EmbedDisclaimer.
apps/web/components/ChatPanel/ChatBubble/EmbedDisclaimer/EmbedDisclaimer.css.ts - Added styles for link and modal in the EmbedDisclaimer component.
apps/web/components/ChatPanel/ChatBubble/EmbedDisclaimer/EmbedDisclaimer.tsx - Introduced EmbedDisclaimer component with props for managing user acceptance of terms.
- Implemented form management using react-hook-form.
apps/web/components/ChatPanel/WatsonChatPanel/WatsonChatPanel.tsx - Added replaceDirectorateOfImmigrationWebChatWithAI and chatTermsUrl variables.
- Updated embedDisclaimerProps for ChatBubble.

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.

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 25, 2024

Datadog Report

All test runs 6a96e38 🔗

34 Total Test Services: 0 Failed, 32 Passed
🔻 Test Sessions change in coverage: 2 decreased, 146 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 7.78s 1 no change Link
api 0 0 0 4 0 2.71s 1 no change Link
application-api-files 0 0 0 12 0 5.64s 1 no change Link
application-core 0 0 0 92 0 18.24s 1 decreased (-0.2%) Link
application-system-api 0 0 0 120 2 3m 6.6s 1 no change Link
application-template-api-modules 0 0 0 123 0 2m 26.41s 1 no change Link
application-templates-accident-notification 0 0 0 148 0 18.18s 1 no change Link
application-templates-criminal-record 0 0 0 2 0 10.18s 1 no change Link
application-templates-driving-license 0 0 0 13 0 15.22s 1 no change Link
application-templates-example-payment 0 0 0 2 0 10.62s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (2)

  • application-core - jest 79.37% (-0.2%) - Details
  • judicial-system-web - jest 32.01% (-0.01%) - Details

Copy link

codecov bot commented Oct 25, 2024

Codecov Report

Attention: Patch coverage is 0% with 64 lines in your changes missing coverage. Please review.

Project coverage is 36.78%. Comparing base (739f1f6) to head (7f0c4df).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...web/components/ChatPanel/ChatBubble/ChatBubble.tsx 0.00% 25 Missing ⚠️
...nel/ChatBubble/EmbedDisclaimer/EmbedDisclaimer.tsx 0.00% 23 Missing ⚠️
...ents/ChatPanel/WatsonChatPanel/WatsonChatPanel.tsx 0.00% 16 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16577      +/-   ##
==========================================
- Coverage   36.80%   36.78%   -0.02%     
==========================================
  Files        6854     6855       +1     
  Lines      142256   142308      +52     
  Branches    40572    40591      +19     
==========================================
- Hits        52353    52351       -2     
- Misses      89903    89957      +54     
Flag Coverage Δ
judicial-system-backend 55.32% <ø> (ø)
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 Δ
...ents/ChatPanel/WatsonChatPanel/WatsonChatPanel.tsx 0.00% <0.00%> (ø)
...nel/ChatBubble/EmbedDisclaimer/EmbedDisclaimer.tsx 0.00% <0.00%> (ø)
...web/components/ChatPanel/ChatBubble/ChatBubble.tsx 0.00% <0.00%> (ø)

... and 3 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 739f1f6...7f0c4df. Read the comment docs.

@RunarVestmann RunarVestmann marked this pull request as ready for review October 28, 2024 09:35
@RunarVestmann RunarVestmann requested a review from a team as a code owner October 28, 2024 09:35
@RunarVestmann RunarVestmann added the automerge Merge this PR as soon as all checks pass label Oct 28, 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: 10

🧹 Outside diff range and nitpick comments (4)
apps/web/components/ChatPanel/ChatBubble/ChatBubble.tsx (3)

30-30: Consider renaming 'hasButtonBeenClicked' to 'hasAcceptedTerms' for clarity

The variable hasButtonBeenClicked is used to track whether the user has accepted the terms from the disclaimer. Renaming it to hasAcceptedTerms would improve code readability and better reflect its purpose.

Apply this diff to rename the variable:

- const hasButtonBeenClicked = useRef(false)
+ const hasAcceptedTerms = useRef(false)

And update its usages accordingly.


48-86: Ensure the 'FocusableBox' component meets accessibility standards

Consider verifying that the FocusableBox component includes necessary accessibility attributes. If the button lacks sufficient accessible text for screen readers, adding an aria-label or aria-labelledby attribute would enhance accessibility.


72-72: Avoid inline styles for maintainability

Using inline styles can make the code harder to maintain and override. Consider using CSS classes instead of inline styles for controlling visibility.

Apply this diff:

- <Box style={{ visibility: loading ? 'hidden' : 'visible' }}>
+ <Box className={loading ? styles.hidden : undefined}>

And define the hidden class in your CSS:

.hidden {
  visibility: hidden;
}
apps/web/components/ChatPanel/WatsonChatPanel/WatsonChatPanel.tsx (1)

418-418: Use null instead of an empty string for chatTermsUrl default

Assigning '' (empty string) as the default value for chatTermsUrl might lead to unintended behavior when performing truthy checks. Using null can be clearer for representing the absence of a value.

Apply this diff to adjust the default value:

- const chatTermsUrl = n('chatTermsUrl', '')
+ const chatTermsUrl = n('chatTermsUrl', null)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 203c6b1 and d4080fa.

📒 Files selected for processing (4)
  • apps/web/components/ChatPanel/ChatBubble/ChatBubble.tsx (3 hunks)
  • apps/web/components/ChatPanel/ChatBubble/EmbedDisclaimer/EmbedDisclaimer.css.ts (1 hunks)
  • apps/web/components/ChatPanel/ChatBubble/EmbedDisclaimer/EmbedDisclaimer.tsx (1 hunks)
  • apps/web/components/ChatPanel/WatsonChatPanel/WatsonChatPanel.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
apps/web/components/ChatPanel/ChatBubble/ChatBubble.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/ChatPanel/ChatBubble/EmbedDisclaimer/EmbedDisclaimer.css.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/ChatPanel/ChatBubble/EmbedDisclaimer/EmbedDisclaimer.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/ChatPanel/WatsonChatPanel/WatsonChatPanel.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 (2)
apps/web/components/ChatPanel/ChatBubble/EmbedDisclaimer/EmbedDisclaimer.css.ts (1)

1-3: LGTM! Clean imports following best practices.

The imports are well-organized, separating third-party and internal dependencies.

apps/web/components/ChatPanel/ChatBubble/ChatBubble.tsx (1)

Line range hint 1-88: The implementation follows Next.js and TypeScript best practices

The code effectively integrates the EmbedDisclaimer component, manages state efficiently with useState and useRef, and appropriately uses TypeScript for type safety.

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 (1)
apps/web/components/ChatPanel/ChatBubble/ChatBubble.tsx (1)

29-30: Consider adding documentation for state and ref

While the implementation is correct, adding JSDoc comments would improve code maintainability by explaining:

  • Why a ref is used for tracking button clicks
  • The purpose of the modal state
+// Tracks if the button has been clicked to prevent showing the modal multiple times
 const hasButtonBeenClicked = useRef(false)
+// Controls the visibility of the disclaimer modal
 const [isConfirmModalOpen, setIsConfirmModalOpen] = useState(false)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d4080fa and 6cc800c.

📒 Files selected for processing (2)
  • apps/web/components/ChatPanel/ChatBubble/ChatBubble.tsx (3 hunks)
  • apps/web/components/ChatPanel/ChatBubble/EmbedDisclaimer/EmbedDisclaimer.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/components/ChatPanel/ChatBubble/EmbedDisclaimer/EmbedDisclaimer.tsx
🧰 Additional context used
📓 Path-based instructions (1)
apps/web/components/ChatPanel/ChatBubble/ChatBubble.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 (3)
apps/web/components/ChatPanel/ChatBubble/ChatBubble.tsx (3)

1-1: LGTM: Import statements are well-organized

The new imports are properly structured, with React hooks and the EmbedDisclaimer component and its types clearly separated.

Also applies to: 6-9


18-18: LGTM: Props interface is well-typed

Good use of TypeScript's Pick utility type to ensure type safety while only including the necessary props from EmbedDisclaimerProps.


Line range hint 1-94: LGTM: Follows NextJS best practices

The component adheres to NextJS best practices:

  • Proper use of TypeScript for type safety
  • Efficient state management with hooks
  • Clean component structure

@kodiakhq kodiakhq bot merged commit 621c4cc into main Oct 28, 2024
33 checks passed
@kodiakhq kodiakhq bot deleted the feature/web-chat-terms-disclaimer branch October 28, 2024 15:56
RunarVestmann added a commit that referenced this pull request Oct 30, 2024
* Add disclaimer

* Move EmbedDisclaimer component

* Remove whitespace

* Address coderabbit suggestions

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
kodiakhq bot added a commit that referenced this pull request Oct 30, 2024
* Add disclaimer

* Move EmbedDisclaimer component

* Remove whitespace

* Address coderabbit suggestions

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants