[Fix] Mysql Users + Postgres Host fix#1161
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughHost-aware database user logic added: service contract methods (usesHost, databaseUserExists), host resolution/validation in create/update actions, enums updated for table display, controller and resource use a new DatabaseUserTable with conditional host column, UI components updated, and comprehensive tests added. ChangesDatabase User Host Support & Table Refactor
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR addresses database-user handling differences between MySQL-style engines (user identity includes host) and PostgreSQL (no host-based user identity), and updates the database-users UI to use the app’s VitoTable/InertiaTable setup.
Changes:
- Introduces engine-aware “uses host” + “user exists” behavior on the database service layer, and updates create/update validations accordingly.
- Migrates the Database Users index page to
VitoTable, including a custom cell renderer for linked databases and conditional display of thehostcolumn. - Expands feature tests to cover host-collision rules, PostgreSQL behavior, and host validation/hardening.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Feature/DatabaseUserTest.php | Adds coverage for host uniqueness rules (MySQL) and host-less behavior (PostgreSQL), plus UI column visibility assertions. |
| resources/js/vito-table-setup.ts | Registers a custom cell component for InertiaTable rendering. |
| resources/js/types/database-user.d.ts | Adds permission_color to match UI/table display needs. |
| resources/js/pages/database-users/index.tsx | Switches to VitoTable + dropdown actions; passes usesHost into dialogs/components. |
| resources/js/pages/database-users/components/edit-database-user.tsx | Hides remote/host fields when the engine doesn’t use hosts. |
| resources/js/pages/database-users/components/create-database-user.tsx | Adds usesHost gating and switches submit to a real form submit button. |
| resources/js/pages/database-users/components/columns.tsx | Removes old TanStack table column definitions (replaced by InertiaTable). |
| resources/js/components/database-user-databases.tsx | New cell component to render linked databases as badges (or “-” when empty). |
| app/Tables/Servers/DatabaseUserTable.php | New InertiaTable definition with conditional host column and component-based databases column. |
| app/Services/Database/Postgresql.php | Declares usesHost() = false and overrides existence checks to be username-only. |
| app/Services/Database/Database.php | Extends the database service contract with usesHost() and databaseUserExists(). |
| app/Services/Database/AbstractDatabase.php | Provides default host-based implementations for engines like MySQL/MariaDB. |
| app/Http/Resources/DatabaseUserResource.php | Returns permission text + color (consistent with enum UI display expectations). |
| app/Http/Controllers/DatabaseUserController.php | Uses DatabaseUserTable for the index payload and toggles host column based on engine. |
| app/Enums/DatabaseUserStatus.php | Implements HasTableDisplay for InertiaTable enum rendering. |
| app/Enums/DatabaseUserPermission.php | Implements HasTableDisplay for InertiaTable enum rendering. |
| app/Actions/Database/UpdateDatabaseUser.php | Normalizes host-change logic and adds engine-aware collision checks. |
| app/Actions/Database/CreateDatabaseUser.php | Introduces engine-aware existence checks and host validation/normalization. |
There was a problem hiding this comment.
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 `@resources/js/pages/database-users/index.tsx`:
- Line 26: Replace the frontend's derived usesHost boolean (currently computed
as page.props.server.services['database'] !== 'postgresql' in usesHost) with an
explicit Inertia prop provided by the backend; update DatabaseUserController to
compute usesHost using the existing backend logic
(AbstractDatabase::usesHost()/Postgresql::usesHost()) and include it in the
Inertia props sent to the page, then change the frontend to read
page.props.usesHost (or the chosen prop name) instead of inspecting
page.props.server.services['database'], so the frontend stays aligned with
backend handlers and future DB types.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: dde527a5-3e52-4a08-9763-bb3b5329134b
📒 Files selected for processing (18)
app/Actions/Database/CreateDatabaseUser.phpapp/Actions/Database/UpdateDatabaseUser.phpapp/Enums/DatabaseUserPermission.phpapp/Enums/DatabaseUserStatus.phpapp/Http/Controllers/DatabaseUserController.phpapp/Http/Resources/DatabaseUserResource.phpapp/Services/Database/AbstractDatabase.phpapp/Services/Database/Database.phpapp/Services/Database/Postgresql.phpapp/Tables/Servers/DatabaseUserTable.phpresources/js/components/database-user-databases.tsxresources/js/pages/database-users/components/columns.tsxresources/js/pages/database-users/components/create-database-user.tsxresources/js/pages/database-users/components/edit-database-user.tsxresources/js/pages/database-users/index.tsxresources/js/types/database-user.d.tsresources/js/vito-table-setup.tstests/Feature/DatabaseUserTest.php
💤 Files with no reviewable changes (1)
- resources/js/pages/database-users/components/columns.tsx
Summary by CodeRabbit
New Features
Bug Fixes
Tests