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

🎨 Enable to update submission status from drop down in task list by grades and detailed workbook page (#1858) #1859

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from

Conversation

KATO-Hiro
Copy link
Collaborator

@KATO-Hiro KATO-Hiro commented Mar 23, 2025

close #1858

Summary by CodeRabbit

  • New Features

    • Introduced a new component for displaying task submission statuses directly within tables.
    • Enabled customizable dropdown styling for enhanced visual feedback.
  • Refactor

    • Replaced modal-based task updates with inline interactions for a streamlined user experience.
    • Updated handling of task status changes for real-time updates.
  • Style

    • Improved dropdown alignment and positioning for better usability.

Copy link

coderabbitai bot commented Mar 23, 2025

Walkthrough

This pull request introduces a new Svelte component, SubmissionStatusInTableBodyCell, which encapsulates a table cell showing the submission status and integrates an updating dropdown. The UpdatingDropdown component has been enhanced with a new dropdownClass property and refined type definitions. Additionally, the modal logic previously used in TaskList and workbook pages has been removed in favor of directly updating task results via an updateTaskResult function triggered by the new dropdown and cell component interactions.

Changes

File Path(s) Change Summary
src/lib/components/SubmissionStatus/SubmissionStatusInTableBodyCell.svelte Introduces a new component that wraps a table cell with a submission status image and an UpdatingDropdown, handling click events and emitting update events.
src/lib/components/SubmissionStatus/UpdatingDropdown.svelte
src/lib/components/TaskTables/…/TaskTableBodyCell.svelte
Adds an optional dropdownClass property for dynamic styling and updates type definitions (including imagePath in SubmissionStatus) and method signatures for clearer structure.
src/lib/components/TaskList.svelte
src/routes/workbooks/[slug]/+page.svelte
Removes modal components and logic; introduces an updateTaskResult function for direct task result updates and integrates the new SubmissionStatus table cell component.

Sequence Diagram(s)

Loading
sequenceDiagram
  participant U as User
  participant TS as SubmissionStatusInTableBodyCell
  participant UD as UpdatingDropdown
  participant P as Parent Component

  U->>TS: Click on submission status cell
  TS->>UD: Toggle dropdown visibility
  U->>UD: Select new status option
  UD->>P: Emit onupdate event with updated task result
  P->>P: Update task result state internally
  P->>TS: Re-render with updated submission status

Assessment against linked issues

Objective Addressed Explanation
[UI] Allow updating submission status via dropdown (#1858)

Poem

I'm a coding rabbit, hopping with delight,
Crafting dropdowns glowing in the soft screen light.
Tasks update smoothly as I bounce along the code,
In every updated cell, a new story is told.
Hoppy days ahead—celebrate the upgrade! 🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 20e1f3e and e6d18bb.

📒 Files selected for processing (1)
  • src/lib/components/SubmissionStatus/UpdatingModal.svelte (0 hunks)
💤 Files with no reviewable changes (1)
  • src/lib/components/SubmissionStatus/UpdatingModal.svelte

🪧 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.
  • @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: 1

🧹 Nitpick comments (2)
src/lib/components/SubmissionStatus/SubmissionStatusInTableBodyCell.svelte (1)

1-30: New component looks good, but consider UX implications

The new component nicely encapsulates the submission status display and update functionality within a table cell.

Two aspects to consider:

  1. The entire TableBodyCell is clickable to toggle the dropdown (line 22). Users might expect only an icon or button to be clickable - this could be confusing if they click anywhere in the cell. Consider making the click target more explicit.
  2. The UpdatingDropdown (line 29) is placed outside TableBodyCell unlike other implementations. Unlike in TaskTableBodyCell.svelte, no dropdownClass is specified here for positioning. Consider adding consistent positioning to ensure the dropdown appears correctly.
src/lib/components/SubmissionStatus/UpdatingDropdown.svelte (1)

181-181: Consider translating comment to English.

For better maintainability and international collaboration, consider translating the Japanese comment to English. While the comment provides helpful context about the workaround for dropdown handling, maintaining all code comments in a single language improves codebase consistency.

- <!-- HACK: classの設定は、テーブルの上部・下部をクリックしたときに、いずれもドロップダウンを操作できるようにするための苦肉の策 -->
+ <!-- HACK: This class setting is a workaround to allow dropdown operation when clicking on the top or bottom of the table -->
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 61a63c4 and 20e1f3e.

📒 Files selected for processing (5)
  • src/lib/components/SubmissionStatus/SubmissionStatusInTableBodyCell.svelte (1 hunks)
  • src/lib/components/SubmissionStatus/UpdatingDropdown.svelte (6 hunks)
  • src/lib/components/TaskList.svelte (3 hunks)
  • src/lib/components/TaskTables/TaskTableBodyCell.svelte (1 hunks)
  • src/routes/workbooks/[slug]/+page.svelte (3 hunks)
🔇 Additional comments (14)
src/lib/components/TaskTables/TaskTableBodyCell.svelte (1)

68-74: Proper positioning for the updating dropdown

The addition of dropdownClass="left-auto right-0 mt-8" provides proper styling for dropdown positioning, ensuring it appears correctly relative to the button.

src/lib/components/TaskList.svelte (2)

35-47: Good implementation of direct task result updates

The updateTaskResult function correctly updates the specific task in the array when changes occur. This is a cleaner approach than using modal-based updates.


94-100: Check potential padding duplication

The integration with the new component looks good, but note that you're wrapping SubmissionStatusTableBodyCell in a div with padding classes "px-1 sm:px-3", while the component itself already has padding defined in its implementation (line 21 in SubmissionStatusInTableBodyCell.svelte).

Verify that this doesn't create excessive padding or inconsistent spacing across the UI.

src/routes/workbooks/[slug]/+page.svelte (1)

46-55: Good map-based implementation for task result updates

The updateTaskResult function correctly updates the task result in the map when changes occur. The approach with creating a new Map instance is appropriate for maintaining reactivity.

src/lib/components/SubmissionStatus/UpdatingDropdown.svelte (10)

12-12: Good addition of optional property for styling customization.

The addition of an optional dropdownClass property to the Props interface allows for more flexible styling when this component is used in different contexts, such as in the task list table.


15-15: Good implementation of destructuring with default value.

The destructuring has been properly updated to include the new dropdownClass parameter with a default empty string value, which is a good practice for optional properties.


48-48: Consistent interface definition.

The Props interface is consistently updated here to match the usage section, which is good for maintaining coherence throughout the component.


51-51: Consistent props destructuring.

The destructuring correctly mirrors what's defined in the interface Props, with appropriate default value for the optional parameter.


72-72: Improved type safety for handleClick function.

Replacing the inline type definition with a reference to the SubmissionStatus type enhances type safety and maintainability.


93-93: Proper type extension for new feature.

Adding the imagePath property to the SubmissionStatus type is necessary to support the feature of displaying and updating status images.


160-160: Correctly updates image path during status change.

The submission_status_image_path is now properly set from the submissionStatus object, ensuring visual consistency when status is updated.


162-163: Logic update for accepted submission status.

The condition for setting is_ac now includes both ac and ac_with_editorial statuses. Consider documenting this change clearly if this represents a change in business logic, as it affects which submissions are considered as accepted.

Are there other components that rely on the is_ac property that might need to be updated to handle both statuses?


174-174: Consistent inclusion of imagePath in submission options.

The imagePath is now correctly included when mapping submission status options, ensuring the data structure consistency throughout the component.


186-186: Effective dropdown styling with dynamic class.

The class attribute now correctly incorporates the dropdownClass variable, allowing for context-specific styling. This is key to the PR objective of enhancing the dropdown's flexibility across different UI contexts.

Comment on lines +173 to +180
<!-- 回答状況 -->
<div class="">
<SubmissionStatusTableBodyCell
taskResult={getTaskResult(workBookTask.taskId)}
{isLoggedIn}
onupdate={(updatedTask: TaskResult) => updateTaskResult(updatedTask)}
/>
</div>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

TableBodyCell consistency issue

Unlike other cells in this table row, the SubmissionStatusTableBodyCell is wrapped in a regular div instead of a TableBodyCell component. This inconsistency could cause layout issues.

Apply this change to maintain consistent table structure:

-              <!-- 回答状況 -->
-              <div class="">
-                <SubmissionStatusTableBodyCell
-                  taskResult={getTaskResult(workBookTask.taskId)}
-                  {isLoggedIn}
-                  onupdate={(updatedTask: TaskResult) => updateTaskResult(updatedTask)}
-                />
-              </div>
+              <!-- 回答状況 -->
+              <TableBodyCell class="">
+                <SubmissionStatusTableBodyCell
+                  taskResult={getTaskResult(workBookTask.taskId)}
+                  {isLoggedIn}
+                  onupdate={(updatedTask: TaskResult) => updateTaskResult(updatedTask)}
+                />
+              </TableBodyCell>
📝 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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<!-- 回答状況 -->
<div class="">
<SubmissionStatusTableBodyCell
taskResult={getTaskResult(workBookTask.taskId)}
{isLoggedIn}
onupdate={(updatedTask: TaskResult) => updateTaskResult(updatedTask)}
/>
</div>
<!-- 回答状況 -->
<TableBodyCell class="">
<SubmissionStatusTableBodyCell
taskResult={getTaskResult(workBookTask.taskId)}
{isLoggedIn}
onupdate={(updatedTask: TaskResult) => updateTaskResult(updatedTask)}
/>
</TableBodyCell>

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