feat(plugins): Optimize plugin badge fetching and rendering to preven…#1580
feat(plugins): Optimize plugin badge fetching and rendering to preven…#1580
Conversation
…t flicker and enhance visibility
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughMoved plugin badge/count fetching before tab DOM creation, replacing Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Frontend as Frontend JS
participant API as Backend API
participant DOM as Browser DOM
User->>Frontend: open Plugins page
Frontend->>API: fetchPluginCounts(prefixes)
API-->>Frontend: counts JSON / error
alt counts received
Frontend->>Frontend: compute visiblePlugins from counts
Frontend->>DOM: generateTabs(visiblePlugins, counts)
Frontend->>Frontend: applyPluginBadges(counts, prefixes)
Frontend->>DOM: initialize active inner sub-tab (Objects/Events/History)
else fetch error (fail-open)
Frontend->>Frontend: generateTabs(all show_ui plugins, null)
Frontend->>DOM: initialize default tab flow
end
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@front/pluginsCore.php`:
- Around line 288-290: The prefetch of badge counts (fetchPluginCounts called
with pluginDefinitions.map p=>p.unique_prefix) currently treats errors/empty
responses as zero and skips rendering tabs; change it to "fail open": when
fetchPluginCounts rejects or response.errors exists, set pluginCounts to
null/undefined (or leave it unset) and log the error, but do not block tab
creation; update any rendering logic that checks pluginCounts (and the prefixes
handling) to treat a missing count as "unknown" (i.e., show the plugin if
p.show_ui) instead of hiding it so DataTable queries still render; ensure the
same change is applied to the other occurrences referenced (around the sections
using fetchPluginCounts at the other ranges) and keep fetchPluginCounts error
handling robust (catch exceptions and continue).
- Around line 381-393: The code is directly interpolating foreignKey into the
GraphQL document via fkOpt and the query built from prefixes.map, which allows
injection from the ?mac= URL param; change this to use GraphQL variables instead
of string concatenation: remove fkOpt interpolation and build the fragments
without embedding foreignKey, create a variables object (e.g., { foreignKey })
and send the query and variables to the server using the same pattern as
postPluginGraphQL(), and update the AJAX call to JSON.stringify({ query,
variables }) so pluginsObjects/pluginsEvents/pluginsHistory receive the
foreignKey via variables rather than inline text.
- Around line 460-466: The bug is that initializeDataTables() always targets the
Objects inner tab even when autoHideEmptyTabs() has hidden it and a different
inner sub-tab is active; update the logic where activeSubHidden is handled (the
block using activeSubHidden, $pane.find('ul.nav-tabs li:visible:first a',
$firstVisibleSubA, and $firstVisibleSubA.tab('show')) so that instead of forcing
the first visible sub-tab to show, you detect which inner sub-tab is currently
active (or was programmatically activated by autoHideEmptyTabs()) and explicitly
initialize that active sub-tab's DataTable via the same DataTable initialization
routine (the code path used by initializeDataTables()), and if necessary trigger
shown.bs.tab only for deferred initialization listeners for that specific active
sub-tab so its table gets initialized when the outer tab opens.
🪄 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: CHILL
Plan: Pro
Run ID: 8befec67-9554-427f-8da5-8ed051d0accd
📒 Files selected for processing (1)
front/pluginsCore.php
…and improved comments
…t flicker and enhance visibility
Summary by CodeRabbit