From 75c76d9486ffbdc7dcf161f6506e2eebcab2683f Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Sat, 2 Sep 2023 00:30:26 +0200 Subject: [PATCH] [git-index] do not show staging area error messages as "Version Control" toolwindow notifications GitOrigin-RevId: 4c6ceddf7562ec2aa51545c76fcb83b0e0b59a07 --- .../src/git4idea/GitNotificationIdsHolder.kt | 4 +++- .../index/actions/StagingAreaOperation.kt | 2 +- .../index/actions/StagingAreaOperationAction.kt | 15 ++++++--------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/plugins/git4idea/src/git4idea/GitNotificationIdsHolder.kt b/plugins/git4idea/src/git4idea/GitNotificationIdsHolder.kt index b596dd4b00db..fb8e17ef8f12 100644 --- a/plugins/git4idea/src/git4idea/GitNotificationIdsHolder.kt +++ b/plugins/git4idea/src/git4idea/GitNotificationIdsHolder.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package git4idea import com.intellij.notification.impl.NotificationIdsHolder @@ -83,6 +83,7 @@ class GitNotificationIdsHolder : NotificationIdsHolder { REVERT_ABORT_SUCCESS, STAGE_COMMIT_ERROR, STAGE_COMMIT_SUCCESS, + STAGE_OPERATION_FAILED, STASH_FAILED, STASH_LOCAL_CHANGES_DETECTED, TAG_CREATED, @@ -190,6 +191,7 @@ class GitNotificationIdsHolder : NotificationIdsHolder { const val REVERT_ABORT_SUCCESS = "git.revert.abort.success" const val STAGE_COMMIT_ERROR = "git.stage.commit.error" const val STAGE_COMMIT_SUCCESS = "git.stage.commit.successful" + const val STAGE_OPERATION_FAILED = "git.stage.operation.error" const val STASH_FAILED = "git.stash.failed" const val STASH_LOCAL_CHANGES_DETECTED = "git.stash.local.changes.detected" const val TAG_CREATED = "git.tag.created" diff --git a/plugins/git4idea/src/git4idea/index/actions/StagingAreaOperation.kt b/plugins/git4idea/src/git4idea/index/actions/StagingAreaOperation.kt index c20b4bbb4487..060603d368a9 100644 --- a/plugins/git4idea/src/git4idea/index/actions/StagingAreaOperation.kt +++ b/plugins/git4idea/src/git4idea/index/actions/StagingAreaOperation.kt @@ -23,7 +23,7 @@ interface StagingAreaOperation { val actionText: Supplier<@NlsActions.ActionText String> val progressTitle: @NlsContexts.ProgressTitle String val icon: Icon? - val errorMessage: @NlsContexts.NotificationContent String + val errorMessage: @NlsContexts.NotificationTitle String val shortcutText: String? get() = null fun matches(statusNode: GitFileStatusNode): Boolean diff --git a/plugins/git4idea/src/git4idea/index/actions/StagingAreaOperationAction.kt b/plugins/git4idea/src/git4idea/index/actions/StagingAreaOperationAction.kt index 2a47222bf61d..6da4f723a480 100644 --- a/plugins/git4idea/src/git4idea/index/actions/StagingAreaOperationAction.kt +++ b/plugins/git4idea/src/git4idea/index/actions/StagingAreaOperationAction.kt @@ -5,16 +5,16 @@ import com.intellij.openapi.actionSystem.Presentation import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.progress.ProgressManager import com.intellij.openapi.project.Project -import com.intellij.openapi.ui.MessageType import com.intellij.openapi.util.NlsContexts -import com.intellij.openapi.util.NlsContexts.NotificationContent +import com.intellij.openapi.util.NlsContexts.NotificationTitle import com.intellij.openapi.util.ThrowableComputable import com.intellij.openapi.util.text.HtmlBuilder import com.intellij.openapi.util.text.HtmlChunk import com.intellij.openapi.vcs.VcsException -import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier +import com.intellij.openapi.vcs.VcsNotifier import com.intellij.vcsUtil.VcsFileUtil import git4idea.GitContentRevision +import git4idea.GitNotificationIdsHolder import git4idea.index.ui.GitFileStatusNode import git4idea.repo.GitRepository import git4idea.repo.GitRepositoryManager @@ -88,10 +88,7 @@ fun runProcess(project: Project, @NlsContexts.ProgressTitle title: String, c title, canBeCancelled, project) } -private fun showErrorMessage(project: Project, @NotificationContent messageTitle: String, exceptions: Collection) { - val message = HtmlBuilder().append(HtmlChunk.text("$messageTitle:").bold()) - .br() - .appendWithSeparators(HtmlChunk.br(), exceptions.map { HtmlChunk.text(it.localizedMessage) }) - - VcsBalloonProblemNotifier.showOverVersionControlView(project, message.toString(), MessageType.ERROR) +private fun showErrorMessage(project: Project, @NotificationTitle messageTitle: String, exceptions: Collection) { + val message = HtmlBuilder().appendWithSeparators(HtmlChunk.br(), exceptions.map { HtmlChunk.text(it.localizedMessage) }) + VcsNotifier.getInstance(project).notifyError(GitNotificationIdsHolder.STAGE_OPERATION_FAILED, messageTitle, message.toString()) } \ No newline at end of file