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: Allow to switch courses from the course icon #8669

Merged
merged 48 commits into from
Jun 8, 2024

Conversation

az108
Copy link
Contributor

@az108 az108 commented May 25, 2024

Checklist

General

Client

Motivation and Context

Many Applications like Slack allow users to navigate between areas just by clicking on the icon. This small feature is a nice little bonus for experienced users to navigate easily between recently accessed courses instead of always navigating to the homepage and searching for the course they want. This feature is also very beneficial for the Test Servers as the developers have too many Courses to choose from but mostly only need 2 - 5 courses to work on. This feature allows them to easily test their features. Exercise Instructors also profit from this change as they tend to have many courses but only need to visit a few of them.

Description

Added the logic and dropdown box to a course icon after navigating to one course. The 5 recently accessed courses will be displayed or if a user is only enrolled in 1 or 2 courses, then these will be displayed. Added a own courseStorageKey for the Dropdown Courses as the normal one only stores 3 Courses in the Recently Accessed Courses. Also adjusted the padding on the Course Icon. Additionally a shared method was extracted to a util Class for Courses. The scenario that the navbar is collapsed or is shortend because the screen is small was considered.

Before:
image
After:
image

Steps for Testing

  • Click on some Courses: Click on Courses to store them as recently Accessed Courses
  • Navigate to a Course: Click on the Course Icon and ensure a dropdown with the recently Accessed Courses appears
  • Click on it and try to navigate to another Course: Check if the navigating to a recently Accessed Course works

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

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

@az108 az108 requested a review from a team as a code owner May 25, 2024 19:09
Copy link

coderabbitai bot commented May 25, 2024

Walkthrough

The changes introduce a new dropdown menu for courses in the course-overview.component.html with dynamic content based on the courses array. The rendering logic within the container element now depends on isNavbarCollapsed. Additionally, the CourseAccessStorageService and related components were updated to handle course access timestamps for the dropdown menu, with new constants and methods added for better management of course access data.

Changes

Files/Paths Change Summaries
src/main/webapp/app/overview/course-overview.component.html Introduced a new dropdown-courses section, modified structure based on isNavbarCollapsed.
src/main/webapp/app/overview/course-overview.component.scss No changes to exported or public entities.
src/main/webapp/app/overview/courses.component.ts Added import for sortCourses and replaced sorting logic with sortCourses(courses).
src/main/webapp/app/course/course-access-storage.service.ts Expanded functionality to manage course access timestamps, added new constants and methods.
src/main/webapp/app/course/manage/course-management-tab-bar/course-management-tab-bar.component.ts Updated onCourseSelected method to include additional parameters for course access storage.
src/main/webapp/app/course/manage/course-management.component.ts Modified getLastAccessedCourses method to include CourseAccessStorageService.STORAGE_KEY.
src/main/webapp/app/shared/util/course.util.ts Introduced sortCourses function to sort courses alphabetically by their titles.
src/test/javascript/spec/component/course/course-overview.component.spec.ts Added imports and test cases for CourseForDashboardDTO and CoursesForDashboardDTO.
src/test/javascript/spec/service/course-access-storage.service.spec.ts Added parameters to onCourseAccessed and getLastAccessedCourses methods for extended functionality.
src/test/javascript/spec/component/course/course-management-tab-bar.component.spec.ts Added parameter to method call in test case for Course Management Tab Bar Component.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant Navbar
    participant CourseOverviewComponent
    participant CourseAccessStorageService

    User->>Navbar: Collapse Navbar
    Navbar->>CourseOverviewComponent: Update isNavbarCollapsed
    CourseOverviewComponent->>CourseAccessStorageService: getLastAccessedCourses(STORAGE_KEY_DROPDOWN)
    CourseAccessStorageService-->>CourseOverviewComponent: Return last accessed courses
    CourseOverviewComponent-->>User: Render dropdown-courses section with dynamic content
Loading
sequenceDiagram
    participant User
    participant CourseManagementTabBarComponent
    participant CourseAccessStorageService

    User->>CourseManagementTabBarComponent: Select Course
    CourseManagementTabBarComponent->>CourseAccessStorageService: onCourseAccessed(courseId, STORAGE_KEY, MAX_DISPLAYED_RECENTLY_ACCESSED_COURSES_OVERVIEW)
    CourseAccessStorageService-->>CourseManagementTabBarComponent: Store course access timestamp
    CourseManagementTabBarComponent->>CourseAccessStorageService: onCourseAccessed(courseId, STORAGE_KEY_DROPDOWN, MAX_DISPLAYED_RECENTLY_ACCESSED_COURSES_DROPDOWN)
    CourseAccessStorageService-->>CourseManagementTabBarComponent: Store course access timestamp
Loading

Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between ac41e34 and 7ad7e75.

Files selected for processing (1)
  • src/main/webapp/app/overview/course-overview.component.html (1 hunks)
Additional context used
Path-based instructions (1)
src/main/webapp/app/overview/course-overview.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.


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 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 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 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 as 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.

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.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

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 May 25, 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: 2

Outside diff range and nitpick comments (5)
src/main/webapp/app/overview/course-overview.component.ts (1)

Line range hint 110-110: Remove unnecessary type annotations that are trivially inferred from their initializations to clean up the code.

- private courseId: number;
- private subscription: Subscription;
- course?: Course;
- refreshingCourse = false;
- private teamAssignmentUpdateListener: Subscription;
- private quizExercisesChannel: string;

Also applies to: 120-120, 121-121, 122-122, 126-126, 127-127

src/test/javascript/spec/component/course/course-overview.component.spec.ts (4)

Line range hint 124-124: Specify explicit types instead of using any.

- const course1Dashboard = { course: course1 } as CourseForDashboardDTO;
- const course2Dashboard = { course: course2 } as CourseForDashboardDTO;
+ const course1Dashboard: CourseForDashboardDTO = { course: course1 };
+ const course2Dashboard: CourseForDashboardDTO = { course: course2 };

Also applies to: 126-126


Line range hint 130-130: Avoid using non-null assertions. Consider handling potential null values gracefully.

- this.controlConfiguration.subject!.next(this.controls);
+ if (this.controlConfiguration.subject && this.controls) {
+     this.controlConfiguration.subject.next(this.controls);
+ }

Line range hint 289-294: Prefer using for...of instead of forEach for better readability and performance in loops.

- tabs.forEach((tab) => {
+ for (const tab of tabs) {

Also applies to: 310-315, 325-328


Line range hint 4-5: Some imports are only used as types. Consider importing them using import type to make this explicit and potentially improve build optimization.

- import { Course, CourseInformationSharingConfiguration } from 'app/entities/course.model';
+ import type { Course, CourseInformationSharingConfiguration } from 'app/entities/course.model';

Also applies to: 8-9, 9-10, 19-20, 20-21, 26-27

src/main/webapp/app/overview/course-overview.component.ts Outdated Show resolved Hide resolved
changed for loop

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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: 6

src/main/webapp/app/overview/course-overview.component.ts Outdated Show resolved Hide resolved
src/main/webapp/app/overview/course-overview.component.ts Outdated Show resolved Hide resolved
src/main/webapp/app/overview/course-overview.component.ts Outdated Show resolved Hide resolved
src/main/webapp/app/overview/course-overview.component.ts Outdated Show resolved Hide resolved
coderabbitai[bot]
coderabbitai bot previously approved these changes May 25, 2024
package.json Outdated Show resolved Hide resolved
got added by accident
Copy link
Contributor

@iyannsch iyannsch left a comment

Choose a reason for hiding this comment

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

Overall very cool idea, I like the functionality and I think it looks good how you implemented the changes ☺️

Apart from my in-code comments, I´d like to request that you increase the surface area that can be clicked to open the dropdown. Why make it only possible to click on the logo and the downward-facing arrow but not on the name of the course? You could also move the downward-facing arrow to the middle then. See attatched screenshot showing the proposed cursor location.

Looking forward to your answers!

src/main/webapp/app/overview/course-overview.component.ts Outdated Show resolved Hide resolved
src/main/webapp/app/overview/course-overview.component.ts Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
accident changes
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: 2

src/main/webapp/app/overview/course-overview.component.ts Outdated Show resolved Hide resolved
src/main/webapp/app/overview/course-overview.component.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@egekurt123 egekurt123 left a comment

Choose a reason for hiding this comment

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

Tested on ts3, works fine now

Copy link
Contributor

@muradium muradium left a comment

Choose a reason for hiding this comment

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

Changes lgtm, reapproval

Copy link
Contributor

@sarpsahinalp sarpsahinalp left a comment

Choose a reason for hiding this comment

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

Changes lgtm, reapprove

Copy link
Contributor

@rabeatwork rabeatwork left a comment

Choose a reason for hiding this comment

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

maintainer approve

@az108 az108 added ready to merge maintainer-approved The feature maintainer has approved the PR and removed lock:artemis-test1 labels Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) maintainer-approved The feature maintainer has approved the PR ready to merge tests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.