mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[GH-ISSUE #5371] [Feature]: Batch Edit Selected Clients — Modify Common Parameters Across Multiple Clients at Once #3757
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#3757
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jshir700 on GitHub (Jun 16, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5371
Is your feature request related to a problem?
The client management page already has a mature bulk operations system — row selection with checkboxes, a toolbar with dedicated buttons for attach/detach/group/delete, and a "More" dropdown with adjust, sub-links, and bulk add. For an operator managing hundreds of clients, this is a solid foundation.
But there's a significant gap. The only batch operation that modifies client settings is Adjust (
ClientBulkAdjustModal), and it only supports additive/incremental changes — add days to expiry, add traffic to balance. You cannot set client properties to specific values in bulk.Consider these common scenarios that have no batch solution today:
limitIpfrom 0 to 3 on all bronze-tier clientscommentorgroupfield across a client batchtotalGB(not add, but set to) on a batchexpiryTime(not +days, but a fixed date)flowfrom none toxtls-rprx-visionon VLESS clientsThe client form (
ClientFormModal.tsx) exposes ~19 user-facing parameters across 3 tabs (Basics, Credentials, Links). The batch adjust modal covers exactly 2 of them (addDays, addGB), and those are the additive variant, not set-to-value.Meanwhile, the toolbar infrastructure is already there — the selected-count tag, the button group, the modal-based workflow. What's missing is a batch edit modal that lets you pick which fields to change and set them to specific values, leaving everything else untouched.
Describe the solution you'd like
The core idea mirrors the inbound batch edit: select multiple clients → click "Batch Edit" → pick the fields to change → apply once.
The same design principles apply:
Backend — new API endpoint
POST /panel/api/clients/bulkUpdateRequest body:
Semantics:
"fields"— only non-null keys are applied. Omitted/null keys are left untouched per client."credentials"— protocol-gated fields (flow, security). Applied only to clients whose inbounds support those settings."inboundChanges"— optional array of inbound IDs to attach and/or detach across all selected clients. Both are optional — omit to leave inbound membership untouched.Response:
Each client is updated independently via the existing
UpdateByEmailservice method so validation (email uniqueness, inbound existence) works identically to the single-edit path. Partial success is reported — the operator only needs to re-check the skipped ones.Frontend — new
ClientBatchEditModalcomponentFile:
frontend/src/pages/clients/ClientBatchEditModal.tsxA modal with 3 tab pages that mirror the existing
ClientFormModallayout, keeping the mental model consistent:enable(three-state Switch),totalGB(InputNumber),expiryTime(DateTimePicker),limitIp(InputNumber),comment(Input),group(Select/AutoComplete),tgId(InputNumber, shown only when tgBot enabled),reset(InputNumber),inboundChanges(Select multi for attach/detach)tgIdonly shown when tgBot enabledflow(Select: none/vision/vision-udp443),security(Select: auto/aes-128-gcm/chacha20-poly1305/none/zero)flowshown only when selected clients have TLS-flow-capable inbounds;securityonly for VMESS inboundsexternalLinks— add new link/subscription entries (append-only; doesn't touch existing links)Three-state controls:
All fields start in a neutral state. The user explicitly sets a field to change it. Boolean fields (
enable) use a three-state Switch:For numeric and text fields, a checkbox or toggle beside each control lets the user "activate" it — when inactive, the field's value is not included in the request.
Current value preview:
Below each active control, a compact preview shows the current value of that field for each selected client, so the operator can verify the change is safe before applying:
How the user gets there
ClientBatchEditModal.Integration points (files to modify)
frontend/src/pages/clients/ClientsPage.tsxClientBatchEditModal; addbatchEditOpen+batchEditClientsstate; add "Batch Edit" button in toolbar when rows selected; wire to open modal; render<ClientBatchEditModal>frontend/src/pages/clients/ClientBatchEditModal.tsxinternal/web/controller/client.goClientBulkUpdateRequeststruct +bulkUpdatehandler that iterates emails + applies partial fieldsinternal/web/service/client.goUpdateClientPartialmethod that updates only non-null fields, reuses existingUpdateByEmailfor runtime syncinternal/web/web.goPOST /panel/api/clients/bulkUpdateinternal/web/translation/*.jsonHow this differs from the existing
ClientBulkAdjustModalThe existing
ClientBulkAdjustModalserves a different purpose. It's an incremental tool: "add X days to all these clients' expiry dates" or "add Y GB to all these clients' traffic balances." This is useful for extending service, but it's the only bulk edit the panel offers.The proposed
ClientBatchEditModalis a set-to-value tool: "set all these clients' totalGB to 100GB" or "set all these clients' limitIp to 3" or "disable all these clients." These are fundamentally different operations that require different UI (three-state controls, current-value preview) and different API semantics (partial update, not additive).Both modals should coexist — they target different use cases:
ClientBulkAdjustModal(incremental)ClientBatchEditModal(set-to-value)ClientBulkAdjustModal(incremental)ClientBatchEditModal(set-to-value)Alternatives you've considered
Run the existing
bulkAdjustN times to approximate a set. You can't.bulkAdjustis additive — it only supportsaddDaysandaddBytes. There is no way to "subtract" to reach a specific value, and even if you could, you'd need to know each client's current values, which varies per client.Single-edit modal for each client. The status quo. For 50+ clients this is prohibitive. The risk of parameter drift (slightly different values entered per client) is high, and the time cost scales linearly.
Script the REST API. Possible for a power user, but requires API-token auth, familiarity with the client JSON payload (which varies by protocol — VMESS uses
id, Trojan usespassword, SS usesemail), and manual error handling. Most panel operators are not developers.Extend
ClientBulkAdjustModalto support set-to-value mode. The existing modal is built for two specific additive fields. Adding set-to-value semantics (with three-state controls, current-value preview, and non-additive field dispatch) would completely change its character. It's cleaner to have a dedicated modal with a unified pattern, just like the single-editClientFormModalalready has a different shape fromClientBulkAdjustModal.Concrete use cases
Use case 1: Bulk disable stale clients. You run a monthly cleanup where ~200 clients with expired subscriptions should be disabled (not deleted — they might re-subscribe and need their history). Currently you must open each one and uncheck "enable." With batch edit: filter by "expiry before date" → select all → Batch Edit → Basics → set Enable to Off → Apply. 10 seconds instead of 30+ minutes.
Use case 2: Tier migration. You decide to increase the
limitIpon all "premium" clients from 3 to 5. You have 85 premium clients. Without batch edit: you open each form and change limitIp, one by one. With batch edit: filter by group "premium" → select all → Batch Edit → set limitIp → Apply. 5 seconds.Use case 3: Bulk protocol migration. You migrate from VMESS to VLESS and need to update the flow control on 60 VLESS clients from "none" to
xtls-rprx-vision. Without batch edit: 60 individual edits. With batch edit: select the 60 → Batch Edit → Credentials → set Flow → Apply. 5 seconds.Use case 4: Server migration comment. You're migrating 120 clients from server A to server B. You want to set their
commentfield to "Migrated to server B — June 2026" so support staff know where they are. Without batch edit: not achievable in bulk — you'd have to script the API or do 120 manual edits. With batch edit: select the 120 → Batch Edit → set comment → Apply.Use case 5: Uniform traffic cap. A promotional campaign gives 50 new clients a 500GB traffic cap. After the campaign ends, you need to set (not add) their
totalGBto exactly 100GB. The existing bulkAdjust only adds traffic — you can't reduce. With batch edit: select the 50 → Batch Edit → set totalGB → Apply. 5 seconds.Appendix: i18n keys
pages.clients.batchEditClientspages.clients.batchEditTabBasicspages.clients.batchEditTabCredentialspages.clients.batchEditTabLinkspages.clients.batchEditKeepOriginalpages.clients.batchEditApplypages.clients.batchEditSavedpages.clients.batchEditPartialErrorpages.clients.batchEditAttachInboundspages.clients.batchEditDetachInboundspages.clients.batchEditNoMatchingClientspages.clients.batchEditAndMorepages.clients.batchEditShowCurrentMockups, screenshots, or examples
No response
Which parts of the panel would this affect?
Backend (API endpoints, login, settings)
Are you willing to help?
Before submitting
@github-actions[bot] commented on GitHub (Jun 16, 2026):
The gap you describe is confirmed in the source. The existing
POST /panel/api/clients/bulkAdjustendpoint (registered ininternal/web/controller/client.go:62) accepts onlyemails,addDays, andaddBytes— strictly additive adjustments. The correspondingClientBulkAdjustModal.tsxreflects exactly this: twoInputNumberfields and no set-to-value semantics. There is nobulkUpdate(set-to-value) endpoint or modal anywhere in the codebase.What already exists that a PR could build on:
POST /panel/api/clients/update/:email, handled by(ClientController).updateininternal/web/controller/client.go:153, which calls(ClientService).UpdateByEmailininternal/web/service/client_crud.go:569. That method does a full replacement of themodel.Clientfields inside each inbound's settings JSON and propagates to the Xray runtime and any attached nodes.BulkDelete,BulkAdjust,BulkAttach,BulkDetach) ininternal/web/service/client_bulk.goall follow the same pattern: deduplicate emails → group by inbound → one read-modify-write per inbound → single DB transaction per inbound → broadcastnotifyClientsChanged(). A newBulkUpdateservice method would follow the same structure.frontend/src/pages/clients/ClientsPage.tsxalready wires upselectedRowKeys, the selection count tag, and lazy-loaded modals (ClientBulkAdjustModal,BulkAttachInboundsModal,BulkDetachInboundsModal,BulkAddToGroupModal) — adding a new button and a new lazy-imported modal fits the existing pattern directly.Design considerations for an implementation:
BulkUpdateservice method should not reuseUpdateByEmailin a loop; doing so would re-read and re-write each inbound's settings JSON once per email, which is the same O(emails × inbounds) pattern the existing bulk methods deliberately avoid. The inbound-grouping pattern frombulkAdjustInboundClients/bulkDelInboundClientsis the right model.UpdateByEmailinclient_crud.gotakes a fullmodel.Clientvalue — partial/set-to-value semantics would require either a separate struct with pointer/nullable fields or amap[string]anypatch approach, similar to howbulkAdjustInboundClientsapplies fields selectively to the inbound settings JSON (map[string]any).flow, VMesssecurity) require reading the inbound's protocol before deciding whether to write the field, so the per-inbound grouping naturally accommodates this.enablefield lives only in the inbound settings JSON client entry;totalGBandexpiryTimeare mirrored in both the inbound JSON and theclient_trafficstable (astotalandexpiry_time). A correct implementation must update both locations, asbulkAdjustInboundClientsdoes at lines 401–414 ofclient_bulk.go.A PR implementing this would touch:
internal/web/service/client_bulk.go(newBulkUpdatemethod),internal/web/controller/client.go(new handler + struct), the route group ininitRouter, and the frontend (ClientBatchEditModal.tsx+ wiring inClientsPage.tsx+ i18n keys).This reply was generated automatically; a maintainer may follow up.