Skip to content

Clear passcode frontend - #43084

Merged
MagnusHJensen merged 5 commits into
mainfrom
42369-clear-passcode-frontend
Apr 7, 2026
Merged

Clear passcode frontend#43084
MagnusHJensen merged 5 commits into
mainfrom
42369-clear-passcode-frontend

Conversation

@MagnusHJensen

@MagnusHJensen MagnusHJensen commented Apr 6, 2026

Copy link
Copy Markdown
Member

Related issue: Resolves #42369

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. Done in backend task for whole story

  • 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 "Clear passcode" action for iOS and iPad hosts in the host actions menu, accessible only to Premium tier users with appropriate permissions.
    • Added confirmation modal for clearing device passcodes.
    • Passcode clearing activity now appears in the activity feed with actor information.
    • Action is conditionally disabled during specific device states (Lost Mode, pending wipe) with contextual tooltips.

@codecov

codecov Bot commented Apr 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.77778% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.84%. Comparing base (6a9d394) to head (9572d07).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...e/modals/ClearPasscodeModal/ClearPasscodeModal.tsx 11.76% 15 Missing ⚠️
.../hosts/details/HostDetailsPage/HostDetailsPage.tsx 0.00% 8 Missing ⚠️
...vityFeed/GlobalActivityItem/GlobalActivityItem.tsx 0.00% 4 Missing ⚠️
frontend/services/entities/hosts.ts 0.00% 3 Missing ⚠️
...sscodeActivityItem/ClearedPasscodeActivityItem.tsx 50.00% 2 Missing ⚠️
...ls/HostDetailsPage/HostActionsDropdown/helpers.tsx 97.14% 1 Missing ⚠️
frontend/utilities/endpoints.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #43084   +/-   ##
=======================================
  Coverage   66.84%   66.84%           
=======================================
  Files        2581     2583    +2     
  Lines      207154   207060   -94     
  Branches     9180     9207   +27     
=======================================
- Hits       138475   138414   -61     
+ Misses      56086    56076   -10     
+ Partials    12593    12570   -23     
Flag Coverage Δ
frontend 54.75% <52.77%> (-0.01%) ⬇️

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.

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 the new Clear passcode MDM action and related activity entries, wiring it into the Host details UI and activity feeds.

Changes:

  • Added a new host endpoint + service method to POST /fleet/hosts/:id/clear_passcode.
  • Added “Clear passcode” to the Host actions dropdown (iOS/iPadOS only, non-personal enrollments) plus a new confirmation modal.
  • Added support for the new cleared_passcode activity type in host activity + global activity templates.

Reviewed changes

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

Show a summary per file
File Description
frontend/utilities/endpoints.ts Adds HOST_CLEAR_PASSCODE endpoint builder.
frontend/services/entities/hosts.ts Adds hostAPI.clearPasscode POST call.
frontend/pages/hosts/details/HostDetailsPage/modals/ClearPasscodeModal/index.ts Barrel export for the new modal.
frontend/pages/hosts/details/HostDetailsPage/modals/ClearPasscodeModal/ClearPasscodeModal.tsx Implements the clear passcode confirmation modal + API call.
frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx Wires dropdown selection to open the new modal.
frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/helpers.tsx Adds option + eligibility/disabled-state rules for “Clear passcode”.
frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/HostActionsDropdown.tests.tsx Updates option rendering tests + adds clear passcode-specific tests.
frontend/pages/hosts/details/cards/Activity/ActivityItems/ClearedPasscodeActivityItem/index.ts Barrel export for the host activity item.
frontend/pages/hosts/details/cards/Activity/ActivityItems/ClearedPasscodeActivityItem/ClearedPasscodeActivityItem.tsx Renders host past-activity row for cleared passcode.
frontend/pages/hosts/details/cards/Activity/ActivityConfig.tsx Registers the new host past activity component mapping.
frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx Adds a template string for global activity feed rendering.
frontend/interfaces/activity.ts Adds ActivityType.ClearedPasscode and updates host past activity union + filter label.

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

@MagnusHJensen
MagnusHJensen marked this pull request as ready for review April 7, 2026 20:26
@MagnusHJensen
MagnusHJensen requested a review from a team as a code owner April 7, 2026 20:26

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

@MagnusHJensen

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

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.

1 similar comment
@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

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.

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This PR introduces a "Clear passcode" action for iOS/iPadOS hosts in the Fleet frontend. The implementation includes: adding the ActivityType.ClearedPasscode enum and activity type definitions; creating the ClearPasscodeModal component for confirmation; extending the host actions dropdown with the new option and eligibility checks (based on platform, MDM status, user role, and Fleet tier); adding activity display components and mappings; and integrating the API service method and endpoint builder for the clear passcode operation. The feature respects visibility rules for host platform, enrollment status, and user permissions, with disabled states and tooltips during specific MDM device statuses.

Possibly related PRs

  • #42197 — Modifies activity type definitions and GlobalActivityItem templates to add support for new ActivityType rendering in the activity feed system.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Clear passcode frontend' clearly describes the main change—adding frontend support for a clear passcode feature across multiple components and UI elements.
Linked Issues check ✅ Passed The PR implements all objectives from #42369: adds clear passcode option to host actions dropdown for iOS/iPadOS non-personal enrollments, includes confirmation modal per Figma, and adds frontend activity support.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the linked issue #42369 requirements: activity type definitions, UI components, helper logic, API service methods, and endpoints for clear passcode functionality.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed PR description includes most required sections with checked items for testing, security validation, and endpoint compatibility, but the 'changes file' section notes backend handling without confirming frontend changes file status.

✏️ 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 42369-clear-passcode-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 and usage tips.

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

🧹 Nitpick comments (2)
frontend/pages/hosts/details/HostDetailsPage/modals/ClearPasscodeModal/ClearPasscodeModal.tsx (1)

33-36: State update after component unmount.

The onExit() callback will unmount this modal, so the subsequent setIsClearingPasscode(false) call attempts to update state on an unmounted component. While React 18 no longer warns about this, the state update is effectively dead code.

♻️ Suggested fix: remove unnecessary state update
     } finally {
       onExit();
-      setIsClearingPasscode(false);
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/pages/hosts/details/HostDetailsPage/modals/ClearPasscodeModal/ClearPasscodeModal.tsx`
around lines 33 - 36, The finally block calls onExit() which unmounts the modal
and then calls setIsClearingPasscode(false), causing a state update after
unmount; remove the setIsClearingPasscode(false) call from the finally block in
the ClearPasscodeModal component (referencing the finally block that invokes
onExit and setIsClearingPasscode) so only onExit() runs, or alternatively move
setIsClearingPasscode(false) to run before onExit() if you must reset local
state prior to unmounting.
frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/HostActionsDropdown.tests.tsx (1)

1946-1986: Consider adding test coverage for "wiped" device status.

The implementation disables "Clear passcode" for both "wiped" and "wiping" statuses (see helpers.tsx lines 612-620), but only "wiping" is tested here. Consider adding "wiped" to ensure both paths are covered.

💡 Suggested test addition
     it("is disabled with tooltip when pending wipe", async () => {
+    // Test "wiping" status
       const render = createCustomRenderer({
         // ... existing test for "wiping"
       });
+      // ... assertions
+    });
+
+    it("is disabled with tooltip when wiped", async () => {
+      const render = createCustomRenderer({
+        context: {
+          app: {
+            isGlobalAdmin: true,
+            isPremiumTier: true,
+            isMacMdmEnabledAndConfigured: true,
+            currentUser: createMockUser(),
+          },
+        },
+      });
+
+      const { user } = render(
+        <HostActionsDropdown
+          hostTeamId={null}
+          onSelect={noop}
+          hostStatus="online"
+          hostPlatform="ios"
+          hostMdmEnrollmentStatus="On (company-owned)"
+          isConnectedToFleetMdm
+          hostMdmDeviceStatus="wiped"
+          hostScriptsEnabled
+        />
+      );
+
+      await user.click(screen.getByText("Actions"));
+
+      const option = screen.getByText("Clear passcode");
+      expect(option).toBeInTheDocument();
+      expect(option).toHaveAttribute("aria-disabled", "true");
     });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/HostActionsDropdown.tests.tsx`
around lines 1946 - 1986, Add a sibling test to the existing "is disabled with
tooltip when pending wipe" case that covers the "wiped" device status: render
HostActionsDropdown with hostMdmDeviceStatus="wiped" (keeping other props the
same), open the Actions menu, and assert the "Clear passcode" option exists, has
aria-disabled="true", and shows the same tooltip text; this ensures the
helpers.tsx logic that disables Clear passcode for both "wiping" and "wiped" is
covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/HostActionsDropdown.tests.tsx`:
- Around line 1946-1986: Add a sibling test to the existing "is disabled with
tooltip when pending wipe" case that covers the "wiped" device status: render
HostActionsDropdown with hostMdmDeviceStatus="wiped" (keeping other props the
same), open the Actions menu, and assert the "Clear passcode" option exists, has
aria-disabled="true", and shows the same tooltip text; this ensures the
helpers.tsx logic that disables Clear passcode for both "wiping" and "wiped" is
covered.

In
`@frontend/pages/hosts/details/HostDetailsPage/modals/ClearPasscodeModal/ClearPasscodeModal.tsx`:
- Around line 33-36: The finally block calls onExit() which unmounts the modal
and then calls setIsClearingPasscode(false), causing a state update after
unmount; remove the setIsClearingPasscode(false) call from the finally block in
the ClearPasscodeModal component (referencing the finally block that invokes
onExit and setIsClearingPasscode) so only onExit() runs, or alternatively move
setIsClearingPasscode(false) to run before onExit() if you must reset local
state prior to unmounting.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 92aae737-79be-48b5-a370-6b9242825de1

📥 Commits

Reviewing files that changed from the base of the PR and between 6a9d394 and 2854ec1.

📒 Files selected for processing (12)
  • frontend/interfaces/activity.ts
  • frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx
  • frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/HostActionsDropdown.tests.tsx
  • frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/helpers.tsx
  • frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx
  • frontend/pages/hosts/details/HostDetailsPage/modals/ClearPasscodeModal/ClearPasscodeModal.tsx
  • frontend/pages/hosts/details/HostDetailsPage/modals/ClearPasscodeModal/index.ts
  • frontend/pages/hosts/details/cards/Activity/ActivityConfig.tsx
  • frontend/pages/hosts/details/cards/Activity/ActivityItems/ClearedPasscodeActivityItem/ClearedPasscodeActivityItem.tsx
  • frontend/pages/hosts/details/cards/Activity/ActivityItems/ClearedPasscodeActivityItem/index.ts
  • frontend/services/entities/hosts.ts
  • frontend/utilities/endpoints.ts

sgress454
sgress454 previously approved these changes Apr 7, 2026

@sgress454 sgress454 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.

Tested 👍 , one totally non-blocking nit.

@MagnusHJensen
MagnusHJensen merged commit bc32339 into main Apr 7, 2026
19 checks passed
@MagnusHJensen
MagnusHJensen deleted the 42369-clear-passcode-frontend branch April 7, 2026 21:36

const ClearPasscodeModal = ({ id, onExit }: IClearPasscodeModalProps) => {
const { renderFlash } = useContext(NotificationContext);
const [isClearingPasscode, setIsClearingPasscode] = React.useState(false);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@MagnusHJensen for future, double check we are pulling out named imports so this would be:

import React, { useContext, useState } from "react";

<3

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Right, that is a miss in my part, that is normally how I do it

@RachelElysia RachelElysia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🔥🔥🔥 code ty

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.

Clear passcode: frontend

4 participants