Skip to content

Development: Combine post and answer post reactions bars in communication mode client code #10224

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

Merged
merged 11 commits into from
Jan 31, 2025

Conversation

asliayk
Copy link
Contributor

@asliayk asliayk commented Jan 28, 2025

Checklist

General

Client

Motivation and Context

  • Maintaining separate PostReactionsBarComponent and AnswerPostReactionsBarComponent leads to duplicated logic, making updates and consistency harder to manage. Merging them into a single PostingReactionsBarComponent improves maintainability, ensures consistency, and simplifies future modifications.
  • Both components need to be migrated to the new client architecture using signals. Once merged, this new component should be migrated to use signals as part of the client update.

Description

  • PostReactionsBarComponent and AnswerPostReactionsBarComponent are merged into a single PostingReactionsBarComponent to eliminate duplication and improve maintainability.
  • The new PostingReactionsBarComponent is migrated to the client architecture using signals.
  • ChannelIconComponent is also migrated to use signals as part of the client update.
  • New client tests are added for PostingReactionsBarComponent to ensure functionality remains intact after migration & combining components.

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 1 Course with Communication enabled
  1. Log in to Artemis
  2. Navigate to Communication section of a course
  3. Open a random channel that contains posts and replies to test all the functionalities of the posting reaction bar: try to edit/delete posts & answers, and add reactions to them.

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)
channel-icon.component.ts 100%
answer-post.component.ts 94.87% ✅ ❌
post.component.ts 95.49% ✅ ❌
answer-post-reactions-bar.component.ts not found (deleted)
post-reactions-bar.component.ts not found (deleted)
posting-reactions-bar.component.ts 92.14% ✅ ❌
posting-reactions-bar.directive.ts not found (deleted)

Summary by CodeRabbit

Summary by CodeRabbit

Based on the comprehensive changes, here are the release notes:

  • New Features

    • Introduced a new generic PostingReactionsBarComponent for managing post reactions.
    • Enhanced emoji reaction handling with more flexible input mechanisms.
  • Refactoring

    • Renamed and consolidated reaction bar components.
    • Updated input property handling using Angular's new input() function.
    • Simplified component imports and paths.
  • Breaking Changes

    • Removed PostReactionsBarComponent and AnswerPostReactionsBarComponent.
    • Changed input property syntax from @Input() decorators to input() function.
    • Updated component selectors from jhi-post-reactions-bar to jhi-posting-reactions-bar.
  • Improvements

    • Improved type safety for reaction bar components.
    • Enhanced user interaction logic for post reactions.
    • Standardized component structure for better maintainability.

@asliayk asliayk added tests client Pull requests that update TypeScript code. (Added Automatically!) labels Jan 28, 2025
@asliayk asliayk self-assigned this Jan 28, 2025
@asliayk asliayk temporarily deployed to artemis-test4.artemis.cit.tum.de January 30, 2025 13:39 — with GitHub Actions Inactive
@asliayk asliayk marked this pull request as ready for review January 30, 2025 14:35
@asliayk asliayk requested a review from a team as a code owner January 30, 2025 14:35
Copy link
Contributor

coderabbitai bot commented Jan 30, 2025

Walkthrough

The pull request involves a comprehensive refactoring of the reactions bar components in the Metis communication system. The changes primarily focus on consolidating multiple reaction bar components into a single, more generic PostingReactionsBarComponent. This involves renaming components, updating import statements, modifying component logic, and adjusting test suites to reflect the new structure. The refactoring aims to create a more flexible and reusable component for handling reactions across different types of postings.

Changes

File Path Change Summary
app/overview/course-conversations/other/channel-icon/channel-icon.component.* Updated method calls from property access to method invocations and migrated input properties to use input() function
app/shared/metis/answer-post/answer-post.component.* Replaced AnswerPostReactionsBarComponent with PostingReactionsBarComponent
app/shared/metis/post/post.component.* Renamed reactions bar component and updated input property names
app/shared/metis/posting-reactions-bar/ Added new posting-reactions-bar.component.* and removed old reaction bar components
test/javascript/spec/component/shared/metis/ Updated test suites to reflect component changes and new naming conventions

Possibly related PRs

Suggested Labels

chore, ready to merge, component:Communication


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c8c5344 and 9d9b64b.

📒 Files selected for processing (1)
  • src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.component.html (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.component.html
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: server-style
  • GitHub Check: Call Build Workflow / Build .war artifact
  • GitHub Check: client-tests-selected
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: client-style
  • GitHub Check: server-tests
  • GitHub Check: client-tests
  • GitHub Check: Analyse

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
Contributor

@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 comments (3)
src/test/javascript/spec/component/shared/metis/post/post.component.spec.ts (3)

Line range hint 1-400: Add tests for reactions bar integration.

Given that this PR merges the reactions bar components, we should add tests to verify the integration with the new PostingReactionsBarComponent.

Consider adding these test cases:

it('should render PostingReactionsBarComponent', () => {
    component.posting = metisPostExerciseUser1;
    fixture.detectChanges();
    const reactionsBar = getElement(debugElement, 'jhi-posting-reactions-bar');
    expect(reactionsBar).not.toBeNull();
});

it('should pass correct props to PostingReactionsBarComponent', () => {
    component.posting = metisPostExerciseUser1;
    fixture.detectChanges();
    const reactionsBar = debugElement.query(By.css('jhi-posting-reactions-bar'));
    expect(reactionsBar.properties['posting']).toBe(metisPostExerciseUser1);
});

Line range hint 80-93: Add PostingReactionsBarComponent to test declarations.

The component declarations array should include the mock for PostingReactionsBarComponent.

Add the following to the declarations array:

 declarations: [
     PostComponent,
     FaIconComponent,
     MockPipe(HtmlForMarkdownPipe),
     MockComponent(PostingHeaderComponent),
     MockComponent(PostingContentComponent),
     MockComponent(PostingFooterComponent),
+    MockComponent(PostingReactionsBarComponent),
     MockComponent(AnswerPostCreateEditModalComponent),
     MockRouterLinkDirective,
     MockQueryParamsDirective,
     TranslatePipeMock,
     ArtemisDatePipe,
     ArtemisTranslatePipe,
     MockDirective(TranslateDirective),
 ],

Line range hint 1-400: Follow jest expectation patterns from coding guidelines.

Several test expectations don't follow the coding guidelines for specific types:

  • Boolean expectations should use toBeTrue()/toBeFalse()
  • Reference comparisons should use toBe()
  • Existence checks should use toBeNull()/toBeNotNull()

Update these test cases to follow the guidelines:

-expect(contextLink).toBeNull();
+expect(contextLink).toBeNull();  // Already follows guidelines

-expect(header).not.toBeNull();
+expect(header).toBeNotNull();

-expect(component.isPinned()).toBe(true);
+expect(component.isPinned()).toBeTrue();

-expect(component.isPinned()).toBe(false);
+expect(component.isPinned()).toBeFalse();
🧹 Nitpick comments (6)
src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.component.ts (3)

1-1: Consider using separate imports for decorators like @Input, @Output, and @ViewChild.
While using the input(), output(), and viewChild() signal-based approach is valid in Angular 16+, splitting out these decorators from the main Angular import can aid in clarity. For example:

import { Component, OnChanges, OnInit, inject } from '@angular/core';
import { Input, Output, ViewChild } from '@angular/core';

223-223: Use @ts-expect-error instead of @ts-ignore.
Angular style guidelines discourage @ts-ignore; prefer @ts-expect-error, which will fail if the error is resolved.

- // @ts-ignore
+ // @ts-expect-error
🧰 Tools
🪛 GitHub Check: client-style

[warning] 223-223:
Use "@ts-expect-error" instead of "@ts-ignore", as "@ts-ignore" will do nothing if the following line is error-free


303-305: Consider skipping the external click handling if the emoji selector is not visible.
When the user toggles the emoji selector rapidly, multiple reflows could occur. A defensive check could improve responsiveness.

src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.component.html (3)

5-8: Add aria-label to improve accessibility.

The reply button should have an aria-label for better accessibility.

 <button class="reaction-button clickable reply-btn" 
+        aria-label="{{ 'artemisApp.conversationsLayout.threadSideBar.reply' | artemisTranslate }}"
         (click)="isCommunicationPage() ? openThread.emit() : openAnswerView()">

74-80: Add aria-label to emoji picker button.

The emoji picker button should have an aria-label for screen readers.

 <button class="reaction-button clickable px-2 fs-small" 
+        aria-label="{{ 'artemisApp.metis.chooseReaction' | artemisTranslate }}"
         (click)="showReactionSelector = !showReactionSelector" 
         cdkOverlayOrigin #trigger="cdkOverlayOrigin">

149-158: Consider extracting pin button conditions to a method.

The pin button has complex conditions that could be moved to a component method for better maintainability.

// In component class:
isPinButtonEnabled(): boolean {
  return this.canPin && !this.isReadOnlyMode();
}

isPinButtonActive(): boolean {
  return this.displayPriority === DisplayPriority.PINNED && this.canPin;
}
 <button
     class="reaction-button pin clickable fs-small"
     [class.reaction-button--not-hoverable]="!canPin"
-    [class.reaction-button--reacted]="displayPriority === DisplayPriority.PINNED && canPin"
+    [class.reaction-button--reacted]="isPinButtonActive()"
     [disabled]="!canPin || isReadOnlyMode()"
-    (click)="canPin && togglePin()"
+    (click)="isPinButtonEnabled() && togglePin()"
 >
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 72ca6ae and c8c5344.

📒 Files selected for processing (18)
  • src/main/webapp/app/overview/course-conversations/other/channel-icon/channel-icon.component.html (1 hunks)
  • src/main/webapp/app/overview/course-conversations/other/channel-icon/channel-icon.component.ts (2 hunks)
  • src/main/webapp/app/shared/metis/answer-post/answer-post.component.html (2 hunks)
  • src/main/webapp/app/shared/metis/answer-post/answer-post.component.ts (3 hunks)
  • src/main/webapp/app/shared/metis/post/post.component.html (2 hunks)
  • src/main/webapp/app/shared/metis/post/post.component.ts (3 hunks)
  • src/main/webapp/app/shared/metis/posting-reactions-bar/answer-post-reactions-bar/answer-post-reactions-bar.component.html (0 hunks)
  • src/main/webapp/app/shared/metis/posting-reactions-bar/answer-post-reactions-bar/answer-post-reactions-bar.component.ts (0 hunks)
  • src/main/webapp/app/shared/metis/posting-reactions-bar/post-reactions-bar/post-reactions-bar.component.html (0 hunks)
  • src/main/webapp/app/shared/metis/posting-reactions-bar/post-reactions-bar/post-reactions-bar.component.ts (0 hunks)
  • src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.component.html (1 hunks)
  • src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.component.ts (1 hunks)
  • src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.directive.ts (0 hunks)
  • src/test/javascript/spec/component/shared/metis/answer-post/answer-post.component.spec.ts (3 hunks)
  • src/test/javascript/spec/component/shared/metis/post/post.component.spec.ts (3 hunks)
  • src/test/javascript/spec/component/shared/metis/postings-footer/posting-footer.component.spec.ts (0 hunks)
  • src/test/javascript/spec/component/shared/metis/postings-reactions-bar/answer-post-reactions-bar/answer-post-reactions-bar.component.spec.ts (0 hunks)
  • src/test/javascript/spec/component/shared/metis/postings-reactions-bar/posting-reactions-bar.component.spec.ts (19 hunks)
💤 Files with no reviewable changes (7)
  • src/main/webapp/app/shared/metis/posting-reactions-bar/answer-post-reactions-bar/answer-post-reactions-bar.component.html
  • src/main/webapp/app/shared/metis/posting-reactions-bar/post-reactions-bar/post-reactions-bar.component.html
  • src/test/javascript/spec/component/shared/metis/postings-footer/posting-footer.component.spec.ts
  • src/main/webapp/app/shared/metis/posting-reactions-bar/answer-post-reactions-bar/answer-post-reactions-bar.component.ts
  • src/test/javascript/spec/component/shared/metis/postings-reactions-bar/answer-post-reactions-bar/answer-post-reactions-bar.component.spec.ts
  • src/main/webapp/app/shared/metis/posting-reactions-bar/post-reactions-bar/post-reactions-bar.component.ts
  • src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.directive.ts
✅ Files skipped from review due to trivial changes (1)
  • src/main/webapp/app/shared/metis/answer-post/answer-post.component.html
🧰 Additional context used
📓 Path-based instructions (10)
src/main/webapp/app/shared/metis/post/post.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/metis/posting-reactions-bar/posting-reactions-bar.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/metis/post/post.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/other/channel-icon/channel-icon.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/test/javascript/spec/component/shared/metis/answer-post/answer-post.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}}

src/main/webapp/app/shared/metis/answer-post/answer-post.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/shared/metis/posting-reactions-bar/posting-reactions-bar.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/metis/post/post.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}}

src/main/webapp/app/overview/course-conversations/other/channel-icon/channel-icon.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/metis/postings-reactions-bar/posting-reactions-bar.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}}

🪛 Biome (1.9.4)
src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.component.ts

[error] 373-373: Avoid the use of spread (...) syntax on accumulators.

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

(lint/performance/noAccumulatingSpread)

src/test/javascript/spec/component/shared/metis/postings-reactions-bar/posting-reactions-bar.component.spec.ts

[error] 361-361: Forbidden extra non-null assertion.

Safe fix: Remove extra non-null assertion.

(lint/suspicious/noExtraNonNullAssertion)

🪛 GitHub Check: client-style
src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.component.ts

[warning] 223-223:
Use "@ts-expect-error" instead of "@ts-ignore", as "@ts-ignore" will do nothing if the following line is error-free

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (17)
src/main/webapp/app/overview/course-conversations/other/channel-icon/channel-icon.component.ts (3)

Line range hint 1-9: LGTM! Clean component setup with proper imports.

The component follows Angular best practices with standalone imports and proper component configuration.


11-13: Well-structured input properties using signals!

The migration from @input decorators to signal-based inputs is well implemented, maintaining proper typing and sensible default values.


16-19: Good use of readonly for immutable icon properties!

The readonly modifier ensures icons cannot be accidentally modified after initialization.

src/main/webapp/app/overview/course-conversations/other/channel-icon/channel-icon.component.html (1)

1-14: Clean template with proper signal usage and modern Angular syntax!

The template correctly:

  • Uses the new @if syntax instead of *ngIf as per guidelines
  • Properly accesses signal inputs using method call syntax
  • Maintains consistent icon sizing
src/test/javascript/spec/component/shared/metis/post/post.component.spec.ts (2)

7-8: LGTM! Import paths have been simplified.

The import paths have been updated to use absolute paths instead of relative paths, which improves maintainability and readability.

Also applies to: 40-42


46-49: Verify AccountService and LocalStorageService mocking.

The new services have been added with their mock implementations. However, let's verify their usage in the test suite.

Run this script to check if these services are actually used in the tests:

Also applies to: 77-78

✅ Verification successful

Services are correctly mocked for dependency injection and inheritance

The AccountService and LocalStorageService are correctly mocked as they are required by:

  • The parent PostingDirective class that this component extends
  • The dependency injection system for authorization and storage management
  • The MetisService which this component uses for all authorization and state operations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for AccountService and LocalStorageService usage in the test file
rg -A 5 "AccountService|LocalStorageService" "src/test/javascript/spec/component/shared/metis/post/post.component.spec.ts"

# Check if there are any assertions or spy setups for these services
ast-grep --pattern 'expect($_).toHaveBeenCalled$$$' "src/test/javascript/spec/component/shared/metis/post/post.component.spec.ts"

Length of output: 1125


Script:

#!/bin/bash
# Check the component implementation for service usage
rg -A 5 "AccountService|LocalStorageService" "src/app/shared/metis/post/post.component.ts"

# Look for any test cases that might be testing these services
rg -B 2 -A 5 "describe|it\(" "src/test/javascript/spec/component/shared/metis/post/post.component.spec.ts"

Length of output: 9324


Script:

#!/bin/bash
# Find the component file
fd -e ts "post.component.ts" --exclude "*.spec.ts"

# Search for service usage in related files
rg -l "AccountService|LocalStorageService" --type ts --glob "!*.spec.ts" "src/"

Length of output: 9849


Script:

#!/bin/bash
# Check the actual component implementation
cat "src/main/webapp/app/shared/metis/post/post.component.ts"

# Check the component template if it exists
cat "src/main/webapp/app/shared/metis/post/post.component.html"

Length of output: 22461

src/main/webapp/app/shared/metis/posting-reactions-bar/posting-reactions-bar.component.ts (1)

91-122: Good use of Angular signals for binding inputs and outputs.
The approach of defining inputs/outputs as signals (e.g. input<T>, output<void>) follows modern Angular best practices and maintains consistent readability.

src/test/javascript/spec/component/shared/metis/postings-reactions-bar/posting-reactions-bar.component.spec.ts (3)

393-393: Verify correct reaction creation.
The test logic for building a Reaction object is correct. It ensures the method constructs the object with the right emojiId, post, or answerPost.


546-555: Properly differentiates between an AnswerPost vs. a Post.
The tested logic cleanly validates that when the posting is an AnswerPost, the reaction is attached accordingly, and vice versa.


568-577: Good check for insufficient permissions during pin toggling.
The test ensures that a user without the proper rights cannot pin or unpin. This aligns with the app's expected authorization flow.

src/main/webapp/app/shared/metis/answer-post/answer-post.component.ts (3)

35-35: Successful import alignment with new component.
Replacing the old AnswerPostReactionsBarComponent with PostingReactionsBarComponent ensures consistent usage of the unified reactions bar.


55-55: Compositional approach for Angular imports.
Using the new PostingReactionsBarComponent within imports is coherent with Angular’s module-less style approach for standalone components.


80-80: Visibility changed from private to protected.
This change allows derived classes to access reactionsBarComponent if needed in an extended scenario. Confirm it aligns with your inheritance design.

src/main/webapp/app/shared/metis/post/post.component.ts (1)

32-32: LGTM! Component consolidation changes look good.

The import statement and ViewChild decorator have been correctly updated to use the new PostingReactionsBarComponent with proper generic type.

Also applies to: 97-97

src/test/javascript/spec/component/shared/metis/answer-post/answer-post.component.spec.ts (2)

29-34: LGTM! Service dependencies properly configured.

The addition of LocalStorageService and AccountService with their mock implementations improves the test setup.


124-125: LGTM! Component selector updated correctly.

The test now correctly queries for 'jhi-posting-reactions-bar' instead of 'jhi-answer-post-reactions-bar', aligning with the component consolidation.

src/main/webapp/app/shared/metis/post/post.component.html (1)

95-97: LGTM! Component usage updated correctly.

The changes correctly update both instances of the reactions bar:

  1. Component selector changed to posting-reactions-bar
  2. Input property renamed to isReadOnlyMode following boolean naming convention

Also applies to: 129-131

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 30, 2025
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, left one comment about the if nesting, maybe you could try to improve that a bit

@asliayk asliayk temporarily deployed to artemis-test4.artemis.cit.tum.de January 30, 2025 16:41 — with GitHub Actions Inactive
Copy link

@Cathy0123456789 Cathy0123456789 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. Editing, deleting, answering, reacting to, etc. posts works just as expected

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 TS4, everything works as expected

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.

thx for the code improvements

@krusche krusche changed the title Communication: Combine Post and AnswerPost Reactions Bars Development: Combine post and answer post reactions bars in communication mode client code Jan 31, 2025
@krusche krusche merged commit f48bd12 into develop Jan 31, 2025
109 of 113 checks passed
@krusche krusche deleted the chore/communication/combine-reactionbar-components branch January 31, 2025 21:29
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!) ready to merge tests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants