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

Communication: Add profile picture to user selector #9764

Merged

Conversation

asliayk
Copy link
Contributor

@asliayk asliayk commented Nov 12, 2024

Checklist

General

Client

Motivation and Context

Currently, when users select individuals to create a direct/group chat, only names are displayed, and profile pictures are not visible. This can make it harder to identify the correct person.

Description

Added profile picture component to user selector to get relevant profile pictures.

Steps for Testing

Prerequisites:

  • 1 Instructor/Student
  • 1 Course with Communication enabled
  1. Log in to Artemis
  2. Navigate to Communication section of a course
  3. Click + button next to the search area to create direct/group chat.
  4. Notice that when the user searches for names, the suggestions now contain relevant profile pictures.

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Test Coverage

Screenshots

direct chat dialog
image

group chat dialog
image

Summary by CodeRabbit

  • New Features

    • Enhanced user selection display in the dropdown with profile pictures and user labels.
  • Bug Fixes

    • Retained existing functionality for search status messages and user role filters.
  • Tests

    • Updated test suite to include a mock for the ProfilePictureComponent, ensuring accurate testing of the CourseUsersSelectorComponent and verifying the rendering of profile pictures.

@asliayk asliayk added client Pull requests that update TypeScript code. (Added Automatically!) small component:Communication labels Nov 12, 2024
@asliayk asliayk self-assigned this Nov 12, 2024
@asliayk asliayk requested a review from a team as a code owner November 12, 2024 20:41
@github-actions github-actions bot added the tests label Nov 12, 2024
Copy link

coderabbitai bot commented Nov 12, 2024

Walkthrough

The changes in this pull request primarily focus on enhancing the user interface of the CourseUsersSelectorComponent. The HTML template has been updated to use a new ng-template for displaying user results, which includes a profile picture component. Additionally, the module has been modified to import the ProfilePictureComponent, making it available for use. The test suite has also been updated to include a mock of the ProfilePictureComponent, ensuring that the component's functionality is properly tested.

Changes

File Change Summary
src/main/webapp/app/shared/course-users-selector/course-users-selector.component.html Updated resultFormatter to resultTemplate and added a new ng-template for user display with profile pictures.
src/main/webapp/app/shared/course-users-selector/course-users-selector.module.ts Added ProfilePictureComponent to the imports array of the CourseUsersSelectorModule.
src/test/javascript/spec/component/shared/course-users-selector/course-users-selector.component.spec.ts Added mock component for ProfilePictureComponent in the test module declarations and adjusted imports.

Possibly related PRs

Suggested labels

ready to merge

Suggested reviewers

  • PaRangger
  • JohannesStoehr
  • edkaya
  • florian-glombik
  • sachmii

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 10df059 and 387dcdc.

📒 Files selected for processing (2)
  • src/main/webapp/app/shared/course-users-selector/course-users-selector.component.html (1 hunks)
  • src/test/javascript/spec/component/shared/course-users-selector/course-users-selector.component.spec.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/webapp/app/shared/course-users-selector/course-users-selector.component.html
  • src/test/javascript/spec/component/shared/course-users-selector/course-users-selector.component.spec.ts

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 or @coderabbitai title 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

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

🧹 Outside diff range and nitpick comments (1)
src/main/webapp/app/shared/course-users-selector/course-users-selector.component.html (1)

26-29: Consider making sizes configurable and updating ID prefixes

The hardcoded values and naming could be improved:

  1. Consider making image and font sizes configurable via inputs
  2. The 'sidebar' prefix in IDs (sidebar-profile-picture, sidebar-default-profile-picture) might not be appropriate for this context

Example improvement:

-    [imageSizeInRem]="'1.1'"
-    [fontSizeInRem]="'0.5'"
-    [imageId]="'sidebar-profile-picture'"
-    [defaultPictureId]="'sidebar-default-profile-picture'"
+    [imageSizeInRem]="config.imageSizeInRem"
+    [fontSizeInRem]="config.fontSizeInRem"
+    [imageId]="'user-selector-profile-picture'"
+    [defaultPictureId]="'user-selector-default-profile-picture'"
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7876792 and e9dd86c.

📒 Files selected for processing (3)
  • src/main/webapp/app/shared/course-users-selector/course-users-selector.component.html (1 hunks)
  • src/main/webapp/app/shared/course-users-selector/course-users-selector.module.ts (1 hunks)
  • src/test/javascript/spec/component/shared/course-users-selector/course-users-selector.component.spec.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/main/webapp/app/shared/course-users-selector/course-users-selector.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

src/main/webapp/app/shared/course-users-selector/course-users-selector.module.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/test/javascript/spec/component/shared/course-users-selector/course-users-selector.component.spec.ts (1)

Pattern src/test/javascript/spec/**/*.ts: jest: true; mock: NgMocks; bad_practices: avoid_full_module_import; perf_improvements: mock_irrelevant_deps; service_testing: mock_http_for_logic; no_schema: avoid_NO_ERRORS_SCHEMA; expectation_specificity: true; solutions: {boolean: toBeTrue/False, reference: toBe, existence: toBeNull/NotNull, undefined: toBeUndefined, class_obj: toContainEntries/toEqual, spy_calls: {not_called: not.toHaveBeenCalled, once: toHaveBeenCalledOnce, with_value: toHaveBeenCalledWith|toHaveBeenCalledExactlyOnceWith}}

🔇 Additional comments (5)
src/main/webapp/app/shared/course-users-selector/course-users-selector.module.ts (2)

7-7: LGTM!

The import statement follows Angular style guidelines with proper naming and absolute import path.


10-10: ⚠️ Potential issue

Critical: Move ProfilePictureComponent to correct array

The ProfilePictureComponent should not be in the imports array. Components must be declared in the declarations array of an NgModule. The imports array is meant for importing other modules only.

Additionally, since this component is from app/shared/, it's likely already declared in ArtemisSharedModule which you're already importing. You shouldn't declare it again to avoid multiple declaration errors.

Apply this fix:

@NgModule({
-    imports: [CommonModule, FormsModule, ReactiveFormsModule, ArtemisSharedModule, ArtemisSharedComponentModule, ProfilePictureComponent],
+    imports: [CommonModule, FormsModule, ReactiveFormsModule, ArtemisSharedModule, ArtemisSharedComponentModule],
    exports: [CourseUsersSelectorComponent],
    declarations: [CourseUsersSelectorComponent],
})

Let's verify if ProfilePictureComponent is already declared in ArtemisSharedModule:

src/main/webapp/app/shared/course-users-selector/course-users-selector.component.html (2)

16-16: LGTM: Input configuration updated correctly

The change from resultFormatter to resultTemplate properly implements the template-based approach needed for the enhanced user display.


23-39: LGTM: Well-structured template implementation

The template implementation effectively combines profile pictures with user labels using proper flex layout and accessibility considerations.

src/test/javascript/spec/component/shared/course-users-selector/course-users-selector.component.spec.ts (1)

9-9: LGTM! Correct imports for mocking.

The imports for MockComponent and ProfilePictureComponent are correctly added to support the new profile picture feature.

Also applies to: 17-17

coderabbitai[bot]
coderabbitai bot previously approved these changes Nov 12, 2024
@PaRangger
Copy link
Contributor

Tested on TS3, looks great! I left some small nitpicks for the code.

sachmii
sachmii previously approved these changes Nov 13, 2024
Copy link

@sachmii sachmii left a comment

Choose a reason for hiding this comment

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

Tested on TS3, looks good.

Bildschirmfoto 2024-11-13 um 10 47 32

Copy link

@Longppham Longppham left a comment

Choose a reason for hiding this comment

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

I tested the student side on TS4. After following the described steps for testing, everything worked as described! Showed multiple pictures and names but also for 1 search result!

Since this works very well and having pictures added makes searching a lot easier. I would love to see this implemented.

image
image

@asliayk asliayk dismissed stale reviews from sachmii and coderabbitai[bot] via 36a3c03 November 13, 2024 12:36
@github-actions github-actions bot added deployment-error Added by deployment workflows if an error occured and removed deploy:artemis-test1 labels Nov 14, 2024
@ahbitaqu ahbitaqu added deploy:artemis-test1 and removed deployment-error Added by deployment workflows if an error occured labels Nov 14, 2024
@ahbitaqu ahbitaqu temporarily deployed to artemis-test1.artemis.cit.tum.de November 14, 2024 19:56 — with GitHub Actions Inactive
Copy link

@ahbitaqu ahbitaqu left a comment

Choose a reason for hiding this comment

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

[Tested on TS1]
No issues found here. Very welcome feature!

image

Copy link

@Malekos74 Malekos74 left a comment

Choose a reason for hiding this comment

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

Server tested on: 01

Works as expected. I like it

Copy link

@sawys777 sawys777 left a comment

Choose a reason for hiding this comment

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

Tested on TS1, everything worked as expected.

@krusche krusche added this to the 7.7.1 milestone Nov 16, 2024
@krusche krusche merged commit 9d543b9 into develop Nov 16, 2024
169 of 177 checks passed
@krusche krusche deleted the feature/communication/add-profile-picture-to-user-selector branch November 16, 2024 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) component:Communication ready for review small tests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.