Skip to content

Conversation

@Boy132
Copy link
Member

@Boy132 Boy132 commented Nov 4, 2025

Isn't really doing anything on it's own, but allows plugins to "embed" the server list as normal page when expanding the app panel.

@Boy132 Boy132 self-assigned this Nov 4, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 4, 2025

📝 Walkthrough

Walkthrough

The ServerResource class adds a navigation icon property, a getNavigationBadge() method returning the current user's directly accessible server count as a string, and an embedServerList(bool $condition = true) method to toggle slug registration and navigation presence.

Changes

Cohort / File(s) Summary
ServerResource: navigation, badge, embed toggle
app/Filament/App/Resources/Servers/ServerResource.php
Added `protected static string

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ServerResource
  participant ServerModel as Server
  Note over ServerResource: Navigation badge retrieval flow
  User->>ServerResource: request navigation badge
  ServerResource->>Server: query directlyAccessible()->where('owner_id', user.id)->count()
  Server-->>ServerResource: count
  ServerResource-->>User: return count as string

  Note over ServerResource: embedServerList(bool) flow
  User->>ServerResource: call embedServerList(condition)
  alt condition = true
    ServerResource->>ServerResource: set slug = null\nregister navigation
  else condition = false
    ServerResource->>ServerResource: set slug = '/' \nunregister navigation
  end
Loading

Pre-merge checks

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main feature addition of allowing the server list to be embedded, which aligns with the primary change of adding an embedServerList() method.
Description check ✅ Passed The description is related to the changeset and explains the purpose of the additions - allowing plugins to embed the server list as a normal page when expanding the app panel.

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

🧹 Nitpick comments (1)
app/Filament/App/Resources/Servers/ServerResource.php (1)

36-40: Add return type and consider the implications of mutating static properties.

The method lacks a return type declaration and modifies static properties at runtime, which can cause unexpected behavior in long-running processes, tests, or when the resource class is instantiated multiple times.

Apply this diff to add the return type:

-public static function embedServerList(bool $condition = true)
+public static function embedServerList(bool $condition = true): void
 {
     static::$slug = $condition ? null : '/';
     static::$shouldRegisterNavigation = $condition;
 }

Alternatively, return static to enable method chaining:

-public static function embedServerList(bool $condition = true)
+public static function embedServerList(bool $condition = true): static
 {
     static::$slug = $condition ? null : '/';
     static::$shouldRegisterNavigation = $condition;
+    return new static();
 }

Consider documenting the method's purpose with a docblock to clarify when and how plugins should use it.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 21f9f25 and d594567.

📒 Files selected for processing (1)
  • app/Filament/App/Resources/Servers/ServerResource.php (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/Filament/App/Resources/Servers/ServerResource.php (1)
app/Models/User.php (1)
  • directAccessibleServers (284-291)
🔇 Additional comments (1)
app/Filament/App/Resources/Servers/ServerResource.php (1)

13-13: LGTM!

The navigation icon assignment is appropriate for a server resource.

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

♻️ Duplicate comments (1)
app/Filament/App/Resources/Servers/ServerResource.php (1)

19-22: Cache the user instance and clarify filtering intent.

The same performance and logic concerns previously raised still apply: user() is called twice, and the additional where('owner_id', ...) filter narrows directAccessibleServers() to only owned servers, excluding subuser access.

🧹 Nitpick comments (1)
app/Filament/App/Resources/Servers/ServerResource.php (1)

36-40: Add documentation for plugin initialization timing.

The method correctly toggles between embedded and default modes by modifying static properties. However, consider these edge cases:

  1. Timing dependency: This must be called before Filament registers the resource, otherwise changes won't take effect.
  2. Multiple plugins: If multiple plugins call this method, the last call wins—there's no conflict detection.

Consider adding a docblock to clarify usage:

+    /**
+     * Toggle server list embedding in navigation.
+     * Must be called during plugin initialization, before resource registration.
+     * 
+     * @param bool $condition True to embed (show in nav), false for default behavior
+     */
     public static function embedServerList(bool $condition = true): void
     {
         static::$slug = $condition ? null : '/';
         static::$shouldRegisterNavigation = $condition;
     }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d594567 and 8f9464d.

📒 Files selected for processing (1)
  • app/Filament/App/Resources/Servers/ServerResource.php (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/Filament/App/Resources/Servers/ServerResource.php (1)
app/Models/User.php (1)
  • directAccessibleServers (284-291)
🔇 Additional comments (1)
app/Filament/App/Resources/Servers/ServerResource.php (1)

13-13: LGTM! Valid Filament navigation icon.

The navigationIcon property is correctly defined with a valid Tabler icon reference for Filament resources.

@Boy132 Boy132 merged commit 4bda7cb into main Nov 5, 2025
25 checks passed
@Boy132 Boy132 deleted the boy132/embed-server-list branch November 5, 2025 15:18
@github-actions github-actions bot locked and limited conversation to collaborators Nov 5, 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.

4 participants