Add embedded plugin directory mode#225
Conversation
|
Note
|
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title clearly and concisely describes the main addition: an embedded mode for the plugin directory. |
| Description check | ✅ Passed | The description is well-related to the changeset, explaining the purpose of the embedded mode and listing the specific changes made. |
| Linked Issues check | ✅ Passed | All primary objectives from issue #114 are addressed: iframe embedding support, host context message handling, and plugin filtering work as specified. |
| Out of Scope Changes check | ✅ Passed | All changes are scoped to embedding functionality: controller parameters, view models, UI updates, embed script, and UI tests. No unrelated modifications detected. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
📝 Generate docstrings
- Create stacked PR
- Commit on current branch
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch
feature/plugins-embed-mode
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 @coderabbitai help to get the list of available commands and usage tips.
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
PluginBuilder/Views/Home/GetPluginDetails.cshtml (1)
15-20:⚠️ Potential issue | 🟠 Major | ⚡ Quick winKeep the embed “Write a review” link on the same plugin version.
In embed mode this URL is built from the canonical details route, so it drops
version,btcpayVersion, andincludePreRelease. Opening the standalone page from a versioned/compatibility-filtered drawer will jump to the default/latest details page instead.Suggested fix
var pluginUrl = Url.Action(nameof(HomeController.GetPluginDetails), "Home", new { pluginSlug = Model.Plugin.ProjectSlug }, Context.Request.Scheme, Context.Request.Host.ToString()); - var writeReviewUrl = Model.EmbedMode ? $"{pluginUrl}`#write-review`" : "`#write-review`"; + var standaloneDetailsUrl = Url.Action(nameof(HomeController.GetPluginDetails), "Home", new + { + pluginSlug = Model.Plugin.ProjectSlug, + version = Model.Plugin.Version, + btcpayVersion = string.IsNullOrEmpty(btcpayVersionRoute) ? null : btcpayVersionRoute, + includePreRelease = string.IsNullOrEmpty(includePreReleaseRoute) ? null : includePreReleaseRoute + }); + var writeReviewUrl = Model.EmbedMode ? $"{standaloneDetailsUrl}`#write-review`" : "`#write-review`";🤖 Prompt for 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. In `@PluginBuilder/Views/Home/GetPluginDetails.cshtml` around lines 15 - 20, The embed "Write a review" link loses version and filter query params because pluginUrl is built without forwarding Model.PluginVersion, btcpayVersion, and includePreRelease; when Model.EmbedMode is true the writeReviewUrl uses pluginUrl which drops these values. Fix by appending the current version and query params to pluginUrl when building writeReviewUrl in the view: read Model.Plugin.Version (or Model.PluginVersion) plus Context.Request.Query["btcpayVersion"] and Context.Request.Query["includePreRelease"] (btcpayVersionRoute, includePreReleaseRoute) and include them in the route/query string used by writeReviewUrl (and preserve writeReviewTarget/writeReviewRel behavior for EmbedMode).PluginBuilder/Controllers/HomeController.cs (1)
540-588:⚠️ Potential issue | 🟠 Major | ⚡ Quick winPreserve version and compatibility state through review POST redirects.
These actions only round-trip
embed. If a user posts from a details URL like?version=1.2.3&btcpayVersion=2.1.0&includePreRelease=true, the redirect lands on the default/latest details page instead of the version they were viewing. That breaks the versioned embed flow this PR is adding.Also applies to: 643-699
🤖 Prompt for 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. In `@PluginBuilder/Controllers/HomeController.cs` around lines 540 - 588, UpsertReview currently only preserves the "embed" query when redirecting back to GetPluginDetails, so version-related query parameters (e.g. version, btcpayVersion, includePreRelease) are lost and the user is sent to the default/latest details page; update the redirect construction in UpsertReview (the RedirectToAction call when owner and the final Redirect((url ?? "/") + "`#reviews`")) to read Request.Query for version, btcpayVersion, includePreRelease (and any other versioning params used by the details view) and add them into the routeValues passed to Url.Action/RedirectToAction so the same version/compatibility state is preserved; apply the same change to the other similar handler(s) referenced around lines 643-699 (same pattern building URL/redirect after posting reviews) and ensure PluginVersion parsing logic remains compatible with the preserved query values.
🤖 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 `@PluginBuilder.Tests/PublicTests/PluginDetailsUITests.cs`:
- Around line 97-117: The test assumes the parent page is same-origin which is
false after SetContentAsync(about:blank); fix by ensuring the parent is
navigated to a real origin before accessing iframe.contentWindow or using
window.location.origin: either navigate the page to the detailsUrl origin (e.g.,
await tester.Page.GotoAsync(the origin) or construct a base HTML on that origin)
so contentWindow/document/location access works, or avoid same-origin access
entirely by using a frame handle APIs (Page.Frame / WaitForFrame /
Frame.EvaluateAsync) to locate the iframe by src and call postMessage (or use
targetOrigin='*' for postMessage calls) instead of reading
contentWindow.document/location directly; update places referencing
tester.Page!.SetContentAsync, WaitForFunctionAsync, EvaluateAsync, and the
contentWindow.postMessage/location checks accordingly.
In `@PluginBuilder/Views/Home/GetPluginDetails.cshtml`:
- Around line 206-208: The rendered links use a static Model.Plugin.Version
(asp-route-version) so when the client-side version picker swaps versions via JS
the hrefs still point to the original version; update the view and JS so links
stay in sync: render the anchors with data attributes (e.g., data-version-link
or a data-url-template containing a {version} placeholder) instead of a
hard-coded asp-route-version, and in the existing version-picker change handler
update all anchors with that data attribute by replacing {version} (and
preserving asp-route-btcpayVersion and asp-route-includePreRelease values) or by
rewriting the query param "version" in their hrefs whenever the picker changes;
apply the same change for the other group of links noted around the 239-250
region so rating/filter/sort clicks use the selected version.
---
Outside diff comments:
In `@PluginBuilder/Controllers/HomeController.cs`:
- Around line 540-588: UpsertReview currently only preserves the "embed" query
when redirecting back to GetPluginDetails, so version-related query parameters
(e.g. version, btcpayVersion, includePreRelease) are lost and the user is sent
to the default/latest details page; update the redirect construction in
UpsertReview (the RedirectToAction call when owner and the final Redirect((url
?? "/") + "`#reviews`")) to read Request.Query for version, btcpayVersion,
includePreRelease (and any other versioning params used by the details view) and
add them into the routeValues passed to Url.Action/RedirectToAction so the same
version/compatibility state is preserved; apply the same change to the other
similar handler(s) referenced around lines 643-699 (same pattern building
URL/redirect after posting reviews) and ensure PluginVersion parsing logic
remains compatible with the preserved query values.
In `@PluginBuilder/Views/Home/GetPluginDetails.cshtml`:
- Around line 15-20: The embed "Write a review" link loses version and filter
query params because pluginUrl is built without forwarding Model.PluginVersion,
btcpayVersion, and includePreRelease; when Model.EmbedMode is true the
writeReviewUrl uses pluginUrl which drops these values. Fix by appending the
current version and query params to pluginUrl when building writeReviewUrl in
the view: read Model.Plugin.Version (or Model.PluginVersion) plus
Context.Request.Query["btcpayVersion"] and
Context.Request.Query["includePreRelease"] (btcpayVersionRoute,
includePreReleaseRoute) and include them in the route/query string used by
writeReviewUrl (and preserve writeReviewTarget/writeReviewRel behavior for
EmbedMode).
🪄 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: 0e262627-a4a2-4e45-a160-3e8e8384a56c
📒 Files selected for processing (6)
PluginBuilder.Tests/PublicTests/PluginDetailsUITests.csPluginBuilder.Tests/PublicTests/PublicDirectoryUITests.csPluginBuilder/Controllers/HomeController.csPluginBuilder/Views/Home/AllPlugins.cshtmlPluginBuilder/Views/Home/GetPluginDetails.cshtmlPluginBuilder/wwwroot/js/public-embed.js
🚧 Files skipped from review as they are similar to previous changes (1)
- PluginBuilder/Views/Home/AllPlugins.cshtml
|
Approve. Clean embed-mode architecture - postMessage protocol is fail-closed on install requests (uses verified |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
PluginBuilder/Views/Home/GetPluginDetails.cshtml (1)
15-22:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winKeep the embed “Write a review” link on the same selected version.
In embed mode this always opens the bare plugin details URL, so a user who was looking at a specific
versionor compatibility-filtered pre-release lands on a different page before reviewing. Please append the currentversion,btcpayVersion, andincludePreReleasevalues here as well.🤖 Prompt for 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. In `@PluginBuilder/Views/Home/GetPluginDetails.cshtml` around lines 15 - 22, The embed "Write a review" link ignores current query/route filters; update construction so when building pluginUrl and subsequently writeReviewUrl in GetPluginDetails.cshtml you include the current version, btcpayVersion and includePreRelease values (use currentBtcpayVersion, currentIncludePreRelease and the existing version value from Model or Context.Request.Query) as route/query values only when non-empty; keep writeReviewTarget and writeReviewRel behavior the same but point writeReviewUrl to the augmented pluginUrl (with version, btcpayVersion, includePreRelease appended) so the embed opens the same selected version/filters.PluginBuilder/Controllers/HomeController.cs (1)
559-608:⚠️ Potential issue | 🟠 Major | ⚡ Quick winPreserve the active details query across review mutations.
Lines 578, 603-607, 684-687, and 711-714 now redirect with only
pluginSlug/sort, so a user viewing?version=...&btcpayVersion=...&includePreRelease=...gets bounced back to the default details page after submit/vote/delete. That breaks the versioned details flow this PR is trying to preserve. Please thread the current details query through these POSTs and include it in theGetPluginDetailsredirect.Also applies to: 661-715
🤖 Prompt for 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. In `@PluginBuilder/Controllers/HomeController.cs` around lines 559 - 608, The redirects in UpsertReview currently only pass pluginSlug and sort, dropping the active details query (version, btcpayVersion, includePreRelease, etc.); update UpsertReview (and the other POST handlers that redirect to GetPluginDetails) to preserve the current Request.Query by either: 1) extracting the relevant query keys (e.g., "version","btcpayVersion","includePreRelease","sort") from Request.Query and include them in the anonymous route values passed to Url.Action(nameof(GetPluginDetails), "Home", ...) along with pluginSlug, or 2) build the original query string from Request.Query and append it to the generated URL before Redirect(); apply the same change to the other POST methods in this file that call Redirect/RedirectToAction to GetPluginDetails so the versioned details view is preserved.
🤖 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.
Outside diff comments:
In `@PluginBuilder/Controllers/HomeController.cs`:
- Around line 559-608: The redirects in UpsertReview currently only pass
pluginSlug and sort, dropping the active details query (version, btcpayVersion,
includePreRelease, etc.); update UpsertReview (and the other POST handlers that
redirect to GetPluginDetails) to preserve the current Request.Query by either:
1) extracting the relevant query keys (e.g.,
"version","btcpayVersion","includePreRelease","sort") from Request.Query and
include them in the anonymous route values passed to
Url.Action(nameof(GetPluginDetails), "Home", ...) along with pluginSlug, or 2)
build the original query string from Request.Query and append it to the
generated URL before Redirect(); apply the same change to the other POST methods
in this file that call Redirect/RedirectToAction to GetPluginDetails so the
versioned details view is preserved.
In `@PluginBuilder/Views/Home/GetPluginDetails.cshtml`:
- Around line 15-22: The embed "Write a review" link ignores current query/route
filters; update construction so when building pluginUrl and subsequently
writeReviewUrl in GetPluginDetails.cshtml you include the current version,
btcpayVersion and includePreRelease values (use currentBtcpayVersion,
currentIncludePreRelease and the existing version value from Model or
Context.Request.Query) as route/query values only when non-empty; keep
writeReviewTarget and writeReviewRel behavior the same but point writeReviewUrl
to the augmented pluginUrl (with version, btcpayVersion, includePreRelease
appended) so the embed opens the same selected version/filters.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a7288fe3-ce62-4c08-8034-ab7f9af2835d
📒 Files selected for processing (5)
PluginBuilder.Tests/PublicTests/PluginDetailsUITests.csPluginBuilder/Controllers/HomeController.csPluginBuilder/ViewModels/Home/PluginDetailsViewModel.csPluginBuilder/Views/Home/GetPluginDetails.cshtmlPluginBuilder/wwwroot/js/public-embed.js
|
Stamp confirms on
Approve stands at head |
b807f30 to
def55cf
Compare
Summary
Adds an embedded mode for the public plugin directory so BTCPay Server can render the Plugin Builder catalog inside Manage Plugins.
Resolves #114
Changes
embed=1support for the public directory list.