Skip to content

Add frontend support for enrollment profile renewal failed activity#44530

Open
MagnusHJensen wants to merge 3 commits intomainfrom
41422-frontend-enrollment-renewal-failed-activity
Open

Add frontend support for enrollment profile renewal failed activity#44530
MagnusHJensen wants to merge 3 commits intomainfrom
41422-frontend-enrollment-renewal-failed-activity

Conversation

@MagnusHJensen
Copy link
Copy Markdown
Member

@MagnusHJensen MagnusHJensen commented Apr 30, 2026

Related issue: Resolves #41422

image image image image

Checklist for submitter

If some of the following don't apply, delete the relevant line.

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
    See Changes files for more information. Part of backend PR

  • Input data is properly validated, SELECT * is avoided, SQL injection is prevented (using placeholders for values in statements), JS inline code is prevented especially for url redirects, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters.

  • Timeouts are implemented and retries are limited to avoid infinite loops

  • If paths of existing endpoints are modified without backwards compatibility, checked the frontend/CLI for any necessary changes

Testing

  • QA'd all new/changed functionality manually

Summary by CodeRabbit

  • New Features
    • Added "Enrollment profile renewal failed" activity type and label.
    • Failure entries appear in activity feeds and host details with a dedicated activity item.
    • Users can open a failure details modal showing status, host name, relative failure time, guidance about certificate expiration, and a link to Fleet support.

Copilot AI review requested due to automatic review settings April 30, 2026 18:46
@MagnusHJensen MagnusHJensen requested a review from a team as a code owner April 30, 2026 18:46
Copy link
Copy Markdown

@claude claude Bot left a comment

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 to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

❌ Patch coverage is 16.32653% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.78%. Comparing base (13cec63) to head (3b002c0).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...onents/CommandDetailsModal/CommandDetailsModal.tsx 14.28% 12 Missing ⚠️
...lmentProfileModal/FailedEnrollmentProfileModal.tsx 18.18% 9 Missing ⚠️
.../hosts/details/HostDetailsPage/HostDetailsPage.tsx 0.00% 8 Missing ⚠️
.../DashboardPage/cards/ActivityFeed/ActivityFeed.tsx 25.00% 6 Missing ⚠️
...vityFeed/GlobalActivityItem/GlobalActivityItem.tsx 0.00% 4 Missing ⚠️
...tem/FailedEnrollmentProfileRenewalActivityItem.tsx 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #44530      +/-   ##
==========================================
- Coverage   66.79%   66.78%   -0.02%     
==========================================
  Files        2637     2639       +2     
  Lines      212132   212175      +43     
  Branches     9555     9574      +19     
==========================================
+ Hits       141690   141695       +5     
- Misses      57576    57614      +38     
  Partials    12866    12866              
Flag Coverage Δ
frontend 54.71% <16.32%> (-0.08%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds UI support for the new failed_enrollment_profile_renewal activity across host and global activity feeds, including a dedicated details modal that surfaces MDM command result details.

Changes:

  • Adds host activity item rendering for failed_enrollment_profile_renewal and wires it into the host activity config.
  • Adds global activity feed template + “has details” handling for the new activity type.
  • Introduces FailedEnrollmentProfileModal leveraging a more flexible CommandResultsModal (custom title/body; can fetch by command UUID without host UUID).

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
frontend/pages/hosts/details/cards/Activity/ActivityItems/FailedEnrollmentProfileRenewalActivityItem/index.ts Re-export for new host activity item.
frontend/pages/hosts/details/cards/Activity/ActivityItems/FailedEnrollmentProfileRenewalActivityItem/FailedEnrollmentProfileRenewalActivityItem.tsx New host activity item UI for renewal-failed activity.
frontend/pages/hosts/details/cards/Activity/ActivityConfig.tsx Registers new activity item in host past activity map.
frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx Opens new failed-enrollment-profile modal from host activity details handler.
frontend/pages/hosts/components/CommandDetailsModal/index.ts Re-exports helpers/types from CommandResultsModal.
frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tsx Adds customizable modal title/body and supports fetching results without host_uuid.
frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx Adds global activity template + enables details for new activity type.
frontend/pages/DashboardPage/cards/ActivityFeed/ActivityFeed.tsx Opens new failed-enrollment-profile modal from global activity details handler.
frontend/interfaces/activity.ts Adds new ActivityType value and filter label mapping.
frontend/components/modals/FailedEnrollmentProfileModal/index.ts Re-export for new modal.
frontend/components/modals/FailedEnrollmentProfileModal/FailedEnrollmentProfileModal.tsx New modal wrapping CommandResultsModal with custom body text.

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

Comment thread frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tsx Outdated
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 30, 2026

Walkthrough

Adds a new activity type ActivityType.FailedEnrollmentProfileRenewal and UI for it: a FailedEnrollmentProfileRenewalActivityItem component and a FailedEnrollmentProfileModal (with exported IFailedEnrollmentProfileModalProps) plus an index.ts re-export. Refactors CommandResultsModal to export ICommandResultsModalCommand and GetIconName, accept optional title and contentBody props, and use a fetcher that supports missing host_identifier. Wires modal opening/closing into ActivityFeed and HostDetailsPage to show details for the new activity.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding frontend support for a new enrollment profile renewal failed activity type across multiple UI components.
Description check ✅ Passed The PR description includes a linked issue, checklist items addressing input validation, timeouts, and endpoint compatibility, plus QA confirmation. However, it lacks added/updated automated test confirmation and changes file documentation.
Linked Issues check ✅ Passed The PR fully addresses all three objectives from issue #41422: global activity feed filter updated, activity templates added to both feeds, and details modal implemented using the existing API endpoint.
Out of Scope Changes check ✅ Passed All changes are tightly scoped to the enrollment profile renewal failed activity feature. The refactoring of CommandDetailsModal to support custom rendering is directly necessary to enable the feature, with no extraneous modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 41422-frontend-enrollment-renewal-failed-activity

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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tsx (1)

194-206: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Guard query execution when command_uuid is empty.

On Line 204, command_uuid can still be an empty string from upstream fallback paths, which causes a request with invalid query params and a noisy error state. Add an enabled guard.

Suggested fix
     {
       ...DEFAULT_USE_QUERY_OPTIONS,
+      enabled: !!command_uuid,
       keepPreviousData: true,
       staleTime: 2000,
     }

Also applies to: 227-231

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

In `@frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tsx`
around lines 194 - 206, The useQuery calls that fetch command results (the call
using useQuery with the key object containing scope: "command_results",
host_identifier and command_uuid) should be guarded so they don't run when
command_uuid is empty; add an enabled option (e.g., enabled:
Boolean(command_uuid)) to the query options to prevent execution with invalid
params, and apply the same enabled guard to the other useQuery instance that
references command_uuid around lines 227-231 so both queries only run when
command_uuid is non-empty.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@frontend/components/modals/FailedEnrollmentProfileModal/FailedEnrollmentProfileModal.tsx`:
- Around line 27-30: The status message in FailedEnrollmentProfileModal uses
result.name which can be null and yields an empty bold segment; update the
rendering to use a safe fallback (e.g., "Unnamed profile" or "Unknown profile")
when result.name is falsy so the copy is never blank — modify the JSX that
currently renders <b>{result.name}</b> to render <b>{result.name || "Unnamed
profile"}</b> (or equivalent), keeping displayTime and surrounding text
unchanged.

In `@frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tsx`:
- Around line 208-212: The code calls
commandApi.getHostCommandResults(queryKey[0]) unconditionally which triggers the
host-specific request even when queryKey[0].host_identifier is empty; change the
logic to check queryKey[0].host_identifier first and only call
commandApi.getHostCommandResults when host_identifier is non-empty, otherwise
call commandApi.getCommandResults(queryKey[0].command_uuid), so only the
intended endpoint is invoked (refer to commandApi.getHostCommandResults,
commandApi.getCommandResults and queryKey[0].host_identifier).

In `@frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx`:
- Around line 880-886: The handler for
ActivityType.FailedEnrollmentProfileRenewal is setting
enrollmentProfileFailedDetails with an empty command_uuid which can trigger the
failed-renewal modal and a subsequent failed request; update the logic in
HostDetailsPage to guard on details?.command_uuid (or truthy
details.command_uuid) before calling setEnrollmentProfileFailedDetails so the
modal is only opened when a valid command_uuid exists (leave state unchanged or
ensure modal remains closed when command_uuid is missing).

---

Outside diff comments:
In `@frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tsx`:
- Around line 194-206: The useQuery calls that fetch command results (the call
using useQuery with the key object containing scope: "command_results",
host_identifier and command_uuid) should be guarded so they don't run when
command_uuid is empty; add an enabled option (e.g., enabled:
Boolean(command_uuid)) to the query options to prevent execution with invalid
params, and apply the same enabled guard to the other useQuery instance that
references command_uuid around lines 227-231 so both queries only run when
command_uuid is non-empty.
🪄 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: 2b8c803a-e29c-4b60-bb5c-16d4dba2586e

📥 Commits

Reviewing files that changed from the base of the PR and between f70a02a and 6ad2478.

📒 Files selected for processing (11)
  • frontend/components/modals/FailedEnrollmentProfileModal/FailedEnrollmentProfileModal.tsx
  • frontend/components/modals/FailedEnrollmentProfileModal/index.ts
  • frontend/interfaces/activity.ts
  • frontend/pages/DashboardPage/cards/ActivityFeed/ActivityFeed.tsx
  • frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx
  • frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tsx
  • frontend/pages/hosts/components/CommandDetailsModal/index.ts
  • frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx
  • frontend/pages/hosts/details/cards/Activity/ActivityConfig.tsx
  • frontend/pages/hosts/details/cards/Activity/ActivityItems/FailedEnrollmentProfileRenewalActivityItem/FailedEnrollmentProfileRenewalActivityItem.tsx
  • frontend/pages/hosts/details/cards/Activity/ActivityItems/FailedEnrollmentProfileRenewalActivityItem/index.ts

Comment thread frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tsx Outdated
Comment thread frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx
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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@frontend/components/modals/FailedEnrollmentProfileModal/FailedEnrollmentProfileModal.tsx`:
- Around line 26-30: The message currently uses result.hostname via
hostDisplayName in messageText which incorrectly references the device; replace
that with the enrollment profile label (e.g., result.enrollmentProfileLabel or
result.enrollment_profile_label) and rename hostDisplayName to something like
profileDisplayName (fallback "this enrollment profile") so messageText reads
"Fleet enrollment profile renewal failed for
<b>{profileDisplayName}</b>{displayTime}"; update any references to
hostDisplayName to the new profileDisplayName.
🪄 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: 2b3bea83-6f1a-4351-8604-960825b871c7

📥 Commits

Reviewing files that changed from the base of the PR and between ea5b806 and 3b002c0.

📒 Files selected for processing (2)
  • frontend/components/modals/FailedEnrollmentProfileModal/FailedEnrollmentProfileModal.tsx
  • frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.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.

New activity for failed_enrollment_profile_renewal: Frontend changes

2 participants