Support release device from AB in the frontend - #49748
Conversation
e691c83 to
cd8d76c
Compare
There was a problem hiding this comment.
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.
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
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
canReleaseFromABdoesn’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 explicitisAppleDevice(hostPlatform)check.
const canReleaseFromAB = (config: IHostActionConfigOptions) => {
const {
isPremiumTier,
hostMdmEnrollmentStatus,
isAppleBusinessEnabledAndConfigured,
isGlobalAdmin,
isTeamAdmin,
hostPlatform,
WalkthroughThe 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
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx (1)
2210-2217: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winVerify coverage for the global activity path.
Please confirm that a
GlobalActivityItemtest coversActivityType.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
📒 Files selected for processing (24)
frontend/__mocks__/hostMock.tsfrontend/interfaces/activity.tsfrontend/interfaces/host.tsfrontend/interfaces/mdm.tsfrontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsxfrontend/pages/ManageControlsPage/OSSettings/cards/ConfigurationProfiles/components/ProfileUploader/helpers.tsxfrontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/HostActionsDropdown.tests.tsxfrontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/HostActionsDropdown.tsxfrontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/helpers.tsxfrontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsxfrontend/pages/hosts/details/HostDetailsPage/components/ReleaseFromABModal/ReleaseFromABModal.tests.tsxfrontend/pages/hosts/details/HostDetailsPage/components/ReleaseFromABModal/ReleaseFromABModal.tsxfrontend/pages/hosts/details/HostDetailsPage/components/ReleaseFromABModal/helpers.tsfrontend/pages/hosts/details/HostDetailsPage/components/ReleaseFromABModal/index.tsfrontend/pages/hosts/details/cards/Activity/ActivityConfig.tsxfrontend/pages/hosts/details/cards/Activity/ActivityItems/ReleasedFromABActivityItem/ReleasedFromABActivityItem.tests.tsxfrontend/pages/hosts/details/cards/Activity/ActivityItems/ReleasedFromABActivityItem/ReleasedFromABActivityItem.tsxfrontend/pages/hosts/details/cards/Activity/ActivityItems/ReleasedFromABActivityItem/index.tsfrontend/pages/hosts/details/modals/MDMStatusModal/MDMStatusModal.tsxfrontend/pages/hosts/details/modals/MDMStatusModal/_styles.scssfrontend/services/entities/hosts.tsfrontend/services/entities/mdm_apple_bm.tsfrontend/utilities/endpoints.tsfrontend/utilities/helpers.tsx
Codecov Report❌ Patch coverage is 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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/oree/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
Summary by CodeRabbit