mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-25 15:25:01 +03:00
feat(hosts): add drag-and-drop and global subscription ordering (#6895)
Hosts already had one saved order on the Hosts page, but subscriptions honoured it only inside each inbound, so a host of a later inbound could never come before one of an earlier inbound (#6894). A new opt-in setting makes raw/base64, Clash/Mihomo and JSON subscriptions follow the Hosts page order across inbounds; the default keeps today's inbound-first output unchanged. The Hosts table gains drag-and-drop reordering next to the Up/Down buttons, on a pointer-reorder hook the Routing Rules table now shares.
This commit is contained in:
@@ -4,6 +4,34 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSubHostSortModePersistsAndRejectsInvalidValues(t *testing.T) {
|
||||
setupSettingTestDB(t)
|
||||
s := &SettingService{}
|
||||
settings, err := s.GetAllSetting()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if settings.SubHostSortMode != "inbound-first" {
|
||||
t.Fatalf("default = %q", settings.SubHostSortMode)
|
||||
}
|
||||
settings.SubHostSortMode = "hosts-first"
|
||||
if err := s.UpdateAllSetting(settings, SecretClears{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
reloaded, err := s.GetAllSetting()
|
||||
if err != nil || reloaded.SubHostSortMode != "hosts-first" {
|
||||
t.Fatalf("reloaded mode = %+v, err=%v", reloaded, err)
|
||||
}
|
||||
settings.SubHostSortMode = "invalid"
|
||||
if err := s.UpdateAllSetting(settings, SecretClears{}); err == nil || err.Error() != "subscription host sort mode must be inbound-first or hosts-first" {
|
||||
t.Fatalf("invalid mode error = %v", err)
|
||||
}
|
||||
mode, err := s.GetSubHostSortMode()
|
||||
if err != nil || mode != "hosts-first" {
|
||||
t.Fatalf("invalid save changed mode: %q, %v", mode, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSubInfoNodeSettingsDefaultsAndPersists(t *testing.T) {
|
||||
setupSettingTestDB(t)
|
||||
s := &SettingService{}
|
||||
|
||||
Reference in New Issue
Block a user