Skip to content

Commit 6d21671

Browse files
melpikecoderabbitai[bot]CodeRabbit
authored
Apple MDM: require server URL confirmation before turning off (#48595)
Adds a text input to the "Turn off MDM" confirmation modal that requires the admin to type the Fleet server URL before the Turn off button becomes enabled. Prevents accidental MDM deactivation on the wrong Fleet instance. <!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #42073 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved the Apple MDM disable flow by requiring the correct Fleet URL before confirming the action. * The disable confirmation modal now appears only when the needed configuration is available, reducing the chance of errors. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
1 parent 21c0243 commit 6d21671

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

frontend/pages/admin/IntegrationsPage/cards/MdmSettings/AppleMdmPage/AppleMdmPage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ const AppleMdmPage = ({ router }: { router: InjectedRouter }) => {
131131
onRenew={onRenewCert}
132132
/>
133133
)}
134-
{showTurnOffMdmModal && (
134+
{showTurnOffMdmModal && config && (
135135
<TurnOffAppleMdmModal
136+
serverUrl={config.server_settings.server_url}
136137
onCancel={toggleTurnOffMdmModal}
137138
onConfirm={turnOffMdm}
138139
/>

frontend/pages/admin/IntegrationsPage/cards/MdmSettings/AppleMdmPage/components/modals/TurnOffAppleMdmModal/TurnOffAppleMdmModal.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
import React, { useCallback, useState } from "react";
22

33
import Button from "components/buttons/Button";
4-
4+
import InputField from "components/forms/fields/InputField";
55
import Modal from "components/Modal";
66

77
const baseClass = "modal turn-off-apple-mdm-modal";
8+
const bemClass = "turn-off-apple-mdm-modal";
89

910
interface ITurnOffAppleMdmModalProps {
11+
serverUrl: string;
1012
onCancel: () => void;
1113
onConfirm: () => void;
1214
}
1315

1416
const TurnOffAppleMdmModal = ({
17+
serverUrl,
1518
onConfirm,
1619
onCancel,
1720
}: ITurnOffAppleMdmModalProps): JSX.Element => {
1821
const [isDeleting, setIsDeleting] = useState(false);
22+
const [enteredUrl, setEnteredUrl] = useState("");
1923

2024
const onClickConfirm = useCallback(() => {
2125
setIsDeleting(true);
@@ -25,16 +29,28 @@ const TurnOffAppleMdmModal = ({
2529
return (
2630
<Modal title="Turn off MDM" onExit={onCancel} className={baseClass}>
2731
<div className={baseClass}>
28-
If you want to use MDM features again, you&apos;ll have to upload a new
29-
APNs certificate and all end users will have to turn MDM off and back
30-
on.
32+
<p>
33+
If you want to use MDM features again, you&apos;ll have to upload a
34+
new APNs certificate and all end users will have to turn MDM off and
35+
back on.
36+
</p>
37+
<p>
38+
To confirm, enter your Fleet URL: <b>{serverUrl}</b>
39+
</p>
40+
<InputField
41+
autofocus
42+
inputWrapperClass={`${bemClass}__url-input`}
43+
placeholder="https://fleet.example.com"
44+
value={enteredUrl}
45+
onChange={(val: string) => setEnteredUrl(val)}
46+
/>
3147
<div className="modal-cta-wrap">
3248
<Button
3349
type="button"
3450
variant="alert"
3551
onClick={onClickConfirm}
3652
isLoading={isDeleting}
37-
disabled={isDeleting}
53+
disabled={isDeleting || enteredUrl !== serverUrl}
3854
>
3955
Turn off
4056
</Button>

0 commit comments

Comments
 (0)