Skip to content

Support release device from AB in the frontend - #49748

Merged
MagnusHJensen merged 5 commits into
mainfrom
49368-release-ab-frontend
Jul 23, 2026
Merged

Support release device from AB in the frontend#49748
MagnusHJensen merged 5 commits into
mainfrom
49368-release-ab-frontend

Conversation

@MagnusHJensen

@MagnusHJensen MagnusHJensen commented Jul 22, 2026

Copy link
Copy Markdown
Member

Related issue: Resolves #49368

Video:

Screen.Recording.2026-07-22.at.16.31.22.mov

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

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

Summary by CodeRabbit

  • New Features
    • Added “Release from Apple Business” to eligible host actions, including a confirmation modal with success and error handling.
    • Added Apple Business release entries to the activity feed.
  • Bug Fixes
    • Improved user-facing Apple Business error and “Learn more” messaging, including clearer output when Apple Business device status isn’t accessible.

@MagnusHJensen MagnusHJensen linked an issue Jul 22, 2026 that may be closed by this pull request
Base automatically changed from 49367-release-ab to main July 22, 2026 18:01
@MagnusHJensen
MagnusHJensen force-pushed the 49368-release-ab-frontend branch from e691c83 to cd8d76c Compare July 22, 2026 18:08
Copilot AI review requested due to automatic review settings July 22, 2026 18:08

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.

Pull request overview

Adds frontend support for releasing an Apple device from Apple Business (AB) from the host details page, including action gating, confirmation modal, API wiring, and activity feed rendering.

Changes:

  • Adds a new “Release from Apple Business” host action (gated by role/config/device state) and wires it to a new release modal in Host details.
  • Introduces a new AB release API endpoint + entity method and handles backend error messaging (including “Learn more” links).
  • Adds host/global activity feed support for “released from AB” events and extends MDM/DEP-related host data for UI states.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
frontend/utilities/helpers.tsx Adds shared helper to format backend errors containing “Learn more” links.
frontend/utilities/endpoints.ts Adds RELEASE_AB_HOSTS API endpoint constant.
frontend/styles/var/padding.ts Adds a new padding token key used by UI typing.
frontend/services/entities/mdm_apple_bm.ts Adds releaseHostsFromAB API call + response typing.
frontend/services/entities/hosts.ts Extends DEP assignment response typing with response_status.
frontend/pages/ManageControlsPage/OSSettings/cards/ConfigurationProfiles/components/ProfileUploader/helpers.tsx Switches to shared “Learn more” error helper.
frontend/pages/hosts/details/modals/MDMStatusModal/MDMStatusModal.tsx Adds UI for NOT_ACCESSIBLE DEP device state.
frontend/pages/hosts/details/modals/MDMStatusModal/_styles.scss Adds styling for the “not accessible” profile-assignment error block.
frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx Adds state + rendering for the Release-from-AB modal.
frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/HostActionsDropdown.tsx Plumbs new config/host flags into action availability.
frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/HostActionsDropdown.tests.tsx Adds coverage for showing/hiding the new action.
frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/helpers.tsx Adds option + gating logic for “Release from Apple Business”.
frontend/pages/hosts/details/HostDetailsPage/components/ReleaseFromABModal/ReleaseFromABModal.tsx New confirmation modal that calls release API and notifies success/failure.
frontend/pages/hosts/details/HostDetailsPage/components/ReleaseFromABModal/ReleaseFromABModal.tests.tsx New unit test for checkbox-gated “Release” button enablement.
frontend/pages/hosts/details/HostDetailsPage/components/ReleaseFromABModal/index.ts Barrel export for modal.
frontend/pages/hosts/details/HostDetailsPage/components/ReleaseFromABModal/helpers.ts Error-message mapping for release failures (incl. “Learn more”).
frontend/pages/hosts/details/cards/Activity/ActivityItems/ReleasedFromABActivityItem/ReleasedFromABActivityItem.tsx New host activity item renderer for AB release.
frontend/pages/hosts/details/cards/Activity/ActivityItems/ReleasedFromABActivityItem/ReleasedFromABActivityItem.tests.tsx Tests for the new host activity item.
frontend/pages/hosts/details/cards/Activity/ActivityItems/ReleasedFromABActivityItem/index.ts Barrel export for activity item.
frontend/pages/hosts/details/cards/Activity/ActivityConfig.tsx Registers the new host activity type → component mapping.
frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx Adds global activity feed template for AB release events.
frontend/interfaces/mdm.ts Exports MDM_ENROLLMENT_STATUSES const for safer iteration in tests.
frontend/interfaces/host.ts Adds dep_assigned_to_fleet to host interface.
frontend/interfaces/activity.ts Adds ReleasedDeviceFromAB activity type and filter label.
frontend/mocks/hostMock.ts Updates default host mock for new dep_assigned_to_fleet field.

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

Comment thread frontend/styles/var/padding.ts
Copilot AI review requested due to automatic review settings July 22, 2026 18:15
@MagnusHJensen

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/helpers.tsx:424

  • canReleaseFromAB doesn’t check the host platform, so the action can potentially appear for non‑Apple hosts that share the same MDM enrollment status strings (e.g. Android COBO uses "On (automatic)"). The story calls out that this action should only be shown for AB‑enrolled Apple devices (macOS/iOS/iPadOS), and other host-action gates in this file consistently include an explicit isAppleDevice(hostPlatform) check.
const canReleaseFromAB = (config: IHostActionConfigOptions) => {
  const {
    isPremiumTier,
    hostMdmEnrollmentStatus,
    isAppleBusinessEnabledAndConfigured,
    isGlobalAdmin,
    isTeamAdmin,
    hostPlatform,

Copilot AI review requested due to automatic review settings July 22, 2026 18:24
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The frontend adds a “Release from Apple Business” host action with eligibility checks, a confirmation modal, API integration, result handling, and host refresh behavior. It adds Apple Business release activity types and renders them in global and host activity feeds. Shared “Learn more” error formatting is centralized, and a dedicated UI state is added for inaccessible Apple Business device lookups. Host and MDM interfaces, mocks, endpoint definitions, and tests are updated.

Possibly related issues

Possibly related PRs

  • fleetdm/fleet#49680: Adds the backend route and implementation corresponding to the new Apple Business release API client.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes implement the new dropdown action, modal, error handling, learn-more links, activities, and admin/device gating required by #49368.
Out of Scope Changes check ✅ Passed The extra type and helper refactors appear directly tied to the Apple Business release flow and its related UI/error handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly summarizes the main frontend change: adding Apple Business release support.
Description check ✅ Passed The description includes the related issue, checklist, testing, and manual QA notes, so it is mostly complete.
✨ 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 49368-release-ab-frontend

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.

@MagnusHJensen

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.

Comment thread frontend/utilities/helpers.tsx Outdated
Comment thread frontend/services/entities/hosts.ts Outdated

@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: 4

🧹 Nitpick comments (1)
frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx (1)

2210-2217: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Verify coverage for the global activity path.

Please confirm that a GlobalActivityItem test covers ActivityType.ReleasedDeviceFromAB, including the host display name and fallback behavior. If not, add one to prevent this case from silently falling back to the default activity template.

Also applies to: 2717-2719

🤖 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/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx`
around lines 2210 - 2217, Add or update GlobalActivityItem test coverage for
ActivityType.ReleasedDeviceFromAB, verifying the rendered host display name and
the fallback behavior when it is absent. Ensure the test exercises the global
activity path and confirms this activity uses releasedDeviceFromAB rather than
the default template.
🤖 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/details/HostDetailsPage/components/ReleaseFromABModal/ReleaseFromABModal.tsx`:
- Around line 32-35: Update the ReleaseFromABModal exit handling so
user-initiated dismissal through onModalExit, cancel, Escape, or backdrop is
ignored while isSubmitting. Preserve a separate completion path for the
request’s finally block that resets submission state and closes the modal after
the API call finishes.

In
`@frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/HostActionsDropdown.tests.tsx`:
- Around line 2876-2911: Update the test named “does not render to an any team
admin” to configure createMockUser() with membership in a team different from
hostTeamId, using the currentUser.teams data consumed by
permissions.isTeamAdmin. Remove reliance on the unused app.isAnyTeamAdmin flag
while preserving the assertion that “Release from Apple Business” is not
rendered.

In `@frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx`:
- Around line 1768-1770: Update the onRelease callback in HostDetailsPage to
refetch past activities in addition to refetchHostDetails, ensuring the activity
feed immediately includes the new release activity. Reuse the existing
past-activities refetch symbol or query mechanism used by the page.

In `@frontend/utilities/helpers.tsx`:
- Around line 995-1000: Update the error-message parsing block to derive the
Learn More URL from the same case-insensitive marker position used by the
detection logic, rather than searching from the beginning for a lowercase
“https://”. Preserve the extracted message prefix while ensuring mixed-case
schemes and earlier URLs select the URL belonging to the matched Learn More
marker.

---

Nitpick comments:
In
`@frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx`:
- Around line 2210-2217: Add or update GlobalActivityItem test coverage for
ActivityType.ReleasedDeviceFromAB, verifying the rendered host display name and
the fallback behavior when it is absent. Ensure the test exercises the global
activity path and confirms this activity uses releasedDeviceFromAB rather than
the default template.
🪄 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: 927828e4-3b32-4460-8c11-e2a33444793c

📥 Commits

Reviewing files that changed from the base of the PR and between b9136f4 and 2fcbe48.

📒 Files selected for processing (24)
  • frontend/__mocks__/hostMock.ts
  • frontend/interfaces/activity.ts
  • frontend/interfaces/host.ts
  • frontend/interfaces/mdm.ts
  • frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx
  • frontend/pages/ManageControlsPage/OSSettings/cards/ConfigurationProfiles/components/ProfileUploader/helpers.tsx
  • frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/HostActionsDropdown.tests.tsx
  • frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/HostActionsDropdown.tsx
  • frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/helpers.tsx
  • frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx
  • frontend/pages/hosts/details/HostDetailsPage/components/ReleaseFromABModal/ReleaseFromABModal.tests.tsx
  • frontend/pages/hosts/details/HostDetailsPage/components/ReleaseFromABModal/ReleaseFromABModal.tsx
  • frontend/pages/hosts/details/HostDetailsPage/components/ReleaseFromABModal/helpers.ts
  • frontend/pages/hosts/details/HostDetailsPage/components/ReleaseFromABModal/index.ts
  • frontend/pages/hosts/details/cards/Activity/ActivityConfig.tsx
  • frontend/pages/hosts/details/cards/Activity/ActivityItems/ReleasedFromABActivityItem/ReleasedFromABActivityItem.tests.tsx
  • frontend/pages/hosts/details/cards/Activity/ActivityItems/ReleasedFromABActivityItem/ReleasedFromABActivityItem.tsx
  • frontend/pages/hosts/details/cards/Activity/ActivityItems/ReleasedFromABActivityItem/index.ts
  • frontend/pages/hosts/details/modals/MDMStatusModal/MDMStatusModal.tsx
  • frontend/pages/hosts/details/modals/MDMStatusModal/_styles.scss
  • frontend/services/entities/hosts.ts
  • frontend/services/entities/mdm_apple_bm.ts
  • frontend/utilities/endpoints.ts
  • frontend/utilities/helpers.tsx

Comment thread frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx
Comment thread frontend/utilities/helpers.tsx Outdated
Copilot AI review requested due to automatic review settings July 22, 2026 18:40
@MagnusHJensen
MagnusHJensen marked this pull request as ready for review July 22, 2026 18:40
@MagnusHJensen
MagnusHJensen requested a review from a team as a code owner July 22, 2026 18:40
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 41.66667% with 56 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.87%. Comparing base (b9136f4) to head (4354152).
⚠️ Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
...mponents/ReleaseFromABModal/ReleaseFromABModal.tsx 31.25% 22 Missing ⚠️
.../hosts/details/HostDetailsPage/HostDetailsPage.tsx 0.00% 10 Missing ⚠️
...tailsPage/components/ReleaseFromABModal/helpers.ts 10.00% 9 Missing ⚠️
frontend/utilities/helpers.tsx 14.28% 6 Missing ⚠️
...vityFeed/GlobalActivityItem/GlobalActivityItem.tsx 0.00% 4 Missing ⚠️
frontend/services/entities/mdm_apple_bm.ts 0.00% 3 Missing ⚠️
...ls/HostDetailsPage/HostActionsDropdown/helpers.tsx 95.00% 1 Missing ⚠️
...s/details/modals/MDMStatusModal/MDMStatusModal.tsx 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #49748      +/-   ##
==========================================
- Coverage   67.90%   67.87%   -0.04%     
==========================================
  Files        3896     3899       +3     
  Lines      249020   248759     -261     
  Branches    13101    13092       -9     
==========================================
- Hits       169108   168849     -259     
- Misses      64677    64693      +16     
+ Partials    15235    15217      -18     
Flag Coverage Δ
frontend 60.32% <41.66%> (-0.05%) ⬇️

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.

@MagnusHJensen
MagnusHJensen merged commit 5d8f46b into main Jul 23, 2026
28 checks passed
@MagnusHJensen
MagnusHJensen deleted the 49368-release-ab-frontend branch July 23, 2026 07:43
@coderabbitai coderabbitai Bot mentioned this pull request Jul 27, 2026
2 tasks
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.

Release from AB: Frontend

3 participants