Skip to content

Show the primary user email on the Hosts page when multiple are present#48869

Open
spalmesano0 wants to merge 5 commits into
mainfrom
idp-username-in-column
Open

Show the primary user email on the Hosts page when multiple are present#48869
spalmesano0 wants to merge 5 commits into
mainfrom
idp-username-in-column

Conversation

@spalmesano0

@spalmesano0 spalmesano0 commented Jul 7, 2026

Copy link
Copy Markdown
Member

Related issue: Resolves #30758

Checklist for submitter

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.

Testing

  • Added/updated automated tests
  • QA'd all new/changed functionality manually

Summary by CodeRabbit

  • New Features
    • Updated the Hosts page “User email” column to display a primary IdP username (or, if missing, the first Chrome profile email) per host.
    • When multiple emails exist, the cell shows a +N indicator and a tooltip listing the remaining emails (capped with +N more when applicable).
  • Bug Fixes
    • Improved ordering and fallback behavior for email selection and tooltip contents; consistent placeholder (---) when no emails exist.
  • Tests
    • Added coverage for primary-email selection, tooltip/counter rendering, and edge cases.

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.08%. Comparing base (4af0bef) to head (ada1dcd).
⚠️ Report is 22 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #48869      +/-   ##
==========================================
+ Coverage   68.03%   68.08%   +0.05%     
==========================================
  Files        3689     3692       +3     
  Lines      234203   234265      +62     
  Branches    12303    12461     +158     
==========================================
+ Hits       159338   159510     +172     
+ Misses      60547    60436     -111     
- Partials    14318    14319       +1     
Flag Coverage Δ
frontend 59.34% <100.00%> (+0.38%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

Copilot AI left a comment

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.

Warning

  • Copilot's review of this pull request may be incomplete because some of the changed files are excluded by your Copilot content exclusion settings. See Excluding content from Copilot for details.

Pull request overview

Updates the Hosts page “User email” column to show a primary (preferred-source) email address directly in the table, with a +N suffix and tooltip to reveal additional emails when multiple are present. This improves host ownership discoverability in environments where “Used by” can be ambiguous.

Changes:

  • Replaces the “N users” display with a primary email + optional +N suffix and tooltip listing additional emails.
  • Adds getPrimaryDeviceUser helper (with unit tests) to pick an IdP email first, then Chrome profile, then first available.
  • Extends TooltipTruncatedTextCell with justifySuffixEnd and showTooltipWithSuffix options, plus styling support.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
frontend/pages/hosts/ManageHostsPage/HostTableConfig.tsx Picks a primary device user email and renders it with suffix + tooltip in the Hosts table.
frontend/pages/hosts/ManageHostsPage/HostTableConfig.tests.tsx Adds unit tests for primary-email selection and rendering behavior in the Hosts table column.
frontend/components/TableContainer/DataTable/TooltipTruncatedTextCell/TooltipTruncatedTextCell.tsx Adds props to control suffix alignment and tooltip enabling when suffix is present.
frontend/components/TableContainer/DataTable/TooltipTruncatedTextCell/_styles.scss Adds CSS to pin the suffix to the right edge when requested.
changes/30758-idp-username-hosts-column User-visible change note (content excluded from review by policy).
Files excluded by content exclusion policy (1)
  • changes/30758-idp-username-hosts-column

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@spalmesano0 spalmesano0 marked this pull request as ready for review July 7, 2026 16:54
@spalmesano0 spalmesano0 requested a review from a team as a code owner July 7, 2026 16:54

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9cf79f14-5444-4b49-93b9-926c1942a396

📥 Commits

Reviewing files that changed from the base of the PR and between f1d9f72 and ada1dcd.

📒 Files selected for processing (1)
  • frontend/pages/hosts/ManageHostsPage/HostTableConfig.tests.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/pages/hosts/ManageHostsPage/HostTableConfig.tests.tsx

Walkthrough

The Hosts table "User email" column now renders a primary email chosen from IdP accounts, then Chrome profiles, then the first available user, with a +N suffix and tooltip listing additional emails. HostTableConfig.tsx adds and exports getPrimaryDeviceUser for this selection and tooltip data. TooltipTruncatedTextCell now supports suffix alignment and suffix-triggered tooltips, with matching style updates. Tests cover the helper logic and the updated cell rendering.

Changes

Cohort / File(s) Summary
TooltipTruncatedTextCell Added justifySuffixEnd and showTooltipWithSuffix props, updated tooltip disable logic and effect dependencies, added justify-suffix-end SCSS modifier
HostTableConfig Added exported getPrimaryDeviceUser helper; updated "User email" cell to render primary email with suffix and tooltip; added changelog entry
HostTableConfig.tests.tsx Added tests for getPrimaryDeviceUser and the updated cell rendering

Sequence Diagram(s)

flowchart TD
DeviceUsers --> getPrimaryDeviceUser
getPrimaryDeviceUser --> SelectByPriority
SelectByPriority --> ComputeSuffixAndTooltipLines
ComputeSuffixAndTooltipLines --> TooltipTruncatedTextCellRender
TooltipTruncatedTextCellRender --> TooltipVisibilityCheck
TooltipVisibilityCheck --> RenderedHostRow
Loading

Related issues: #30758 (Username (IdP) in Hosts columns)

Suggested labels: frontend, enhancement

Suggested reviewers: noahtalerman

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: showing the primary user email on the Hosts page when multiple users exist.
Description check ✅ Passed The description includes the required related issue, checklist items, and testing notes, with only noncritical optional sections omitted.
Linked Issues check ✅ Passed The PR shows the primary IdP email on the Hosts page and adds the supporting tooltip/count behavior needed to identify the primary user.
Out of Scope Changes check ✅ Passed All changes support the Hosts page email display update and its tests/styles; no unrelated code was introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 idp-username-in-column

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.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/components/TableContainer/DataTable/TooltipTruncatedTextCell/TooltipTruncatedTextCell.tsx (1)

41-47: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider widening the return type to React.ReactNode.

Static analysis flags JSX.Element as too narrow at Line 43; it excludes null, strings, and fragments that this component could plausibly return in the future.

♻️ Proposed fix
-}: ITooltipTruncatedTextCellProps): JSX.Element => {
+}: ITooltipTruncatedTextCellProps): React.ReactNode => {
🤖 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
`@frontend/components/TableContainer/DataTable/TooltipTruncatedTextCell/TooltipTruncatedTextCell.tsx`
around lines 41 - 47, The return type on TooltipTruncatedTextCell is too narrow
with JSX.Element and should be widened to React.ReactNode. Update the component
signature for TooltipTruncatedTextCell so it uses React.ReactNode instead,
keeping it compatible with null, strings, and fragments while preserving the
existing props and classNames logic.

Source: Linters/SAST tools

🤖 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 `@frontend/pages/hosts/ManageHostsPage/HostTableConfig.tests.tsx`:
- Around line 85-93: The test in getPrimaryDeviceUser is using toContain with
expect.stringContaining("more"), which compares the matcher object directly
instead of checking each tooltip line’s text. Update the assertion to use a
predicate on tooltipLines so it actually verifies that no entry contains “more”,
while keeping the existing exact-length check for the cap case.

---

Nitpick comments:
In
`@frontend/components/TableContainer/DataTable/TooltipTruncatedTextCell/TooltipTruncatedTextCell.tsx`:
- Around line 41-47: The return type on TooltipTruncatedTextCell is too narrow
with JSX.Element and should be widened to React.ReactNode. Update the component
signature for TooltipTruncatedTextCell so it uses React.ReactNode instead,
keeping it compatible with null, strings, and fragments while preserving the
existing props and classNames logic.
🪄 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: 94fda647-8f5e-4944-96b5-fbfb6e49863a

📥 Commits

Reviewing files that changed from the base of the PR and between af51636 and f1d9f72.

📒 Files selected for processing (5)
  • changes/30758-idp-username-hosts-column
  • frontend/components/TableContainer/DataTable/TooltipTruncatedTextCell/TooltipTruncatedTextCell.tsx
  • frontend/components/TableContainer/DataTable/TooltipTruncatedTextCell/_styles.scss
  • frontend/pages/hosts/ManageHostsPage/HostTableConfig.tests.tsx
  • frontend/pages/hosts/ManageHostsPage/HostTableConfig.tsx

Comment thread frontend/pages/hosts/ManageHostsPage/HostTableConfig.tests.tsx
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.

Username (IdP) in Hosts columns

2 participants