Skip to content

Fix the path used for the metadataDashboardButton#953

Merged
svogt0511 merged 5 commits intomainfrom
pb575-metadata-completeness
Mar 20, 2026
Merged

Fix the path used for the metadataDashboardButton#953
svogt0511 merged 5 commits intomainfrom
pb575-metadata-completeness

Conversation

@svogt0511
Copy link
Contributor

@svogt0511 svogt0511 commented Mar 18, 2026

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:

  • Be humble in the language and feedback you give, ask don't tell.
  • Consider using positive language as opposed to neutral when offering feedback. This is to avoid the negative bias that can occur with neutral language appearing negative.
  • Offer suggestions on how to improve code e.g. simplification or expanding clarity.
  • Ensure you give reasons for the changes you are proposing.

Summary by CodeRabbit

  • Bug Fixes

    • Dashboard link now targets the correct dashboard when a page-specific ID is present and falls back to the base dashboard when not.
    • Link behavior no longer depends on user context, reducing incorrect links.
  • New Features

    • Dashboard button appears in more places (DOI lists, provider and repository pages).
    • Button opens the dashboard in a new browser tab for consistent navigation.
  • Style

    • Adjusted dashboard button link font sizing for improved readability.

@svogt0511 svogt0511 requested a review from KellyStathis March 18, 2026 20:56
@coderabbitai
Copy link

coderabbitai bot commented Mar 18, 2026

📝 Walkthrough

Walkthrough

Removes the injected currentUser service from MetadataDashboardButton; builds the dashboard URL from an optional @dashboardId (lowercased) and exposes an openLink(url) action. Multiple templates were updated to pass @dashboardId into DoiList/MetadataDashboardButton and doi-list layout adjusted to render the button in an extra branch.

Changes

Cohort / File(s) Summary
Metadata Dashboard Button (JS)
app/components/metadata-dashboard-button.js
Removed @service currentUser; metadataDashboardUrl now conditionally appends "/" + this.args.dashboardId.toLowerCase() when @dashboardId is present; added @action openLink(url) to open the URL in a new tab.
Metadata Dashboard Button (template)
app/components/metadata-dashboard-button.hbs
Replaced anchor-based markup with a BsButton that calls this.openLink(this.metadataDashboardUrl) on click; updated element id to metadata-dashboard-button.
Doi list template
app/components/doi-list.hbs
Refactored MetadataDashboardButton invocations to pass @dashboardId={{@dashboardId}}; added an additional branch to render the button when this.link is not repositories.show.dois; simplified wrapper structure and added a panel panel-transparent wrapper in one branch.
Provider & Repository templates (call-sites)
app/templates/providers/show/dois.hbs, app/templates/providers/show/index.hbs, app/templates/repositories/show/dois/index.hbs, app/templates/repositories/show/index.hbs
Now pass dashboardId into DoiList or MetadataDashboardButton with values: this.model.provider.uid, this.model.uid, this.model.repository.symbol, and this.model.id respectively.
Styles
app/styles/local.css
Added rule .metadata-dashboard-button a { font-size: 16px !important; } to enforce link font size inside the button.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing the path/URL generation for the metadataDashboardButton component.
Linked Issues check ✅ Passed The PR implementation fulfills issue #952's requirement by making metadataDashboardButton derive its URL from the current page's resource symbol instead of the authenticated user's symbol.
Out of Scope Changes check ✅ Passed All changes are within scope: component logic refactored to use dashboardId argument, templates updated to pass appropriate dashboardId values, and button UI updated to use the new openLink action.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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 pb575-metadata-completeness
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@svogt0511 svogt0511 self-assigned this Mar 18, 2026
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

🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between 00ee964 and 843fe5e.

📒 Files selected for processing (1)
  • app/components/metadata-dashboard-button.js

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.

♻️ Duplicate comments (1)
app/components/metadata-dashboard-button.js (1)

10-10: ⚠️ Potential issue | 🟠 Major

Line 10: Last-segment extraction still breaks resource-symbol resolution on nested routes.

For paths like /providers/abc/edit or /repositories/xyz/settings, split('/').pop() yields edit/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

📥 Commits

Reviewing files that changed from the base of the PR and between 843fe5e and e685852.

📒 Files selected for processing (1)
  • app/components/metadata-dashboard-button.js

@svogt0511 svogt0511 temporarily deployed to vercel-bracco-preview March 18, 2026 22:00 — with GitHub Actions Inactive
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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between e685852 and 535127b.

📒 Files selected for processing (6)
  • app/components/doi-list.hbs
  • app/components/metadata-dashboard-button.js
  • app/templates/providers/show/dois.hbs
  • app/templates/providers/show/index.hbs
  • app/templates/repositories/show/dois/index.hbs
  • app/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

@svogt0511 svogt0511 temporarily deployed to vercel-bracco-preview March 19, 2026 18:39 — with GitHub Actions Inactive
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.

🧹 Nitpick comments (1)
app/components/metadata-dashboard-button.js (1)

7-9: Add type guard for dashboardId to prevent unsafe .toLowerCase() call.

Line 8 calls .toLowerCase() without verifying dashboardId is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 535127b and 44fd1f5.

📒 Files selected for processing (3)
  • app/components/metadata-dashboard-button.hbs
  • app/components/metadata-dashboard-button.js
  • app/styles/local.css
✅ Files skipped from review due to trivial changes (1)
  • app/styles/local.css

@svogt0511 svogt0511 temporarily deployed to vercel-bracco-preview March 19, 2026 21:29 — with GitHub Actions Inactive
@svogt0511 svogt0511 merged commit a15cb0a into main Mar 20, 2026
12 checks passed
@svogt0511 svogt0511 deleted the pb575-metadata-completeness branch March 20, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix the path used for the metadataDashboardButton

2 participants