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 loading indicator when adding users to channel #10032

Conversation

PaRangger
Copy link
Contributor

@PaRangger PaRangger commented Dec 16, 2024

Checklist

General

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data (e.g. using paging).
  • I strictly followed the client coding and design guidelines.
  • Following the theming guidelines, I specified colors only in the theming variable files and checked that the changes look consistent in both the light and the dark theme.
  • I added multiple screenshots/screencasts of my UI changes.

Motivation and Context

Currently, when adding a lot of users to a channel it may load for a while. The button does not show a loading indicator, leading to users clicking it repeatedly, sending various heavy requests to the server.

Description

I added a loading indicator when adding users to a channel and disabled the button while loading.

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 2 Students
  • 1 Programming Exercise with Complaints enabled
  1. Log in to Artemis
  2. Navigate to course
  3. Navigate to the communication tab
  4. Create a channel (group channel or public channel)
  5. On the top right of the channel, click the "Add users" button
  6. Go to "Add whole groups" and add all students/tutors/instructors (This should take a while on the testservers)
  7. Click "Add Users" and check if a loading indicator is displayed and if the button is disabled

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

Client

Class/File Line Coverage Confirmation (assert/expect)
conversation-add-users-form.component.ts 90.9%
conversation-add-users-dialog.component.ts 93.47%

Screenshots

Bildschirmfoto 2024-12-16 um 19 37 01

Summary by CodeRabbit

  • New Features

    • Added a loading spinner to the submit button in the user addition form, providing visual feedback during submission.
    • Introduced a loading state management mechanism in the user addition dialog component.
  • Bug Fixes

    • Ensured form submission is only possible when not in a loading state.
  • Tests

    • Updated test components to include the new loading state property.

@PaRangger PaRangger added client Pull requests that update TypeScript code. (Added Automatically!) small bugfix component:Communication communication Pull requests that affect the corresponding module labels Dec 16, 2024
@PaRangger PaRangger self-assigned this Dec 16, 2024
@github-actions github-actions bot removed the communication Pull requests that affect the corresponding module label Dec 16, 2024
@PaRangger PaRangger temporarily deployed to artemis-test3.artemis.cit.tum.de December 16, 2024 18:49 — with GitHub Actions Inactive
@github-actions github-actions bot added the tests label Dec 16, 2024
@PaRangger PaRangger marked this pull request as ready for review December 16, 2024 19:31
@PaRangger PaRangger requested a review from a team as a code owner December 16, 2024 19:31
Copy link

coderabbitai bot commented Dec 16, 2024

Walkthrough

This pull request introduces loading state management for the conversation add users dialog in an Angular application. The changes span multiple files in the course conversations module, adding a new isLoading property to track the loading state during user addition processes. The implementation includes visual feedback through a loading spinner in the form's submit button, ensuring users are aware when an asynchronous operation is in progress. The modifications enhance the user interface by providing clear loading indicators during user addition to channels or group chats.

Changes

File Change Summary
.../conversation-add-users-form.component.html Added loading spinner with conditional rendering using <fa-icon> when isLoading() is true
.../conversation-add-users-form.component.ts Added isLoading input property, faSpinner icon, and updated isSubmitPossible getter to check loading state
.../conversation-add-users-dialog.component.html Added [isLoading] input binding to form component
.../conversation-add-users-dialog.component.ts Added isLoading property and updated addUsers method to manage loading state
.../conversation-add-users-dialog.component.spec.ts Added isLoading property to stub component for testing

Sequence Diagram

sequenceDiagram
    participant User
    participant Dialog
    participant Form
    participant Service

    User->>Dialog: Initiate Add Users
    Dialog->>Form: Set isLoading = false
    User->>Form: Select Users
    User->>Form: Submit
    Form->>Dialog: Trigger addUsers()
    Dialog->>Dialog: Set isLoading = true
    Dialog->>Service: Add Users
    Service-->>Dialog: Users Added
    Dialog->>Dialog: Set isLoading = false
    Dialog->>Form: Update UI
Loading

Possibly related PRs

Suggested labels

ready to merge

Suggested reviewers

  • HawKhiem
  • sachmii
  • florian-glombik
  • krusche
  • edkaya
  • Malekos74

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request.


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 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: 2

🧹 Nitpick comments (1)
src/main/webapp/app/overview/course-conversations/dialogs/conversation-add-users-dialog/conversation-add-users-dialog.component.ts (1)

32-32: Consider using a signal for loading state

Since this component manages an async operation state, consider using an Angular signal for better reactivity and state management.

-    protected isLoading: boolean = false;
+    protected isLoading = signal<boolean>(false);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5449cc4 and c8cfff0.

📒 Files selected for processing (5)
  • src/main/webapp/app/overview/course-conversations/dialogs/conversation-add-users-dialog/add-users-form/conversation-add-users-form.component.html (1 hunks)
  • src/main/webapp/app/overview/course-conversations/dialogs/conversation-add-users-dialog/add-users-form/conversation-add-users-form.component.ts (3 hunks)
  • src/main/webapp/app/overview/course-conversations/dialogs/conversation-add-users-dialog/conversation-add-users-dialog.component.html (1 hunks)
  • src/main/webapp/app/overview/course-conversations/dialogs/conversation-add-users-dialog/conversation-add-users-dialog.component.ts (4 hunks)
  • src/test/javascript/spec/component/overview/course-conversations/dialogs/conversation-add-users-dialog/conversation-add-users-dialog.component.spec.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
src/main/webapp/app/overview/course-conversations/dialogs/conversation-add-users-dialog/add-users-form/conversation-add-users-form.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/overview/course-conversations/dialogs/conversation-add-users-dialog/conversation-add-users-dialog.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/overview/course-conversations/dialogs/conversation-add-users-dialog/conversation-add-users-dialog.component.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/main/webapp/app/overview/course-conversations/dialogs/conversation-add-users-dialog/add-users-form/conversation-add-users-form.component.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/overview/course-conversations/dialogs/conversation-add-users-dialog/conversation-add-users-dialog.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/overview/course-conversations/dialogs/conversation-add-users-dialog/conversation-add-users-dialog.component.html (1)

20-20: LGTM! Loading state properly propagated to form component

The loading state is correctly bound to the child component, following Angular's input binding pattern.

src/main/webapp/app/overview/course-conversations/dialogs/conversation-add-users-dialog/add-users-form/conversation-add-users-form.component.ts (2)

28-29: LGTM! Modern input() syntax used for loading state

The loading state is implemented using Angular's new input() syntax, which is the recommended approach.


46-49: LGTM! Submit button state properly managed

The isSubmitPossible getter correctly considers the loading state to prevent multiple submissions while maintaining existing validation logic.

src/main/webapp/app/overview/course-conversations/dialogs/conversation-add-users-dialog/add-users-form/conversation-add-users-form.component.html (1)

66-68: LGTM! Clean implementation of loading indicator

The implementation follows Angular's new syntax guidelines with @if and provides good user feedback with the spinner animation. The margin spacing (ms-2) ensures clean visual separation between text and spinner.

Let's verify the FontAwesome spinner icon import:

✅ Verification successful

FontAwesome spinner icon is properly imported

The faSpinner icon is correctly imported from @fortawesome/free-solid-svg-icons in the component's TypeScript file, ensuring the loading indicator will work as expected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the faSpinner icon is properly imported in the component
rg "import.*faSpinner.*from.*@fortawesome/free-solid-svg-icons" src/main/webapp/app/overview/course-conversations/dialogs/conversation-add-users-dialog/add-users-form/

Length of output: 376

src/test/javascript/spec/component/overview/course-conversations/dialogs/conversation-add-users-dialog/conversation-add-users-dialog.component.spec.ts (1)

32-32: LGTM! Clean implementation of loading state input

The implementation correctly uses Angular's new input() syntax and maintains appropriate access level.

Copy link

@HawKhiem HawKhiem 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 TS2. Upon adding users, the loading indicator is displayed and the "Add users" button is disabled. However other buttons are not disabled. Should they also be disabled to avoid overhead?

test.mp4

Copy link

@JerroyTan JerroyTan 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 TS5]
Functionality works as described. Thought I have some concerns:

  1. While users are still being added, the add more users button loads, but user can still exit and go to add users again. I fear that this could in extreme cases lead to synchronize issues.
    image

  2. In similar fashion, when deleting a course, the user can also exit the loading dialogue while it is still loading. When I tried this and tried to add another channel it did not work. Maybe this would belong to another issue to be opened since it does not only affect user adding functionality.

@PaRangger
Copy link
Contributor Author

Tested on TS2. Upon adding users, the loading indicator is displayed and the "Add users" button is disabled. However other buttons are not disabled. Should they also be disabled to avoid overhead?

test.mp4

Hi! This PR serves as a quick fix to prevent users from spamming the button. So this functionality, while not ideal, is still kind of intended to be there. It only affects the client and does not do any uneccesary calls to the server 😄

Copy link

⚠️ Unable to deploy to test servers ⚠️

Testserver "artemis-test3.artemis.cit.tum.de" is already in use by PR #9921.

@github-actions github-actions bot added the deployment-error Added by deployment workflows if an error occured label Dec 21, 2024
@sawys777 sawys777 added deploy:artemis-test1 and removed deployment-error Added by deployment workflows if an error occured labels Dec 21, 2024
@sawys777 sawys777 temporarily deployed to artemis-test1.artemis.cit.tum.de December 21, 2024 17:46 — with GitHub Actions Inactive
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 works as described

@PaRangger
Copy link
Contributor Author

Tested on TS2. Upon adding users, the loading indicator is displayed and the "Add users" button is disabled. However other buttons are not disabled. Should they also be disabled to avoid overhead?

test.mp4

Hi, Thanks for the review! The purpose of the PR mainly is to avoid that users make a lot of uneccesary heavy server requests. Currently they do that because there is no indicator whatsoever that their button click did something. I was trying to tackle that issue specifically. I don't think that the other buttons are a big problem since they do not send any request to the server. 😊

@krusche krusche merged commit 0f1bf00 into develop Dec 24, 2024
23 of 29 checks passed
@krusche krusche deleted the bugfix/communication/disable-create-channel-button-while-loading branch December 24, 2024 12:50
@krusche krusche added this to the 7.8.1 milestone Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix client Pull requests that update TypeScript code. (Added Automatically!) component:Communication ready for review small tests
Projects
Status: Merged
Status: Done
Development

Successfully merging this pull request may close these issues.

9 participants