mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #5214] [CLOSED] [Feature] Sort inbounds by sorting index. #5822
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#5822
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?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/5214
Author: @Ponywka
Created: 6/11/2026
Status: ❌ Closed
Base:
main← Head:feature/inbound-sorting📝 Commits (4)
2548041feat(backend): add sorting index field to inboundsc30756bfeat(api): add sorting index field to inboundsc7b305dfeat(frontend): add sorting index to inbound edit modal and tablecd536dbMerge branch 'main' into feature/inbound-sorting📊 Changes
31 files changed (+419 additions, -9 deletions)
View changed files
📝
frontend/public/openapi.json(+6 -0)📝
frontend/src/generated/examples.ts(+1 -0)📝
frontend/src/generated/schemas.ts(+5 -0)📝
frontend/src/generated/types.ts(+1 -0)📝
frontend/src/generated/zod.ts(+1 -0)📝
frontend/src/lib/xray/inbound-form-adapter.ts(+4 -0)📝
frontend/src/models/dbinbound.ts(+3 -0)📝
frontend/src/pages/inbounds/form/InboundFormModal.tsx(+8 -0)📝
frontend/src/pages/inbounds/list/types.ts(+1 -0)📝
frontend/src/pages/inbounds/list/useInboundColumns.tsx(+7 -0)📝
frontend/src/schemas/forms/inbound-form.ts(+1 -0)📝
frontend/src/test/__snapshots__/inbound-form-modal.test.tsx.snap(+10 -0)📝
frontend/src/test/inbound-form-adapter.test.ts(+46 -1)📝
internal/database/model/model.go(+1 -0)📝
internal/sub/service.go(+1 -1)📝
internal/web/service/inbound.go(+8 -7)📝
internal/web/service/inbound_node.go(+1 -0)➕
internal/web/service/inbound_sorting_test.go(+288 -0)📝
internal/web/translation/ar-EG.json(+2 -0)📝
internal/web/translation/en-US.json(+2 -0)...and 11 more files
📄 Description
Summary
Adds a
sortingIndexfield to inbounds that lets operators control the display order of the inbound list.Why
The inbound list previously returned results in insertion order, making it hard to keep related inbounds together or promote frequently-used entries to the top. A numeric sort index gives operators explicit control without requiring them recreate inbounds.
Type of change
Areas affected
How was this tested?
Manual UI test - inbound list ordering
I created 10 inbounds through the panel UI.
The first five were added in this order:
They were created out of order on purpose, to make sure the list is sorted by
sortingIndex, not by creation order.Then I added five more entries named
Spacing, using the same sorting index values:This was done to check the secondary ordering by
id ASCwhen several inbounds have the samesortingIndex.After saving, the inbound list was shown in this order:
This confirms that inbounds are sorted by
sorting_index ASC, and entries with the same value are sorted byid ASC.Backend unit tests
Added 8 Go tests in
internal/web/service/inbound_sorting_test.go.Covered cases:
UpdateInboundsavesSortingIndex, including an explicit0GetInboundssorts bysorting_index ASC, then byid ASC0and positive valuesGetAllInbounds,SearchInbounds,GetInboundTags, andGetInboundsByTrafficResetalso respectsorting_index ASCFrontend unit tests
Added 8 Vitest tests in
src/test/inbound-form-adapter.test.ts.Covered cases:
rawInboundToFormValuesuses0whensortingIndexis missingsortingIndexvalues are preservedformValuesToWirePayloadincludessortingIndexin the payloadraw → values → payloadkeeps the value unchangedInboundFormBaseSchemarejects values outside the allowed range (> 32767,< -32768)Screenshots / recordings
Breaking changes
GORM adds the
sorting_indexcolumn automatically on first start (auto-migrate). Existing rows getDEFAULT 0, so all current inbounds share the same index and continue to sort by id ASC - identical to previous behavior. No manual migration or config change required.Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.