Fix the path used for the metadataDashboardButton#953
Conversation
📝 WalkthroughWalkthroughRemoves the injected Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
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: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/components/metadata-dashboard-button.js`:
- Line 10: The current implementation in metadata-dashboard-button.js builds the
dashboard path by taking this.router.currentURL.split('/').pop(), which returns
child route segments like "edit" or "settings" and yields wrong symbols for
nested provider routes; change the logic to prefer the route param (use
this.router.currentRoute.params.provider_id or the appropriate param name) and
build the URL as ENV.METADATA_DASHBOARD_URL + "/" + providerId when that param
exists, and if not present fall back to extracting the provider id with a safe
regex (e.g. match /\/providers\/([^\/]+)/) from this.router.currentURL before
concatenating.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 44d098f0-8920-42dd-99b0-dab7ec7be290
📒 Files selected for processing (1)
app/components/metadata-dashboard-button.js
There was a problem hiding this comment.
♻️ Duplicate comments (1)
app/components/metadata-dashboard-button.js (1)
10-10:⚠️ Potential issue | 🟠 MajorLine 10: Last-segment extraction still breaks resource-symbol resolution on nested routes.
For paths like
/providers/abc/editor/repositories/xyz/settings,split('/').pop()yieldsedit/settings, not the symbol, so the generated metadata dashboard URL is wrong.Proposed fix
get metadataDashboardUrl() { - return ENV.METADATA_DASHBOARD_URL + (this.router.currentURL ? "/" + this.router.currentURL.split('/').pop() : ''); + const path = (this.router.currentURL || '').split(/[?#]/)[0]; + const match = path.match(/\/(?:providers|repositories|users)\/([^/]+)/); + const symbol = match?.[1]; + + if (!symbol) { + return null; + } + + return `${ENV.METADATA_DASHBOARD_URL}/${symbol}`; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/components/metadata-dashboard-button.js` at line 10, The current URL segment extraction in metadata-dashboard-button.js uses this.router.currentURL.split('/').pop(), which returns route action names like "edit" or "settings" instead of the resource symbol; change the logic to parse this.router.currentURL by filtering out empty segments and choose the last segment unless it matches route action names (e.g. "edit", "settings", "new", "create", "update", "delete"), in which case use the penultimate segment (the actual resource symbol), then concatenate that symbol to ENV.METADATA_DASHBOARD_URL when building the returned URL.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@app/components/metadata-dashboard-button.js`:
- Line 10: The current URL segment extraction in metadata-dashboard-button.js
uses this.router.currentURL.split('/').pop(), which returns route action names
like "edit" or "settings" instead of the resource symbol; change the logic to
parse this.router.currentURL by filtering out empty segments and choose the last
segment unless it matches route action names (e.g. "edit", "settings", "new",
"create", "update", "delete"), in which case use the penultimate segment (the
actual resource symbol), then concatenate that symbol to
ENV.METADATA_DASHBOARD_URL when building the returned URL.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f587dfbd-baf2-434e-8fd5-1f632fddf634
📒 Files selected for processing (1)
app/components/metadata-dashboard-button.js
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/components/doi-list.hbs`:
- Around line 19-25: The panel rendering currently gated only by (eq this.link
'repositories.show.dois') should also require a valid `@dashboardId` to avoid
rendering MetadataDashboardButton with no target; update the template logic in
doi-list.hbs so the block that renders <MetadataDashboardButton
`@dashboardId`={{`@dashboardId`}} /> only executes when `@dashboardId` is present (in
addition to the existing non-repositories.show.dois check), ensuring callers
like users/show/dois.hbs and dois/index.hbs that omit `@dashboardId` won’t produce
an invalid dashboard target.
In `@app/templates/repositories/show/index.hbs`:
- Line 21: Replace the repository identifier passed into MetadataDashboardButton
from this.model.id to this.model.symbol so it matches the identifier used by the
DoiList component (repositories.show.dois) and follows the same pattern as
providers; update the prop invocation in the template where
<MetadataDashboardButton `@dashboardId`={{this.model.id}} /> appears to use
`@dashboardId`={{this.model.symbol}} ensuring both parent and child components use
the repository symbol consistently.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 29e57f1a-6c89-4751-8d81-d7fbb96335e7
📒 Files selected for processing (6)
app/components/doi-list.hbsapp/components/metadata-dashboard-button.jsapp/templates/providers/show/dois.hbsapp/templates/providers/show/index.hbsapp/templates/repositories/show/dois/index.hbsapp/templates/repositories/show/index.hbs
✅ Files skipped from review due to trivial changes (1)
- app/templates/repositories/show/dois/index.hbs
🚧 Files skipped from review as they are similar to previous changes (1)
- app/components/metadata-dashboard-button.js
There was a problem hiding this comment.
🧹 Nitpick comments (1)
app/components/metadata-dashboard-button.js (1)
7-9: Add type guard fordashboardIdto prevent unsafe.toLowerCase()call.Line 8 calls
.toLowerCase()without verifyingdashboardIdis a string. While all current call sites pass string values from model properties (uid,id,symbol), the component lacks defensive type checking. This could fail if a non-string truthy value is accidentally passed, or if model properties are ever set to non-string values.Consider adding a type check before the
.toLowerCase()call:Suggested approach
get metadataDashboardUrl() { - return ENV.METADATA_DASHBOARD_URL + (this.args.dashboardId ? "/" + this.args.dashboardId.toLowerCase() : ''); + if (typeof this.args.dashboardId !== 'string' || !this.args.dashboardId) { + return ENV.METADATA_DASHBOARD_URL; + } + return ENV.METADATA_DASHBOARD_URL + '/' + this.args.dashboardId.toLowerCase(); }Note: All current call sites (6 locations) provide
@dashboardId, so this is preventive rather than addressing a current issue.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/components/metadata-dashboard-button.js` around lines 7 - 9, The getter metadataDashboardUrl currently calls this.args.dashboardId.toLowerCase() without verifying the type; add a defensive type guard so only string values are lowercased: check that this.args.dashboardId is truthy and typeof this.args.dashboardId === 'string' before calling .toLowerCase(), otherwise treat it as absent (use the empty-string branch) or coerce safely (e.g., String(...) if you want non-strings). Update the metadataDashboardUrl getter to perform this check and concatenate the resulting value exactly as before when valid.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@app/components/metadata-dashboard-button.js`:
- Around line 7-9: The getter metadataDashboardUrl currently calls
this.args.dashboardId.toLowerCase() without verifying the type; add a defensive
type guard so only string values are lowercased: check that
this.args.dashboardId is truthy and typeof this.args.dashboardId === 'string'
before calling .toLowerCase(), otherwise treat it as absent (use the
empty-string branch) or coerce safely (e.g., String(...) if you want
non-strings). Update the metadataDashboardUrl getter to perform this check and
concatenate the resulting value exactly as before when valid.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1a25df84-9057-493d-9b93-3fdab55840b7
📒 Files selected for processing (3)
app/components/metadata-dashboard-button.hbsapp/components/metadata-dashboard-button.jsapp/styles/local.css
✅ Files skipped from review due to trivial changes (1)
- app/styles/local.css
Purpose
closes: #952
preview: https://bracco-nfz8ohu83-datacite.vercel.app/
Approach
In the button component, grab the page url and pop off the last component.
Open Questions and Pre-Merge TODOs
Learning
Types of changes
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
Reviewer, please remember our guidelines:
Summary by CodeRabbit
Bug Fixes
New Features
Style