Skip to content

Conversation

@notAreYouScared
Copy link
Member

If a server has 0 allocations, do not show the create allocation button.

@notAreYouScared notAreYouScared self-assigned this Nov 9, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 9, 2025

📝 Walkthrough

Walkthrough

The add_allocation toolbar action visibility logic in AllocationResource is modified to hide the action in additional scenarios. It now hides when either the allocations feature is disabled or the server lacks an allocation, expanding the prior hiding condition.

Changes

Cohort / File(s) Summary
Allocation Resource Configuration
app/Filament/Server/Resources/Allocations/AllocationResource.php
Modified the add_allocation toolbar action to hide when either allocations feature is disabled or server has no allocation (previously hidden only when feature was disabled)

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: hiding the allocation action when a server has no allocations.
Description check ✅ Passed The description is directly related to the changeset, clearly stating the purpose of hiding the create allocation button when a server has 0 allocations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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: 0

🧹 Nitpick comments (1)
app/Filament/Server/Resources/Allocations/AllocationResource.php (1)

108-108: Consider using allocation count for more explicit intent.

The condition $server->allocation === null checks if the primary allocation is null, which typically indicates 0 allocations (given the auto-reassignment logic on line 100). However, for clarity and robustness, consider checking the allocation count directly to match the PR objective "0 allocations":

-                    ->hidden(fn () => !config('panel.client_features.allocations.enabled') || $server->allocation === null)
+                    ->hidden(fn () => !config('panel.client_features.allocations.enabled') || $server->allocations()->count() === 0)

This approach:

  • More explicitly matches the PR description and intent
  • Is consistent with allocation count checks elsewhere (lines 105, 107, 109)
  • Handles edge cases where allocation_id might be null while allocations exist
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aa35d7d and 952b014.

📒 Files selected for processing (1)
  • app/Filament/Server/Resources/Allocations/AllocationResource.php (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/Filament/Server/Resources/Allocations/AllocationResource.php (2)
app/Models/Allocation.php (1)
  • server (129-132)
app/Models/Server.php (1)
  • allocation (277-280)

@notAreYouScared notAreYouScared merged commit f4ee33f into main Nov 9, 2025
25 checks passed
@notAreYouScared notAreYouScared deleted the charles/hide-allocation-btn branch November 9, 2025 17:11
@github-actions github-actions bot locked and limited conversation to collaborators Nov 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants