fix: add warning for pass through body - #2512
Conversation
WalkthroughThe pull request introduces request pass-through feature detection and user-facing warnings. It adds channel-level pass-through status checks in the channels table, conditionally displays alert icons next to channel names, adds a global pass-through warning banner, and expands localization strings across multiple languages to communicate that pass-through disables built-in NewAPI features. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
web/src/i18n/locales/en.json (1)
843-845: Pass‑through warnings read clearly; consider minor wording polish and naming consistencyThe three strings are technically accurate and clearly communicate that enabling pass‑through disables New API’s built‑in features and is not recommended. Two small, optional tweaks you might consider:
- Consistency: elsewhere this file uses “New API” (with a space, e.g., “New API project repository address”), while these new strings use “NewAPI”. Aligning on a single product name spelling would look more polished.
- Tone (optional only): “If this causes issues, please do not submit an issue.” is fairly direct. If you want a softer UX without changing meaning, something like “we can’t provide support for issues caused by this configuration” might feel less confrontational while still discouraging bug reports for self‑inflicted breakage.
If you’re happy with the existing tone and naming, the current strings are already serviceable.
web/src/i18n/locales/vi.json (1)
799-801: Vietnamese translations correctly mirror the new warnings; optional naming alignmentThe three Vietnamese lines accurately reflect the intent and detail of the source strings (channel vs global pass‑through, disabled built‑in features, non‑recommended usage, and no‑support note). No functional issues here.
If you decide to standardize the product name spelling in other locales (e.g., “New API” vs “NewAPI” in English), you may want to mirror that convention here as well for cross‑language consistency, but that’s purely cosmetic.
web/src/components/table/channels/ChannelsColumnDefs.jsx (1)
42-46: Pass-through detection helper and NAME column warning behavior are correct, with one small enhancement to consider
isRequestPassThroughEnabled(record)defensively handles missing records, tag rows (children), object vs JSON-stringsetting, and JSON parse failures; this is a good, low-risk helper.- NAME column now reuses the existing
remarktooltip asnameNodeand, when pass-through is enabled, decorates it with an alert icon and a separate explanatory tooltip, which is a clean UX.- Tag rows correctly skip pass-through evaluation via the
children !== undefinedguard.One small potential hardening: if
record.settingmay containpass_through_body_enabledas a non-boolean (e.g.,"true"or1), the strict=== truecheck will ignore it. If that’s possible from your API, consider normalizing via the sametoBooleanhelper used elsewhere in the app for options before comparing.Also applies to: 194-214, 248-305
web/src/hooks/channels/useChannelsData.jsx (1)
29-30: Global pass-through flag fetching and exposure look correct
- Importing
toBooleanand using it infetchGlobalPassThroughEnabledagainst/api/option/with keyglobal.pass_through_request_enabledis a reasonable way to normalize the stored value into a boolean.- Errors or malformed responses safely fall back to
falsewithout impacting the rest of the hook.- The initial
useEffectwires this fetch once on mount, andglobalPassThroughEnabledis cleanly exposed in the returned object forChannelsPageto consume.If you ever need the banner to react live to changes made in other admin screens without a full page reload, you could optionally call
fetchGlobalPassThroughEnabledinsiderefreshor after relevant mutations—but the current one-shot load is fine for most admin flows.Also applies to: 89-91, 92-108, 164-165, 1051-1052
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
web/src/components/table/channels/ChannelsColumnDefs.jsxweb/src/components/table/channels/index.jsxweb/src/hooks/channels/useChannelsData.jsxweb/src/i18n/locales/en.jsonweb/src/i18n/locales/fr.jsonweb/src/i18n/locales/ja.jsonweb/src/i18n/locales/ru.jsonweb/src/i18n/locales/vi.jsonweb/src/i18n/locales/zh.json
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
Repo: QuantumNous/new-api PR: 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/hooks/channels/useChannelsData.jsx
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
Repo: QuantumNous/new-api PR: 1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the database stores mapped keys (display names) in the models field after applying model mapping transformations. When loading a channel, data.models contains the mapped keys, not the original model names. The filtering logic if (data.models.includes(key)) in the initialization is correct.
Applied to files:
web/src/hooks/channels/useChannelsData.jsx
🧬 Code graph analysis (2)
web/src/components/table/channels/index.jsx (1)
web/src/components/table/channels/ChannelsTable.jsx (1)
channelsData(30-63)
web/src/hooks/channels/useChannelsData.jsx (1)
web/src/helpers/api.js (6)
res(224-224)res(225-225)res(301-301)res(302-302)API(29-37)API(29-37)
🔇 Additional comments (5)
web/src/i18n/locales/zh.json (1)
833-835: LGTM! Pass-through warning translations added.Three new Chinese translation keys have been added for pass-through functionality warnings. The keys serve different UI contexts (channel-specific vs. global, with/without issue submission guidance), which justifies having separate entries despite content similarity.
The translations clearly communicate that enabling pass-through will disable NewAPI's built-in features and advise users not to file issues related to this choice.
web/src/i18n/locales/fr.json (1)
851-853: LGTM! French translations align with source locale.The three French translation keys mirror the Chinese locale additions and maintain consistent messaging about pass-through functionality warnings. The translations appropriately convey:
- Channel-level and global pass-through scope
- Impact on NewAPI built-in features
- Guidance about issue reporting
The localization is properly integrated and ready for use.
web/src/i18n/locales/ru.json (1)
860-862: Pass-through warning translations look accurate and consistentThe Russian strings correctly capture the intent of the Chinese originals and match the keys referenced from the UI (banner and per-channel tooltip). No issues from an i18n or interpolation standpoint.
web/src/components/table/channels/index.jsx (1)
21-23: Global pass-through banner integration looks solidUsing
channelsData.globalPassThroughEnabledto gate theBannerand pulling the description viachannelsData.twith the dedicated i18n key is straightforward and keeps the concern localized to this page. Icon usage and simple spacing viastyle={{ marginBottom: 12 }}are also fine.Also applies to: 68-83
web/src/i18n/locales/ja.json (1)
799-801: Japanese pass-through warnings are well-localizedThe three new Japanese messages accurately reflect the Chinese source strings, including the “not best practice” guidance and the note about not filing issues if problems arise. Keys align with those used in the channels table and global banner.
…rough-body fix: add warning for pass through body
Summary by CodeRabbit
New Features
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.