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

fix: add loading states where required and update live quiz deletion logic #4314

Merged
merged 3 commits into from
Oct 17, 2024

Conversation

sjschlapbach
Copy link
Member

@sjschlapbach sjschlapbach commented Oct 17, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced loading states for various actions, enhancing user feedback during operations such as logging out, starting sessions, and unpublishing content.
    • Added a new mutation for deleting live quizzes, replacing the previous session deletion functionality.
  • Bug Fixes

    • Improved handling of loading states across multiple components for a smoother user experience.

These updates aim to improve user interactions and streamline the management of sessions and quizzes within the application.

Copy link

aviator-app bot commented Oct 17, 2024

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was merged manually (without Aviator). Merging manually can negatively impact the performance of the queue. Consider using Aviator next time.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

Copy link

cypress bot commented Oct 17, 2024

klicker-uzh    Run #3261

Run Properties:  status check passed Passed #3261  •  git commit 6ff6b65ce1 ℹ️: Merge b6eb9eaa51a9dfe93024f7180a179b18bbe39512 into 24e1bb99210c57dd6d58ea4257cb...
Project klicker-uzh
Run status status check passed Passed #3261
Run duration 11m 36s
Commit git commit 6ff6b65ce1 ℹ️: Merge b6eb9eaa51a9dfe93024f7180a179b18bbe39512 into 24e1bb99210c57dd6d58ea4257cb...
Committer Julius Schlapbach
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 1
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 138

@sjschlapbach sjschlapbach marked this pull request as ready for review October 17, 2024 14:30
Copy link

coderabbitai bot commented Oct 17, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

This pull request introduces various enhancements across multiple components in the frontend application, primarily focusing on the implementation of loading states for various mutation operations. Components such as Header, StartModal, and several others have been updated to reflect loading statuses during asynchronous actions, improving user feedback. Additionally, the GraphQL schema has been modified to replace the deleteSession mutation with a new deleteLiveQuiz mutation, consolidating deletion logic for quizzes.

Changes

File Path Change Summary
apps/frontend-control/src/components/layout/Header.tsx Added loading state for logout mutation, renamed loading to loggingOut.
apps/frontend-control/src/components/sessions/StartModal.tsx Added loading state for session start action, renamed loading to startingSession.
apps/frontend-manage/src/components/courses/actions/StartLiveQuizButton.tsx Added loading state for startSession mutation, renamed loading to startingSession.
apps/frontend-manage/src/components/courses/actions/UnpublishMicroLearningButton.tsx Added loading state for unpublishing process, renamed loading to unpublishing.
apps/frontend-manage/src/components/courses/groupActivity/GroupActivityUnpublishButton.tsx Added loading state for unpublishGroupActivity, renamed loading to unpublishing.
apps/frontend-manage/src/components/sessions/Session.tsx Renamed DeleteSessionDocument to DeleteLiveQuizDocument, added loading state for startSession.
apps/frontend-manage/src/pages/index.tsx Added loading state for toggleIsArchived, renamed loading to toggelingArchive.
apps/frontend-pwa/src/components/practiceQuiz/Bookmark.tsx Added loading state for bookmarkingStack mutation, renamed loading to bookmarkingStack.
apps/frontend-pwa/src/components/course/SuspendedGroupView.tsx Added setSubmitting(true) in the onSubmit function of Formik.

Possibly related PRs

Suggested reviewers

  • rschlaefli

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 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: 0

🧹 Outside diff range and nitpick comments (4)
apps/frontend-manage/src/components/courses/groupActivity/GroupActivityGradingStack.tsx (1)

370-370: Approve the change with a minor suggestion.

The modification to the disabled prop improves the button's behavior by disabling it when grading is completed. This aligns well with the PR objective of updating quiz-related logic.

However, consider retaining the isSubmitting condition to prevent potential multiple submissions:

-disabled={!isValid || gradingCompleted}
+disabled={!isValid || isSubmitting || gradingCompleted}

This ensures the button remains disabled during form submission, preventing accidental multiple clicks.

apps/frontend-manage/src/components/sessions/Session.tsx (3)

43-53: LGTM: Improved startSession mutation with loading state and refetch

The addition of the startingQuiz loading state enhances user feedback during session start. The refetchQueries option ensures that the list of running sessions is updated after starting a new session, improving data consistency.

Consider adding error handling to provide user feedback if the session start fails.


Line range hint 55-74: LGTM: Updated deleteLiveQuiz mutation

The renaming of the mutation from deleteSession to deleteLiveQuiz aligns with the PR objective of updating the live quiz deletion logic. The optimistic response has been correctly updated to maintain consistency.

Consider adding error handling to provide user feedback if the deletion fails.


248-267: LGTM: Extended edit functionality to scheduled sessions

The edit session button is now displayed for both prepared and scheduled sessions, providing more flexibility in session management. This change allows users to make modifications to sessions even after they've been scheduled.

Consider adding a tooltip or info icon to explain the implications of editing a scheduled session, especially if it might affect participants who have already joined or prepared for the session.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between cc005f3 and b6eb9ea.

📒 Files selected for processing (9)
  • apps/frontend-control/src/components/layout/Header.tsx (2 hunks)
  • apps/frontend-manage/src/components/courses/actions/StartLiveQuizButton.tsx (2 hunks)
  • apps/frontend-manage/src/components/courses/actions/UnpublishMicroLearningButton.tsx (1 hunks)
  • apps/frontend-manage/src/components/courses/groupActivity/GroupActivityGradingStack.tsx (1 hunks)
  • apps/frontend-manage/src/components/courses/groupActivity/GroupActivityUnpublishButton.tsx (1 hunks)
  • apps/frontend-manage/src/components/sessions/Session.tsx (6 hunks)
  • apps/frontend-manage/src/pages/index.tsx (3 hunks)
  • apps/frontend-pwa/src/components/course/SuspendedGroupView.tsx (1 hunks)
  • apps/frontend-pwa/src/components/practiceQuiz/Bookmark.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • apps/frontend-control/src/components/layout/Header.tsx
  • apps/frontend-manage/src/components/courses/actions/StartLiveQuizButton.tsx
  • apps/frontend-manage/src/components/courses/actions/UnpublishMicroLearningButton.tsx
  • apps/frontend-manage/src/components/courses/groupActivity/GroupActivityUnpublishButton.tsx
  • apps/frontend-manage/src/pages/index.tsx
  • apps/frontend-pwa/src/components/course/SuspendedGroupView.tsx
  • apps/frontend-pwa/src/components/practiceQuiz/Bookmark.tsx
🧰 Additional context used
🔇 Additional comments (4)
apps/frontend-manage/src/components/sessions/Session.tsx (4)

16-16: LGTM: Updated import for deletion mutation

The change from DeleteSessionDocument to DeleteLiveQuizDocument suggests a more specific mutation for deleting live quizzes. This change aligns with the PR objective of updating the live quiz deletion logic.


193-193: LGTM: Disabled start session button during loading

The addition of the disabled prop controlled by the startingQuiz loading state prevents multiple clicks on the start session button while the session is being started. This improves user experience and prevents potential errors.


355-355: LGTM: Updated DeletionModal to use deleteLiveQuiz

The deleteElement prop in the DeletionModal component has been correctly updated to use deleteLiveQuiz instead of deleteSession. This change maintains consistency with the renamed deletion mutation.


269-277: LGTM: Extended delete functionality to completed sessions

The delete session button is now displayed for prepared, scheduled, and completed sessions, providing more control over session management. This aligns with the PR objective of updating the live quiz deletion logic.

Please verify that deleting completed sessions doesn't have unintended consequences, such as loss of important data or breaking references in other parts of the system. Consider running the following script to check for any references to completed sessions:

✅ Verification successful

Verified: No unintended consequences found when deleting completed sessions

Deleting completed sessions does not appear to adversely affect other parts of the system based on the current references. The session.status === SessionStatus.Completed checks are used solely for display and filtering purposes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for references to completed sessions in the codebase
rg --type typescript --type javascript 'session.*status.*Completed' -C 3

Length of output: 109


Script:

#!/bin/bash
# Search for references to completed sessions in the codebase with corrected file types
rg --type ts --type tsx --type js --type jsx 'session.*status.*Completed' -C 3

Length of output: 108


Script:

#!/bin/bash
# Search for references to completed sessions in the codebase using glob patterns
rg -g "*.ts" -g "*.tsx" -g "*.js" -g "*.jsx" 'session.*status.*Completed' -C 3

Length of output: 1339

Copy link

@sjschlapbach sjschlapbach merged commit 3ab1a1a into v3 Oct 17, 2024
13 of 16 checks passed
@sjschlapbach sjschlapbach deleted the mutation-loading-states branch October 17, 2024 16:41
Copy link

cypress bot commented Oct 17, 2024

klicker-uzh    Run #3267

Run Properties:  status check passed Passed #3267  •  git commit 3ab1a1ab32: fix: add loading states where required and update live quiz deletion logic (#431...
Project klicker-uzh
Run status status check passed Passed #3267
Run duration 11m 35s
Commit git commit 3ab1a1ab32: fix: add loading states where required and update live quiz deletion logic (#431...
Committer Julius Schlapbach
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 138

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