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

enhance(apps/analytics): allow switching between courses and activity on analytics dashboards #4406

Merged
merged 2 commits into from
Dec 22, 2024

Conversation

sjschlapbach
Copy link
Member

@sjschlapbach sjschlapbach commented Dec 22, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced AnalyticsNavigation components across various sections (Activity, Overview, Performance, Quiz) with new slug props for improved functionality.
    • Introduced a loading state and a course selection dropdown in the Overview section, allowing users to select and navigate to specific courses.
  • Bug Fixes

    • Improved layout structure in the Overview section by changing from flexbox to grid.

Copy link

coderabbitai bot commented Dec 22, 2024

Warning

Rate limit exceeded

@sjschlapbach has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 56 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between dfc6c1f and c2d50a9.

📒 Files selected for processing (4)
  • apps/frontend-manage/src/components/analytics/quiz/QuizAnalyticsNavigation.tsx (1 hunks)
  • apps/frontend-manage/src/pages/analytics/[courseId]/quizzes/[id].tsx (1 hunks)
  • packages/i18n/messages/de.ts (1 hunks)
  • packages/i18n/messages/en.ts (1 hunks)
📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces a new slug prop to the AnalyticsNavigation component across multiple analytics-related components. This change involves updating the AnalyticsNavigationProps interface in the main AnalyticsNavigation component to include the slug property. The components for activity, performance, and quiz analytics are modified to pass specific slug values, enhancing the navigation and routing capabilities of the analytics sections.

Changes

File Change Summary
apps/frontend-manage/src/components/analytics/overview/AnalyticsNavigation.tsx - Updated AnalyticsNavigationProps interface to include slug: string
- Added imports for useQuery, GetUserCoursesDocument, Loader, SelectField, and useRouter
- Implemented course selection query and navigation logic
apps/frontend-manage/src/components/analytics/activity/ActivityAnalyticsNavigation.tsx Added slug="activity" prop to AnalyticsNavigation component
apps/frontend-manage/src/components/analytics/performance/PerformanceAnalyticsNavigation.tsx Added slug="performance" prop to AnalyticsNavigation component
apps/frontend-manage/src/components/analytics/quiz/QuizSelectionNavigation.tsx Added slug="quizzes" prop to AnalyticsNavigation component

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

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

🧹 Nitpick comments (3)
apps/frontend-manage/src/components/analytics/overview/AnalyticsNavigation.tsx (3)

1-19: Consider improving type safety and backward compatibility

The interface change makes slug required, which could break existing usages. Consider:

  1. Making slug optional with a default value
  2. Adding TypeScript types for GraphQL operations
- import { GetUserCoursesDocument } from '@klicker-uzh/graphql/dist/ops'
+ import { GetUserCoursesDocument, GetUserCoursesQuery } from '@klicker-uzh/graphql/dist/ops'

interface AnalyticsNavigationProps {
  hrefLeft: string
  labelLeft: React.ReactNode
  hrefRight: string
  labelRight: React.ReactNode
-  slug: string
+  slug?: string
}

33-35: Enhance loading and error state handling

Consider improving the user experience during loading and error states:

  1. Add a more contextual loading state
  2. Include error state UI
  3. Consider skeleton loading for better UX
+ if (error) {
+   return (
+     <div className="text-red-600">
+       {t('shared.errors.failedToLoadCourses')}
+     </div>
+   )
+ }

if (loading) {
-  return <Loader />
+  return (
+    <div className="mb-6 grid w-full grid-cols-2 md:grid-cols-3">
+      <div className="animate-pulse h-8 bg-gray-200 rounded" />
+      <div className="hidden md:block animate-pulse h-8 bg-gray-200 rounded" />
+      <div className="animate-pulse h-8 bg-gray-200 rounded" />
+    </div>
+  )
}

39-45: Enhance navigation links accessibility and interaction feedback

The navigation links could benefit from improved accessibility and user interaction:

<Link
  href={hrefLeft}
- className="flex flex-row items-center justify-start gap-2"
+ className="flex flex-row items-center justify-start gap-2 hover:text-primary-600 focus:outline-none focus:ring-2 focus:ring-primary-500 rounded-md transition-colors"
+ aria-label={typeof labelLeft === 'string' ? labelLeft : 'Previous section'}
>

Also applies to: 63-69

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6fa3bb6 and dfc6c1f.

📒 Files selected for processing (4)
  • apps/frontend-manage/src/components/analytics/activity/ActivityAnalyticsNavigation.tsx (1 hunks)
  • apps/frontend-manage/src/components/analytics/overview/AnalyticsNavigation.tsx (1 hunks)
  • apps/frontend-manage/src/components/analytics/performance/PerformanceAnalyticsNavigation.tsx (1 hunks)
  • apps/frontend-manage/src/components/analytics/quiz/QuizSelectionNavigation.tsx (1 hunks)
🔇 Additional comments (3)
apps/frontend-manage/src/components/analytics/performance/PerformanceAnalyticsNavigation.tsx (1)

12-12: LGTM! Verify navigation path consistency.

The addition of slug="performance" is clean and aligns with the PR objective.

Let's verify the navigation paths are consistent across the analytics components:

✅ Verification successful

Navigation paths are consistent across analytics components

The verification confirms that navigation paths follow a consistent pattern /analytics/${courseId}/(performance|activity|quizzes) across all analytics components. The circular navigation flow is properly maintained:

  • Performance → Activity → Quizzes → Performance
  • Each component correctly links to its adjacent sections
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistent analytics navigation paths
# Expected pattern: /analytics/${courseId}/(performance|activity|quizzes)

rg -g '*.tsx' -g '*.ts' '/analytics/\$\{courseId\}/(performance|activity|quizzes)'

Length of output: 1170

apps/frontend-manage/src/components/analytics/activity/ActivityAnalyticsNavigation.tsx (1)

12-12: LGTM! Implementation is consistent.

The addition of slug="activity" follows the same pattern as other analytics navigation components.

apps/frontend-manage/src/components/analytics/quiz/QuizSelectionNavigation.tsx (1)

12-12: Consider consistent naming patterns.

While the implementation is correct, there are two potential consistency improvements to consider:

  1. Component naming: Other components follow the pattern {Section}AnalyticsNavigation (e.g., ActivityAnalyticsNavigation), while this uses QuizSelectionNavigation
  2. Slug value: Uses plural "quizzes" while URL patterns typically use singular form

Consider renaming to maintain consistency:

-function QuizSelectionNavigation({ courseId }: { courseId: string }) {
+function QuizAnalyticsNavigation({ courseId }: { courseId: string }) {
   return (
     <AnalyticsNavigation
       hrefLeft={`/analytics/${courseId}/performance`}
       labelLeft={<PerformanceDashboardLabel />}
       hrefRight={`/analytics/${courseId}/activity`}
       labelRight={<ActivityDashboardLabel />}
-      slug="quizzes"
+      slug="quiz"
     />
   )
 }

-export default QuizSelectionNavigation
+export default QuizAnalyticsNavigation

Let's verify the component naming patterns across the codebase:

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant