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

enhance(apps/frontend-pwa): improve layout of group messages #4274

Merged
merged 6 commits into from
Sep 23, 2024

Conversation

sjschlapbach
Copy link
Member

Screenshot 2024-09-23 at 12 59 01

Copy link

aviator-app bot commented Sep 23, 2024

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was merged manually (without Aviator). Merging manually can negatively impact the performance of the queue. Consider using Aviator next time.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

Copy link

coderabbitai bot commented Sep 23, 2024

Walkthrough

Walkthrough

The changes in GroupView.tsx involve a restructuring of the group messaging interface, including adjustments to the message display area and the message submission form. The message display now features a scrollable container, participant avatars, and grouped consecutive messages from the same user. The submission form has been redesigned with a new send button and improved layout, aligning the textarea and button horizontally while implementing state management for button functionality.

Changes

File Change Summary
apps/frontend-pwa/src/components/course/GroupView.tsx Restructured message display with scrollable container, added avatars and usernames, improved message formatting, updated message submission form with new button design and layout adjustments.

Possibly related PRs


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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

@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: 3

Outside diff range and nitpick comments (1)
apps/frontend-pwa/src/components/course/GroupView.tsx (1)

215-221: Remove unnecessary key prop on Image component

The key prop on the Image component is unnecessary unless the Image is part of an array being iterated over. The key prop is primarily used by React to identify which items have changed, are added, or are removed.

You can remove the key prop from the Image component:

<Image
-  key={message.participant.avatar}
   src={
     message.participant.avatar
       ? `${process.env.NEXT_PUBLIC_AVATAR_BASE_PATH}/${message.participant.avatar}.svg`
       : '/user-solid.svg'
   }
   alt=""
   height={25}
   width={25}
   className={twMerge(
     'order-1',
     ownMessage && 'order-2'
   )}
 />
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9729fd0 and 79ea1e5.

Files selected for processing (1)
  • apps/frontend-pwa/src/components/course/GroupView.tsx (2 hunks)
Additional comments not posted (2)
apps/frontend-pwa/src/components/course/GroupView.tsx (2)

2-3: Imports added for FontAwesomeIcon and faPaperPlane

The imports for FontAwesomeIcon and faPaperPlane are correct and necessary for the send button icon.


250-250: Ensure message.createdAt is properly formatted

While displaying the message timestamp, ensure that message.createdAt is in a valid date format compatible with dayjs. If createdAt could be undefined or null, it might lead to formatting issues.

Run the following script to verify the validity of createdAt fields:

Verification successful

message.createdAt is properly formatted and validated

All createdAt fields are confirmed to be non-null and properly defined within the GroupMessage interface. No formatting issues with dayjs are detected.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all group messages have a valid 'createdAt' field.

# Test: Search for any 'createdAt' fields that are null or undefined.
# Expect: No results, meaning all 'createdAt' fields are valid.

ast-grep --lang typescript --pattern '$.createdAt == null' --json | jq '.'

# Alternatively, check the type definitions for 'GroupMessage'.
ast-grep --lang typescript --pattern 'interface GroupMessage { $$$ }' --json | jq '.'

Length of output: 166

apps/frontend-pwa/src/components/course/GroupView.tsx Outdated Show resolved Hide resolved
Copy link

cypress bot commented Sep 23, 2024

klicker-uzh    Run #3037

Run Properties:  status check passed Passed #3037  •  git commit f76a1abad5 ℹ️: Merge 280aab6cb6def3c8a167ff86dce7183067875ded into 47fd322a7ccfea4a1b104798da36...
Project klicker-uzh
Branch Review group-messages-layout
Run status status check passed Passed #3037
Run duration 09m 07s
Commit git commit f76a1abad5 ℹ️: Merge 280aab6cb6def3c8a167ff86dce7183067875ded into 47fd322a7ccfea4a1b104798da36...
Committer Julius Schlapbach
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 44
View all changes introduced in this branch ↗︎

Copy link

Copy link

@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 (2)
apps/frontend-pwa/src/components/course/GroupView.tsx (2)

187-256: LGTM: Improved message display area with a suggestion

The restructured message display area significantly enhances the user experience:

  • The scrollable container with reversed flex direction creates a more natural chat-like interface.
  • Including participant avatars and usernames improves message attribution.
  • Grouping messages from the same user reduces visual clutter.
  • The layout adapts well for both sent and received messages.

These changes contribute to a more organized and readable group chat interface.

Consider adding an aria-label to the scrollable message container for improved accessibility. For example:

<div
  className="mb-2 flex max-h-80 min-h-40 flex-col-reverse gap-1.5 overflow-scroll"
  data-cy="group-messages"
+ aria-label={t('pwa.groups.messageList')}
>

Don't forget to add the corresponding translation key.


259-307: LGTM: Well-implemented message submission form with a suggestion

The new message submission form is well-implemented:

  • Formik provides robust form handling and validation.
  • The textarea allows for multi-line messages, improving flexibility.
  • The paper plane icon in the submit button is intuitive and visually appealing.
  • Disabling the submit button when invalid or submitting prevents errors.

These changes significantly improve the user experience when sending messages.

Consider adding a success notification after successfully sending a message. This could be implemented by adding a state variable and displaying a temporary notification. For example:

const [showSuccessNotification, setShowSuccessNotification] = useState(false);

// In the onSubmit function:
setShowSuccessNotification(true);
setTimeout(() => setShowSuccessNotification(false), 3000);

// In the JSX:
{showSuccessNotification && (
  <UserNotification
    type="success"
    message={t('pwa.groups.messageSentSuccess')}
  />
)}

Don't forget to add the corresponding translation key.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 79ea1e5 and 280aab6.

Files selected for processing (1)
  • apps/frontend-pwa/src/components/course/GroupView.tsx (2 hunks)
Additional comments not posted (3)
apps/frontend-pwa/src/components/course/GroupView.tsx (3)

2-3: LGTM: New imports for FontAwesome icons

The new imports for FontAwesome icons are correctly added and necessary for the paper plane icon used in the send button of the message form.


183-185: LGTM: Improved H3 styling

The modification to the H3 component's className enhances the visual separation between the header and the content by adding a bottom border. This change contributes to a cleaner layout.


193-193: LGTM: Typo in variable name fixed

The typo in the variable name has been correctly fixed from 'ownMesssage' to 'ownMessage'. This change improves code readability and prevents potential confusion or errors.

@sjschlapbach sjschlapbach merged commit 8744f99 into v3 Sep 23, 2024
10 of 12 checks passed
@sjschlapbach sjschlapbach deleted the group-messages-layout branch September 23, 2024 20:33
Copy link

cypress bot commented Sep 23, 2024

klicker-uzh    Run #3038

Run Properties:  status check passed Passed #3038  •  git commit 8744f99cf0: enhance(apps/frontend-pwa): improve layout of group messages (#4274)
Project klicker-uzh
Branch Review v3
Run status status check passed Passed #3038
Run duration 09m 08s
Commit git commit 8744f99cf0: enhance(apps/frontend-pwa): improve layout of group messages (#4274)
Committer Julius Schlapbach
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 1
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 44
View all changes introduced in this branch ↗︎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants