mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-13 15:52:01 +07:00
IJPL-164824 Add new notifications after excluding folders from the WD list
(cherry picked from commit 792a8309663fa12d3070b32fb2bd597d26dedea1) IJ-CR-147809 GitOrigin-RevId: adbe17b307ae8aaff9d06f8ae20145fadc22f589
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5cb1d12a39
commit
a34c2dce2d
@@ -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:
|
||||
|
||||
@@ -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 = "<br> ", prefix = "<br> ") { 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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Path>, onSuccess: () -> Unit = {}) {
|
||||
service<CoreUiCoroutineScopeHolder>().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)
|
||||
}
|
||||
Reference in New Issue
Block a user