Skip to content

feat: add copy button to User and Database Name in database credentials#4596

Open
ravindu0823 wants to merge 2 commits into
Dokploy:canaryfrom
ravindu0823:fix/db-credentials-copy-buttons
Open

feat: add copy button to User and Database Name in database credentials#4596
ravindu0823 wants to merge 2 commits into
Dokploy:canaryfrom
ravindu0823:fix/db-credentials-copy-buttons

Conversation

@ravindu0823

Copy link
Copy Markdown

What

Adds a copy-to-clipboard button to the User and Database Name fields in the Internal Credentials cards across all database types, making them consistent with the existing copy buttons on the Password and Internal Host fields.

Fixes #4495

Root cause

The Internal Credentials cards rendered User and Database Name as plain <Input disabled value=... /> with no copy affordance, while Password and Internal Connection URL already used ToggleVisibilityInput (which includes a copy button). ToggleVisibilityInput cannot be reused here because it masks the value as a password.

Fix

  • New component apps/dokploy/components/shared/copy-input.tsx: a visible Input paired with a copy Button, mirroring toggle-visibility-input.tsx. It exports a pure, testable helper copyToClipboard(value) that copies the value (via copy-to-clipboard), shows a sonner toast, and returns the value (falling back to "" for undefined).
  • Swapped the plain <Input> for <CopyInput> on the User / Database Name fields in the 6 credential components (postgres, mysql, mariadb — User + Database Name; mongo, redis, libsql — User only), keeping disabled and the existing value. The Input import is retained since other fields still use it.

Test

New TDD test apps/dokploy/__test__/utils/copy-input.test.ts mocks copy-to-clipboard and sonner, then asserts copyToClipboard copies the value, shows a toast, returns the value, and falls back to "" for undefined.

Confirmed RED first (module absent), then GREEN:

 ✓ __test__/utils/copy-input.test.ts (4 tests) 4ms

 Test Files  1 passed (1)
      Tests  4 passed (4)

Typecheck clean: pnpm --filter=dokploy run typecheck.

🤖 Generated with Claude Code

The Internal Credentials cards rendered User and Database Name as plain
disabled inputs with no copy affordance, unlike the Password and Internal
Host fields. Add a new CopyInput component (a visible input paired with a
copy button) and use it for the User and Database Name fields across all
database types.

Fixes Dokploy#4495

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ravindu0823 ravindu0823 requested a review from Siumauricio as a code owner June 9, 2026 09:10
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Jun 9, 2026
…submits

Address review: the shared Button does not default type to "button", so a
typeless button acts as type="submit". CopyInput is a reusable component; if
dropped inside a form its copy action would submit the form. Set type="button"
explicitly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add copy button to User and Database Name in database credentials

1 participant