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: Improve tab navigation on login page #9373

Merged
merged 1 commit into from
Sep 27, 2024
Merged

Conversation

krusche
Copy link
Member

@krusche krusche commented Sep 27, 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.

Motivation and Context

  • The login was a bit cumbersome

Description

  • Improve tab navigation and validation
  • Migrate home component to standalone and related services to use the new inject mechanism

Steps for Testing

  1. Log in to Artemis

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

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a new route for the HomeComponent, accessible at the root URL.
    • Enhanced form validation logic in the HomeComponent for better user experience.
  • Improvements

    • Updated input handling in the login form to improve interactivity and accessibility.
    • Simplified dependency injection across various services and components using Angular's latest practices.
  • Bug Fixes

    • Refined error message display logic to prevent premature notifications.
  • Chores

    • Removed obsolete modules and routing configurations related to the HomeComponent.

@krusche krusche requested a review from a team as a code owner September 27, 2024 20:05
Copy link

coderabbitai bot commented Sep 27, 2024

Walkthrough

The pull request introduces several changes across multiple files, including updates to the Jest configuration for coverage thresholds, modifications to routing and component structures in Angular, and refactoring of dependency injection methods. Key updates include the addition of a new route for the HomeComponent, removal of certain modules and methods, and a transition to using Angular's inject function for dependency management. Additionally, modifications to form handling and testing setups are implemented to enhance functionality and maintainability.

Changes

File Path Change Summary
jest.config.js Coverage thresholds for statements and lines updated; branches remains unchanged.
src/main/webapp/app/app-routing.module.ts New route added for HomeComponent at the empty path.
src/main/webapp/app/app.module.ts Removed import for ArtemisHomeModule.
src/main/webapp/app/core/auth/account.service.ts Transitioned to using inject for service dependencies; constructor removed.
src/main/webapp/app/core/auth/auth-jwt.service.ts Refactored to use inject for service dependencies; constructor removed.
src/main/webapp/app/core/auth/state-storage.service.ts Removed constructor and several state management methods; simplified functionality.
src/main/webapp/app/core/auth/user-route-access-service.ts Updated to use inject for dependencies; constructor removed.
src/main/webapp/app/core/login/login.service.ts Transitioned to using inject for dependencies; constructor removed.
src/main/webapp/app/home/home.component.html Updated form input handling; added length constraints and refined error message logic.
src/main/webapp/app/home/home.component.ts Modified to use standalone component feature; updated dependency injection and added new methods.
src/main/webapp/app/home/home.module.ts Deleted module defining ArtemisHomeModule.
src/main/webapp/app/home/home.route.ts Deleted routing configuration for the home component.
src/main/webapp/app/home/saml2-login/saml2-login.component.ts Updated to use inject for dependencies; marked as standalone.
src/test/javascript/spec/service/account.service.spec.ts Updated testing setup for asynchronous behavior; improved clarity of tests.
src/test/javascript/spec/service/state-storage.service.spec.ts Removed tests related to previous and destination state management.

Possibly related PRs

Suggested labels

tests, ready for review, client, user interface, bugfix, small, documentation

Suggested reviewers

  • dfuchss
  • EneaGore
  • SimonEntholzer
  • JohannesStoehr
  • pzdr7
  • florian-glombik

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.

@github-actions github-actions bot added tests client Pull requests that update TypeScript code. (Added Automatically!) labels Sep 27, 2024
@krusche krusche added this to the 7.5.4 milestone Sep 27, 2024
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: 13

🧹 Outside diff range comments (6)
src/main/webapp/app/core/auth/state-storage.service.ts (1)

Line range hint 17-20: Add JSDoc comment for getUrl method.

To maintain consistency and improve code documentation, please add a JSDoc comment for the getUrl method, similar to the one provided for storeUrl.

Here's a suggested JSDoc comment:

/**
 * Get the previousURL stored in the current session.
 * @returns The stored URL as a string.
 */
getUrl(): string {
    // ... existing implementation ...
}
src/main/webapp/app/core/auth/auth-jwt.service.ts (1)

Line range hint 1-50: Overall structure aligns well with guidelines, minor improvements possible

The file structure largely adheres to the provided coding guidelines:

  • Single quotes are used for strings
  • PascalCase is used for the class name
  • camelCase is used for method names
  • Curly braces and indentation are consistent
  • JSDoc style comments are included

To fully align with the coding guidelines:

Consider refactoring class methods to use arrow functions. For example:

login = (credentials: Credentials): Observable<object> => {
    return this.http.post('api/public/authenticate', credentials);
};

loginSAML2 = (rememberMe: boolean): Observable<object> => {
    return this.http.post('api/public/saml2', rememberMe.toString());
};

// Apply similar changes to other methods

This change would make the code fully compliant with the arrow function preference specified in the coding guidelines.

src/main/webapp/app/home/saml2-login/saml2-login.component.ts (1)

Line range hint 25-62: Overall structure looks good, with a minor suggestion for improvement.

The unchanged parts of the component, including the ngOnInit and loginSAML2 methods, appear to be functioning correctly. The code adheres to the guidelines for string quotes and includes appropriate error handling and user feedback mechanisms.

For consistency with modern JavaScript/TypeScript practices and to align with the arrow function style guideline, consider refactoring the methods to use arrow function syntax:

ngOnInit = (): void => {
    // ... (existing code)
};

loginSAML2 = () => {
    // ... (existing code)
};

This change would make the code style more consistent throughout the component.

src/main/webapp/app/core/login/login.service.ts (1)

Line range hint 1-16: Overall impact: Positive refactoring with no functional changes.

The changes in this file represent a positive refactoring of the dependency injection mechanism without altering the core functionality of the LoginService. This update aligns the code with modern Angular practices and may offer slight performance improvements. The transition to using the inject function simplifies the code structure and reduces boilerplate, making it easier to maintain in the future.

These changes are low-risk as they don't introduce any new functionality or modify existing behavior. The service methods remain untouched, ensuring that the login, logout, and related processes continue to work as before.

Consider applying this dependency injection pattern consistently across other services in the application for uniformity and to leverage the benefits of this approach throughout the codebase.

src/main/webapp/app/core/auth/user-route-access-service.ts (1)

Line range hint 1-17: Summary: Successful refactoring of dependency injection.

The changes in this file successfully modernize the dependency injection approach by using the inject function from Angular's core library. This refactoring:

  1. Simplifies the code by removing the constructor.
  2. Aligns with current Angular best practices.
  3. Maintains the existing functionality of the UserRouteAccessService.

These modifications contribute to the PR's objective of updating related services to utilize the new injection mechanism. The changes are minimal and focused, reducing the risk of introducing new issues while improving the code's maintainability.

As the team continues to adopt this new injection pattern, consider creating a brief documentation or style guide entry to ensure consistency across the codebase and to help onboard new team members to this approach.

src/test/javascript/spec/service/account.service.spec.ts (1)

Line range hint 1-54: Excellent update to modern Angular testing practices!

The changes to the import statements and TestBed configuration are well-implemented. Moving from HttpClientTestingModule to provideHttpClient and provideHttpClientTesting aligns with current best practices for Angular testing.

The addition of fakeAsync and tick for handling asynchronous operations is a great improvement. It will make the tests more reliable and easier to reason about.

Consider grouping related imports together for better readability. For example:

import { TestBed, fakeAsync, tick } from '@angular/core/testing';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';
import { of } from 'rxjs';
// ... other imports
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 17d1602 and 4ec9328.

📒 Files selected for processing (15)
  • jest.config.js (1 hunks)
  • src/main/webapp/app/app-routing.module.ts (1 hunks)
  • src/main/webapp/app/app.module.ts (0 hunks)
  • src/main/webapp/app/core/auth/account.service.ts (2 hunks)
  • src/main/webapp/app/core/auth/auth-jwt.service.ts (2 hunks)
  • src/main/webapp/app/core/auth/state-storage.service.ts (1 hunks)
  • src/main/webapp/app/core/auth/user-route-access-service.ts (2 hunks)
  • src/main/webapp/app/core/login/login.service.ts (2 hunks)
  • src/main/webapp/app/home/home.component.html (2 hunks)
  • src/main/webapp/app/home/home.component.ts (4 hunks)
  • src/main/webapp/app/home/home.module.ts (0 hunks)
  • src/main/webapp/app/home/home.route.ts (0 hunks)
  • src/main/webapp/app/home/saml2-login/saml2-login.component.ts (1 hunks)
  • src/test/javascript/spec/service/account.service.spec.ts (3 hunks)
  • src/test/javascript/spec/service/state-storage.service.spec.ts (0 hunks)
💤 Files not reviewed due to no reviewable changes (4)
  • src/main/webapp/app/app.module.ts
  • src/main/webapp/app/home/home.module.ts
  • src/main/webapp/app/home/home.route.ts
  • src/test/javascript/spec/service/state-storage.service.spec.ts
🧰 Additional context used
📓 Path-based instructions (10)
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/core/auth/account.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/main/webapp/app/core/auth/auth-jwt.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/main/webapp/app/core/auth/state-storage.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/main/webapp/app/core/auth/user-route-access-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/main/webapp/app/core/login/login.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/main/webapp/app/home/home.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/home/home.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/home/saml2-login/saml2-login.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/service/account.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}}

🔇 Additional comments (25)
src/main/webapp/app/core/auth/state-storage.service.ts (4)

1-1: LGTM: Import statement updated correctly.

The import statement has been appropriately updated to include the inject function from '@angular/core'. This change aligns with the new dependency injection approach used in the class.


5-6: LGTM: Improved dependency injection approach.

The changes to the class improve the dependency injection mechanism:

  1. Removal of the constructor simplifies the class structure.
  2. Use of the inject function for SessionStorageService aligns with modern Angular practices.
  3. The property name sessionStorage correctly follows the camelCase naming convention.

These changes enhance code readability and maintainability.


Line range hint 8-15: LGTM: Simplified class with clear URL storage functionality.

The StateStorageService has been effectively simplified:

  1. Focus on storing and retrieving the 'previousUrl'.
  2. Proper use of camelCase for method names.
  3. Clear and concise JSDoc comment for storeUrl.
  4. Correct use of single quotes for strings.

These changes align well with the PR objectives and coding guidelines.


Line range hint 1-22: Summary: Effective simplification aligning with PR objectives.

The changes to StateStorageService effectively contribute to the PR's goal of improving login page functionality:

  1. Simplified class structure focusing on URL storage.
  2. Improved dependency injection using the inject function.
  3. Removal of unused state management methods.
  4. Adherence to coding guidelines (naming conventions, string quotes, etc.).

These changes should result in a more maintainable and focused component. The only suggested improvement is to add a JSDoc comment for the getUrl method to maintain consistent documentation.

src/main/webapp/app/core/auth/auth-jwt.service.ts (1)

1-1: LGTM: Import statement updated correctly

The import statement has been appropriately updated to include the inject function from '@angular/core'. This change is necessary for the new dependency injection method and aligns with the Angular style guide.

src/main/webapp/app/home/saml2-login/saml2-login.component.ts (3)

1-1: Excellent migration to standalone component format!

The changes in imports and component decorator effectively migrate the component to a standalone format, which aligns with the PR objectives. The use of the inject function and importing ArtemisSharedModule demonstrate good practices in modern Angular development and adherence to code reuse guidelines.

Also applies to: 7-7, 13-14


21-23: Clean and concise input property declarations!

The direct declaration of input properties in the class body is a clean and modern approach. It simplifies the component by eliminating the need for constructor initialization. The naming conventions and type specifications are correctly followed, adhering to TypeScript best practices.


Line range hint 1-62: Summary: Excellent migration to standalone component with modern practices!

This review has covered all the changes made to the Saml2LoginComponent. The migration to a standalone component format, the use of modern dependency injection techniques, and the overall code structure are all commendable. The changes align well with the PR objectives and adhere to the provided coding guidelines.

A few minor suggestions have been made for further improvements:

  1. Adding readonly to the injected services for added safety.
  2. Considering the use of arrow function syntax for class methods for consistency.

These suggestions are optional and do not impact the overall quality of the changes. The PR appears ready for merging, pending any additional reviews or manual tests as specified in the PR objectives.

src/main/webapp/app/core/login/login.service.ts (1)

1-1: LGTM: Import statement updated correctly.

The import statement has been appropriately updated to include the inject function from '@angular/core'. This change is necessary for the new dependency injection method and aligns with Angular's latest practices.

jest.config.js (2)

105-108: Summary of changes to jest.config.js

The only changes in this file are slight decreases to the coverage thresholds for statements and lines. While these changes are minor, they don't align with the PR objectives of improving tab navigation or migrating components.

To ensure these changes don't negatively impact the project's overall quality:

  1. Could you clarify if these threshold adjustments are intentional or if they're a side effect of other changes?
  2. If intentional, what's the rationale behind lowering the thresholds?
  3. How do these changes relate to the PR's main objectives?

It's important to maintain high test coverage to ensure the reliability and maintainability of the codebase, especially when making UI and architectural changes as described in the PR objectives.


105-108: Question: Why are we decreasing the coverage thresholds?

I noticed that the coverage thresholds for statements and lines have been slightly decreased:

  • statements: 87.38 -> 87.35
  • lines: 87.44 -> 87.41

This change seems to go against the TODO comment above, which suggests increasing these values to at least 90% in the future.

Could you please explain the reasoning behind this decrease? Given the project's goal to improve code quality, it might be beneficial to maintain or even increase these thresholds instead of lowering them. This would ensure that we're moving towards better test coverage over time.

To verify the impact of these changes, we can run the following script:

This script will help us understand if the current test coverage meets the new thresholds and if the decrease is necessary.

src/main/webapp/app/core/auth/user-route-access-service.ts (1)

1-1: LGTM: Import statement updated correctly.

The import statement has been appropriately updated to include inject and isDevMode from '@angular/core'. This change aligns with the refactoring of dependency injection and maintains consistency with the existing code usage.

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

17-20: LGTM! Verify impact on application routing.

The addition of a lazy-loaded root route for the HomeComponent is a good practice and aligns with the project's coding guidelines. Here are a few points to consider:

  1. Ensure that any previous root route has been properly removed to avoid conflicts.
  2. Test the initial load behavior of the application to confirm it loads the HomeComponent as expected.
  3. Verify that the HomeComponent exists at the path ./home/home.component.

To verify the HomeComponent exists and there are no conflicting routes, run the following script:

src/main/webapp/app/home/home.component.html (4)

48-50: Improved error message display logic for username.

The addition of the usernameTouched check prevents premature error messages, enhancing the user experience. This change aligns well with the PR objective of improving validation processes.


74-76: Improved error message display logic for password.

The addition of the passwordTouched check prevents premature error messages, enhancing the user experience. This change aligns well with the PR objective of improving validation processes.


96-101: Improved login button validation and accessibility.

The changes simplify the form validation logic and improve keyboard navigation. The use of isFormValid in the disabled condition provides a more robust validation check, and the addition of tabindex="3" ensures a logical tab order in the form.


Line range hint 1-170: Correct usage of new Angular syntax.

The template consistently uses @if directives instead of *ngIf, which aligns with the provided coding guidelines. This adoption of the new Angular syntax improves code readability and maintainability.

src/main/webapp/app/core/auth/account.service.ts (3)

1-1: LGTM: Import of inject function

The addition of the inject import from '@angular/core' is appropriate for the transition to the new dependency injection method. This change aligns with modern Angular practices and simplifies the service's constructor.


Line range hint 1-42: Summary: Successful transition to new dependency injection method

The changes in this file successfully implement the transition from constructor-based dependency injection to using the inject function. This update aligns with the PR objectives of updating related services to utilize the new injection mechanism. Key points:

  1. The overall functionality of the AccountService remains unchanged.
  2. The new approach simplifies the class structure and reduces boilerplate code.
  3. The change is consistent with modern Angular practices.

These modifications contribute to improved code maintainability without introducing breaking changes to the service's functionality.


38-42: LGTM: Transition to new dependency injection method

The change from constructor-based dependency injection to using the inject function is a positive improvement. This approach simplifies the class structure and aligns with modern Angular practices. The dependencies are correctly injected and assigned to private class properties.

To ensure all previously injected dependencies are still included, let's run the following script:

✅ Verification successful

Dependency injection verification successful

All previously injected dependencies are correctly implemented using the inject function. No missing dependencies were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all previously injected dependencies are still included in the new injection method.

# Test: Search for the old constructor and compare with new inject statements
echo "Old constructor dependencies:"
rg "constructor\(" src/main/webapp/app/core/auth/account.service.ts -A 10
echo "\nNew inject statements:"
rg "private \w+ = inject\(" src/main/webapp/app/core/auth/account.service.ts

Length of output: 563

src/test/javascript/spec/service/account.service.spec.ts (1)

54-63: Well-structured test setup and teardown!

The changes in the beforeEach and afterEach blocks are well-implemented:

  1. Using TestBed.inject for service injection is the correct approach in Angular tests.
  2. Initializing httpMock with TestBed.inject(HttpTestingController) is appropriate for HTTP request mocking.
  3. Adding httpMock.verify() in the afterEach block is an excellent practice to ensure all expected HTTP requests were made during each test.

These changes contribute to more robust and reliable tests.

src/main/webapp/app/home/home.component.ts (4)

1-1: Imports updated appropriately

The import statements have been updated to include necessary modules and components. The code changes are appropriate.

Also applies to: 3-3, 14-14


47-47: Assignment of USERNAME_MAX_LENGTH

Assigning imported constants to class properties for use within the component is appropriate.


74-74: Initialization of isFormValid and isSubmittingLogin

The addition of these properties aids in form validation and submission handling. The code changes are appropriate.


81-82: Ensure usernameTouched and passwordTouched are utilized

You have added the properties usernameTouched and passwordTouched, but it's unclear from the provided code how they are utilized. Ensure that these properties are being used appropriately to track the touched state of the input fields.

Please verify that usernameTouched and passwordTouched are bound to the template and updated accordingly.

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.

1 participant