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

General: Make sure the filter button renders when reloading the course statistics page #10231

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

badkeyy
Copy link
Contributor

@badkeyy badkeyy commented Jan 29, 2025

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 principle of data economy for all client-server REST calls.
  • 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 integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.
  • I added authorities to all new routes and checked the course groups for displaying navigation elements (links, buttons).
  • I documented the TypeScript code using JSDoc style.
  • I added multiple screenshots/screencasts of my UI changes.
  • I translated all newly inserted strings into English and German.

Motivation and Context

Currently the filter button of the course statistics page does not render when reloading the page. This PR fixes that.
Fixes #10130

Description

Add EventEmitter that fires when child view sets the BarControl (that includes the filter button) in order to time the rendering at the parent view

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 2 Students
  • 1 Programming Exercise with Complaints enabled
  1. Log in to Artemis
  2. Navigate to Course Statistics page
  3. Reload the page
  4. Find that the filter button renders

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

Performance Review

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Screenshots

video

Summary by CodeRabbit

  • New Features

    • Enhanced control rendering mechanism with asynchronous handling.
    • Added controlsRendered event emitter to signal control rendering completion.
  • Improvements

    • Improved component interaction by introducing a new mechanism to track control rendering state.
    • Updated subscription logic to handle asynchronous control configuration updates.

@badkeyy badkeyy requested a review from a team as a code owner January 29, 2025 12:37
@github-actions github-actions bot added the client Pull requests that update TypeScript code. (Added Automatically!) label Jan 29, 2025
Copy link

coderabbitai bot commented Jan 29, 2025

Walkthrough

The pull request introduces changes to handle control configuration updates and rendering in the course overview and statistics components. Modifications include updating the subscription logic in the CourseOverviewComponent to utilize asynchronous operations, adding a controlsRendered event emitter in the CourseStatisticsComponent, and enhancing the BarControlConfigurationProvider interface with a new property for control rendering events. These changes aim to improve the management of component controls and their rendering processes.

Changes

File Change Summary
src/main/webapp/app/overview/course-overview.component.ts Updated subscription to control configuration with async/await handling
src/main/webapp/app/overview/course-statistics/course-statistics.component.ts Added controlsRendered EventEmitter to signal control rendering completion
src/main/webapp/app/shared/tab-bar/tab-bar.ts Added controlsRendered property to BarControlConfigurationProvider interface
src/test/javascript/spec/component/course/course-overview.component.spec.ts Added controlsRendered EventEmitter to ControlsTestingComponent for testing

Assessment against linked issues

Objective Addressed Explanation
Filter button persistence [#10130] Unable to definitively confirm if the changes directly resolve the filter disappearance issue.

Possibly related PRs

Suggested labels

tests, bugfix, enhancement, ready to merge

Suggested reviewers

  • EneaGore
  • florian-glombik
  • HawKhiem
  • krusche
  • BBesrour

📜 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 2def3c2 and e938b58.

📒 Files selected for processing (1)
  • src/test/javascript/spec/component/course/course-overview.component.spec.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/test/javascript/spec/component/course/course-overview.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}}

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: Call Build Workflow / Build .war artifact
  • GitHub Check: client-tests
  • GitHub Check: server-tests
  • GitHub Check: Analyse
🔇 Additional comments (2)
src/test/javascript/spec/component/course/course-overview.component.spec.ts (2)

29-29: LGTM!

The addition of EventEmitter to the imports is appropriate for implementing the control rendering notification mechanism.


121-122: LGTM! The controlsRendered property implementation aligns with the PR objectives.

The EventEmitter<void> property correctly implements the mechanism to notify when the filter button controls are rendered, addressing the issue where the filter button wasn't rendering on page reload.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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

🧹 Nitpick comments (2)
src/main/webapp/app/shared/tab-bar/tab-bar.ts (1)

11-11: LGTM! Consider adding JSDoc for the new property.

The addition of controlsRendered event emitter is a good solution for handling control rendering events. Consider adding JSDoc documentation to explain its purpose and usage.

 export interface BarControlConfigurationProvider {
     controlConfiguration: BarControlConfiguration;
+    /** Emits when the controls template has been rendered in the view. */
     controlsRendered: EventEmitter<void>;
 }
src/main/webapp/app/overview/course-overview.component.ts (1)

626-630: LGTM! Consider unsubscribing from controlsRendered.

The async/await pattern is well implemented to ensure proper control rendering sequence. However, since we're using firstValueFrom on an event emitter, consider cleaning up the subscription to prevent potential memory leaks.

     this.controlsSubscription =
         this.controlConfiguration.subject?.subscribe(async (controls: TemplateRef<any>) => {
             this.controls = controls;
-            await firstValueFrom(provider.controlsRendered);
+            const controlsRenderedSubscription = provider.controlsRendered.subscribe();
+            await firstValueFrom(provider.controlsRendered);
+            controlsRenderedSubscription.unsubscribe();
             this.tryRenderControls();
         }) || undefined;
📜 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 2def3c2.

📒 Files selected for processing (3)
  • src/main/webapp/app/overview/course-overview.component.ts (1 hunks)
  • src/main/webapp/app/overview/course-statistics/course-statistics.component.ts (3 hunks)
  • src/main/webapp/app/shared/tab-bar/tab-bar.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/main/webapp/app/shared/tab-bar/tab-bar.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-overview.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-statistics/course-statistics.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

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Call Build Workflow / Build .war artifact
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: server-tests
  • GitHub Check: Analyse
🔇 Additional comments (2)
src/main/webapp/app/overview/course-statistics/course-statistics.component.ts (2)

119-119: LGTM! Property initialization looks good.

The controlsRendered event emitter is properly initialized as a class property.


285-285: LGTM! Event emission is correctly placed.

The event is emitted at the right time in the ngAfterViewInit lifecycle hook, ensuring that the controls template is available.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 29, 2025
vinceclifford
vinceclifford previously approved these changes Jan 29, 2025
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 TS5, works as expected.

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 TS4. Works as expected 👍🏼

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, works fine.

@helios-aet helios-aet bot temporarily deployed to artemis-test6.artemis.cit.tum.de February 5, 2025 13:30 Inactive
Copy link

@zagemello zagemello 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 TS6, all works as expected.

@helios-aet helios-aet bot temporarily deployed to artemis-test5.artemis.cit.tum.de February 5, 2025 14:23 Inactive
Copy link

@kevinfischer4 kevinfischer4 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, button renders after reloading the page (tested in Chrome and Safari) 👍

@helios-aet helios-aet bot temporarily deployed to artemis-test1.artemis.cit.tum.de February 5, 2025 20:34 Inactive
@Fallthunderclap
Copy link

Tested on TS1, button renders after reloading the page (tested in Firefox)

@helios-aet helios-aet bot temporarily deployed to artemis-test7.artemis.cit.tum.de February 5, 2025 21:46 Inactive
@Longppham
Copy link

Tested on TS1

works as expected

Copy link

@HanyangXu0508 HanyangXu0508 left a comment

Choose a reason for hiding this comment

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

test locally and worked as expected

@helios-aet helios-aet bot temporarily deployed to artemis-test5.artemis.cit.tum.de February 7, 2025 14:19 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 TS5, the filter button renders as supposed to

@helios-aet helios-aet bot temporarily deployed to artemis-test4.artemis.cit.tum.de February 11, 2025 19:56 Inactive
Copy link

@flbrgit flbrgit 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, the button renders without problems

Copy link

@Feras797 Feras797 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, the button renders.

@krusche krusche added this to the 7.10.1 milestone Feb 15, 2025
@krusche
Copy link
Member

krusche commented Feb 15, 2025

we need to wait if all client tests pass

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.

One client test in course-overview.component.spec.ts consistently fails. Please fix it first, otherwise we cannot merge this PR

@krusche krusche modified the milestones: 7.10.1, 7.10.2 Feb 15, 2025
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 for review tests
Projects
Status: Ready For Review
Development

Successfully merging this pull request may close these issues.

General: Filter disappears after selection in Course-Statistics