fix: defaut ui triage (#4802)
* fix: theme-aware payment paths, auto-group validation, route guards, perf group filtering - Add common.ThemeAwarePath to generate correct redirect URLs based on active theme (default vs classic), replacing hardcoded /console/* paths in 7 controllers and service/quota.go (#4765) - Validate auto-group availability against getUserGroups before defaulting form values; playground falls back to 'default' group when 'auto' is unavailable (#4796, #4799) - Enforce HeaderNavModules settings in rankings route (frontend + backend API) and SidebarModulesAdmin in playground route to block direct URL access when features are disabled (#4704, #4512) - Filter perf_metrics API response to only include currently configured groups, hiding stale data from deleted groups (#4790) - Preserve query params (pay=success/fail) in /console/topup → /wallet frontend redirect * fix: update hero section text and localization strings for clarity
This commit is contained in:
@@ -151,15 +151,7 @@ export function ApiKeysMutateDrawer({
|
||||
ratio: info.ratio,
|
||||
})
|
||||
)
|
||||
|
||||
// Add auto group if configured
|
||||
if (!groups.some((g) => g.value === 'auto')) {
|
||||
groups.unshift({
|
||||
value: 'auto',
|
||||
label: 'auto',
|
||||
desc: t('Auto (Circuit Breaker)'),
|
||||
})
|
||||
}
|
||||
const backendHasAuto = groups.some((g) => g.value === 'auto')
|
||||
|
||||
const form = useForm<ApiKeyFormValues>({
|
||||
resolver: zodResolver(apiKeyFormSchema),
|
||||
@@ -169,17 +161,28 @@ export function ApiKeysMutateDrawer({
|
||||
// Load existing data when updating
|
||||
useEffect(() => {
|
||||
if (open && isUpdate && currentRow) {
|
||||
// For update, fetch fresh data
|
||||
getApiKey(currentRow.id).then((result) => {
|
||||
if (result.success && result.data) {
|
||||
form.reset(transformApiKeyToFormDefaults(result.data))
|
||||
}
|
||||
})
|
||||
} else if (open && !isUpdate) {
|
||||
// For create, reset to defaults
|
||||
form.reset(getApiKeyFormDefaultValues(defaultUseAutoGroup))
|
||||
form.reset(getApiKeyFormDefaultValues(defaultUseAutoGroup && backendHasAuto))
|
||||
}
|
||||
}, [open, isUpdate, currentRow, form, defaultUseAutoGroup])
|
||||
}, [open, isUpdate, currentRow, form, defaultUseAutoGroup, backendHasAuto])
|
||||
|
||||
// Correct group after groups load: if the form value is not in available groups, fall back
|
||||
useEffect(() => {
|
||||
if (groups.length === 0) return
|
||||
const currentGroup = form.getValues('group')
|
||||
if (currentGroup && !groups.some((g) => g.value === currentGroup)) {
|
||||
const fallback = groups.find((g) => g.value === 'default')?.value ?? groups[0]?.value ?? ''
|
||||
form.setValue('group', fallback)
|
||||
if (currentGroup === 'auto') {
|
||||
form.setValue('cross_group_retry', false)
|
||||
}
|
||||
}
|
||||
}, [groups, form])
|
||||
|
||||
const onSubmit = async (data: ApiKeyFormValues) => {
|
||||
setIsSubmitting(true)
|
||||
|
||||
Reference in New Issue
Block a user