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: Fix an issue that stops channels from loading messages #9745

Merged

Conversation

PaRangger
Copy link
Contributor

@PaRangger PaRangger commented Nov 11, 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.
  • I added multiple screenshots/screencasts of my UI changes.
  • I translated all newly inserted strings into English and German.

Motivation and Context

Currently, when entering a channel where a user wrote messages and later the user was deleted, the module throws an error and will not load. This makes the channel completely unusable for all other users.

Description

I fixed the issue by adding the edge case to the posting header component that caused the errors. The error was caused by the tranlate directive getting an undefined key.

Steps for Testing

Prerequisites:

  • 1 Admin
  • 1 Course with communication enabled
  1. You can Test all the steps first without deploying to see the error. Just make sure the version is 7.7.1 or higher. Afterwards do steps 15. to 17. with the changes deployed and the error should be gone. You can also skip steps 2-14 if you go to TS3 and go to my Test Course "Paul Ranggers Test Course" into the "random" channel.
  2. Log into Artemis as an admin (on TS3 your TUMOnline account is an admin)
  3. Go to user management
  4. Create a new user with student role and add him to your student identifier's group
  5. Log out
  6. Go to reset password form and request a password for the new user
  7. Log in to Artemis as user
  8. Go to course
  9. Go to the communication tab
  10. Write some messages and answers
  11. Log out
  12. Log into Artemis as admin
  13. Go to User Management in the navbar
  14. Delete the user
  15. Go to course
  16. Go to the communication tab
  17. Verify that the channel now loads and the user is displayed as deleted

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

Before:

Bildschirmfoto 2024-11-11 um 19 53 56

After:

Bildschirmfoto 2024-11-11 um 19 59 04

Summary by CodeRabbit

  • New Features

    • Enhanced user role handling by introducing a default case for unrecognized author roles, now displaying 'student' for deleted users.
    • Added new localization entries for deleted user roles and tooltips in both German and English.
  • Bug Fixes

    • Improved clarity on the status of deleted users within the application interface.

@PaRangger PaRangger added client Pull requests that update TypeScript code. (Added Automatically!) bugfix component:Communication communication Pull requests that affect the corresponding module labels Nov 11, 2024
@PaRangger PaRangger self-assigned this Nov 11, 2024
@github-actions github-actions bot removed the communication Pull requests that affect the corresponding module label Nov 11, 2024
@PaRangger PaRangger marked this pull request as ready for review November 11, 2024 19:06
@PaRangger PaRangger requested a review from a team as a code owner November 11, 2024 19:06
Copy link

coderabbitai bot commented Nov 11, 2024

Walkthrough

The changes in this pull request involve modifications to the PostingHeaderDirective class to handle unrecognized author roles by setting default values for user authority and tooltips. Additionally, new localization entries for the "deleted" user role and its tooltip have been added to both the German and English localization files. These adjustments ensure that the application can appropriately display information regarding deleted users and enhance the overall user interface.

Changes

File Path Change Summary
src/main/webapp/app/shared/metis/posting-header/posting-header.directive.ts Modified setUserAuthorityIconAndTooltip to handle unrecognized author roles by setting default values.
src/main/webapp/i18n/de/metis.json Added new entries for the "deleted" user role and tooltip: "deleted": "Gelöscht" and tooltip entry.
src/main/webapp/i18n/en/metis.json Added new entries for the "deleted" user role and tooltip: "deleted": "Deleted" and tooltip entry.

Possibly related PRs

Suggested labels

tests

Suggested reviewers

  • edkaya
  • asliayk
  • JohannesStoehr
  • SimonEntholzer
  • pzdr7

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 (2)
src/main/webapp/app/shared/metis/posting-header/posting-header.directive.ts (1)

98-101: Consider adding a comment explaining the fallback behavior.

For better maintainability, consider adding a comment explaining why we default to 'student' authority when handling deleted users.

         } else {
+            // Default to student authority for deleted users to maintain UI consistency
             this.userAuthority = 'student';
             this.userRoleBadge = 'artemisApp.metis.userRoles.deleted';
             this.userAuthorityTooltip = 'artemisApp.metis.userAuthorityTooltips.deleted';
         }
src/main/webapp/i18n/en/metis.json (1)

151-152: Consider enhancing the tooltip message.

While the tooltip follows the correct format, its message "Deleted: This user was deleted." is redundant. Consider providing more context about what this means for the communication channel.

-                "deleted": "Deleted: This user was deleted."
+                "deleted": "Deleted: This user's account has been removed but their messages are preserved."
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between de36813 and 585b9ed.

📒 Files selected for processing (3)
  • src/main/webapp/app/shared/metis/posting-header/posting-header.directive.ts (1 hunks)
  • src/main/webapp/i18n/de/metis.json (1 hunks)
  • src/main/webapp/i18n/en/metis.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/main/webapp/app/shared/metis/posting-header/posting-header.directive.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/i18n/de/metis.json (1)

Pattern src/main/webapp/i18n/de/**/*.json: German language translations should be informal (dutzen) and should never be formal (sietzen). So the user should always be addressed with "du/dein" and never with "sie/ihr".

🔇 Additional comments (4)
src/main/webapp/app/shared/metis/posting-header/posting-header.directive.ts (1)

98-101: LGTM! The implementation handles deleted users gracefully.

The new else branch appropriately handles the case of deleted users by setting default values and using translation keys, which aligns with the PR objective of fixing the communication channel loading issue.

Let's verify that the translation keys exist in both language files:

✅ Verification successful

Translation keys are properly implemented in both language files

The implementation is fully supported by the translation system:

  • artemisApp.metis.userRoles.deleted exists in both English ("Deleted") and German ("Gelöscht")
  • artemisApp.metis.userAuthorityTooltips.deleted exists in both English ("Deleted: This user was deleted.") and German ("Gelöscht: Nutzer:in wurde gelöscht.")
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the translation keys for deleted users exist in both language files
# Expected: Both translation keys should be present in both language files

echo "Checking English translations..."
rg "userRoles.deleted|userAuthorityTooltips.deleted" src/main/webapp/i18n/en/metis.json

echo "Checking German translations..."
rg "userRoles.deleted|userAuthorityTooltips.deleted" src/main/webapp/i18n/de/metis.json

Length of output: 327


Script:

#!/bin/bash
# Let's first check if the translation files exist and their content
echo "Checking if translation files exist..."
fd "metis.json" src/main/webapp/i18n

echo -e "\nChecking content of English translations..."
cat src/main/webapp/i18n/en/metis.json 2>/dev/null | jq -r '.artemisApp.metis | select(.) | {userRoles, userAuthorityTooltips}'

echo -e "\nChecking content of German translations..."
cat src/main/webapp/i18n/de/metis.json 2>/dev/null | jq -r '.artemisApp.metis | select(.) | {userRoles, userAuthorityTooltips}'

Length of output: 1611

src/main/webapp/i18n/en/metis.json (2)

145-146: LGTM! Clear and consistent role definition.

The new "deleted" user role entry follows the existing pattern and provides a clear label for deleted users, which is essential for fixing the communication channel loading issue.


145-152: Verify German translations exist.

Since the PR mentions translations in both English and German, let's verify that corresponding translations exist in the German localization file.

✅ Verification successful

Let me verify the complete context by checking both files side by side.


German translations are complete and consistent

The German translations for both user authority roles and tooltips are properly implemented and match their English counterparts:

  • All roles (instructor, tutor, student, deleted) have corresponding translations
  • All tooltips are properly translated with equivalent meaning and context
  • Gender-inclusive language is appropriately used in German (e.g., "Tutor:in", "Studierende:r")
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for corresponding German translations
# Expected: Should find matching entries in the German translation file

# Check for the deleted user role and tooltip in the German translation file
rg -A1 '"deleted":' "src/main/webapp/i18n/de/metis.json"

Length of output: 364


Script:

#!/bin/bash
# Get the complete userAuthority section from both files for comparison
echo "=== English translations ==="
rg -A4 '"userAuthority": \{' "src/main/webapp/i18n/en/metis.json"

echo -e "\n=== German translations ==="
rg -A4 '"userAuthority": \{' "src/main/webapp/i18n/de/metis.json"

echo -e "\n=== English tooltips ==="
rg -A4 '"userAuthorityTooltips": \{' "src/main/webapp/i18n/en/metis.json"

echo -e "\n=== German tooltips ==="
rg -A4 '"userAuthorityTooltips": \{' "src/main/webapp/i18n/de/metis.json"

Length of output: 1368

src/main/webapp/i18n/de/metis.json (1)

145-146: LGTM! The translations are well-implemented.

The new translations for deleted users are:

  • Consistent with existing translation style
  • Use appropriate gender-inclusive language
  • Clear and concise in conveying the user's deleted status

Also applies to: 151-152

Copy link
Contributor

@SimonEntholzer SimonEntholzer left a comment

Choose a reason for hiding this comment

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

code looks good, but for some reason I can't reproduce the issue on a test server (Ts3) It seems that viewing a channel where a deleted user posted on works on other branches too. Am I missing something, or is the issue somewhere else?

@PaRangger
Copy link
Contributor Author

PaRangger commented Nov 12, 2024

code looks good, but for some reason I can't reproduce the issue on a test server (Ts3) It seems that viewing a channel where a deleted user posted on works on other branches too. Am I missing something, or is the issue somewhere else?

Hi thanks for the feedback! That is very interesting - TS3 is still on an older branch with some recent communication features missing, namely the "grouping" of messages. Maybe that's why it is still displaying properly there? (properly meaning that it's not crashing) Edit: I just confirmed that it is the recent features that seem to break the loading. As soon as the newer features without the bugfix are deployed the channel you wrote a message in with a deleted user does not load anymore.

Anyhow, I checked out the channel on TS3 and I'm still getting the error in the console that I thought causes the issue. So, if its just a local problem its still nice to get rid of the error 😄

Bildschirmfoto 2024-11-12 um 16 07 20

Copy link
Contributor

@FelberMartin FelberMartin 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, first without deployement and the random channel loaded indefinitely and the console showed errors. With deployment channel loads, and the messages are shown with the user "Deleted User"

Copy link
Contributor

@cremertim cremertim left a comment

Choose a reason for hiding this comment

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

Lgtm

Copy link
Contributor

@julian-wls julian-wls left a comment

Choose a reason for hiding this comment

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

Changes look good to me!
Great work!

@krusche krusche changed the title Communication: Fix issue that stops communication channel from loading messages Communication: Fix an issue that stops channels from loading messages Nov 16, 2024
@krusche krusche added this to the 7.7.1 milestone Nov 16, 2024
@krusche krusche merged commit d3311ae into develop Nov 16, 2024
54 of 63 checks passed
@krusche krusche deleted the bugfix/communication/fix-crashing-module-on-deleted-user branch November 16, 2024 09:23
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
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

8 participants