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

Communication: Add FAQ search bar #9423

Merged
merged 13 commits into from
Oct 12, 2024

Conversation

cremertim
Copy link
Contributor

@cremertim cremertim commented Oct 4, 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.
  • I added multiple screenshots/screencasts of my UI changes.

Motivation and Context

I as a student want to be able to search for desired FAQ's based on the text of the FAQ

Description

Added a search bar to the Course Overview so a student can search via Text for the FAQ

Steps for Testing

Prerequisites:

  • 1 Student
  • 1 Course with active FAQ
  1. Log in to Artemis
  2. Navigate to Course Overview
  3. Go to FAQ section
  4. See search bar and input a searchText
  5. Verifiy it only shows the FAQ's with ALL inputs tokens of the user
  6. Filter for category
  7. Verify only FAQ with category and search are displayed

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

Exam Mode Test

  • Test 1
  • Test 2

Performance Tests

  • Test 1
  • Test 2

Test Coverage

Class/File Line Coverage Confirmation (assert/expect)
faq-service.ts 98.3%
course-faq.component.ts 98.14%
faq.component.ts 95.83%

Screenshots

image

Discussion:

Please give me feedback in the comments how you would expect the search functionalities to work:
a) Atleast 1 search token is contained within the FAQ
b) Every search token is contained within the FAQ

a) Search is performed on already filtered FAQ's (based on categories)
b) Search is performed on all FAQ's -> would remove filtering of the FAQ's

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Introduced a new search functionality within the course FAQ component.
    • Added a reusable SearchFilterComponent for handling search inputs.
  • Improvements
    • Enhanced layout using Bootstrap classes for better responsiveness and spacing.
    • Simplified component state management for improved performance.
    • Improved search operations with dynamic input handling.
  • Style
    • Updated layout for filter dropdowns to ensure consistent alignment with new search components.

@cremertim cremertim requested a review from a team as a code owner October 4, 2024 12:07
Copy link

coderabbitai bot commented Oct 4, 2024

Walkthrough

The changes in this pull request involve updates to the course-faq component, enhancing its search functionality and layout. The HTML structure of course-faq.component.html has been modified to utilize Bootstrap utility classes and to include a new <jhi-search-filter> component. The TypeScript file course-faq.component.ts has been updated to manage a new searchInput property and related methods for handling search operations. Additionally, the SearchFilterComponent has been restructured as a standalone component, and the FaqService has been enhanced with a new method for searching FAQs.

Changes

File Change Summary
src/main/webapp/app/overview/course-faq/course-faq.component.html Updated layout with Bootstrap classes, added <jhi-search-filter> component for search functionality.
src/main/webapp/app/overview/course-faq/course-faq.component.ts Added searchInput property, removed sidebarData, added setSearchValue, refreshFaqList, and applySearch methods.
src/main/webapp/app/faq/faq.component.html Updated layout with Bootstrap classes, added <jhi-search-filter> component for search functionality.
src/main/webapp/app/faq/faq.component.ts Added searchInput property, added setSearchValue, refreshFaqList, and applySearch methods.
src/main/webapp/app/shared/search-filter/search-filter.component.ts Updated to be a standalone component with ArtemisSharedModule as a dependency.
src/main/webapp/app/shared/shared.module.ts Removed SearchFilterComponent from declarations and exports arrays.
src/main/webapp/app/shared/sidebar/sidebar.module.ts Added import for SearchFilterComponent in ArtemisSidebarModule.
src/main/webapp/app/faq/faq.service.ts Added hasSearchTokens(faq: Faq, searchTerm: string) method for search token checking.
src/test/javascript/spec/component/course/course-exercises.component.spec.ts Updated to mock SearchFilterComponent in tests.
src/test/javascript/spec/component/exam/participate/exam-navigation-sidebar.component.spec.ts Added mock for SearchFilterComponent in tests.
src/test/javascript/spec/component/overview/course-faq/course-faq.component.spec.ts Updated tests to include SearchFilterComponent and enhanced search functionality tests.
src/test/javascript/spec/component/shared/sidebar/sidebar-accordion.component.spec.ts Added mock for SearchFilterComponent in tests.
src/test/javascript/spec/component/tutorial-groups/course-tutorial-groups/course-tutorial-groups.component.spec.ts Updated to mock SearchFilterComponent in tests.
src/test/javascript/spec/service/faq.service.spec.ts Added test for hasSearchTokens method in FaqService.

Possibly related PRs

Suggested labels

feature, ready for review, component:Communication, small, bugfix

Suggested reviewers

  • JohannesStoehr
  • SimonEntholzer
  • pzdr7
  • farisd16
  • edkaya
  • N0W0RK

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 the client Pull requests that update TypeScript code. (Added Automatically!) label Oct 4, 2024
@cremertim cremertim changed the title 'Communicaiton' Implement FAQ search bar Communicaiton Implement FAQ search bar Oct 4, 2024
Copy link

github-actions bot commented Oct 4, 2024

⚠️ Unable to deploy to test servers ⚠️

The docker build needs to run through before deploying.

@github-actions github-actions bot added the deployment-error Added by deployment workflows if an error occured label Oct 4, 2024
@cremertim cremertim removed the deployment-error Added by deployment workflows if an error occured label Oct 4, 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: 9

🧹 Outside diff range comments (1)
src/main/webapp/app/overview/course-faq/course-faq.component.ts (1)

Line range hint 1-99: Overall implementation of search feature is on track, but needs completion.

The changes made to the CourseFaqComponent are well-structured and align with the PR objectives of implementing a search bar for the FAQ section. The component now includes the necessary imports, properties, and methods to support search functionality. However, the actual filtering of FAQs based on the search value is not yet implemented.

To complete the feature, consider updating the applyFilters method or creating a new method to filter the FAQs based on the searchValue. This will ensure that the FAQ list updates dynamically as the user types in the search bar, providing a responsive and user-friendly search experience.

Additionally, ensure that the search functionality is thoroughly tested, including edge cases and performance considerations, as outlined in the PR objectives.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 21753bc and 93c1d71.

📒 Files selected for processing (5)
  • src/main/webapp/app/overview/course-faq/course-faq.component.html (1 hunks)
  • src/main/webapp/app/overview/course-faq/course-faq.component.ts (3 hunks)
  • src/main/webapp/app/shared/search/search.component.html (1 hunks)
  • src/main/webapp/app/shared/search/search.component.scss (1 hunks)
  • src/main/webapp/app/shared/search/search.component.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
src/main/webapp/app/overview/course-faq/course-faq.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/overview/course-faq/course-faq.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/shared/search/search.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/shared/search/search.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 (10)
src/main/webapp/app/shared/search/search.component.scss (1)

1-4: 🛠️ Refactor suggestion

Consider refactoring the .mn-icon-field class for better maintainability and responsiveness.

While the class achieves its immediate goal, there are a few concerns:

  1. The use of !important is generally discouraged as it can lead to specificity issues and make future style overrides difficult. Consider refactoring the CSS to avoid using !important.

  2. The fixed negative margin (-3.5rem) might not be responsive across different screen sizes. Consider using relative units or a more flexible positioning approach.

  3. The z-index value of 10 is arbitrary and could potentially conflict with other elements. It's recommended to establish a z-index scale for the entire application to ensure consistent stacking behavior.

Here's a suggestion for improvement:

.mn-icon-field {
  position: relative;
  display: inline-flex;
  align-items: center;

  &::before {
    content: '\1F50D'; // Unicode for a magnifying glass icon
    position: absolute;
    left: 0.5rem;
    pointer-events: none;
  }

  input {
    padding-left: 2rem; // Adjust based on your icon size
  }
}

This approach uses relative positioning and a pseudo-element for the icon, which is more flexible and doesn't rely on negative margins or !important. Adjust the values as needed to fit your specific design requirements.

To ensure this change doesn't affect other parts of the application, please run the following command:

This will help identify any other places where the class is used, allowing you to assess the impact of these changes.

✅ Verification successful

Verified usage of .mn-icon-field across multiple components.

The .mn-icon-field class is utilized in the following locations:

  • src/main/webapp/app/shared/search/search.component.scss
  • src/main/webapp/app/shared/search/search.component.html
  • src/main/webapp/app/shared/search-filter/search-filter.component.scss
  • src/main/webapp/app/shared/search-filter/search-filter.component.html

Please ensure that any refactoring of this class accounts for all its usages to maintain consistency and prevent unintended styling issues.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other occurrences of mn-icon-field class
rg --type html --type typescript 'mn-icon-field'

Length of output: 83


Script:

#!/bin/bash
# Attempting to search for 'mn-icon-field' in HTML and TypeScript files using correct type specifiers
rg 'mn-icon-field' --type html --type ts --type tsx

Length of output: 79


Script:

#!/bin/bash
# Searching for 'mn-icon-field' in all files without specifying file types
rg 'mn-icon-field'

Length of output: 428

src/main/webapp/app/shared/search/search.component.html (2)

1-2: LGTM: Proper use of Angular reactive forms and Bootstrap classes.

The form structure is well-defined using Angular's reactive forms, which is a good practice for managing form state and validation. The use of Bootstrap classes for styling is also appropriate.


1-19: Summary: Well-implemented search component aligning with PR objectives.

The implemented search bar for the FAQ section is well-structured, using Angular best practices and reactive forms. It includes accessibility features and internationalization support, which aligns with the comprehensive approach outlined in the PR objectives.

A few minor suggestions were made to further enhance accessibility:

  1. Adding a visually hidden label for the search input.
  2. Including an aria-label for the search button.

These small improvements will make the search feature more inclusive without affecting the visual design.

The component appears ready for integration testing and performance review as per the PR checklist. Great job on implementing this feature!

src/main/webapp/app/shared/search/search.component.ts (2)

6-12: LGTM: Component decorator follows best practices

The component decorator is well-structured and follows Angular's style guide. The use of a standalone component with explicit imports enhances modularity and maintainability.


1-31: Overall assessment: Good component structure with minor improvements needed

The SearchComponent is well-structured and follows many Angular best practices. It's a standalone component with clear separation of concerns. However, there are a few minor improvements needed:

  1. Correct the import of the Output decorator.
  2. Add proper type annotations and use the @output() decorator for the event emitter.
  3. Update the form control in the setSearchValue method to keep view and model in sync.
  4. Add access modifiers to methods for consistency.

After addressing these points, the component will be more robust and maintainable.

src/main/webapp/app/overview/course-faq/course-faq.component.html (2)

2-2: Improved layout using Bootstrap utility classes

The change from inline styles to Bootstrap utility classes (d-flex justify-content-between) is a good practice. It enhances maintainability and consistency with the Bootstrap design system while providing a flexible container for the new search feature.


Line range hint 9-24: Correct usage of new Angular syntax

The template correctly uses the new @if and @for directives instead of *ngIf and *ngFor, adhering to the provided coding guidelines. This adoption of the latest Angular syntax is commendable.

src/main/webapp/app/overview/course-faq/course-faq.component.ts (3)

18-18: LGTM: SearchComponent import added.

The import of SearchComponent aligns with the PR objective of implementing a search bar for the FAQ section. It follows the Angular style guide for imports.


26-26: LGTM: SearchComponent added to imports array.

The addition of SearchComponent to the imports array is consistent with its usage in the component and follows Angular's best practices for component configuration.


42-43: LGTM: searchValue property added.

The searchValue property is correctly named using camelCase and initialized as an empty string, following good practices for search input fields. This addition aligns with the PR objective of implementing a search feature for the FAQ section.

src/main/webapp/app/shared/search/search.component.html Outdated Show resolved Hide resolved
src/main/webapp/app/shared/search/search.component.html Outdated Show resolved Hide resolved
src/main/webapp/app/shared/search/search.component.ts Outdated Show resolved Hide resolved
src/main/webapp/app/shared/search/search.component.ts Outdated Show resolved Hide resolved
src/main/webapp/app/shared/search/search.component.ts Outdated Show resolved Hide resolved
src/main/webapp/app/shared/search/search.component.ts Outdated Show resolved Hide resolved
@cremertim cremertim temporarily deployed to artemis-test2.artemis.cit.tum.de October 4, 2024 12:37 — with GitHub Actions Inactive
@cremertim cremertim changed the title Communicaiton Implement FAQ search bar Communicaition Implement FAQ search bar Oct 4, 2024
@cremertim cremertim changed the title Communicaition Implement FAQ search bar Communication Implement FAQ search bar Oct 4, 2024
@cremertim cremertim temporarily deployed to artemis-test2.artemis.cit.tum.de October 4, 2024 13:02 — with GitHub Actions Inactive
@github-actions github-actions bot added the tests label Oct 7, 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: 7

🧹 Outside diff range comments (1)
src/main/webapp/app/overview/course-faq/course-faq.component.html (1)

Line range hint 9-29: Update Angular structural directives for consistency

The file uses a mix of new (@if, @for) and old (*ngIf, *ngFor) Angular syntax. According to the coding guidelines, @if and @for should always be used over the old style. Please update the remaining instances of *ngIf and *ngFor to use the new syntax.

For example, update:

<ul ngbDropdownMenu class="checkbox-menu text-nowrap pe-2" aria-labelledby="filter-dropdown-button">
    @for (category of existingCategories; track category) {
        <li>
            <label class="d-flex align-items-center">
                <input
                    id="filter-{{ category.category }}"
                    class="ms-2 form-check-input"
                    (change)="toggleFilters(category.category!)"
                    [checked]="activeFilters.has(category.category!)"
                    type="checkbox"
                />
                <jhi-custom-exercise-category-badge [category]="category" class="mt-2 ms-1" />
            </label>
        </li>
    }
</ul>

to:

@if (hasCategories) {
    <ul ngbDropdownMenu class="checkbox-menu text-nowrap pe-2" aria-labelledby="filter-dropdown-button">
        @for (category of existingCategories; track category) {
            <li>
                <label class="d-flex align-items-center">
                    <input
                        id="filter-{{ category.category }}"
                        class="ms-2 form-check-input"
                        (change)="toggleFilters(category.category!)"
                        [checked]="activeFilters.has(category.category!)"
                        type="checkbox"
                    />
                    <jhi-custom-exercise-category-badge [category]="category" class="mt-2 ms-1" />
                </label>
            </li>
        }
    </ul>
}

This change will ensure consistency throughout the file and adherence to the coding guidelines.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 93c1d71 and fb1ad44.

📒 Files selected for processing (6)
  • src/main/webapp/app/faq/faq.service.ts (1 hunks)
  • src/main/webapp/app/overview/course-faq/course-faq.component.html (1 hunks)
  • src/main/webapp/app/overview/course-faq/course-faq.component.ts (5 hunks)
  • src/main/webapp/app/shared/search-filter/search-filter.component.ts (1 hunks)
  • src/main/webapp/app/shared/shared.module.ts (0 hunks)
  • src/main/webapp/app/shared/sidebar/sidebar.module.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • src/main/webapp/app/shared/shared.module.ts
🧰 Additional context used
📓 Path-based instructions (5)
src/main/webapp/app/faq/faq.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/overview/course-faq/course-faq.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/overview/course-faq/course-faq.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/shared/search-filter/search-filter.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/shared/sidebar/sidebar.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

🪛 Biome
src/main/webapp/app/faq/faq.service.ts

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

Unsafe fix: Use a template literal.

(lint/style/useTemplate)

🔇 Additional comments (12)
src/main/webapp/app/shared/search-filter/search-filter.component.ts (2)

4-4: LGTM: Import of ArtemisSharedModule

The import of ArtemisSharedModule is a good practice for code reuse and modularity. It aligns with the coding guidelines for promoting code reuse.


Line range hint 1-33: Overall assessment: Changes align with PR objectives and coding guidelines

The modifications to make SearchFilterComponent standalone and import ArtemisSharedModule align well with the PR objectives of implementing a FAQ search bar. These changes enhance modularity and reusability, which can contribute to better performance and maintainability of the search functionality.

The existing code adheres to the project's coding guidelines, including naming conventions, string quotes, and TypeScript best practices. The component's functionality for handling search events is preserved, supporting the PR's goal of adding search capabilities to the FAQ section.

To ensure these changes don't introduce any unintended side effects, please run the following verification script:

This script will help identify any potential issues related to the component's new standalone nature and its relationship with ArtemisSharedModule.

✅ Verification successful

Overall assessment: Changes align with PR objectives and coding guidelines

The verification confirms that SearchFilterComponent is appropriately utilized across the codebase and that making it standalone does not introduce any issues. ArtemisSharedModule is correctly exported, and there are no problematic circular dependencies detected. These changes enhance modularity and maintain the integrity of the search functionality as intended by the PR objectives.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of making SearchFilterComponent standalone

# Test 1: Check for any remaining non-standalone usage of SearchFilterComponent
echo "Checking for non-standalone usage of SearchFilterComponent:"
rg --type typescript "SearchFilterComponent" -g "!**/search-filter.component.ts"

# Test 2: Verify ArtemisSharedModule exports
echo "Verifying ArtemisSharedModule exports:"
rg --type typescript "export class ArtemisSharedModule" -A 10 -g "**/shared.module.ts"

# Test 3: Check for any circular dependencies
echo "Checking for potential circular dependencies:"
rg --type typescript "import.*from.*search-filter" -g "!**/search-filter.component.ts"

Length of output: 680


Script:

#!/bin/bash
# Description: Re-verify the impact of making SearchFilterComponent standalone with corrected file patterns

# Test 1: Check for any remaining non-standalone usage of SearchFilterComponent
echo "Checking for non-standalone usage of SearchFilterComponent:"
rg "SearchFilterComponent" -g "!**/search-filter.component.ts" -g "*.ts" -g "*.tsx"

# Test 2: Verify ArtemisSharedModule exports
echo "Verifying ArtemisSharedModule exports:"
rg "export class ArtemisSharedModule" -A 10 -g "**/shared.module.ts" -g "*.ts" -g "*.tsx"

# Test 3: Check for any circular dependencies
echo "Checking for potential circular dependencies:"
rg "import.*from.*search-filter" -g "!**/search-filter.component.ts" -g "*.ts" -g "*.tsx"

Length of output: 7036

src/main/webapp/app/overview/course-faq/course-faq.component.html (1)

2-2: Improved layout with Bootstrap utility classes

The use of Bootstrap utility classes d-flex justify-content-between for layout management is a good practice. It improves the responsiveness and maintainability of the component.

src/main/webapp/app/shared/sidebar/sidebar.module.ts (2)

19-19: LGTM: Import statement is correct.

The import statement for SearchFilterComponent follows the coding guidelines and is correctly placed at the end of the import list.


32-32: Verify standalone component setup and consider using importProvidersFrom.

The addition of SearchFilterComponent to the imports array is correct for using standalone components in NgModules. However, to improve code organization and take full advantage of standalone components, consider the following:

  1. Verify that SearchFilterComponent is indeed set up as a standalone component in its definition file.
  2. If you're using Angular 14 or later, consider using importProvidersFrom for a more explicit import of standalone components:
import { importProvidersFrom } from '@angular/core';

@NgModule({
  imports: [
    // ... other imports
    importProvidersFrom(SearchFilterComponent),
  ],
  // ... rest of the module definition
})
export class ArtemisSidebarModule {}

This approach can help with better tree-shaking and make the intent of importing a standalone component more clear.

To verify the standalone component setup, please run the following script:

✅ Verification successful

Standalone Component Verification Successful

The SearchFilterComponent is correctly set up as a standalone component.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify SearchFilterComponent is set up as a standalone component

# Test: Check if SearchFilterComponent is decorated with standalone: true
ast-grep --lang typescript --pattern 'class SearchFilterComponent {
  $$$
}

@Component({
  $$$
  standalone: true,
  $$$
})' app/shared/search-filter/search-filter.component.ts

# If the above command doesn't return a match, the component might not be set up as standalone

Length of output: 688


Script:

#!/bin/bash
# Description: Verify SearchFilterComponent is set up as a standalone component

# Test: Check if SearchFilterComponent's @Component decorator includes standalone: true
ast-grep --lang typescript --pattern '@Component({ $$$ standalone: true, $$$ })' app/shared/search-filter/search-filter.component.ts

Length of output: 233


Script:

#!/bin/bash
# Description: Locate SearchFilterComponent and verify it is set up as a standalone component

# Step 1: Find all files named search-filter.component.ts
search_files=$(fd --extension ts --basename 'search-filter.component.ts')

if [ -z "$search_files" ]; then
  echo "No files named search-filter.component.ts found in the repository."
  exit 1
fi

# Step 2: Check each found file for standalone: true in the @Component decorator
for file in $search_files; do
  echo "Checking $file for standalone: true..."
  result=$(ast-grep --lang typescript --pattern '@Component({ $$$ standalone: true, $$$ })' "$file")
  if [ -n "$result" ]; then
    echo "$file is a standalone component."
  else
    echo "$file is NOT set up as a standalone component."
  fi
done

Length of output: 505


Script:

#!/bin/bash
# Description: Locate SearchFilterComponent and verify it is set up as a standalone component

# Step 1: Find all files named search-filter.component.ts
search_files=$(fd --extension ts --base-name 'search-filter.component.ts')

if [ -z "$search_files" ]; then
  echo "No files named search-filter.component.ts found in the repository."
  exit 1
fi

# Step 2: Check each found file for standalone: true in the @Component decorator
for file in $search_files; do
  echo "Checking $file for standalone: true..."
  result=$(ast-grep --lang typescript --pattern '@Component({ $$$ standalone: true, $$$ })' "$file")
  if [ -n "$result" ]; then
    echo "$file is a standalone component."
  else
    echo "$file is NOT set up as a standalone component."
  fi
done

Length of output: 477


Script:

#!/bin/bash
# Description: Locate SearchFilterComponent and verify it is set up as a standalone component

# Step 1: Find all files named search-filter.component.ts using rg
search_files=$(rg --files --glob 'search-filter.component.ts')

if [ -z "$search_files" ]; then
  echo "No files named search-filter.component.ts found in the repository."
  exit 1
fi

# Step 2: Check each found file for standalone: true in the @Component decorator
for file in $search_files; do
  echo "Checking $file for standalone: true..."
  result=$(ast-grep --lang typescript --pattern '@Component({ $$$ standalone: true, $$$ })' "$file")
  if [ -n "$result" ]; then
    echo "$file is a standalone component."
  else
    echo "$file is NOT set up as a standalone component."
  fi
done

Length of output: 2275

src/main/webapp/app/overview/course-faq/course-faq.component.ts (7)

3-4: LGTM!

The added imports for debounceTime, map, BehaviorSubject, Subject, and Subscription are appropriate and correctly utilized in the component.


18-18: LGTM!

The import of SearchFilterComponent is correctly added to support the new search functionality.


26-26: LGTM!

Including SearchFilterComponent in the imports array ensures it is available within the component. This is correctly implemented.


42-42: LGTM!

Initializing searchInput as a BehaviorSubject to manage search queries is appropriate and follows best practices.


93-93: LGTM!

Using defineSearchedAndFilteredFaq with the current search value ensures that both filters and search queries are applied consistently when toggling filters.


100-104: LGTM!

The applySearch method correctly filters the FAQs based on the search term, utilizing the hasSearchTokens method from the FaqService.


106-108: LGTM!

The setSearchValue method appropriately updates the searchInput BehaviorSubject, effectively handling new search inputs.

ole-ve
ole-ve previously approved these changes Oct 11, 2024
Copy link
Contributor

@ole-ve ole-ve left a comment

Choose a reason for hiding this comment

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

code looks good

ole-ve
ole-ve previously approved these changes Oct 11, 2024
JohannesStoehr
JohannesStoehr previously approved these changes Oct 11, 2024
Copy link
Contributor

@JohannesStoehr JohannesStoehr left a comment

Choose a reason for hiding this comment

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

Reapprove after merge

PaRangger
PaRangger previously approved these changes Oct 11, 2024
SimonEntholzer
SimonEntholzer previously approved these changes Oct 12, 2024
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.

Reapprove

# Conflicts:
#	src/test/javascript/spec/component/exam/participate/exam-navigation-sidebar.component.spec.ts
@krusche krusche added this to the 7.6.0 milestone Oct 12, 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: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 362c798 and 89236a5.

📒 Files selected for processing (1)
  • src/test/javascript/spec/component/exam/participate/exam-navigation-sidebar.component.spec.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/test/javascript/spec/component/exam/participate/exam-navigation-sidebar.component.spec.ts (1)

Pattern src/test/javascript/spec/**/*.ts: jest: true; mock: NgMocks; bad_practices: avoid_full_module_import; perf_improvements: mock_irrelevant_deps; service_testing: mock_http_for_logic; no_schema: avoid_NO_ERRORS_SCHEMA; expectation_specificity: true; solutions: {boolean: toBeTrue/False, reference: toBe, existence: toBeNull/NotNull, undefined: toBeUndefined, class_obj: toContainEntries/toEqual, spy_calls: {not_called: not.toHaveBeenCalled, once: toHaveBeenCalledOnce, with_value: toHaveBeenCalledWith|toHaveBeenCalledExactlyOnceWith}}

🔇 Additional comments (3)
src/test/javascript/spec/component/exam/participate/exam-navigation-sidebar.component.spec.ts (3)

24-24: LGTM: Import statement for SearchFilterComponent.

The import statement for SearchFilterComponent is correctly placed and follows the project's import conventions. This import is necessary for mocking the component in the test module.


39-39: LGTM: Addition of MockComponent(SearchFilterComponent) to declarations.

The MockComponent(SearchFilterComponent) is correctly added to the declarations array, consistent with the mocking strategy used for other components. This allows the SearchFilterComponent to be used in the tests without its actual implementation, which is appropriate for unit testing the ExamNavigationSidebarComponent.


Line range hint 24-39: Overall assessment: Changes look good, with a minor suggestion.

The changes to this test file are minimal and well-implemented. The import and declaration of the mocked SearchFilterComponent are correctly done and consistent with the existing code style. The existing tests remain unchanged, which is appropriate. Consider adding tests for any new interactions with SearchFilterComponent if applicable to ensure comprehensive test coverage.

Copy link
Contributor

@JohannesStoehr JohannesStoehr left a comment

Choose a reason for hiding this comment

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

Reapprove after merge

@krusche krusche merged commit f977aca into develop Oct 12, 2024
20 of 25 checks passed
@krusche krusche deleted the feature/communication/implement-faq-search branch October 12, 2024 11:27
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 to merge tests
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

7 participants