Skip to content

feat: Add navigation buttons for channel edit form sections - #1844

Merged
seefs001 merged 3 commits into
QuantumNous:alphafrom
JoeyLearnsToCode:feat-channel-block-edit
Oct 2, 2025
Merged

feat: Add navigation buttons for channel edit form sections#1844
seefs001 merged 3 commits into
QuantumNous:alphafrom
JoeyLearnsToCode:feat-channel-block-edit

Conversation

@JoeyLearnsToCode

@JoeyLearnsToCode JoeyLearnsToCode commented Sep 19, 2025

Copy link
Copy Markdown
Contributor

Why / 为什么

The channel creation/editing form has become quite long with multiple configuration sections
(Basic Info, API Config, Model Config, Advanced Settings, Channel Extra Settings). Users need to
scroll extensively to navigate between different form sections, which creates a poor user
experience when filling out or reviewing channel configurations.

渠道新增、编辑表单现在很长,包含多个配置区块(基本信息、API配置、模型配置、高级设置、渠道额外设置
)。用户需要大量滚动才能在不同表单区块间导航,在填写或查看渠道配置时用户体验较差。

What / 做了什么

  • Added up/down arrow navigation buttons in the form footer (left side)
  • Implemented smooth scrolling between 5 main form sections
  • Added circular button design with hover tooltips for better UX
  • Supports cyclic navigation (last → first, first → last)
  • Dynamically handles API Config section visibility based on channel type
  • 在表单底部(左侧)新增上下箭头导航按钮
  • 实现5个主要表单区块间的平滑滚动跳转
  • 采用圆形按钮设计,带悬停提示,提升用户体验
  • 支持循环导航(最后一个→第一个,第一个→最后一个)
  • 根据渠道类型动态处理API配置区块的显示状态
feat-newapi

Summary by CodeRabbit

  • New Features
    • Channel Edit/Create modal now uses a multi-section layout (Basic Info, API Config, Model Config, Advanced Settings, Extra Settings) with smooth in-modal navigation.
    • Added up/down navigation controls in the modal footer to jump between sections and auto-scroll to the selected section.
    • Navigation state resets on reopen/reset to start at the first section, improving clarity and flow.
    • Section focusing enhances usability for long forms and speeds up configuration.

@coderabbitai

coderabbitai Bot commented Sep 28, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

Adds section-based navigation to the EditChannelModal: per-section refs, currentSectionIndex and navigation helpers, 2FA verification state, a form container ref, and Up/Down chevron footer controls to scroll between sections. Navigation state resets on open/close and when relevant modal state updates.

Changes

Cohort / File(s) Summary
Channel modal section navigation
web/src/components/table/channels/modals/EditChannelModal.jsx
Adds per-section refs (basicInfo, apiConfig, modelConfig, advancedSettings, channelExtraSettings), formContainerRef, currentSectionIndex, formSections and navigation helpers (scrollToSection, navigateToSection); introduces 2FA verification state/hooks; injects IconChevronUp/IconChevronDown footer controls with tooltips; scrolls to target sections and resets navigation state on open/close/reset; conditionally handles apiConfig visibility (showApiConfigCard).

Sequence Diagram(s)

sequenceDiagram
  actor U as User
  participant M as EditChannelModal
  participant R as Section Refs
  participant V as Viewport

  U->>M: Open modal
  activate M
  M->>M: reset currentSectionIndex = 0
  M->>R: attach refs to sections (basicInfo, apiConfig?, modelConfig, advancedSettings, channelExtraSettings)
  M->>V: scrollToSection(0)

  U->>M: Click ChevronDown
  alt next section available
    M->>M: currentSectionIndex++
    M->>R: resolve target ref
    M->>V: scrollToSection(target)
  else no next
    M->>M: noop
  end

  U->>M: Click ChevronUp
  alt previous section available
    M->>M: currentSectionIndex--
    M->>R: resolve target ref
    M->>V: scrollToSection(target)
  else no previous
    M->>M: noop
  end

  U->>M: Close/Reset modal
  M->>M: reset currentSectionIndex = 0
  deactivate M
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

I hop through forms in tidy lines,
From basic beans to model pines—
A tap, a scroll, the sections glide,
With chevrons pointing, I joyride.
Five little fields, in ordered sets,
A rabbit’s route with no regrets. 🐇⬆️⬇️

Pre-merge checks and finishing touches

✅ 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 clearly summarizes the primary change by stating that navigation buttons are being added for the channel edit form sections, which directly reflects the implementation of up/down arrow controls and section navigation in the modal as described in the PR.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

📜 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 3ed0ae8 and e904359.

📒 Files selected for processing (1)
  • web/src/components/table/channels/modals/EditChannelModal.jsx (12 hunks)

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.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6659a8a and 3ed0ae8.

📒 Files selected for processing (1)
  • web/src/components/table/channels/modals/EditChannelModal.jsx (11 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
PR: QuantumNous/new-api#1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the applyModelMapping function transforms the models list by replacing original model names (mapping values) with display names (mapping keys). The database stores this transformed list containing mapped keys. On channel load, data.models contains these mapped display names, making the initialization filter if (data.models.includes(key)) correct.

Applied to files:

  • web/src/components/table/channels/modals/EditChannelModal.jsx

Comment on lines +256 to +273
const navigateToSection = (direction) => {
const availableSections = formSections.filter(section => {
if (section === 'apiConfig') {
return showApiConfigCard;
}
return true;
});

let newIndex;
if (direction === 'up') {
newIndex = currentSectionIndex > 0 ? currentSectionIndex - 1 : availableSections.length - 1;
} else {
newIndex = currentSectionIndex < availableSections.length - 1 ? currentSectionIndex + 1 : 0;
}

setCurrentSectionIndex(newIndex);
scrollToSection(availableSections[newIndex]);
};

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.

⚠️ Potential issue | 🟠 Major

Fix navigation index when sections collapse.

When showApiConfigCard flips to false the buttons should skip the API block, but currentSectionIndex still points to the old slot from formSections. Pressing Down in that state jumps straight from “基本信息” to “高级设置”, because we increment a stale index. Same problem exists for the Up button.

Please normalise the current position against availableSections before advancing and then persist the canonical index (or switch to storing the section key). One way to address it:

-    let newIndex;
-    if (direction === 'up') {
-      newIndex = currentSectionIndex > 0 ? currentSectionIndex - 1 : availableSections.length - 1;
-    } else {
-      newIndex = currentSectionIndex < availableSections.length - 1 ? currentSectionIndex + 1 : 0;
-    }
-
-    setCurrentSectionIndex(newIndex);
-    scrollToSection(availableSections[newIndex]);
+    const currentKey = formSections[currentSectionIndex];
+    const normalizedIndex = Math.max(
+      availableSections.indexOf(currentKey),
+      0,
+    );
+
+    let newIndex;
+    if (direction === 'up') {
+      newIndex =
+        normalizedIndex > 0
+          ? normalizedIndex - 1
+          : availableSections.length - 1;
+    } else {
+      newIndex =
+        normalizedIndex < availableSections.length - 1
+          ? normalizedIndex + 1
+          : 0;
+    }
+
+    const targetKey = availableSections[newIndex] ?? availableSections[0];
+    if (!targetKey) {
+      return;
+    }
+    setCurrentSectionIndex(formSections.indexOf(targetKey));
+    scrollToSection(targetKey);

This keeps navigation aligned with the filtered list and prevents skipping sections.

📝 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
const navigateToSection = (direction) => {
const availableSections = formSections.filter(section => {
if (section === 'apiConfig') {
return showApiConfigCard;
}
return true;
});
let newIndex;
if (direction === 'up') {
newIndex = currentSectionIndex > 0 ? currentSectionIndex - 1 : availableSections.length - 1;
} else {
newIndex = currentSectionIndex < availableSections.length - 1 ? currentSectionIndex + 1 : 0;
}
setCurrentSectionIndex(newIndex);
scrollToSection(availableSections[newIndex]);
};
const navigateToSection = (direction) => {
const availableSections = formSections.filter(section => {
if (section === 'apiConfig') {
return showApiConfigCard;
}
return true;
});
const currentKey = formSections[currentSectionIndex];
const normalizedIndex = Math.max(
availableSections.indexOf(currentKey),
0,
);
let newIndex;
if (direction === 'up') {
newIndex =
normalizedIndex > 0
? normalizedIndex - 1
: availableSections.length - 1;
} else {
newIndex =
normalizedIndex < availableSections.length - 1
? normalizedIndex + 1
: 0;
}
const targetKey = availableSections[newIndex] ?? availableSections[0];
if (!targetKey) {
return;
}
setCurrentSectionIndex(formSections.indexOf(targetKey));
scrollToSection(targetKey);
};
🤖 Prompt for AI Agents
In web/src/components/table/channels/modals/EditChannelModal.jsx around lines
256-273, the navigation uses a stale currentSectionIndex from the full
formSections list when showApiConfigCard toggles off, causing jumps; normalize
the current position against the filtered availableSections before advancing:
compute the current section key (e.g. formSections[currentSectionIndex]), find
its index in availableSections (fallback to 0 if missing), use that normalized
index to compute the up/down newIndex, then call
setCurrentSectionIndex(newIndex) and
scrollToSection(availableSections[newIndex]); alternatively persist section
selection by key instead of an index so toggling sections cannot leave an
invalid index.

@seefs001
seefs001 changed the base branch from main to alpha October 2, 2025 06:12
@seefs001
seefs001 merged commit 92a4e88 into QuantumNous:alpha Oct 2, 2025
1 check was pending
x22x22 pushed a commit to x22x22/new-api that referenced this pull request Apr 24, 2026
…l-block-edit

feat: Add navigation buttons for channel edit form sections
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.

2 participants