Feat/auto group (#6590)
* feat(token): support custom auto group order * feat(keys): enhance auto group presentation * fix(keys): rework Auto flow border and compact inherited order The Auto group highlight previously tinted the whole control surface with a gradient and animated only a 1px top sweep, which read as a background color rather than a flowing border. Replace it with a border-only effect: an aria-hidden, pointer-events-none overlay whose conic gradient is masked down to a thin ring hugging the rounded perimeter, so the highlight travels around all four edges and corners every 3.2s. The interior stays neutral with a restrained static primary border and glow; prefers-reduced-motion hides the moving layer while keeping the static emphasis. The inherited global Auto order also rendered as spacious two-line rows with circular sequence markers, wasting drawer space. Render it as a compact wrapping strip of one-line chips (index, name, ratio badge) with descriptions kept accessible via title and sr-only text, scrolling only past a much smaller max height. Custom add/remove/reorder editing, empty-array inheritance semantics, and the submit payload are unchanged. * fix(keys): preserve Auto inheritance and unify effects * refactor(keys): temporarily disable AutoGroupBadge in api-key-group-cell
This commit is contained in:
@@ -273,6 +273,34 @@ func getTokenKeyColumnType(t *testing.T, db *gorm.DB, dialect string) string {
|
||||
}
|
||||
}
|
||||
|
||||
func getTokenAutoGroupsColumnType(t *testing.T, db *gorm.DB, dialect string) string {
|
||||
t.Helper()
|
||||
|
||||
switch dialect {
|
||||
case "sqlite":
|
||||
return getSQLiteColumnType(t, db, "tokens", "auto_groups")
|
||||
case "mysql":
|
||||
var columnType string
|
||||
if err := db.Raw(`SELECT DATA_TYPE FROM information_schema.columns
|
||||
WHERE table_schema = DATABASE() AND table_name = ? AND column_name = ?`,
|
||||
"tokens", "auto_groups").Scan(&columnType).Error; err != nil {
|
||||
t.Fatalf("failed to inspect mysql token auto_groups column: %v", err)
|
||||
}
|
||||
return strings.ToLower(columnType)
|
||||
case "postgres":
|
||||
var dataType string
|
||||
if err := db.Raw(`SELECT data_type FROM information_schema.columns
|
||||
WHERE table_schema = current_schema() AND table_name = ? AND column_name = ?`,
|
||||
"tokens", "auto_groups").Scan(&dataType).Error; err != nil {
|
||||
t.Fatalf("failed to inspect postgres token auto_groups column: %v", err)
|
||||
}
|
||||
return strings.ToLower(dataType)
|
||||
default:
|
||||
t.Fatalf("unsupported dialect %q", dialect)
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func runTokenMigrationCompatibilityTest(t *testing.T, db *gorm.DB, dialect string, managedTokensTable *bool) {
|
||||
t.Helper()
|
||||
|
||||
@@ -314,6 +342,12 @@ func runTokenMigrationCompatibilityTest(t *testing.T, db *gorm.DB, dialect strin
|
||||
if got := getTokenKeyColumnType(t, db, dialect); got != "varchar(128)" {
|
||||
t.Fatalf("expected migrated key column type varchar(128), got %q", got)
|
||||
}
|
||||
if !db.Migrator().HasColumn(&model.Token{}, "auto_groups") {
|
||||
t.Fatal("expected migration to add auto_groups column")
|
||||
}
|
||||
if got := getTokenAutoGroupsColumnType(t, db, dialect); got != "text" {
|
||||
t.Fatalf("expected migrated auto_groups column type text, got %q", got)
|
||||
}
|
||||
|
||||
var migratedToken model.Token
|
||||
if err := db.First(&migratedToken, "name = ?", "legacy-token").Error; err != nil {
|
||||
@@ -325,6 +359,9 @@ func runTokenMigrationCompatibilityTest(t *testing.T, db *gorm.DB, dialect strin
|
||||
if migratedToken.Name != "legacy-token" {
|
||||
t.Fatalf("expected migrated token name to be preserved, got %q", migratedToken.Name)
|
||||
}
|
||||
if migratedToken.AutoGroups != "" {
|
||||
t.Fatalf("expected legacy token to inherit global Auto groups, got %q", migratedToken.AutoGroups)
|
||||
}
|
||||
|
||||
inserted := model.Token{
|
||||
UserId: 8,
|
||||
@@ -362,6 +399,9 @@ func TestTokenAutoMigrateUsesVarchar128KeyColumn(t *testing.T) {
|
||||
if got := getTokenKeyColumnType(t, db, "sqlite"); got != "varchar(128)" {
|
||||
t.Fatalf("expected key column type varchar(128), got %q", got)
|
||||
}
|
||||
if got := getSQLiteColumnType(t, db, "tokens", "auto_groups"); got != "text" {
|
||||
t.Fatalf("expected auto_groups column type text, got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTokenMigrationFromChar48ToVarchar128(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user