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: Remove hidden conversations from favorites #9473

Merged
merged 6 commits into from
Oct 19, 2024

Conversation

asliayk
Copy link
Contributor

@asliayk asliayk commented Oct 13, 2024

Checklist

General

Client

Motivation and Context

  • Hiding a favorite conversation does not remove it from the favorites list, so it remains unhidden and is not added to the hidden list.
  • Favoriting a hidden conversation does not change its hidden state. Although it is added to the favorites list, it still displays a "show" button instead of "hide".
    (Closes Communication: Hidden favorite channels still visible in favorites #9349)

Description

  • If the conversation is in favorites and is being hidden, it is added to the hidden list and also removed from the favorites list.
  • If the conversation is hidden and is being favorited, it is added to the favorites list and also removed from the hidden list.

Steps for Testing

Prerequisites:

  • 1 Instructor/Student
  1. Log in to Artemis
  2. Navigate to Communication section of a course
  3. Add a conversation to favorites
  4. Click on hide button to add it to the hidden list
  5. Notice that it is added to the hidden list and also removed from favorites.
  6. Add that channel to the favorites again.
  7. Notice that it is removed from the hidden list and added to the favorites list.

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

Class/File Line Coverage Confirmation (assert/expect)
conversation-options.component.ts 91.83% ✅ ❌

Summary by CodeRabbit

  • New Features

    • Enhanced conversation options to allow users to hide conversations while automatically managing favorite status.
    • Users can now favorite hidden conversations, which will unhide them.
  • Bug Fixes

    • Improved logic for handling conversation visibility and favorite status to ensure consistent behavior.
  • Tests

    • Added new test cases to ensure functionality for hiding and favoriting conversations is working as intended.

@asliayk asliayk added client Pull requests that update TypeScript code. (Added Automatically!) small bugfix component:Communication labels Oct 13, 2024
@asliayk asliayk self-assigned this Oct 13, 2024
@asliayk asliayk requested a review from a team as a code owner October 13, 2024 19:09
@github-actions github-actions bot added the tests label Oct 13, 2024
Copy link

coderabbitai bot commented Oct 13, 2024

Walkthrough

The ConversationOptionsComponent has been modified to enhance the logic in the onHiddenClicked and onFavoriteClicked methods. These updates ensure that when a conversation is hidden, it is removed from favorites if applicable, and when favoriting a hidden conversation, it is unhidden. Additionally, new unit tests have been added to verify these functionalities, ensuring that the component behaves as expected under the new conditions.

Changes

File Change Summary
src/main/webapp/app/shared/sidebar/conversation-options/conversation-options.component.ts Updated onHiddenClicked and onFavoriteClicked methods to include logic for handling favorites and hidden states.
src/test/javascript/spec/component/shared/sidebar/conversation-options.component.spec.ts Added new test cases for hiding and favoriting conversations to enhance test coverage.

Assessment against linked issues

Objective Addressed Explanation
Hidden favorite channels should not be visible in favorites (#9349)

Possibly related PRs

Suggested labels

user interface, ready to merge

Suggested reviewers

  • krusche
  • yassinsws
  • edkaya

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between bd8ed57 and 315f622.

📒 Files selected for processing (1)
  • src/main/webapp/app/shared/sidebar/conversation-options/conversation-options.component.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/webapp/app/shared/sidebar/conversation-options/conversation-options.component.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: 5

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 6549075 and bd8ed57.

📒 Files selected for processing (2)
  • src/main/webapp/app/shared/sidebar/conversation-options/conversation-options.component.ts (1 hunks)
  • src/test/javascript/spec/component/shared/sidebar/conversation-options.component.spec.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/main/webapp/app/shared/sidebar/conversation-options/conversation-options.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/shared/sidebar/conversation-options.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 (2)
src/main/webapp/app/shared/sidebar/conversation-options/conversation-options.component.ts (1)

Line range hint 1-194: Overall assessment: Changes effectively address the PR objectives.

The modifications to the ConversationOptionsComponent successfully implement the required functionality for handling hidden and favorite conversations. The code adheres to the provided coding guidelines and maintains consistency with the existing codebase.

Key points:

  1. Hidden favorite conversations are now removed from the favorites list.
  2. Hidden conversations are unhidden when favorited.
  3. Early returns have been added to improve code safety.
  4. Error handling is consistent with the rest of the component.

The suggested minor improvements using async/await syntax would further enhance code consistency and readability.

To ensure the changes don't introduce any regressions, please run the following verification script:

This script will help verify the correct implementation and usage of the modified methods and related services.

✅ Verification successful

Verification Successful

The ConversationOptionsComponent correctly imports and utilizes the required services and models. Both onHiddenClicked and onFavoriteClicked methods are properly implemented, and there are no unresolved TODO or FIXME comments within the specified lines.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the ConversationOptionsComponent is correctly importing and using the required services and models.

# Test: Check for correct imports and usage of ConversationService, AlertService, and related models.
rg --type typescript -e "import.*ConversationService" -e "import.*AlertService" -e "import.*ConversationDTO" -e "import.*Course" src/main/webapp/app/shared/sidebar/conversation-options/conversation-options.component.ts

# Test: Verify the correct implementation of onHiddenClicked and onFavoriteClicked methods.
rg --type typescript -A 15 -e "onHiddenClicked\(" -e "onFavoriteClicked\(" src/main/webapp/app/shared/sidebar/conversation-options/conversation-options.component.ts

# Test: Check for any TODO comments or FIXME notes that might indicate incomplete implementation.
rg --type typescript -e "TODO|FIXME" src/main/webapp/app/shared/sidebar/conversation-options/conversation-options.component.ts

Length of output: 621


Script:

#!/bin/bash
# Description: Verify that the ConversationOptionsComponent is correctly importing and using the required services and models without relying on --type typescript.

# Test: Check for correct imports and usage of ConversationService, AlertService, ConversationDTO, and Course.
rg -g '*.ts' 'import.*(ConversationService|AlertService|ConversationDTO|Course)' src/main/webapp/app/shared/sidebar/conversation-options/conversation-options.component.ts

# Test: Verify the correct implementation of onHiddenClicked and onFavoriteClicked methods.
rg -A 15 'onHiddenClicked\(|onFavoriteClicked\(' src/main/webapp/app/shared/sidebar/conversation-options/conversation-options.component.ts

# Test: Check for any TODO comments or FIXME notes that might indicate incomplete implementation.
rg 'TODO|FIXME' src/main/webapp/app/shared/sidebar/conversation-options/conversation-options.component.ts

Length of output: 2188

src/test/javascript/spec/component/shared/sidebar/conversation-options.component.spec.ts (1)

88-123: Overall, excellent additions to the test suite.

These new test cases significantly improve the coverage of the ConversationOptionsComponent, specifically addressing the interaction between hidden and favorite states as outlined in the PR objectives. The tests are well-structured, follow good practices, and integrate seamlessly with the existing test suite.

While the current implementation is solid, consider the suggestions in the previous comments to further enhance the robustness and maintainability of the test suite.

SimonEntholzer
SimonEntholzer previously approved these changes Oct 14, 2024
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.

Tested on Ts4 and works as described

PaRangger
PaRangger previously approved these changes Oct 14, 2024
Copy link
Contributor

@PaRangger PaRangger 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. Code LGTM 👍

sachmii
sachmii previously approved these changes Oct 14, 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 TS5, worked as described.

Copy link
Contributor

@az108 az108 left a comment

Choose a reason for hiding this comment

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

Overall the code lgtm, can we consider this change?

Copy link

⚠️ Unable to deploy to test servers ⚠️

Testserver "artemis-test1.artemis.cit.tum.de" is already in use by PR #9511.

@github-actions github-actions bot added the deployment-error Added by deployment workflows if an error occured label Oct 18, 2024
@github-actions github-actions bot removed the deployment-error Added by deployment workflows if an error occured label Oct 18, 2024
@sachmii sachmii temporarily deployed to artemis-test3.artemis.cit.tum.de October 18, 2024 12:34 — with GitHub Actions Inactive
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, still works as described

@krusche krusche added this to the 7.6.1 milestone Oct 18, 2024
@krusche krusche changed the title Communication: Fix removing hidden conversations from favorites Communication: Remove hidden conversations from favorites Oct 18, 2024
Copy link
Member

@krusche krusche 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 👍

@krusche krusche added the maintainer-approved The feature maintainer has approved the PR label Oct 19, 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 maintainer-approved The feature maintainer has approved the PR ready to merge small tests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Communication: Hidden favorite channels still visible in favorites
7 participants