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

Iris: Fix the about page #10016

Merged
merged 3 commits into from
Dec 20, 2024
Merged

Iris: Fix the about page #10016

merged 3 commits into from
Dec 20, 2024

Conversation

bassner
Copy link
Member

@bassner bassner commented Dec 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 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.

Description

  • Added window title to the About Iris page
  • Migrated it to standalone

Steps for Testing

Prerequisites:

  • 1 Exercise with Iris enabled
  1. Open chat
  2. Click small "i" icon next to Iris name
  3. Observe the title of the tab of the newly opened page and check that everything is shown fine

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

  • I (as a reviewer) confirm that the client changes (in particular related to REST calls and UI responsiveness) are implemented with a very good performance even for very large courses with more than 2000 students.
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance even for very large courses with more than 2000 students.

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Summary by CodeRabbit

  • New Features

    • Introduced a new route for the "About Iris" page, enhancing navigation.
  • Improvements

    • Updated the AboutIrisComponent to be standalone, allowing independent usage.
    • Enhanced IrisLogoComponent with reactive properties for size and appearance.
  • Bug Fixes

    • Adjusted HTML template to correctly invoke properties as methods.
  • Refactor

    • Streamlined component logic by removing lifecycle hooks and leveraging reactive programming.
  • Chores

    • Modified module structure by removing components from declarations and adding them to imports.

@bassner bassner added this to the 7.7.5 milestone Dec 13, 2024
@bassner bassner self-assigned this Dec 13, 2024
@bassner bassner requested a review from a team as a code owner December 13, 2024 14:56
@github-actions github-actions bot added the client Pull requests that update TypeScript code. (Added Automatically!) label Dec 13, 2024
Copy link

coderabbitai bot commented Dec 13, 2024

Walkthrough

The changes in this pull request introduce a new route for the Angular application, specifically for the path 'about-iris', which loads the AboutIrisComponent. The AboutIrisComponent has been modified to include new imports and is declared as a standalone component. The IrisLogoComponent has also been updated to utilize reactive state management and is now imported rather than declared in the IrisModule. Additionally, the HTML template for IrisLogoComponent has been modified to access properties as methods.

Changes

File Path Change Summary
src/main/webapp/app/app-routing.module.ts Added new route path: 'about-iris' with loadComponent and data property for page title.
src/main/webapp/app/iris/about-iris/about-iris.component.ts Updated imports, added standalone: true, and modified imports array in the component decorator.
src/main/webapp/app/iris/iris-logo/iris-logo.component.html Changed property access from direct to method invocation for logoUrl and classList.
src/main/webapp/app/iris/iris-logo/iris-logo.component.ts Declared component as standalone, removed OnInit, replaced @Input with input function, and added computed properties.
src/main/webapp/app/iris/iris.module.ts Removed AboutIrisComponent and IrisLogoComponent from declarations, added IrisLogoComponent to imports.

Possibly related PRs

Suggested labels

client, ready for review, iris, chore, code quality, refactoring

Suggested reviewers

  • alexjoham
  • sebastianloose
  • kaancayli
  • Hialus

📜 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 3c34536 and 9ad7bb5.

📒 Files selected for processing (1)
  • src/main/webapp/app/iris/iris-logo/iris-logo.component.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/webapp/app/iris/iris-logo/iris-logo.component.ts

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

🧹 Outside diff range and nitpick comments (2)
src/main/webapp/app/iris/iris-logo/iris-logo.component.ts (1)

21-23: Consider using @Input decorator for input properties

While the input function provides reactive inputs, the project's coding standards or existing codebase may prefer the traditional @Input() decorator for defining input properties. Ensure consistency with the rest of the codebase.

Apply this diff if you decide to revert to @Input():

 export class IrisLogoComponent {
-    size = input<IrisLogoSize | number>(IrisLogoSize.BIG);
-    look = input<IrisLogoLookDirection>(IrisLogoLookDirection.RIGHT);
+    @Input() size: IrisLogoSize | number = IrisLogoSize.BIG;
+    @Input() look: IrisLogoLookDirection = IrisLogoLookDirection.RIGHT;
src/main/webapp/app/app-routing.module.ts (1)

184-188: Consider route placement and access control.

While the implementation follows Angular best practices and correctly implements lazy loading, consider:

  1. Moving this route higher in the routes array, grouped with other similar standalone routes (e.g., near the 'about' route) for better organization.
  2. Evaluating if this route should have access control via UserRouteAccessService and appropriate authorities, similar to other protected routes in the application.

Example placement and access control:

                {
                    path: 'about',
                    loadChildren: () => import('./core/about-us/artemis-about-us.module').then((module) => module.ArtemisAboutUsModule),
                },
+               {
+                   path: 'about-iris',
+                   pathMatch: 'full',
+                   loadComponent: () => import('./iris/about-iris/about-iris.component').then((m) => m.AboutIrisComponent),
+                   data: {
+                       pageTitle: 'artemisApp.exerciseChatbot.title',
+                       authorities: [Authority.USER], // Add if access should be restricted
+                   },
+                   canActivate: [UserRouteAccessService], // Add if access should be restricted
+               },
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fafe68c and 3c34536.

📒 Files selected for processing (5)
  • src/main/webapp/app/app-routing.module.ts (1 hunks)
  • src/main/webapp/app/iris/about-iris/about-iris.component.ts (1 hunks)
  • src/main/webapp/app/iris/iris-logo/iris-logo.component.html (1 hunks)
  • src/main/webapp/app/iris/iris-logo/iris-logo.component.ts (2 hunks)
  • src/main/webapp/app/iris/iris.module.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
src/main/webapp/app/app-routing.module.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/iris/iris-logo/iris-logo.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/iris/iris.module.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/iris/about-iris/about-iris.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/iris/iris-logo/iris-logo.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

🔇 Additional comments (8)
src/main/webapp/app/iris/iris-logo/iris-logo.component.ts (2)

1-1: Verify compatibility with Angular version

The use of computed and input functions from @angular/core suggests reliance on Angular's latest reactive features. Please confirm that the project's Angular version supports these features to ensure compatibility.


25-43: 🛠️ Refactor suggestion

Avoid calling methods directly in templates

According to the coding guidelines (methods_in_html:false), methods should not be invoked directly within templates. The logoUrl() and classList() methods are currently called in the template. Consider refactoring them into properties.

Apply this diff to modify logoUrl and classList into properties:

 export class IrisLogoComponent {
     // ... existing code ...
-    logoUrl = computed(() => {
+    readonly logoUrl = (() => {
         if (this.size() === IrisLogoSize.SMALL) {
             return 'public/images/iris/iris-logo-small.png';
         }
         return `public/images/iris/iris-logo-big-${this.look()}.png`;
-    });
+    })();
 
-    classList = computed(() => {
+    readonly classList = (() => {
         if (this.size() === IrisLogoSize.SMALL) {
             return 'small';
         } else if (this.size() === IrisLogoSize.MEDIUM) {
             return 'medium';
         } else if (this.size() === IrisLogoSize.BIG) {
             return 'big img-fluid';
         } else if (this.size() === IrisLogoSize.FLUID) {
             return 'fluid';
         }
         return '';
-    });
+    })();
 }

Likely invalid or redundant comment.

src/main/webapp/app/iris/about-iris/about-iris.component.ts (2)

3-5: Appropriate imports for standalone component

The addition of IrisLogoComponent, ArtemisTranslatePipe, and TranslateDirective in the imports aligns with making AboutIrisComponent a standalone component.


11-12: Correct usage of standalone: true and imports

Declaring the component as standalone and including necessary imports is proper usage according to Angular best practices.

src/main/webapp/app/iris/iris.module.ts (2)

23-23: Update module imports for standalone components

Since IrisLogoComponent is now a standalone component, it's appropriate to include it in the imports array instead of declarations.


50-50: Include IrisLogoComponent in imports

Adding IrisLogoComponent to the imports ensures it's available where needed, following Angular's module conventions for standalone components.

src/main/webapp/app/app-routing.module.ts (2)

184-188: LGTM! Implementation follows Angular best practices.

The route implementation:

  • Correctly uses lazy loading via loadComponent
  • Properly sets the page title
  • Uses standalone component format as required
  • Follows Angular routing conventions

185-187: Verify translation key and component setup.

Let's ensure the translation key exists and the component is properly exported.

✅ Verification successful

Translation key and component integration are properly set up

The translation key artemisApp.exerciseChatbot.title is used in the about-iris component (about-iris.component.html) and is part of a larger chatbot feature called Iris. The component is properly integrated with the routing module and uses the translation system correctly. The code shows a well-structured chatbot implementation with proper error handling and translations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify translation key existence and component setup

# Check for translation key in English and German translations
echo "Checking translation key existence..."
rg "artemisApp.exerciseChatbot.title" src/main/webapp/i18n/

# Verify component export
echo "Verifying component export..."
rg "export.*class.*AboutIrisComponent" src/main/webapp/app/iris/about-iris/

Length of output: 385


Script:

#!/bin/bash
# Let's check the translation files directly to see if we can find any related keys
echo "Checking translation files for exercise chatbot related keys..."
fd . src/main/webapp/i18n/ -e json -x cat {} | jq -r 'paths | join(".")'

# Let's also check the routing module to understand the context better
echo "Checking the routing configuration..."
cat src/main/webapp/app/app-routing.module.ts

Length of output: 66018


Script:

#!/bin/bash
# Let's check for the translation key in English and German translation files specifically
echo "Checking English translation file..."
fd en.json src/main/webapp/i18n/ -x cat {}

echo "Checking German translation file..."
fd de.json src/main/webapp/i18n/ -x cat {}

# Let's also check for any component related to exerciseChatbot
echo "Checking for exerciseChatbot component..."
rg -l "exerciseChatbot" src/main/webapp/app/

Length of output: 625


Script:

#!/bin/bash
# Let's check the content of these files to understand the context better
echo "Checking about-iris.component.html..."
cat src/main/webapp/app/iris/about-iris/about-iris.component.html

echo "Checking iris-base-chatbot.component.html..."
cat src/main/webapp/app/iris/base-chatbot/iris-base-chatbot.component.html

echo "Checking iris-errors.model.ts..."
cat src/main/webapp/app/entities/iris/iris-errors.model.ts

Length of output: 14516

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 13, 2024
@krusche krusche modified the milestones: 7.7.5, 7.8.0 Dec 13, 2024
@krusche krusche changed the title Iris: Fix and migrate the "About Iris" page Iris: Fix the about page Dec 13, 2024
Copy link
Collaborator

@MaximilianAnzinger MaximilianAnzinger 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 implementing my feedback <3

@krusche krusche merged commit 19b5f7c into develop Dec 20, 2024
22 of 26 checks passed
@krusche krusche deleted the bugfix/about-iris-page branch December 20, 2024 15:57
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!) small
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

3 participants