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: Replace tab bar with a side navigation bar in the students view #8083

Merged
merged 7 commits into from
Mar 20, 2024

Conversation

rabeatwork
Copy link
Contributor

@rabeatwork rabeatwork commented Feb 26, 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.
  • 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.

Motivation and Context

This Pull Request marks the first of many steps toward the new design of Artemis

Description

The tabbar in the students overview was removed and a new navigation-sidebar was added.

Steps for Testing

Prerequisites:

  • 1 Student
  1. Log in to Artemis
  2. Navigate to Course Overview
  3. Select a Course
  4. Correct Navigation Items should be displayed (e.g. Tutorials only if they are enabled)
  5. Navigate through the different navigation items

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked







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
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Test Coverage

Client

Class/File Line Coverage Confirmation (assert/expect)
course-exercise-overview-tour.ts 100%
course-overview.component.ts 92.89%
course-statistics.component.ts 96.26%

Screenshots

image image

Summary by CodeRabbit

  • New Features

    • Introduced a new sidebar navigation structure in course overview, replacing the tab-based layout for improved user experience.
    • Added new icons and animations for the sidebar.
    • Implemented conditional display logic for course exams and exercises sections based on data length.
  • Enhancements

    • Updated layout and structure of course exam details for better content alignment.
    • Adjusted CSS classes for alignment and presentation across various components.
    • Enhanced guided tour by updating the element highlight selector.
    • Modified the footer to have a fixed position with an updated z-index.
  • Style Updates

    • Introduced styling rules for the new course overview component, including sidebar layout and visual elements for a course management interface.
    • Adjusted global styling properties and theme-specific variables for consistency and visual coherence.
  • Refactor

    • Updated template syntax and structure in course statistics component.
    • Modified routing module to reflect accurate page titles for course-related sections.
    • Simplified references within conditional blocks in the header course component.
    • Enhanced code quality with optional chaining in various components and directives.
  • Tests

    • Added new test cases and necessary imports for testing the creation of sidebar items and exercise list controls in course overview.

@rabeatwork rabeatwork requested a review from a team as a code owner February 26, 2024 18:00
Copy link

coderabbitai bot commented Feb 26, 2024

Walkthrough

The recent updates focus on enhancing user experience and interface design across various components of a web application. Key changes include the transition from a tab-based to a sidebar navigation layout in course overview, adjustments in display logic and styling across course-related components, and updates to routing titles. Additionally, improvements are made in the styling of global elements and theme consistency. These changes aim to provide a more intuitive and cohesive user interface.

Changes

File(s) Change Summary
.../app/guided-tour/tours/course-exercise-overview-tour.ts Updated highlightSelector for better element highlighting in tour steps.
.../course-exam-detail.component.html, .../course-exams.component.html Adjusted layout and display conditions for exam details and sections.
.../course-exercises.component.html, .../course-lectures.component.html Improved alignment and justification within elements.
.../course-overview.component.html, .../course-overview.component.scss, .../course-overview.component.ts Transitioned to a sidebar navigation layout, added new icons, and introduced styling for the course overview component.
.../course-statistics.component.html, .../course-statistics.component.ts Updated template syntax and adjusted chart tooltip content; improved unsubscribes and data handling in TypeScript.
courses-routing.module.ts, .../header-course.component.html Updated page titles for routes and simplified variable references.
.../feature-toggle-hide.directive.ts Made feature input property optional and used optional chaining in ngOnDestroy.
.../footer/footer.scss, .../main/main.component.html, .../profiles/page-ribbon.scss Updated positioning and styling for footer, main component, and development ribbon.
.../shared-libs.module.ts Added MatSidenavModule and MatToolbarModule to exports.
global.scss, .../_dark-variables.scss, .../_default-variables.scss Adjusted styling properties for global elements and added new theme variables.
.../course/course-overview.component.spec.ts, .../course/course-overview-exercise-list-controls.integration.spec.ts Added imports for testing modules and a new test case for sidebar items creation.

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>.
    • Generate unit-tests 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 tests 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@artemis-bot artemis-bot added this to In progress in Artemis Development Feb 26, 2024
@github-actions github-actions bot added tests client Pull requests that update TypeScript code. (Added Automatically!) labels Feb 26, 2024
Comment on lines 1 to 5
<ng-template #controls>
<div class="d-flex row course-overview-controls justify-content-end">
<div class="d-flex row course-overview-controls text-end">
<div class="col" aria-label="Filter Dropdown" ngbDropdown>
<button class="btn" [class.btn-secondary]="!numberOfAppliedFilters" [class.btn-success]="!!numberOfAppliedFilters" ngbDropdownToggle id="filter-dropdown-button">
<fa-icon [icon]="faFilter" />
Copy link

@coderabbitai coderabbitai bot Feb 26, 2024

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [9-13]

The use of @if for conditional rendering is not standard Angular syntax. Angular uses *ngIf for such purposes. Please replace @if with *ngIf to ensure the template functions correctly.

- @if (categoryFilter.exercisesWithoutCategoriesPresent) {
+ *ngIf="categoryFilter.exercisesWithoutCategoriesPresent"

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [14-18]

Similarly, the @for directive is used here, which is not recognized in Angular. Angular iterates over collections using *ngFor. Please correct this to use Angular's standard iteration directive.

- @for (category of categoryFilter.exerciseCategories; track category) {
+ *ngFor="let category of categoryFilter.exerciseCategories; trackBy: trackCategory"

Note: Ensure you have a trackCategory function implemented in your component to efficiently track items by identity.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not correct. We follow the new angular best practice.

Copy link

Choose a reason for hiding this comment

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

@MaximilianAnzinger, thank you for pointing out the use of @if and @for as part of the new Angular best practices. I appreciate your patience and the clarification. I'll make sure to follow these guidelines in future reviews.


New Learnings Added
User: MaximilianAnzinger
PR: ls1intum/Artemis#8083
File: src/main/webapp/app/overview/course-statistics/course-statistics.component.html:1-5
Timestamp: 2024-02-27T08:40:15.918Z
Learning: `@if` and `@for` are new and valid Angular syntax replacing *ngIf and *ngFor, and should always be used over the old style in files matching the `src/main/webapp/**/*.html` pattern.

Note: Learnings are effective only in the context of specific code segments. To apply general coding guidelines, please configure path-based instructions.

Comment on lines +66 to +72
@if (ngxDoughnutData && ngxDoughnutColor) {
<ngx-charts-pie-chart [view]="[350, 350]" [results]="ngxDoughnutData" [scheme]="ngxDoughnutColor" [doughnut]="true">
<ng-template #tooltipTemplate let-model="model">
<span>{{ model.name | artemisTranslate }}: {{ model.value }}</span>
</ng-template>
</ngx-charts-pie-chart>
}
Copy link

Choose a reason for hiding this comment

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

The conditional rendering inside the <ngx-charts-pie-chart> component uses @if, which should be replaced with *ngIf for proper Angular syntax.

- @if (ngxDoughnutData && ngxDoughnutColor) {
+ *ngIf="ngxDoughnutData && ngxDoughnutColor"

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
@if (ngxDoughnutData && ngxDoughnutColor) {
<ngx-charts-pie-chart [view]="[350, 350]" [results]="ngxDoughnutData" [scheme]="ngxDoughnutColor" [doughnut]="true">
<ng-template #tooltipTemplate let-model="model">
<span>{{ model.name | artemisTranslate }}: {{ model.value }}</span>
</ng-template>
</ngx-charts-pie-chart>
}
*ngIf="ngxDoughnutData && ngxDoughnutColor"
<ngx-charts-pie-chart [view]="[350, 350]" [results]="ngxDoughnutData" [scheme]="ngxDoughnutColor" [doughnut]="true">
<ng-template #tooltipTemplate let-model="model">
<span>{{ model.name | artemisTranslate }}: {{ model.value }}</span>
</ng-template>
</ngx-charts-pie-chart>

Comment on lines 62 to 75
<h2 class="text-center">{{ currentRelativeScore }} %</h2>
<h4 class="text-center">{{ overallPoints }} / {{ reachablePoints }} Pts</h4>
</div>
<ngx-charts-pie-chart [view]="[350, 350]" [results]="ngxDoughnutData" [scheme]="ngxDoughnutColor" [doughnut]="true">
<ng-template #tooltipTemplate let-model="model">
<span>{{ model.name | artemisTranslate }}: {{ model.value }}</span>
</ng-template>
</ngx-charts-pie-chart>

@if (ngxDoughnutData && ngxDoughnutColor) {
<ngx-charts-pie-chart [view]="[350, 350]" [results]="ngxDoughnutData" [scheme]="ngxDoughnutColor" [doughnut]="true">
<ng-template #tooltipTemplate let-model="model">
<span>{{ model.name | artemisTranslate }}: {{ model.value }}</span>
</ng-template>
</ngx-charts-pie-chart>
}
</div>
<div class="col-md-3 d-flex flex-column align-self-end color-legend-container">
@for (exerciseType of ngxDoughnutData; track exerciseType) {
Copy link

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [73-77]

For iterating over ngxDoughnutData, the correct Angular directive *ngFor should be used instead of @for.

- @for (exerciseType of ngxDoughnutData; track exerciseType) {
+ *ngFor="let exerciseType of ngxDoughnutData; trackBy: trackExerciseType"

Ensure the trackExerciseType function is defined in your component for tracking purposes.

Comment on lines 155 to 159
this.profileService.getProfileInfo()?.subscribe((profileInfo) => {
this.inProduction = profileInfo.inProduction;
});
Copy link

Choose a reason for hiding this comment

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

Fetching profileInfo to set inProduction is a good practice for dynamically adjusting the component's behavior based on the deployment environment. Ensure that error handling is implemented for the subscription to profileService.getProfileInfo() in case the profile information cannot be fetched.

this.profileService.getProfileInfo()?.subscribe({
  next: (profileInfo) => {
    this.inProduction = profileInfo.inProduction;
  },
  error: (err) => {
    console.error('Failed to fetch profile info:', err);
    // Consider setting a default value or handling this scenario appropriately
  }
});

@rabeatwork rabeatwork temporarily deployed to artemis-test5.artemis.cit.tum.de February 27, 2024 10:41 — with GitHub Actions Inactive
@rabeatwork rabeatwork force-pushed the enhancement/replace-tabbar-with-sidebar branch from 245e8fe to 678135e Compare February 27, 2024 11:14
Artemis Development automation moved this from In progress to Review in progress Feb 27, 2024
@rabeatwork rabeatwork moved this from Review in progress to In progress in Artemis Development Feb 27, 2024
@rabeatwork rabeatwork temporarily deployed to artemis-test5.artemis.cit.tum.de February 27, 2024 12:21 — with GitHub Actions Inactive
@rabeatwork rabeatwork force-pushed the enhancement/replace-tabbar-with-sidebar branch from 678135e to 6e5d5e4 Compare February 27, 2024 12:59
Artemis Development automation moved this from In progress to Review in progress Feb 27, 2024
@ls1intum ls1intum deleted a comment from coderabbitai bot Feb 27, 2024
@rabeatwork rabeatwork dismissed a stale review February 27, 2024 20:49

.

@krusche krusche added this to the 7.0.0 milestone Mar 9, 2024
@Mtze Mtze removed the usability label Mar 12, 2024
@krusche krusche added the too-long-open !!! This is an antipattern, we should aim for small PRs that are only open for a short time !!! label Mar 19, 2024
coderabbitai[bot]
coderabbitai bot previously requested changes Mar 19, 2024
Comment on lines +233 to +237
it('should create sidebar items', () => {
component.course = { id: 123, lectures: [], exams: [] };
const sidebarItems = component.getSidebarItems();
expect(sidebarItems.length).toBeGreaterThan(0);
});
Copy link

Choose a reason for hiding this comment

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

While the test should create sidebar items correctly checks for the presence of sidebar items, consider adding more detailed assertions to verify that the sidebar items are correctly created based on specific course data attributes.

Comment on lines +82 to +86
public isProduction = true;
public isTestServer = false;
public pageTitle: string;
public sidebarItems: SidebarItem[];
public isNotManagementView: boolean;
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Based on the information gathered, the initialization of isProduction and isTestServer based on the environment within course-overview.component.ts is confirmed. However, there is no evidence of their usage in conditional rendering or execution paths within the same file or elsewhere in the application, as was the concern raised in the review comment. This suggests that while the properties are initialized as intended, their intended functional impact might not be fully implemented or is implemented in a manner not captured by the search patterns used.

Analysis chain

The addition of properties isProduction, isTestServer, pageTitle, sidebarItems, and isNotManagementView is crucial for the component's functionality. Ensure that these properties are initialized and used correctly throughout the component. Particularly, verify that isProduction and isTestServer are set based on the environment and used to conditionally render or execute code paths that are environment-specific.


To further verify the usage of isProduction and isTestServer in conditional code paths within course-overview.component.ts, and potentially in other parts of the application, the following script will be executed:

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the usage of isProduction and isTestServer in conditional code paths
rg --type ts 'isProduction|isTestServer'

Length of output: 462



Script:

#!/bin/bash
# Check for conditional usage of isProduction and isTestServer within course-overview.component.ts
rg --type ts 'if.*isProduction|if.*isTestServer' src/main/webapp/app/overview/course-overview.component.ts

# Search for potential usage of isProduction and isTestServer in other TypeScript files
rg --type ts 'isProduction|isTestServer' --glob '!src/main/webapp/app/overview/course-overview.component.ts'

Length of output: 219

Comment on lines +170 to +204
getSidebarItems(): SidebarItem[] {
const sidebarItems = this.getDefaultItems();
if (this.course?.lectures) {
const lecturesItem: SidebarItem = this.getLecturesItems();
sidebarItems.splice(-1, 0, lecturesItem);
}
if (this.course?.exams && this.hasVisibleExams()) {
const examsItem: SidebarItem = this.getExamsItems();
sidebarItems.unshift(examsItem);
}
if (isCommunicationEnabled(this.course)) {
const communicationItem: SidebarItem = this.getCommunicationItems();
sidebarItems.push(communicationItem);
}

if (isMessagingEnabled(this.course) || isCommunicationEnabled(this.course)) {
const messagesItem: SidebarItem = this.getMessagesItems();
sidebarItems.push(messagesItem);
}

if (this.hasTutorialGroups()) {
const tutorialGroupsItem: SidebarItem = this.getTutorialGroupsItems();
sidebarItems.push(tutorialGroupsItem);
}

if (this.hasCompetencies()) {
const competenciesItem: SidebarItem = this.getCompetenciesItems();
sidebarItems.push(competenciesItem);
if (this.course?.learningPathsEnabled) {
const learningPathItem: SidebarItem = this.getLearningPathItems();
sidebarItems.push(learningPathItem);
}
}

return sidebarItems;
Copy link

Choose a reason for hiding this comment

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

The getSidebarItems method and related item generation methods are well-implemented, dynamically constructing the sidebar navigation based on the course's properties. Consider adding unit tests for these methods to ensure their correctness, especially in edge cases.

Would you like assistance in creating unit tests for these methods?

@krusche krusche changed the title General: Replace tab-bar with a side-navigation-bar in the students view General: Replace tab bar with a side navigation bar in the students view Mar 20, 2024
@krusche krusche merged commit 4c881e7 into develop Mar 20, 2024
13 of 24 checks passed
@krusche krusche deleted the enhancement/replace-tabbar-with-sidebar branch March 20, 2024 19:05
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 too-long-open !!! This is an antipattern, we should aim for small PRs that are only open for a short time !!! user interface
Projects
Archived in project
Artemis Development
  
Review in progress
Development

Successfully merging this pull request may close these issues.

None yet