Add provider key cycle stats reset handling

This commit is contained in:
fawney19
2026-05-07 03:23:20 +08:00
parent 6c0ac2e8da
commit 10e679bb2f
35 changed files with 1443 additions and 273 deletions

View File

@@ -107,7 +107,7 @@ describe('poolManagementState', () => {
status: 'all',
page: 1,
pageSize: 50,
sortBy: null,
sortBy: 'imported_at',
sortOrder: 'desc',
statsMode: 'current_cycle',
}),

View File

@@ -36,6 +36,7 @@ describe('poolMobilePresentation', () => {
canRefreshToken: true,
canClearCooldown: true,
canRecoverHealth: true,
canResetCycleStats: true,
canDownloadOrCopy: true,
hasProxy: true,
}),
@@ -43,6 +44,7 @@ describe('poolMobilePresentation', () => {
primary: [
'copy_or_download',
'refresh_token',
'reset_cycle_stats',
'clear_cooldown',
'recover_health',
'permissions',

View File

@@ -43,7 +43,7 @@ export const DEFAULT_POOL_MANAGEMENT_VIEW_STATE: PoolManagementViewState = {
status: 'all',
page: 1,
pageSize: 50,
sortBy: null,
sortBy: 'imported_at',
sortOrder: 'desc',
statsMode: 'current_cycle',
}
@@ -76,7 +76,7 @@ function normalizeSortBy(value: unknown): PoolManagementSortBy | null {
if (value === 'imported_at' || value === 'last_used_at') {
return value
}
return null
return DEFAULT_POOL_MANAGEMENT_VIEW_STATE.sortBy
}
function normalizeSortOrder(value: unknown): PoolManagementSortOrder {
@@ -156,6 +156,8 @@ export function buildPoolManagementQueryPatch(
): Record<string, string | undefined> {
const normalized = normalizeViewState(state)
const search = normalized.search.trim()
const isDefaultSort = normalized.sortBy === DEFAULT_POOL_MANAGEMENT_VIEW_STATE.sortBy
&& normalized.sortOrder === DEFAULT_POOL_MANAGEMENT_VIEW_STATE.sortOrder
return {
providerId: normalized.providerId || undefined,
@@ -166,8 +168,8 @@ export function buildPoolManagementQueryPatch(
normalized.pageSize === DEFAULT_POOL_MANAGEMENT_VIEW_STATE.pageSize
? undefined
: String(normalized.pageSize),
sortBy: normalized.sortBy || undefined,
sortOrder: normalized.sortBy ? normalized.sortOrder : undefined,
sortBy: isDefaultSort ? undefined : normalized.sortBy || undefined,
sortOrder: isDefaultSort ? undefined : normalized.sortBy ? normalized.sortOrder : undefined,
statsMode: normalized.statsMode === 'account_total' ? 'account_total' : undefined,
}
}

View File

@@ -21,6 +21,7 @@ export interface PoolMobileTagInput {
export type PoolMobileActionId =
| 'copy_or_download'
| 'refresh_token'
| 'reset_cycle_stats'
| 'clear_cooldown'
| 'recover_health'
| 'permissions'
@@ -33,6 +34,7 @@ export interface PoolMobileActionInput {
canDownloadOrCopy?: boolean
canRefreshToken?: boolean
showRefreshToken?: boolean
canResetCycleStats?: boolean
canClearCooldown?: boolean
canRecoverHealth?: boolean
hasProxy?: boolean
@@ -70,6 +72,9 @@ export function splitPoolMobileActions(input: PoolMobileActionInput): {
if (showRefreshToken) {
primary.push('refresh_token')
}
if (input.canResetCycleStats) {
primary.push('reset_cycle_stats')
}
if (input.canClearCooldown) {
primary.push('clear_cooldown')
}
@@ -92,6 +97,9 @@ export function splitPoolMobileActions(input: PoolMobileActionInput): {
if (showRefreshToken) {
primary.push('refresh_token')
}
if (input.canResetCycleStats) {
primary.push('reset_cycle_stats')
}
if (input.canClearCooldown) {
primary.push('clear_cooldown')
}