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 element height in announcement channel #9664

Merged

Conversation

PaRangger
Copy link
Contributor

@PaRangger PaRangger commented Nov 3, 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 accessing the announcement channel as a student, a big empty bar is at the bottom where the message input is supposed to be. This should not be there and instead the announcements should take over the entire height of the element.

Addresses #9597

Description

I added a check to see if the user is in the announcement channel and if so added a class that extends the height of the message area.

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 1 Students
  • 1 Course with communication enabled
  1. Log in to Artemis as the Instructor
  2. Navigate to course
  3. Navigate to the communication tab
  4. Go to the announcements channel
  5. Write announcements, such that the messages element grows to full height
  6. Verify that the messages element is properly sized, with the "Create Announcement" button still being visible
  7. Log into Artemis as the student
  8. Navigate to the course
  9. Navigate to the communication tab
  10. Navigate to the announcement channel
  11. Check if here the messages element is also full size, without the "Create Announcement" Button

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

Instructor:
Bildschirmfoto 2024-11-03 um 23 22 07
Student:
Bildschirmfoto 2024-11-03 um 23 23 39

Summary by CodeRabbit

  • New Features

    • Enhanced conditional rendering for message input fields based on conversation type and user permissions.
    • Users can now see or hide input fields in announcement channels depending on their permission to create messages.
  • Style

    • Introduced new CSS modifiers for better height management of the conversation messages component, improving layout flexibility.
  • Tests

    • Expanded test coverage to include assertions for input visibility in announcement channels, ensuring correct behavior based on conversation type.

@PaRangger PaRangger added client Pull requests that update TypeScript code. (Added Automatically!) bugfix communication Pull requests that affect the corresponding module labels Nov 3, 2024
@PaRangger PaRangger self-assigned this Nov 3, 2024
@github-actions github-actions bot removed the communication Pull requests that affect the corresponding module label Nov 3, 2024
@PaRangger PaRangger changed the title Fix bar for message input Communication: Fix messages element height in announcement channel Nov 3, 2024
@PaRangger PaRangger changed the title Communication: Fix messages element height in announcement channel Communication: Fix element height in announcement channel Nov 3, 2024
@PaRangger PaRangger temporarily deployed to artemis-test5.artemis.cit.tum.de November 3, 2024 22:32 — with GitHub Actions Inactive
@PaRangger PaRangger temporarily deployed to artemis-test3.artemis.cit.tum.de November 3, 2024 23:24 — with GitHub Actions Inactive
@PaRangger PaRangger marked this pull request as ready for review November 3, 2024 23:36
@PaRangger PaRangger requested a review from a team as a code owner November 3, 2024 23:36
Copy link

coderabbitai bot commented Nov 3, 2024

Walkthrough

The changes in this pull request involve modifications to the HTML, SCSS, and TypeScript files of the conversation-messages component. The HTML updates enhance the conditional rendering of CSS classes for input visibility based on conversation state and user permissions, particularly for announcement channels. The SCSS file introduces new styles for managing the height of the input area, while the TypeScript file adds new properties to control the visibility of these input elements. Overall, the updates refine the UI behavior without altering existing functionalities.

Changes

File Change Summary
src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.component.html Enhanced conditional rendering for CSS classes related to input visibility based on conversation type and user permissions.
src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.component.scss Added new styles for .hide-input-full and .hide-input modifiers to adjust the max-height of the .posting-infinite-scroll-container class.
src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.component.ts Introduced new properties isHiddenInputWithCallToAction and isHiddenInputFull to manage input visibility based on conversation type.
src/test/javascript/spec/component/overview/course-conversations/layout/conversation-messages/conversation-messages.component.spec.ts Updated test cases to include assertions for the new visibility logic related to announcement channels.

Possibly related PRs

Suggested labels

ready to merge, component:Communication

Suggested reviewers

  • krusche
  • florian-glombik
  • rabeatwork
  • sachmii

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 (3)
src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.component.scss (2)

50-52: Consider adding responsive design for hide-input-full modifier.

The significant height increase to 94vh might cause issues on smaller screens or mobile devices. Consider adding media queries similar to the existing ones to ensure proper display across all viewport sizes.

 &.hide-input-full {
     max-height: calc(94vh - var(--message-input-height-prod) - var(--search-height) - var(--channel-header-height));
+    @include media-breakpoint-down(sm) {
+        max-height: calc(90vh - var(--message-input-height-prod) - var(--search-height) - var(--channel-header-height));
+        max-height: calc(90dvh - var(--message-input-height-prod) - var(--search-height) - var(--channel-header-height));
+    }
 }

54-56: Maintain consistent responsive behavior across modifiers.

Similar to the hide-input-full modifier, consider adding media queries for consistent responsive behavior.

 &.hide-input {
     max-height: calc(87vh - var(--message-input-height-prod) - var(--search-height) - var(--channel-header-height));
+    @include media-breakpoint-down(sm) {
+        max-height: calc(90vh - var(--message-input-height-prod) - var(--search-height) - var(--channel-header-height));
+        max-height: calc(90dvh - var(--message-input-height-prod) - var(--search-height) - var(--channel-header-height));
+    }
 }
src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.component.html (1)

70-80: Consider extracting complex conditions into component methods.

While the implementation correctly addresses the height issue in announcement channels, the ngClass conditions are quite complex. Consider extracting these checks into readable component methods:

-                    [ngClass]="{
-                        'posting-infinite-scroll-container': posts.length !== 0,
-                        'content-height-dev': contentHeightDev,
-                        'is-fetching-posts': isFetchingPosts,
-                        'hide-input-full':
-                            getAsChannel(_activeConversation)?.isAnnouncementChannel &&
-                            _activeConversation !== undefined &&
-                            !canCreateNewMessageInConversation(_activeConversation),
-                        'hide-input':
-                            getAsChannel(_activeConversation)?.isAnnouncementChannel && _activeConversation !== undefined && canCreateNewMessageInConversation(_activeConversation),
-                    }"
+                    [ngClass]="getMessageContainerClasses()"

Add to component:

getMessageContainerClasses() {
  return {
    'posting-infinite-scroll-container': this.posts.length !== 0,
    'content-height-dev': this.contentHeightDev,
    'is-fetching-posts': this.isFetchingPosts,
    'hide-input-full': this.shouldHideInputFull(),
    'hide-input': this.shouldHideInput()
  };
}

private shouldHideInputFull(): boolean {
  return this.isAnnouncementChannel() && !this.canCreateNewMessageInConversation(this._activeConversation);
}

private shouldHideInput(): boolean {
  return this.isAnnouncementChannel() && this.canCreateNewMessageInConversation(this._activeConversation);
}

private isAnnouncementChannel(): boolean {
  return this._activeConversation !== undefined && this.getAsChannel(this._activeConversation)?.isAnnouncementChannel;
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d567cf4 and 6769e01.

📒 Files selected for processing (2)
  • src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.component.html (1 hunks)
  • src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.component.scss (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.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.

🔇 Additional comments (3)
src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.component.scss (1)

Line range hint 50-74: Implementation successfully addresses the PR objectives.

The height adjustments effectively solve the empty space issue in the announcement channel while maintaining the existing responsive design patterns. The implementation is clean and follows the component's established patterns.

src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.component.html (2)

Line range hint 1-150: Template syntax follows latest Angular guidelines.

The template correctly uses the new @if and @for syntax throughout, adhering to the coding guidelines.


70-80: Verify the height adjustment in different scenarios.

The implementation looks correct, but let's verify it works as expected in all scenarios:

#!/bin/bash
# Description: Verify the CSS classes are properly defined and used consistently

# Test 1: Check if the new CSS classes are defined in the SCSS file
echo "Checking for CSS class definitions..."
rg -A 2 'hide-input-full|hide-input' 'src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.component.scss'

# Test 2: Check for any other components that might be affected by these height changes
echo "Checking for related height adjustments in other components..."
rg -A 2 'posting-infinite-scroll-container' 'src/main/webapp/**/*.scss'

coderabbitai[bot]
coderabbitai bot previously approved these changes Nov 3, 2024
Copy link
Contributor

@JohannesWt JohannesWt left a comment

Choose a reason for hiding this comment

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

Just a single comment

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

🧹 Outside diff range and nitpick comments (3)
src/test/javascript/spec/component/overview/course-conversations/layout/conversation-messages/conversation-messages.component.spec.ts (2)

147-148: LGTM! Consider enhancing test coverage.

The new assertions correctly validate the UI state for announcement channels. The test verifies that:

  • isHiddenInputFull is false, allowing full height utilization
  • isHiddenInputWithCallToAction is true, showing the announcement button

Consider adding these additional test cases to improve coverage:

  1. Verify the CSS classes are correctly applied to the DOM
  2. Test the transition between announcement and non-announcement channels
  3. Add edge cases for different user permission scenarios

Example:

it('should apply correct CSS classes for announcement channels', fakeAsync(() => {
    const scrollableDiv = fixture.debugElement.query(By.css('.scrollableDiv'));
    expect(scrollableDiv.classes['hide-input-full']).toBeFalsy();
    expect(scrollableDiv.classes['hide-input']).toBeTruthy();
}));

Line range hint 41-161: Enhance test specificity and patterns.

While the test structure is solid, consider these improvements to align with the coding guidelines:

  1. Replace generic toBeTruthy() assertions with more specific matchers:
-expect(announcementButton).toBeTruthy();
+expect(announcementButton).not.toBeNull();

-expect(modal).toBeTruthy();
+expect(modal).not.toBeNull();

-expect(inlineInput).toBeTruthy();
+expect(inlineInput).not.toBeNull();
  1. Make test descriptions more specific:
-it('should create', fakeAsync(() => {
+it('should create component and handle scroll on new message', fakeAsync(() => {

-it('should set initial values correctly', fakeAsync(() => {
+it('should initialize course, active conversation, and posts', fakeAsync(() => {
src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.component.ts (1)

84-85: LGTM! Consider adding property documentation.

The property names are descriptive and follow the Angular style guide. Consider adding JSDoc comments to document their purpose and relationship to the announcement channel functionality.

/** Controls visibility of input with call-to-action for announcement channels */
isHiddenInputWithCallToAction = false;
/** Controls full input visibility for announcement channels */
isHiddenInputFull = false;
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6769e01 and 3972391.

📒 Files selected for processing (3)
  • src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.component.html (1 hunks)
  • src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.component.ts (2 hunks)
  • src/test/javascript/spec/component/overview/course-conversations/layout/conversation-messages/conversation-messages.component.spec.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.component.html
🧰 Additional context used
📓 Path-based instructions (2)
src/main/webapp/app/overview/course-conversations/layout/conversation-messages/conversation-messages.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/layout/conversation-messages/conversation-messages.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}}

Copy link
Contributor

@raffifasaro raffifasaro left a comment

Choose a reason for hiding this comment

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

code LGTM

Copy link

github-actions bot commented Nov 4, 2024

⚠️ Unable to deploy to test servers ⚠️

Testserver "artemis-test2.artemis.cit.tum.de" is already in use by PR #9487.

@github-actions github-actions bot added the deployment-error Added by deployment workflows if an error occured label Nov 4, 2024
@github-actions github-actions bot removed the deployment-error Added by deployment workflows if an error occured label Nov 4, 2024
@vinceclifford vinceclifford temporarily deployed to artemis-test4.artemis.cit.tum.de November 4, 2024 18:59 — with GitHub Actions Inactive
Copy link

@vinceclifford vinceclifford 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, lgtm.

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 TS4. Everything works as described!

Screenshot 2024-11-04 221649
Screenshot 2024-11-04 221703

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!) ready to merge small tests
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.