Skip to content

Update the subscription view page title to use display name#7155

Merged
openshift-merge-bot[bot] merged 4 commits intoopendatahub-io:mainfrom
katieperry4:57319/subscription-view-title-bug
Apr 15, 2026
Merged

Update the subscription view page title to use display name#7155
openshift-merge-bot[bot] merged 4 commits intoopendatahub-io:mainfrom
katieperry4:57319/subscription-view-title-bug

Conversation

@katieperry4
Copy link
Copy Markdown
Contributor

@katieperry4 katieperry4 commented Apr 9, 2026

Closes RHOAIENG-57319

Description

Just a quick change to the subscription view page

Changes the title to the display name instead of the resource name (same for the breadcrumb)

Updates some of the headers in the details section -> Display name to just Name and Name to Resource name

Screen.Recording.2026-04-09.at.9.14.57.AM.mov

How Has This Been Tested?

Tested locally

to test:

  • Pull up a subscription with a display name
  • See that that name is in the title is the display name and the details section headers are updated
  • go pull up a subscription that doesn't have a display name (even go into the console and delete the display name) and see that everything falls back to the resource name if the display name is not present

Test Impact

Updated some mock tests to check for the display name

Request review criteria:

Self checklist (all need to be checked):

  • The developer has manually tested the changes and verified that the changes work
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has added tests or explained why testing cannot be added (unit or cypress tests for related changes)
  • The code follows our Best Practices (React coding standards, PatternFly usage, performance considerations)

If you have UI changes:

  • Included any necessary screenshots or gifs if it was a UI change.
  • Included tags to the UX team if it was a UI/UX change.

After the PR is posted & before it merges:

  • The developer has tested their solution on a cluster by using the image produced by the PR to main

Summary by CodeRabbit

  • New Features

    • Subscriptions now show user-friendly display names across pages, breadcrumbs and titles; details prefer Display Name with fallback to resource name. Labels changed to "Name", "Resource name" and "Created". Edit form pre-fills the display name where applicable.
  • Tests

    • End-to-end tests updated to interact with and assert on display names; mocked subscriptions include displayName and delete/view flows use display names.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 9, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress This PR is in WIP state label Apr 9, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: dc6ea918-fc1a-412d-84e5-d3413c6b0ef1

📥 Commits

Reviewing files that changed from the base of the PR and between b5ef77c and 90e60ea.

📒 Files selected for processing (1)
  • packages/maas/frontend/src/app/pages/subscriptions/ViewSubscriptionPage.tsx
✅ Files skipped from review due to trivial changes (1)
  • packages/maas/frontend/src/app/pages/subscriptions/ViewSubscriptionPage.tsx

📝 Walkthrough

Walkthrough

Mock subscription objects now include a displayName. Cypress tests were updated to locate and assert subscriptions and drive delete/edit flows using the display name (e.g., "Premium Team Subscription") rather than internal IDs. ViewSubscriptionPage computes displaySubscriptionName from subscription.displayName?.trim() with a fallback to the subscriptionName route param and uses it in breadcrumbs and page titles. SubscriptionDetailsSection relabeled fields: "Display name" → "Name", second "Name" → "Resource name", and "Date created" → "Created"; the displayed "Name" prefers displayName when present.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Security review

Issue: Unvalidated rendering of subscription.displayName

  • Risk: Cross-site scripting (XSS) via malicious display names.
  • CWE: CWE-79 (Improper Neutralization of Input During Web Page Generation).
  • Actionable fixes:
    • Ensure server-side validation and canonicalization of displayName (restrict charset, enforce max length).
    • Trim/normalize on ingest; reject or sanitize disallowed characters.
    • Escape output when rendering in React (avoid dangerouslySetInnerHTML). If HTML input must be supported, sanitize using a vetted library (e.g., DOMPurify) before rendering.

Issue: Fallback to route parameter subscriptionName (user-controlled)

  • Risk: Injection or unexpected rendering/behavior from unvalidated route values.
  • CWE: CWE-20 (Improper Input Validation).
  • Actionable fixes:
    • Validate and canonicalize the route subscriptionName before display (allowed charset, length).
    • Prefer server-provided canonical names; log occurrences where fallback is used for investigation.

No other actionable security issues are evident in the diff.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Update the subscription view page title to use display name' directly and specifically describes the main change: switching from resource name to display name for the page title.
Description check ✅ Passed The description covers the issue reference, clear explanation of changes, testing approach with fallback scenarios, mock test updates, and includes screenshots. All required sections are completed.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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
Copy Markdown
Contributor

@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)
packages/cypress/cypress/tests/mocked/modelsAsAService/maasSubscriptions.cy.ts (1)

127-127: Add a test that exercises the missing-displayName fallback path.

These assertions cover only the display-name-present path. Add one case where displayName is absent/blank and assert the view title/details fall back to subscriptionName (premium-team-sub).

Proposed test addition
 describe('View Subscription Page', () => {
   const subscriptionName = 'premium-team-sub';
@@
   it('should display the page content with title, breadcrumb, details, groups, and models', () => {
@@
   });

+  it('should fall back to resource name when displayName is missing', () => {
+    const response = mockSubscriptionInfo(subscriptionName);
+    response.subscription = { ...response.subscription, displayName: undefined };
+
+    cy.interceptOdh(
+      'GET /maas/api/v1/subscription-info/:name',
+      { path: { name: subscriptionName } },
+      { data: response },
+    );
+
+    viewSubscriptionPage.visit(subscriptionName);
+    viewSubscriptionPage.findTitle().should('contain.text', subscriptionName);
+    viewSubscriptionPage
+      .findDetailsSection()
+      .should('contain.text', 'Resource name')
+      .and('contain.text', subscriptionName);
+  });

Also applies to: 130-130, 134-137

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/cypress/cypress/tests/mocked/modelsAsAService/maasSubscriptions.cy.ts`
at line 127, Add a new test case in maasSubscriptions.cy.ts that covers the
missing displayName fallback: create or mock a subscription record with
displayName empty/undefined and subscriptionName 'premium-team-sub', then
trigger the same UI flow used by subscriptionsPage.getRow('Premium Team
Subscription').findKebabAction('View details').click() (and the related
assertions at the other occurrences) and assert that the view title and details
fall back to subscriptionName 'premium-team-sub' instead of displayName; update
the selector usage (subscriptionsPage.getRow(...).findKebabAction('View
details')) to target the row for the subscriptionName variant and add assertions
verifying the displayed title equals 'premium-team-sub'.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/maas/frontend/src/app/pages/subscriptions/ViewSubscriptionPage.tsx`:
- Around line 74-76: Breadcrumb and title currently use the nullish coalescing
operator so an empty string in subscriptionInfo.subscription.displayName renders
as blank; update both occurrences in ViewSubscriptionPage (the BreadcrumbItem
and the title usage) to treat empty/whitespace-only displayName as missing by
trimming the string and falling back to subscriptionName (i.e., replace the
subscriptionInfo?.subscription.displayName ?? subscriptionName usage with a
trimmed-or-fallback check so "" or "   " falls back to subscriptionName).

---

Nitpick comments:
In
`@packages/cypress/cypress/tests/mocked/modelsAsAService/maasSubscriptions.cy.ts`:
- Line 127: Add a new test case in maasSubscriptions.cy.ts that covers the
missing displayName fallback: create or mock a subscription record with
displayName empty/undefined and subscriptionName 'premium-team-sub', then
trigger the same UI flow used by subscriptionsPage.getRow('Premium Team
Subscription').findKebabAction('View details').click() (and the related
assertions at the other occurrences) and assert that the view title and details
fall back to subscriptionName 'premium-team-sub' instead of displayName; update
the selector usage (subscriptionsPage.getRow(...).findKebabAction('View
details')) to target the row for the subscriptionName variant and add assertions
verifying the displayed title equals 'premium-team-sub'.
🪄 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: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: a48538e0-64cf-4631-aebe-2bb42cd89a12

📥 Commits

Reviewing files that changed from the base of the PR and between eac09a7 and 6b67ad2.

📒 Files selected for processing (4)
  • packages/cypress/cypress/tests/mocked/modelsAsAService/maasSubscriptions.cy.ts
  • packages/cypress/cypress/utils/maasUtils.ts
  • packages/maas/frontend/src/app/pages/subscriptions/ViewSubscriptionPage.tsx
  • packages/maas/frontend/src/app/pages/subscriptions/viewSubscription/SubscriptionDetailsSection.tsx

Comment thread packages/maas/frontend/src/app/pages/subscriptions/ViewSubscriptionPage.tsx Outdated
@katieperry4 katieperry4 force-pushed the 57319/subscription-view-title-bug branch from 6b67ad2 to 195173d Compare April 9, 2026 14:07
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.91%. Comparing base (3ef417a) to head (1a60077).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7155      +/-   ##
==========================================
+ Coverage   64.80%   64.91%   +0.10%     
==========================================
  Files        2441     2442       +1     
  Lines       75996    76016      +20     
  Branches    19158    19165       +7     
==========================================
+ Hits        49253    49347      +94     
+ Misses      26743    26669      -74     
Files with missing lines Coverage Δ
...c/app/pages/subscriptions/ViewSubscriptionPage.tsx 65.21% <100.00%> (+1.58%) ⬆️
...ns/viewSubscription/SubscriptionDetailsSection.tsx 83.33% <100.00%> (ø)

... and 20 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 179fbec...1a60077. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@katieperry4 katieperry4 marked this pull request as ready for review April 9, 2026 15:34
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress This PR is in WIP state label Apr 9, 2026
@openshift-ci openshift-ci Bot requested review from ConorOM1 and emilys314 April 9, 2026 15:35
@katieperry4 katieperry4 requested review from Griffin-Sullivan, ashley-o0o, claudialphonse78 and dpanshug and removed request for ConorOM1 April 9, 2026 15:35
Copy link
Copy Markdown
Contributor

@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

♻️ Duplicate comments (1)
packages/maas/frontend/src/app/pages/subscriptions/ViewSubscriptionPage.tsx (1)

66-67: ⚠️ Potential issue | 🟡 Minor

displaySubscriptionName still does not fallback for blank values.

Line [67] uses ??; when displayName?.trim() is '', breadcrumb/title remain blank.

Suggested fix
-  const displaySubscriptionName =
-    subscriptionInfo?.subscription.displayName?.trim() ?? subscriptionName;
+  const displaySubscriptionName =
+    subscriptionInfo?.subscription.displayName?.trim() || subscriptionName;
#!/bin/bash
# Verify the problematic operator pattern in the updated file.
rg -nP "displayName\?\.\s*trim\(\)\s*\?\?" packages/maas/frontend/src/app/pages/subscriptions/ViewSubscriptionPage.tsx

# Check whether fallback edge cases (blank/whitespace displayName) are covered in Cypress mocks/tests.
rg -nP "displayName:\s*''|displayName:\s*'\\s+'" packages/cypress --glob '*.ts'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/maas/frontend/src/app/pages/subscriptions/ViewSubscriptionPage.tsx`
around lines 66 - 67, Replace the nullish-coalescing fallback with a falsy
fallback so blank/whitespace display names fall back to the subscriptionName:
change the expression constructing displaySubscriptionName in
ViewSubscriptionPage (the symbol displaySubscriptionName using
subscriptionInfo?.subscription.displayName?.trim()) to use || (or explicitly
coerce to string then .trim() and ||) instead of ??; also update/add Cypress
mocks/tests that assert behavior for displayName: '' and displayName: '   ' to
verify the fallback works.
🧹 Nitpick comments (1)
packages/cypress/cypress/utils/maasUtils.ts (1)

80-126: Add a fixture for missing/blank displayName to cover fallback behavior.

Current mockSubscriptions() data only exercises the display-name-present path. Add one mock subscription with omitted (or whitespace-only) displayName so tests can assert fallback to name.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cypress/cypress/utils/maasUtils.ts` around lines 80 - 126, The
mockSubscriptions() fixture only contains subscriptions with non-empty
displayName; add an additional MaaSSubscription object to the returned array
with displayName omitted or set to a whitespace-only string so tests exercise
the fallback to name. Update the mockSubscriptions() return to include a
subscription (e.g., name 'no-display-sub') with displayName: '' or absent,
include other required fields (namespace, phase, owner, modelRefs,
creationTimestamp) so consumers of mockSubscriptions() can assert that code
paths in displayName fallback logic use the name field. Ensure the new entry
follows the existing shape used by tests that consume mockSubscriptions().
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@packages/maas/frontend/src/app/pages/subscriptions/viewSubscription/SubscriptionDetailsSection.tsx`:
- Around line 30-33: In SubscriptionDetailsSection where the Name field
currently renders {subscription.displayName ?? subscription.name}, change the
fallback logic to treat empty or whitespace-only displayName as missing: check
subscription.displayName after trimming (e.g., if subscription.displayName &&
subscription.displayName.trim().length > 0) and render that; otherwise render
subscription.name. Update the JSX inside DescriptionListDescription to use this
trimmed check so empty strings or whitespace fall back to subscription.name.

---

Duplicate comments:
In `@packages/maas/frontend/src/app/pages/subscriptions/ViewSubscriptionPage.tsx`:
- Around line 66-67: Replace the nullish-coalescing fallback with a falsy
fallback so blank/whitespace display names fall back to the subscriptionName:
change the expression constructing displaySubscriptionName in
ViewSubscriptionPage (the symbol displaySubscriptionName using
subscriptionInfo?.subscription.displayName?.trim()) to use || (or explicitly
coerce to string then .trim() and ||) instead of ??; also update/add Cypress
mocks/tests that assert behavior for displayName: '' and displayName: '   ' to
verify the fallback works.

---

Nitpick comments:
In `@packages/cypress/cypress/utils/maasUtils.ts`:
- Around line 80-126: The mockSubscriptions() fixture only contains
subscriptions with non-empty displayName; add an additional MaaSSubscription
object to the returned array with displayName omitted or set to a
whitespace-only string so tests exercise the fallback to name. Update the
mockSubscriptions() return to include a subscription (e.g., name
'no-display-sub') with displayName: '' or absent, include other required fields
(namespace, phase, owner, modelRefs, creationTimestamp) so consumers of
mockSubscriptions() can assert that code paths in displayName fallback logic use
the name field. Ensure the new entry follows the existing shape used by tests
that consume mockSubscriptions().
🪄 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: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 365d85fb-d7c2-4cd7-ba16-c2efd8146734

📥 Commits

Reviewing files that changed from the base of the PR and between eac09a7 and 195173d.

📒 Files selected for processing (4)
  • packages/cypress/cypress/tests/mocked/modelsAsAService/maasSubscriptions.cy.ts
  • packages/cypress/cypress/utils/maasUtils.ts
  • packages/maas/frontend/src/app/pages/subscriptions/ViewSubscriptionPage.tsx
  • packages/maas/frontend/src/app/pages/subscriptions/viewSubscription/SubscriptionDetailsSection.tsx

@katieperry4 katieperry4 mentioned this pull request Apr 9, 2026
7 tasks
@katieperry4 katieperry4 force-pushed the 57319/subscription-view-title-bug branch from 684fcef to b5ef77c Compare April 9, 2026 18:13
@claudialphonse78
Copy link
Copy Markdown
Contributor

claudialphonse78 commented Apr 10, 2026

Verified the changes based on the content doc looks good

Open.Data.Hub.2.mp4

/lgtm

const [activeTab, setActiveTab] = React.useState<string | number>('details');
const [subscriptionInfo, loaded, loadError] = useGetSubscriptionInfo(subscriptionName);
const displaySubscriptionName =
subscriptionInfo?.subscription.displayName?.trim() ?? subscriptionName;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ?? will show an empty string from the display name instead of the subscription name

Suggested change
subscriptionInfo?.subscription.displayName?.trim() ?? subscriptionName;
subscriptionInfo?.subscription.displayName?.trim() || subscriptionName;

@openshift-ci openshift-ci Bot removed the lgtm label Apr 15, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 15, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: emilys314

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@katieperry4 katieperry4 force-pushed the 57319/subscription-view-title-bug branch from 90e60ea to 1a60077 Compare April 15, 2026 18:01
@openshift-ci openshift-ci Bot removed the lgtm label Apr 15, 2026
@emilys314
Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm label Apr 15, 2026
@openshift-merge-bot openshift-merge-bot Bot merged commit 8bf6219 into opendatahub-io:main Apr 15, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants