Skip to content

Commit

Permalink
[Security Solution][Endpoint][Admin] Disables malware checkbox when s…
Browse files Browse the repository at this point in the history
…witch is off and can now save in detect mode (#86402) (#86509)
  • Loading branch information
parkiino authored Dec 19, 2020
1 parent dcc7393 commit 4d4dd32
Showing 1 changed file with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,27 @@ const ProtectionRadio = React.memo(({ id, label }: { id: ProtectionModes; label:
const radioButtonId = useMemo(() => htmlIdGenerator()(), []);
// currently just taking windows.malware, but both windows.malware and mac.malware should be the same value
const selected = policyDetailsConfig && policyDetailsConfig.windows.malware.mode;
const isPlatinumPlus = useLicense().isPlatinumPlus();

const handleRadioChange = useCallback(() => {
if (policyDetailsConfig) {
const newPayload = cloneDeep(policyDetailsConfig);
for (const os of OSes) {
newPayload[os][protection].mode = id;
if (id === ProtectionModes.prevent) {
newPayload[os].popup[protection].enabled = true;
} else {
newPayload[os].popup[protection].enabled = false;
if (isPlatinumPlus) {
if (id === ProtectionModes.prevent) {
newPayload[os].popup[protection].enabled = true;
} else {
newPayload[os].popup[protection].enabled = false;
}
}
}
dispatch({
type: 'userChangedPolicyConfig',
payload: { policyConfig: newPayload },
});
}
}, [dispatch, id, policyDetailsConfig]);
}, [dispatch, id, policyDetailsConfig, isPlatinumPlus]);

/**
* Passing an arbitrary id because EuiRadio
Expand Down Expand Up @@ -158,12 +161,16 @@ export const MalwareProtections = React.memo(() => {
if (event.target.checked === false) {
for (const os of OSes) {
newPayload[os][protection].mode = ProtectionModes.off;
newPayload[os].popup[protection].enabled = event.target.checked;
if (isPlatinumPlus) {
newPayload[os].popup[protection].enabled = event.target.checked;
}
}
} else {
for (const os of OSes) {
newPayload[os][protection].mode = ProtectionModes.prevent;
newPayload[os].popup[protection].enabled = event.target.checked;
if (isPlatinumPlus) {
newPayload[os].popup[protection].enabled = event.target.checked;
}
}
}
dispatch({
Expand All @@ -172,7 +179,7 @@ export const MalwareProtections = React.memo(() => {
});
}
},
[dispatch, policyDetailsConfig]
[dispatch, policyDetailsConfig, isPlatinumPlus]
);

const handleUserNotificationCheckbox = useCallback(
Expand Down Expand Up @@ -243,6 +250,7 @@ export const MalwareProtections = React.memo(() => {
id="xpack.securitySolution.endpoint.policyDetail.malware.userNotification"
onChange={handleUserNotificationCheckbox}
checked={userNotificationSelected}
disabled={selected === ProtectionModes.off}
label={i18n.translate(
'xpack.securitySolution.endpoint.policyDetail.malware.notifyUser',
{
Expand Down Expand Up @@ -305,6 +313,7 @@ export const MalwareProtections = React.memo(() => {
);
}, [
radios,
selected,
isPlatinumPlus,
handleUserNotificationCheckbox,
userNotificationSelected,
Expand Down

0 comments on commit 4d4dd32

Please sign in to comment.