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

Development: Migrate the MonacoEditorModule to standalone components #9407

Merged
merged 30 commits into from
Oct 7, 2024

Conversation

pzdr7
Copy link
Contributor

@pzdr7 pzdr7 commented Oct 1, 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 integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.

Changes affecting Programming Exercises

  • High priority: I tested all changes and their related features with all corresponding user types on a test server configured with the integrated lifecycle setup (LocalVC and LocalCI).

Motivation and Context

According to our new client coding guidelines, we want to move away from modules and @Input/@Output. The Monaco Editor still uses a module (for registering its custom languages) and non-signal based inputs and outputs.

Description

  • Deleted the MonacoEditorModule
  • Made the components standalone and implement the OnPush change detection strategy.
  • Replaced the inputs/outputs with signals
  • Added the new MonacoEditorService that replaces the module by
    • registering the custom language
    • implementing the theme switch (now with signals)
  • Adjusted other components, tests, and modules to import the components directly rather than the module

Steps for Testing

Prerequisites:

  • 1 Programming exercise
  • 1 Instructor
  1. Log in and navigate to course management > your course > your programming exercise > Edit
  2. Verify that when you switch between light and dark mode, the problem statement editor also switches between light and dark mode.
  3. Verify that the problem statement still has its markdown syntax highlighting (and is not plain text)

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)
monaco-diff-editor.component.ts 96.49%
monaco-editor.component.ts 97.01%
monaco-editor.service.ts 100%

Screenshots

No UI changes

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced the MonacoDiffEditorComponent to function independently with improved reactivity.
    • Updated component properties for better performance and usability.
  • Bug Fixes

    • Streamlined the component's constructor for improved readability and functionality.
  • Tests

    • Enhanced test coverage for MonacoDiffEditorComponent with updated assertions and property handling.
    • Improved test setup by removing unnecessary module imports and focusing on component imports.

@github-actions github-actions bot added tests client Pull requests that update TypeScript code. (Added Automatically!) labels Oct 1, 2024
Comment on lines +88 to 89
comp.editor = TestBed.createComponent(MonacoEditorComponent).componentInstance;
expect(comp.editor).toBeDefined();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If this looks odd to you: comp.editor is actually a get/set pair. We will remove this when refactoring the build plan components

}

applyTheme(artemisTheme: Theme): void {
monaco.editor.setTheme(artemisTheme === Theme.LIGHT ? 'vs' : 'vs-dark');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

vs-light (from the other components) was actually wrong. The light theme (which is also the fallback for incorrect themes 😅) is vs

@pzdr7 pzdr7 temporarily deployed to artemis-test5.artemis.cit.tum.de October 2, 2024 06:22 — with GitHub Actions Inactive
@pzdr7 pzdr7 marked this pull request as ready for review October 2, 2024 06:36
@pzdr7 pzdr7 requested a review from a team as a code owner October 2, 2024 06:36
Copy link

coderabbitai bot commented Oct 2, 2024

Walkthrough

The changes in this pull request focus on significant updates to the MonacoDiffEditorComponent in monaco-diff-editor.component.ts. The component is now standalone and utilizes an OnPush change detection strategy. Input and output properties have been refactored to use new decorators, enhancing reactivity. The constructor has been simplified by directly injecting dependencies. Additionally, an effect has been introduced for reactive updates to editor options, and theme management has been delegated to the MonacoEditorService.

Changes

File Change Summary
src/main/webapp/app/shared/monaco-editor/monaco-diff-editor.component.ts Updated MonacoDiffEditorComponent to be standalone, modified change detection strategy to OnPush, refactored input/output properties to use new decorators, streamlined constructor by injecting dependencies directly, and introduced an effect for reactive updates to editor options.

Possibly related PRs

Suggested labels

enhancement, documentation, ready to merge

Suggested reviewers

  • florian-glombik
  • egekurt123
  • coolchock
  • Jan-Thurner

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.

@pzdr7 pzdr7 requested a review from JohannesWt October 2, 2024 06:36
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.

Tested on TS6, works as expected and editor highlightings also transfer correctly between dark and light mode

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.

Re-approve

Copy link
Member

@BBesrour BBesrour 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, lgtm!

@krusche krusche added this to the 7.6.0 milestone Oct 7, 2024
@krusche krusche merged commit 1b12f3e into develop Oct 7, 2024
46 of 51 checks passed
@krusche krusche deleted the chore/programming-exercises/monaco-standalone branch October 7, 2024 18:56
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
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants