Skip to content

Conversation

@notAreYouScared
Copy link
Member

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Dec 24, 2025

📝 Walkthrough

Walkthrough

The max_connections field display in the DatabaseResource is refactored to use a localized translation string. A corresponding translation entry is added to the English language file to support this localization change.

Changes

Cohort / File(s) Change Summary
Database display localization
app/Filament/Server/Resources/Databases/DatabaseResource.php
Updated max_connections field formatting callback to use trans('server/database.unlimited') instead of hardcoded 'Unlimited' string when displaying unlimited connections
Translation file
lang/en/server/database.php
Added new translation entry 'unlimited' => 'Unlimited'

Pre-merge checks

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive No description was provided by the author, making it impossible to evaluate relevance to the changeset. Add a pull request description explaining the purpose of the change, context, and why the fix was necessary.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: updating how the 'unlimited' state for database max_connections is displayed on the client side view.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ac36e7a and 2fd8788.

📒 Files selected for processing (2)
  • app/Filament/Server/Resources/Databases/DatabaseResource.php
  • lang/en/server/database.php
🧰 Additional context used
🧬 Code graph analysis (1)
app/Filament/Server/Resources/Databases/DatabaseResource.php (1)
app/Models/Database.php (1)
  • Database (29-195)
🔇 Additional comments (1)
lang/en/server/database.php (1)

14-14: LGTM! Translation key properly added.

The new translation entry follows the existing naming convention and correctly supports the localization change in DatabaseResource.php.

Comment on lines 99 to +101
TextInput::make('max_connections')
->label(trans('server/database.max_connections'))
->formatStateUsing(fn (Database $database) => $database->max_connections === 0 ? $database->max_connections : 'Unlimited'),
->formatStateUsing(fn (Database $database) => $database->max_connections === 0 ? trans('server/database.unlimited') : $database->max_connections),
Copy link

@coderabbitai coderabbitai bot Dec 24, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check database migrations for max_connections definition
rg "max_connections" --type=php -g "**/database/migrations/**" -C 3

echo "---"

# Check the Database model for validation and nullability
cat -n app/Models/Database.php | head -100

echo "---"

# Search for any null assignments or nullable casts
rg -n "max_connections" app/Models/Database.php -C 2

Repository: pelican-dev/panel

Length of output: 6086


🏁 Script executed:

#!/bin/bash
# Check if max_connections is set to null anywhere
rg -n "max_connections\s*=\s*null" --type=php -C 2

echo "---"

# Check for nullable in migration or model
rg -n "nullable.*max_connections|max_connections.*nullable" --type=php -C 2

Repository: pelican-dev/panel

Length of output: 1041


null handling fix needed.

The field is indeed nullable—the migration explicitly allows it (->nullable()) and validation confirms this ('nullable', 'integer'). The current code only checks for zero values, so null entries would display as empty instead of "Unlimited". Update the formatStateUsing logic to handle both cases:

->formatStateUsing(fn (Database $database) => $database->max_connections === 0 || $database->max_connections === null ? trans('server/database.unlimited') : $database->max_connections)
🤖 Prompt for AI Agents
In app/Filament/Server/Resources/Databases/DatabaseResource.php around lines 99
to 101, the formatStateUsing callback only treats zero as "Unlimited" but the
max_connections field is nullable, so null values render empty; update the
callback to treat both null and zero as "Unlimited" (i.e., check for null OR
zero) and return trans('server/database.unlimited') in those cases, otherwise
return the numeric value.

Copy link
Member

@rmartinoscar rmartinoscar Dec 24, 2025

Choose a reason for hiding this comment

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

Suggested change
TextInput::make('max_connections')
->label(trans('server/database.max_connections'))
->formatStateUsing(fn (Database $database) => $database->max_connections === 0 ? $database->max_connections : 'Unlimited'),
->formatStateUsing(fn (Database $database) => $database->max_connections === 0 ? trans('server/database.unlimited') : $database->max_connections),
->formatStateUsing(fn (Database $database) => $database->max_connections ?: trans('server/database.unlimited')),

Copy link

Choose a reason for hiding this comment

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

@rmartinoscar Thanks for the cleaner approach! Your suggestion using truthiness ($database->max_connections ? ... : ...) correctly handles both null and 0 values, since both are falsy in PHP. This is more concise than explicitly checking for each case. 👍

@lancepioch lancepioch marked this pull request as draft December 28, 2025 00:58
@lancepioch
Copy link
Member

I like @rmartinoscar suggestion of using truthiness instead and he said there are a couple more places for the translation, otherwise looks good!

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.

4 participants