Skip to content

feat: default custom topup amount to 100 - #5337

Open
QLHazyCoder wants to merge 4 commits into
QuantumNous:mainfrom
QLHazyCoder:codex/topup-default-amount-100
Open

feat: default custom topup amount to 100#5337
QLHazyCoder wants to merge 4 commits into
QuantumNous:mainfrom
QLHazyCoder:codex/topup-default-amount-100

Conversation

@QLHazyCoder

@QLHazyCoder QLHazyCoder commented Jun 5, 2026

Copy link
Copy Markdown

Summary

  • decouple the default custom topup amount from the minimum allowed topup amount
  • default the custom topup input to 100 while preserving the configured minimum topup floor
  • apply the same initialization behavior to both the default and classic wallet topup pages

Testing

  • �un run build (web/default)
  • �un run typecheck (web/default)
  • �unx eslint src/components/topup/index.jsx src/components/topup/RechargeCard.jsx (web/classic)
  • �un run build (web/classic) -> fails due to existing @lobehub/ui / React export use compatibility issue in dependencies, unrelated to this change
  • local browser check of web/default dev server hit existing backend 500 responses on /api/status, /api/notice, and /api/home_page_content, so runtime wallet-page verification was blocked by environment

Summary by CodeRabbit

  • Bug Fixes

    • Top-up input now enforces the configured minimum amount consistently when editing or blurring the input.
    • Initial/default top-up value now respects both the app’s default preference and the current minimum constraint.
  • New Features

    • Admin settings: new "Default top-up amount" configurable in billing/payment settings.
  • Localization

    • Added translations for the new default top-up label and help text (en/fr/ja/ru/vi/zh).
  • Chores

    • Updated CI to improve multi-architecture image build and publishing.

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Need an answer fast? Review this PR in Change Stack to ask focused questions about the PR or a changed range.

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 83e850a6-be02-4a77-9e0d-f4e94f165b33

📥 Commits

Reviewing files that changed from the base of the PR and between bf16298 and 1a704ad.

📒 Files selected for processing (17)
  • controller/topup.go
  • setting/operation_setting/payment_setting.go
  • web/classic/src/components/settings/PaymentSetting.jsx
  • web/classic/src/components/topup/index.jsx
  • web/classic/src/pages/Setting/Payment/SettingsGeneralPayment.jsx
  • web/default/src/features/system-settings/billing/index.tsx
  • web/default/src/features/system-settings/billing/section-registry.tsx
  • web/default/src/features/system-settings/integrations/payment-settings-section.tsx
  • web/default/src/features/system-settings/types.ts
  • web/default/src/features/wallet/lib/payment.ts
  • web/default/src/features/wallet/types.ts
  • web/default/src/i18n/locales/en.json
  • web/default/src/i18n/locales/fr.json
  • web/default/src/i18n/locales/ja.json
  • web/default/src/i18n/locales/ru.json
  • web/default/src/i18n/locales/vi.json
  • web/default/src/i18n/locales/zh.json
✅ Files skipped from review due to trivial changes (3)
  • web/default/src/features/wallet/types.ts
  • web/default/src/i18n/locales/ja.json
  • web/default/src/i18n/locales/zh.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/classic/src/components/topup/index.jsx

Walkthrough

Refactors the Docker multi-arch publish workflow (dynamic versioning, conditional Docker Hub publish/sign, conditional manifests) and normalizes front-end top-up defaults by introducing clamped defaults, a backend setting, and wiring across admin UIs and translations.

Changes

Docker Build Workflow Restructure

Layer / File(s) Summary
Workflow triggers and version resolution
.github/workflows/docker-build.yml
Workflow triggers now target main with refined filters; workflow_dispatch accepts optional ref. Version resolution computes IMAGE_VERSION and PUBLISH_LATEST and exposes them for downstream jobs.
Auth, image naming, metadata, build/push
.github/workflows/docker-build.yml
Detects Docker Hub publish capability; GHCR login is unconditional. Builds compute GHCR_IMAGE, generate arch-suffixed version tags and optional latest-<arch> tags, and publish conditionally to Docker Hub when enabled.
Signing, manifests, and summaries
.github/workflows/docker-build.yml
Cosign signing for GHCR (and Docker Hub when enabled); manifest creation always makes GHCR version manifests, GHCR latest only when publish_latest is true, and Docker Hub manifests/tags only when dockerhub_enabled is true. Step summaries reflect conditional outputs.

Top-up Default Amount Normalization

Layer / File(s) Summary
Classic component defaults
web/classic/src/components/topup/index.jsx, web/classic/src/components/topup/RechargeCard.jsx
Adds getDefaultTopUpCount(minAmount, defaultAmount=100) (clamped), initializes TopUp topUpCount from it, sets topupInfo.default_topup_amount, updates getTopupInfo() to use clamped default, and enforces minTopUp on RechargeCard blur.
Wallet feature defaults
web/default/src/features/wallet/constants.ts, web/default/src/features/wallet/lib/payment.ts, web/default/src/features/wallet/index.tsx, web/default/src/features/wallet/types.ts
Adds DEFAULT_CUSTOM_TOPUP_AMOUNT = 100 and exported getDefaultCustomTopupAmount(topupInfo) returning the max of configured default and normalized minimum; wallet initializes topupAmount and initial payment calculation from this helper.
Backend setting and API exposure
setting/operation_setting/payment_setting.go, controller/topup.go
Adds PaymentSetting.DefaultTopUpAmount (default 100) and returns default_topup_amount in GetTopUpInfo response.
Admin UI, system defaults, types, and wiring
web/classic/src/pages/Setting/Payment/SettingsGeneralPayment.jsx, web/classic/src/components/settings/PaymentSetting.jsx, web/default/src/features/system-settings/*
Adds DefaultTopUpAmount form field, validation, initial state handling, change detection and option submission (payment_setting.default_topup_amount), system default value, and BillingSettings type mapping.
Translations
web/default/src/i18n/locales/*
Adds new UI label and help text translations for English, French, Japanese, Russian, Vietnamese, and Chinese.

Sequence Diagram(s)

sequenceDiagram
  participant Workflow as GitHub Action (docker-build)
  participant Version as Version step
  participant Build as build_single_arch
  participant Manifest as create_manifests
  participant GHCR as ghcr.io
  participant DockerHub as docker.io
  participant Cosign as cosign

  Workflow->>Version: compute IMAGE_VERSION & PUBLISH_LATEST
  Version->>Build: emit image_version, publish_latest
  Build->>GHCR: push arch-tagged images
  Build->>DockerHub: push arch-tagged images (if DOCKERHUB_ENABLED)
  Build->>Cosign: sign images for GHCR (and Docker Hub if enabled)
  Build->>Manifest: provide IMAGE_VERSION, PUBLISH_LATEST, DOCKERHUB_ENABLED
  Manifest->>GHCR: create version manifest (always) and latest manifest (if publish_latest)
  Manifest->>DockerHub: create manifests/tags (if dockerhub_enabled and publish_latest)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • QuantumNous/new-api#1823: Also modifies GetTopUpInfo output with additional top-up-related fields, overlapping the same handler/payload.
  • QuantumNous/new-api#2011: Refactors Docker Actions multi-arch build/manifest flow with downstream manifest creation similar to this PR.
  • QuantumNous/new-api#2014: Overlaps on Docker multi-arch publish workflow and manifest/tag generation.

Suggested reviewers

  • Calcium-Ion
  • seefs001

"🐰 I hop through CI and front-end carts,
Tagging arches, minding version parts,
One hundred coins set as the start,
Default toppers close to heart,
Ship images clean, and top-ups smart."

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: decoupling and setting the default custom top-up amount to 100 across both wallet implementations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/default/src/features/wallet/lib/payment.ts`:
- Around line 149-154: The function getDefaultCustomTopupAmount can return NaN
when getMinTopupAmount(topupInfo) yields a non-finite value; normalize the min
value before comparing by checking Number.isFinite on the result of
getMinTopupAmount(topupInfo) (or equivalent finite check) and fallback to a safe
numeric default (e.g., 0) when non-finite, then return
Math.max(DEFAULT_CUSTOM_TOPUP_AMOUNT, normalizedMin); update
getDefaultCustomTopupAmount to use the normalized minimum and keep the rest of
the logic intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 80749e0a-d52a-4ad0-b2ad-5fabea7b4d50

📥 Commits

Reviewing files that changed from the base of the PR and between adc390c and 711a031.

📒 Files selected for processing (6)
  • .github/workflows/docker-build.yml
  • web/classic/src/components/topup/RechargeCard.jsx
  • web/classic/src/components/topup/index.jsx
  • web/default/src/features/wallet/constants.ts
  • web/default/src/features/wallet/index.tsx
  • web/default/src/features/wallet/lib/payment.ts

Comment thread web/default/src/features/wallet/lib/payment.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant