Skip to content

为渠道参数覆盖可视化规则提供拖拽排序支持 - #3166

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
somnifex:main
Mar 7, 2026
Merged

Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
somnifex:main

Conversation

@somnifex

@somnifex somnifex commented Mar 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added drag-and-drop reordering for operations in the parameter override editor, allowing you to repositioning operations by dragging them.
  • Chores

    • Updated gitignore configuration.

Copilot AI review requested due to automatic review settings March 7, 2026 06:30
@coderabbitai

coderabbitai Bot commented Mar 7, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Added .history to .gitignore for file exclusion. Implemented drag-and-drop reordering functionality in ParamOverrideEditorModal.jsx with drag state management, visual feedback, and helper methods to reorder operations.

Changes

Cohort / File(s) Summary
Gitignore Configuration
.gitignore
Added .history entry to ignored paths.
Drag-and-Drop Reordering
web/src/components/table/channels/modals/ParamOverrideEditorModal.jsx
Introduced drag-and-drop reordering for operations with new drag state tracking (draggedOperationId, dragOverOperationId, dragOverPosition), reordering helper function, drag lifecycle handlers (handleOperationDragStart, handleOperationDragOver, handleOperationDrop), and conditional styling for drag affordances. Added IconMenu import for drag indicator visuals.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 In the code we hop and play,
Dragging operations every way,
With menu icons, left to right,
Our orders dance in perfect sight,
While .history fades away!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is in Chinese and describes adding drag-and-drop reordering support for channel parameter override visualization rules, which directly matches the main change of introducing drag-and-drop functionality in ParamOverrideEditorModal.jsx.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
web/src/components/table/channels/modals/ParamOverrideEditorModal.jsx (2)

2061-2067: Consider adding onDragLeave to clean up visual state.

If the user drags outside the list area before dropping, the drop indicator visual state (dragOverOperationId) persists until dragEnd. Adding onDragLeave on the container could clear dragOverOperationId for a cleaner UX, though onDragEnd does reset state eventually.

♻️ Optional: Add onDragLeave handler

You could add a container-level handler:

const handleOperationDragLeave = useCallback((event) => {
  // Only reset if leaving the container entirely
  if (!event.currentTarget.contains(event.relatedTarget)) {
    setDragOverOperationId('');
  }
}, []);

And apply it to the operations list container div.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/components/table/channels/modals/ParamOverrideEditorModal.jsx` around
lines 2061 - 2067, Add an onDragLeave handler on the operations list container
to clear the persistent drop indicator when the user drags out of the list;
implement a handleOperationDragLeave (useCallback) that checks whether the
pointer left the container (e.g., using
event.currentTarget.contains(event.relatedTarget)) and calls
setDragOverOperationId('') only when leaving entirely, then attach
onDragLeave={handleOperationDragLeave} to the same container that already has
onDragOver/onDrop/onDragEnd and keep resetOperationDragState for dragend.

2050-2076: Consider adding keyboard-based reordering for accessibility.

The HTML5 drag-and-drop API has limited screen reader support. While the items are keyboard-navigable, users who cannot use a mouse cannot reorder operations via keyboard. Consider adding keyboard shortcuts (e.g., Ctrl+Up/Down) or move up/down buttons as an alternative reordering mechanism in a future iteration.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/components/table/channels/modals/ParamOverrideEditorModal.jsx` around
lines 2050 - 2076, Add keyboard-based reordering for accessibility by augmenting
the operation item UI: detect keyboard commands (e.g., Ctrl+ArrowUp /
Ctrl+ArrowDown) in the onKeyDown handler for the operation element and call new
helper functions (e.g., moveOperationUp(operation.id) and
moveOperationDown(operation.id)) that update the operations array order and
preserve selection; alternatively expose visible Move Up / Move Down buttons
next to each item that call those same helpers. Ensure these helpers integrate
with existing drag handlers (handleOperationDragStart, handleOperationDragOver,
handleOperationDrop, resetOperationDragState) and update any parent state so the
UI reflects the new order and focused/selected item (setSelectedOperationId) for
screen-reader and keyboard users.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@web/src/components/table/channels/modals/ParamOverrideEditorModal.jsx`:
- Around line 2061-2067: Add an onDragLeave handler on the operations list
container to clear the persistent drop indicator when the user drags out of the
list; implement a handleOperationDragLeave (useCallback) that checks whether the
pointer left the container (e.g., using
event.currentTarget.contains(event.relatedTarget)) and calls
setDragOverOperationId('') only when leaving entirely, then attach
onDragLeave={handleOperationDragLeave} to the same container that already has
onDragOver/onDrop/onDragEnd and keep resetOperationDragState for dragend.
- Around line 2050-2076: Add keyboard-based reordering for accessibility by
augmenting the operation item UI: detect keyboard commands (e.g., Ctrl+ArrowUp /
Ctrl+ArrowDown) in the onKeyDown handler for the operation element and call new
helper functions (e.g., moveOperationUp(operation.id) and
moveOperationDown(operation.id)) that update the operations array order and
preserve selection; alternatively expose visible Move Up / Move Down buttons
next to each item that call those same helpers. Ensure these helpers integrate
with existing drag handlers (handleOperationDragStart, handleOperationDragOver,
handleOperationDrop, resetOperationDragState) and update any parent state so the
UI reflects the new order and focused/selected item (setSelectedOperationId) for
screen-reader and keyboard users.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f286f0cb-3483-4040-983a-de24f1d1ebd9

📥 Commits

Reviewing files that changed from the base of the PR and between 05452c1 and 9b39423.

📒 Files selected for processing (2)
  • .gitignore
  • web/src/components/table/channels/modals/ParamOverrideEditorModal.jsx

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

该 PR 为“渠道参数覆盖可视化规则”编辑器增加拖拽排序能力,方便用户在可视化模式下调整规则执行顺序,从而更直观地控制参数覆盖链路。

Changes:

  • 在 ParamOverrideEditorModal 的规则导航列表中加入 HTML5 Drag & Drop 交互与视觉反馈(拖拽中/可放置位置高亮)。
  • 新增 reorderOperations 以在前端状态中重排规则数组。
  • .gitignore 增加忽略本地历史目录 .history。

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.

File Description
web/src/components/table/channels/modals/ParamOverrideEditorModal.jsx 增加规则列表拖拽排序逻辑、状态管理与 UI 提示
.gitignore 忽略 .history 本地文件/目录

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +1652 to +1655
event.preventDefault();
if (!draggedOperationId || draggedOperationId === operationId) {
return;
}

Copilot AI Mar 7, 2026

Copy link

Choose a reason for hiding this comment

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

handleOperationDragOver calls event.preventDefault() before confirming an internal operation drag is in progress. This makes every item a valid drop target even for external drags (e.g., dragging selected text/files), potentially blocking default browser/app behavior. Consider only calling preventDefault (and setting dropEffect) when draggedOperationId is set and differs from operationId, or when dataTransfer contains the expected internal type.

Suggested change
event.preventDefault();
if (!draggedOperationId || draggedOperationId === operationId) {
return;
}
if (!draggedOperationId || draggedOperationId === operationId) {
return;
}
event.preventDefault();

Copilot uses AI. Check for mistakes.
@Calcium-Ion
Calcium-Ion merged commit c706a5c into QuantumNous:main Mar 7, 2026
4 of 5 checks passed
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
为渠道参数覆盖可视化规则提供拖拽排序支持
salem-2007 added a commit to salem-2007/new-api that referenced this pull request Sep 10, 2026
为渠道参数覆盖可视化规则提供拖拽排序支持
junjundesk pushed a commit to junjundesk/new-api that referenced this pull request Oct 3, 2026
为渠道参数覆盖可视化规则提供拖拽排序支持
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants