From a34c2dce2d2637666ff5bcda278870aef5d06c2e Mon Sep 17 00:00:00 2001 From: Vera Petrenkova Date: Tue, 22 Oct 2024 17:17:45 +0200 Subject: [PATCH] IJPL-164824 Add new notifications after excluding folders from the WD list (cherry picked from commit 792a8309663fa12d3070b32fb2bd597d26dedea1) IJ-CR-147809 GitOrigin-RevId: adbe17b307ae8aaff9d06f8ae20145fadc22f589 --- .../resources/messages/DiagnosticBundle.properties | 4 ++-- .../diagnostic/WindowsDefenderCheckerActivity.kt | 7 ++----- .../intellij/diagnostic/WindowsDefenderExcludeUtil.kt | 10 +++------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/platform/platform-impl/resources/messages/DiagnosticBundle.properties b/platform/platform-impl/resources/messages/DiagnosticBundle.properties index 2787a4318ac2..b4e7008275ae 100644 --- a/platform/platform-impl/resources/messages/DiagnosticBundle.properties +++ b/platform/platform-impl/resources/messages/DiagnosticBundle.properties @@ -146,8 +146,8 @@ defender.config.manual=How to configure manually defender.config.suppress1=Ignore for this project defender.config.suppress2=Never ask again defender.config.progress=Updating Microsoft Defender configuration -defender.config.success=Project paths were successfully added to the Microsoft Defender exclusion list -defender.config.failed=Microsoft Defender configuration script failed. Please look for "WindowsDefenderChecker" records in the log. +defender.config.success=The folders have been successfully excluded from Windows Defender's Real-Time Protection. +defender.config.failed=Failed to exclude folders. Check the log for "WindowsDefenderChecker" for more details. defender.config.restore=OK. If you change your mind, use "{0}" action. label.issue.type=Issue Type: diff --git a/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderCheckerActivity.kt b/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderCheckerActivity.kt index 475fcf412008..f064b7e7972e 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderCheckerActivity.kt +++ b/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderCheckerActivity.kt @@ -1,8 +1,8 @@ // Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.diagnostic +import com.intellij.diagnostic.WindowsDefenderExcludeUtil.NOTIFICATION_GROUP import com.intellij.ide.BrowserUtil -import com.intellij.idea.ActionsBundle import com.intellij.notification.Notification import com.intellij.notification.NotificationAction.createSimple import com.intellij.notification.NotificationAction.createSimpleExpiring @@ -66,7 +66,7 @@ internal class WindowsDefenderCheckerActivity : ProjectActivity { val pathList = paths.joinToString(separator = "
  ", prefix = "
  ") { it.toString() } val auto = DiagnosticBundle.message("exclude.folders") val manual = DiagnosticBundle.message("defender.config.manual") - WindowsDefenderExcludeUtil.notification(DiagnosticBundle.message("defender.config.prompt", pathList, auto, manual), NotificationType.INFORMATION) + Notification(NOTIFICATION_GROUP, DiagnosticBundle.message("notification.group.defender.config"), DiagnosticBundle.message("defender.config.prompt", pathList, auto, manual), NotificationType.INFORMATION) .addAction(createSimpleExpiring(auto) { WindowsDefenderExcludeUtil.updateDefenderConfig(checker, project, paths) }) .addAction(createSimpleExpiring(DiagnosticBundle.message("defender.config.suppress1")) { suppressCheck(checker, project, globally = false) }) .addAction(createSimpleExpiring(DiagnosticBundle.message("defender.config.suppress2")) { suppressCheck(checker, project, globally = true) }) @@ -85,9 +85,6 @@ internal class WindowsDefenderCheckerActivity : ProjectActivity { private fun suppressCheck(checker: WindowsDefenderChecker, project: Project, globally: Boolean) { checker.ignoreStatusCheck(if (globally) null else project, true) - val action = ActionsBundle.message("action.ResetWindowsDefenderNotification.text") - WindowsDefenderExcludeUtil.notification(DiagnosticBundle.message("defender.config.restore", action), NotificationType.INFORMATION) - .notify(project) WindowsDefenderStatisticsCollector.suppressed(project, globally) } } diff --git a/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderExcludeUtil.kt b/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderExcludeUtil.kt index f6ba9ac915e4..8c3c899e15d6 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderExcludeUtil.kt +++ b/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderExcludeUtil.kt @@ -6,7 +6,6 @@ import com.intellij.notification.Notification import com.intellij.notification.NotificationType import com.intellij.openapi.components.service import com.intellij.openapi.project.Project -import com.intellij.openapi.util.NlsContexts import com.intellij.platform.ide.CoreUiCoroutineScopeHolder import com.intellij.platform.ide.progress.withBackgroundProgress import kotlinx.collections.immutable.toImmutableList @@ -36,19 +35,19 @@ internal object WindowsDefenderExcludeUtil { fun clearPathsToExclude() { defenderExclusions.replaceAll { _, _ -> false } } - + const val NOTIFICATION_GROUP = "WindowsDefender" fun updateDefenderConfig(checker: WindowsDefenderChecker, project: Project, paths: List, onSuccess: () -> Unit = {}) { service().coroutineScope.launch { @Suppress("DialogTitleCapitalization") withBackgroundProgress(project, DiagnosticBundle.message("defender.config.progress"), false) { val success = checker.excludeProjectPaths(project, paths) if (success) { - notification(DiagnosticBundle.message("defender.config.success"), NotificationType.INFORMATION) + Notification(NOTIFICATION_GROUP, DiagnosticBundle.message("defender.config.success"), NotificationType.INFORMATION) .notify(project) onSuccess() } else { - notification(DiagnosticBundle.message("defender.config.failed"), NotificationType.WARNING) + Notification(NOTIFICATION_GROUP, DiagnosticBundle.message("defender.config.failed"), NotificationType.ERROR) .addAction(ShowLogAction.notificationAction()) .notify(project) } @@ -57,7 +56,4 @@ internal object WindowsDefenderExcludeUtil { } WindowsDefenderStatisticsCollector.auto(project) } - - internal fun notification(@NlsContexts.NotificationContent content: String, type: NotificationType): Notification = - Notification("WindowsDefender", DiagnosticBundle.message("notification.group.defender.config"), content, type) } \ No newline at end of file