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

Programming exercises: Add custom themes for the Monaco editor #9463

Merged
merged 21 commits into from
Oct 13, 2024

Conversation

pzdr7
Copy link
Contributor

@pzdr7 pzdr7 commented Oct 13, 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. (see Allow CSS variables in themes microsoft/monaco-editor#2427)
  • I added multiple integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.
  • I documented the TypeScript code using JSDoc style.
  • I added multiple screenshots/screencasts of my UI changes.

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

We would like to have more control over the styling of the Monaco editor. Currently, we only use the default themes.

Description

  • Introduced interfaces for theme definitions, consisting of
    • an ID and a base theme
    • an interface for the colors of the editor
    • rules for the language tokens (-> syntax highlighting) that can be applied globally or to just one language
  • Adjusted the colors of the editor; particularly, the diff editor now has a theme that is much closer to what you would see on GitHub

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 1 Programming exercise
  1. Log in to Artemis
  2. Navigate to course management > your course > exercise and click the title of the exercise.
  3. Scroll down to and click "Review Changes" and ensure the new diff theme loads (you can compare it to the old design using the screenshots below)
  4. Close the modal
  5. Change your Artemis theme
  6. Click "Review Changes" again. As before, ensure the new diff theme loads

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)
monaco-dark.theme.ts 100%
monaco-editor-theme.model.ts 100%
monaco-light.theme.ts 100%
monaco-editor.service.ts 100%

Screenshots

Before

Screenshot from 2024-10-13 10-21-18

Screenshot from 2024-10-12 12-10-45

After

Screenshot from 2024-10-13 10-06-08

Screenshot from 2024-10-12 12-00-49

Summary by CodeRabbit

  • New Features

    • Introduced custom dark and light themes for the Monaco editor.
    • Added styling configurations for editor colors and language tokens.
  • Bug Fixes

    • Disabled the focus border around the editor for a cleaner appearance.
  • Tests

    • Added unit tests to ensure proper theme registration functionality.

@github-actions github-actions bot added tests client Pull requests that update TypeScript code. (Added Automatically!) labels Oct 13, 2024
@pzdr7 pzdr7 temporarily deployed to artemis-test4.artemis.cit.tum.de October 13, 2024 10:19 — with GitHub Actions Inactive
@pzdr7 pzdr7 marked this pull request as ready for review October 13, 2024 11:50
Copy link

coderabbitai bot commented Oct 13, 2024

Walkthrough

The pull request introduces several new interfaces and constants related to theming in the Monaco editor. It adds the EditorColors, LanguageTokenStyleDefinition, and MonacoThemeDefinition interfaces, as well as constants for light and dark themes. A new class, MonacoEditorTheme, is implemented to manage theme registration. Additionally, style adjustments are made to the editor component, and unit tests are added to ensure the functionality of the new theme features.

Changes

File Path Change Summary
src/main/webapp/app/shared/monaco-editor/model/themes/*.interface.ts Added interfaces: EditorColors, LanguageTokenStyleDefinition, MonacoThemeDefinition.
src/main/webapp/app/shared/monaco-editor/model/themes/*.theme.ts Added constants: MONACO_DARK_THEME_DEFINITION, MONACO_LIGHT_THEME_DEFINITION.
src/main/webapp/app/shared/monaco-editor/model/themes/monaco-editor-theme.model.ts Added class MonacoEditorTheme with methods getId(), register(), and getRecordWithoutUndefinedEntries().
src/main/webapp/app/shared/monaco-editor/monaco-editor.component.scss Introduced a nested style rule to disable the focus border around the editor.
src/main/webapp/app/shared/monaco-editor/monaco-editor.service.ts Added variables lightTheme, darkTheme and methods registerCustomThemes(), registerCustomMarkdownLanguage().
src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-theme.spec.ts Added new test suite for MonacoEditorTheme and a test for theme registration.
src/test/javascript/spec/component/shared/monaco-editor/monaco-editor.service.spec.ts Updated tests to use new theme constants for clarity and maintainability.

Possibly related PRs

Suggested labels

enhancement, ready for review

Suggested reviewers

  • florian-glombik
  • JohannesWt
  • egekurt123
  • Jan-Thurner
  • SimonEntholzer

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 330a677 and 814e38d.

📒 Files selected for processing (10)
  • src/main/webapp/app/shared/monaco-editor/model/themes/editor-colors.interface.ts (1 hunks)
  • src/main/webapp/app/shared/monaco-editor/model/themes/language-token-style-definition.interface.ts (1 hunks)
  • src/main/webapp/app/shared/monaco-editor/model/themes/monaco-dark.theme.ts (1 hunks)
  • src/main/webapp/app/shared/monaco-editor/model/themes/monaco-editor-theme.model.ts (1 hunks)
  • src/main/webapp/app/shared/monaco-editor/model/themes/monaco-light.theme.ts (1 hunks)
  • src/main/webapp/app/shared/monaco-editor/model/themes/monaco-theme-definition.interface.ts (1 hunks)
  • src/main/webapp/app/shared/monaco-editor/monaco-editor.component.scss (1 hunks)
  • src/main/webapp/app/shared/monaco-editor/monaco-editor.service.ts (3 hunks)
  • src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-theme.spec.ts (1 hunks)
  • src/test/javascript/spec/component/shared/monaco-editor/monaco-editor.service.spec.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
src/main/webapp/app/shared/monaco-editor/model/themes/editor-colors.interface.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/monaco-editor/model/themes/language-token-style-definition.interface.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/monaco-editor/model/themes/monaco-dark.theme.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/monaco-editor/model/themes/monaco-editor-theme.model.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/monaco-editor/model/themes/monaco-light.theme.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/monaco-editor/model/themes/monaco-theme-definition.interface.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/monaco-editor/monaco-editor.service.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/monaco-editor/monaco-editor-theme.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/test/javascript/spec/component/shared/monaco-editor/monaco-editor.service.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
src/main/webapp/app/shared/monaco-editor/model/themes/monaco-editor-theme.model.ts

[error] 51-51: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)

🔇 Additional comments (24)
src/main/webapp/app/shared/monaco-editor/model/themes/monaco-theme-definition.interface.ts (2)

1-2: LGTM: Imports are correct and follow guidelines.

The imports are necessary for the interface definition and follow the Angular style guidelines. The use of PascalCase for imported types is correct as per the coding guidelines.


1-9: Overall assessment: Well-structured and aligned with PR objectives.

This new file introduces the MonacoThemeDefinition interface, which is a crucial part of implementing custom themes for the Monaco editor as per the PR objectives. The code is well-structured, follows the coding guidelines, and promotes code reuse. The suggestion to add JSDoc comments would further enhance the code quality and maintainability.

src/main/webapp/app/shared/monaco-editor/model/themes/language-token-style-definition.interface.ts (4)

5-27: LGTM: Interface naming and structure

The LanguageTokenStyleDefinition interface is well-structured and follows the PascalCase naming convention as per the coding guidelines. The interface clearly defines the properties needed for styling language tokens in the Monaco editor.


9-9: LGTM: Property naming and types

The properties within the LanguageTokenStyleDefinition interface are well-defined:

  • All properties use camelCase naming as per the guidelines.
  • Types are appropriate for each property (string for colors and token, union type for fontStyle).
  • Optional properties (languageId, foregroundColor, backgroundColor, fontStyle) are correctly marked with '?'.

This structure provides flexibility in defining token styles while maintaining type safety.

Also applies to: 14-14, 18-18, 22-22, 26-26


1-27: Summary: Well-implemented interface for custom Monaco editor themes

This new LanguageTokenStyleDefinition interface is a solid addition to the project, directly supporting the PR's objective of adding custom themes for the Monaco editor. It provides a clear and type-safe structure for defining token styles, which is crucial for implementing custom syntax highlighting.

Key points:

  1. The interface is well-structured and follows TypeScript and Angular best practices.
  2. Property naming and types are appropriate and consistent with the coding guidelines.
  3. JSDoc comments provide good documentation, with a minor suggestion for improvement.
  4. The implementation aligns well with the PR's goal of enhancing the Monaco editor's styling capabilities.

Overall, this file makes a valuable contribution to the custom theming feature, providing a robust foundation for defining language-specific token styles.


1-27: Verify indentation and consider using a formatting tool

The code generally adheres well to the provided coding guidelines. However, it's important to ensure consistent indentation throughout the project.

Please confirm that the indentation is set to 4 spaces, as specified in the coding guidelines. To maintain consistency across the project, consider using a formatting tool like Prettier with a configuration that matches your project's coding style. This will help automate formatting and ensure consistency across all files.

If the above command returns matches, it confirms that 4-space indentation is being used as expected.

✅ Verification successful

Adjusting the indentation verification script

The previous command failed because typescript is not a recognized file type. Let's target .ts files directly to verify 4-space indentation.


Indentation verified as consistent with 4 spaces

The indentation in language-token-style-definition.interface.ts adheres to the project’s coding guidelines, consistently using 4 spaces throughout the file.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify indentation in the file
rg --type typescript -A 1 '^\s{4}[^\s]' src/main/webapp/app/shared/monaco-editor/model/themes/language-token-style-definition.interface.ts

Length of output: 175


Script:

#!/bin/bash
# Verify 4-space indentation in the TypeScript file
rg -g "*.ts" "^ {4}\S" src/main/webapp/app/shared/monaco-editor/model/themes/language-token-style-definition.interface.ts

Length of output: 316

src/main/webapp/app/shared/monaco-editor/monaco-editor.component.scss (1)

Line range hint 1-62: Consider expanding theme-related modifications

While the current change addresses a specific styling concern, it doesn't fully align with the PR objectives of adding custom themes for the Monaco editor.

Consider expanding on this change to incorporate more theme-related modifications:

  1. Introduce CSS variables for theme-specific colors and styles.
  2. Use these variables throughout the file to enable easy theme switching.
  3. Create separate theme files (e.g., monaco-editor-light-theme.scss and monaco-editor-dark-theme.scss) to define theme-specific variables.

Example:

// In monaco-editor.component.scss
.monaco-editor-container {
    .monaco-editor {
        background-color: var(--monaco-editor-background);
        color: var(--monaco-editor-foreground);
        // ... other theme-related styles
    }
}

// In monaco-editor-light-theme.scss
:root {
    --monaco-editor-background: #ffffff;
    --monaco-editor-foreground: #000000;
    // ... other light theme variables
}

// In monaco-editor-dark-theme.scss
:root {
    --monaco-editor-background: #1e1e1e;
    --monaco-editor-foreground: #d4d4d4;
    // ... other dark theme variables
}

This approach would provide a more comprehensive theming solution, aligning better with the PR objectives.

Let's check if there are any existing theme-related files or variables in the project:

#!/bin/bash
# Search for theme-related files and variables
rg --type css -i '(theme|light|dark)' src/
fd -e scss -e css . src/ | grep -i 'theme'
src/main/webapp/app/shared/monaco-editor/model/themes/monaco-light.theme.ts (2)

1-1: LGTM: Import statement is correct and follows guidelines.

The import statement correctly imports the MonacoThemeDefinition interface using a relative path, which is appropriate for importing from within the same module.


3-5: LGTM: Constant declaration and basic theme properties are well-defined.

The constant MONACO_LIGHT_THEME_DEFINITION is correctly exported and typed. The theme id 'custom-light' is descriptive and follows camelCase naming convention. The use of 'vs' as the base theme is appropriate for a light theme.

src/main/webapp/app/shared/monaco-editor/model/themes/monaco-dark.theme.ts (3)

1-5: LGTM: Import and constant declaration look good.

The import statement and constant declaration follow Angular style guidelines and TypeScript best practices. The constant name is in uppercase, and the type is properly specified.


24-46: Great job on editor colors, especially diff styling!

The editor colors are well-defined and provide good contrast for readability. The diff colors, in particular, align well with the PR objective of making the diff editor resemble GitHub's styling. The use of alpha values for subtle highlighting is a nice touch.

This implementation successfully addresses the PR's goal of adjusting the diff editor's theme to resemble GitHub's styling more closely.


1-47: Excellent implementation of the custom dark theme for Monaco editor!

This file successfully implements a custom dark theme for the Monaco editor, aligning perfectly with the PR objectives. The theme definition is comprehensive, covering both token styles and editor colors, with special attention to diff styling that resembles GitHub's approach.

Key points:

  1. The code is well-structured and follows TypeScript and Angular conventions.
  2. It adheres to the provided coding guidelines, including naming conventions and type specifications.
  3. The color scheme provides good contrast and readability, especially for diff views.

The only suggestion for improvement is to consider extracting color constants for better maintainability, as mentioned in a previous comment.

Overall, this implementation effectively enhances the styling capabilities of the Monaco editor, meeting the primary objective of the PR.

src/test/javascript/spec/component/shared/monaco-editor/monaco-editor-theme.spec.ts (2)

7-36: Well-structured test setup with comprehensive theme definition.

The test setup is well-organized and covers various aspects of the theme, including color definitions and token styles. The explicit use of undefined for removed line backgrounds is a good practice for testing edge cases.

The use of TypeScript interfaces (EditorColors, LanguageTokenStyleDefinition, MonacoThemeDefinition) enhances type safety and code readability.


38-66: Well-implemented test case for theme registration.

The test case effectively verifies the correct registration of the theme using Jest spies and specific assertions. The use of toHaveBeenCalledExactlyOnceWith ensures that the theme is registered with the exact expected parameters, which is crucial for detecting any unintended changes in the theme definition.

The test follows Jest best practices and provides good coverage for the happy path of theme registration.

src/main/webapp/app/shared/monaco-editor/model/themes/editor-colors.interface.ts (1)

7-14: LGTM! Well-documented basic color properties.

The basic editor color properties are well-defined and documented. The use of optional properties allows for flexible theme definitions. The property names follow the camelCase convention as required by the coding guidelines.

src/test/javascript/spec/component/shared/monaco-editor/monaco-editor.service.spec.ts (3)

9-10: LGTM: New theme definition imports.

The new imports for MONACO_LIGHT_THEME_DEFINITION and MONACO_DARK_THEME_DEFINITION are correctly added and will be used in the updated test assertions.


45-45: LGTM: Updated assertion for light theme.

The assertion now correctly uses MONACO_LIGHT_THEME_DEFINITION.id, improving maintainability and adhering to the coding guidelines. The use of toHaveBeenCalledExactlyOnceWith is appropriate for this test case.


Line range hint 1-71: Overall assessment: Changes improve test maintainability.

The updates to this test file align well with the PR objectives by incorporating the new theme definitions. The changes enhance maintainability without altering the core test logic. All modifications adhere to the provided coding guidelines and Jest best practices.

To ensure that the new theme definitions are correctly implemented and no unintended changes were made, please run the following verification script:

This script will help confirm that the new theme definitions are correctly implemented and used consistently across the codebase.

✅ Verification successful

The previous verification scripts encountered issues because rg does not recognize typescript as a predefined file type. To proceed, please run the following updated verification scripts that explicitly target .ts and .tsx files:

Please execute these scripts to gather the necessary information for verifying the review comment.


Verification Successful: Theme Definitions Properly Implemented

The new theme definitions MONACO_LIGHT_THEME_DEFINITION and MONACO_DARK_THEME_DEFINITION are correctly exported from their respective files and properly utilized in the test file. Additionally, no instances of the old theme IDs are found elsewhere in the codebase.

  • Verified exports in src/main/webapp/app/shared/monaco-editor/model/themes/monaco-light.theme.ts
  • Verified exports in src/main/webapp/app/shared/monaco-editor/model/themes/monaco-dark.theme.ts
  • Confirmed no other files use MonacoEditorService.(LIGHT|DARK)_THEME_ID outside the test file
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of new theme definitions and their usage in tests.

# Test 1: Check if the new theme definitions are exported correctly
rg --type typescript "export const MONACO_(LIGHT|DARK)_THEME_DEFINITION" app/shared/monaco-editor/model/themes/

# Test 2: Verify that the test file is using the new theme definitions correctly
rg --type typescript "MONACO_(LIGHT|DARK)_THEME_DEFINITION.id" src/test/javascript/spec/component/shared/monaco-editor/monaco-editor.service.spec.ts

# Test 3: Ensure no other files are still using the old theme IDs
rg --type typescript "MonacoEditorService\.(LIGHT|DARK)_THEME_ID" -g '!src/test/javascript/spec/component/shared/monaco-editor/monaco-editor.service.spec.ts'

Length of output: 529


Script:

#!/bin/bash
# Description: Verify the implementation of new theme definitions and their usage in tests.

# Test 1: Check if the new theme definitions are exported correctly
rg "export const MONACO_(LIGHT|DARK)_THEME_DEFINITION" app/shared/monaco-editor/model/themes/ -g "*.ts" -g "*.tsx"

# Test 2: Verify that the test file is using the new theme definitions correctly
rg "MONACO_(LIGHT|DARK)_THEME_DEFINITION.id" src/test/javascript/spec/component/shared/monaco-editor/monaco-editor.service.spec.ts -g "*.ts" -g "*.tsx"

# Test 3: Ensure no other files are still using the old theme IDs
rg "MonacoEditorService\.(LIGHT|DARK)_THEME_ID" --glob '!src/test/javascript/spec/component/shared/monaco-editor/monaco-editor.service.spec.ts' -g "*.ts" -g "*.tsx"

Length of output: 790


Script:

#!/bin/bash
# Description: Locate the export statements for MONACO_LIGHT_THEME_DEFINITION and MONACO_DARK_THEME_DEFINITION.

# Search for export of MONACO_LIGHT_THEME_DEFINITION
rg "export const MONACO_LIGHT_THEME_DEFINITION" --glob "*.ts" --glob "*.tsx"

# Search for export of MONACO_DARK_THEME_DEFINITION
rg "export const MONACO_DARK_THEME_DEFINITION" --glob "*.ts" --glob "*.tsx"

Length of output: 446

src/main/webapp/app/shared/monaco-editor/monaco-editor.service.ts (6)

6-8: Import New Theme Definitions and Model

The import statements for MONACO_LIGHT_THEME_DEFINITION, MonacoEditorTheme, and MONACO_DARK_THEME_DEFINITION are correctly added and essential for implementing custom theming functionality.


20-21: Define Private Theme Properties

The declaration of lightTheme and darkTheme as private properties follows the coding guidelines for property naming conventions (camelCase) and encapsulation.


24-25: Initialize Themes and Languages in Constructor

Invoking registerCustomThemes() and registerCustomMarkdownLanguage() in the constructor ensures that the editor is properly configured upon service instantiation.


32-37: Register Custom Themes

The registerCustomThemes method correctly initializes and registers the custom light and dark themes, adhering to best practices by encapsulating theme setup within a dedicated method.


51-51: Apply Theme Based on Current Theme

The applyTheme method correctly sets the editor theme based on the current Artemis theme using a ternary operator, ensuring synchronization between the application and editor themes.


97-100: Customize Diff Editor Appearance

The addition of the guides option with indentation: false and setting renderLineHighlight to 'none' effectively customizes the diff editor to match the desired styling, enhancing user experience.

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 lgtm

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.

code lgtm

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 TS4, works as expected also after theme change 👍 I like the new custom theme a lot :)

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.

Tested on TS1, new theme looks like in screenshots and all changes seem to work

@krusche krusche added this to the 7.6.0 milestone Oct 13, 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.

The new theme looks much better 👍

@krusche krusche changed the title General: Add custom themes for the Monaco editor Programming exercises: Add custom themes for the Monaco editor Oct 13, 2024
@krusche krusche added ready to merge maintainer-approved The feature maintainer has approved the PR labels Oct 13, 2024
@krusche krusche merged commit e072169 into develop Oct 13, 2024
96 of 101 checks passed
@krusche krusche deleted the chore/programming-exercises/themes branch October 13, 2024 15:26
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!) maintainer-approved The feature maintainer has approved the PR ready for review ready to merge tests
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

6 participants