diff --git a/platform/collaboration-tools/resources/messages/CollaborationToolsBundle.properties b/platform/collaboration-tools/resources/messages/CollaborationToolsBundle.properties index bfe2b3c9a08e..f3572db94880 100644 --- a/platform/collaboration-tools/resources/messages/CollaborationToolsBundle.properties +++ b/platform/collaboration-tools/resources/messages/CollaborationToolsBundle.properties @@ -57,4 +57,6 @@ review.details.status.reviewer.wait.for.updates={0} is waiting for updates review.comments.reply.action=Reply review.comments.replies.action={0} {0, choice, 1#reply|2#replies} review.comments.resolve.action=Resolve -review.comments.unresolve.action=Unresolve \ No newline at end of file +review.comments.unresolve.action=Unresolve +review.comments.delete.confirmation.title=Delete Comment +review.comments.delete.confirmation=Are you sure you want to delete this comment? diff --git a/platform/collaboration-tools/src/com/intellij/collaboration/ui/codereview/comment/CodeReviewCommentUIUtil.kt b/platform/collaboration-tools/src/com/intellij/collaboration/ui/codereview/comment/CodeReviewCommentUIUtil.kt index 5eb0c2a0016c..c480cdb6ad9f 100644 --- a/platform/collaboration-tools/src/com/intellij/collaboration/ui/codereview/comment/CodeReviewCommentUIUtil.kt +++ b/platform/collaboration-tools/src/com/intellij/collaboration/ui/codereview/comment/CodeReviewCommentUIUtil.kt @@ -1,12 +1,19 @@ // Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.collaboration.ui.codereview.comment +import com.intellij.CommonBundle +import com.intellij.collaboration.messages.CollaborationToolsBundle import com.intellij.collaboration.ui.CollaborationToolsUIUtil import com.intellij.openapi.editor.colors.EditorColors import com.intellij.openapi.editor.colors.EditorColorsManager +import com.intellij.openapi.ui.MessageDialogBuilder import com.intellij.ui.IdeBorderFactory import com.intellij.ui.JBColor +import com.intellij.util.ui.InlineIconButton +import icons.CollaborationToolsIcons import java.awt.BorderLayout +import java.awt.event.ActionEvent +import java.awt.event.ActionListener import java.awt.event.ComponentAdapter import java.awt.event.ComponentEvent import javax.swing.JComponent @@ -35,6 +42,19 @@ object CodeReviewCommentUIUtil { } } + fun createDeleteCommentIconButton(actionListener: (ActionEvent) -> Unit): JComponent { + val icon = CollaborationToolsIcons.Delete + val hoverIcon = CollaborationToolsIcons.DeleteHovered + val button = InlineIconButton(icon, hoverIcon, tooltip = CommonBundle.message("button.delete")) + button.actionListener = ActionListener { + if (MessageDialogBuilder.yesNo(CollaborationToolsBundle.message("review.comments.delete.confirmation.title"), + CollaborationToolsBundle.message("review.comments.delete.confirmation")).ask(button)) { + actionListener(it) + } + } + return button + } + object Actions { const val HORIZONTAL_GAP = 8 } diff --git a/plugins/github/resources/messages/GithubBundle.properties b/plugins/github/resources/messages/GithubBundle.properties index ba3007d30924..98aa0c6065ec 100644 --- a/plugins/github/resources/messages/GithubBundle.properties +++ b/plugins/github/resources/messages/GithubBundle.properties @@ -330,8 +330,6 @@ pull.request.review.submit.approve.button=Approve pull.request.review.submit.comment.button=Comment pull.request.review.submit.comment.description=Submit general feedback without explicit approval pull.request.review.submit.error=Error occurred while submitting a review -pull.request.review.comment.delete.dialog.msg=Are you sure you want to delete this comment? -pull.request.review.comment.delete.dialog.title=Delete Comment pull.request.discard.pending.comments.dialog.title=Discard Pending Review pull.request.discard.pending.comments.dialog.msg=Are you sure you want to delete all pending comments? pull.request.discard.pending.comments=Discard pending comments diff --git a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/comment/ui/GHPRReviewCommentComponent.kt b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/comment/ui/GHPRReviewCommentComponent.kt index 280d39342526..3a32e2286f6c 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/comment/ui/GHPRReviewCommentComponent.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/comment/ui/GHPRReviewCommentComponent.kt @@ -3,6 +3,7 @@ package org.jetbrains.plugins.github.pullrequest.comment.ui import com.intellij.collaboration.ui.HorizontalListPanel import com.intellij.collaboration.ui.codereview.CodeReviewChatItemUIUtil +import com.intellij.collaboration.ui.codereview.comment.CodeReviewCommentUIUtil import com.intellij.openapi.progress.EmptyProgressIndicator import com.intellij.openapi.project.Project import com.intellij.ui.components.JBLabel @@ -72,7 +73,7 @@ object GHPRReviewCommentComponent { val editButton = GHTextActions.createEditButton(editablePaneHandle).apply { isVisible = comment.canBeUpdated } - val deleteButton = GHTextActions.createDeleteButton { + val deleteButton = CodeReviewCommentUIUtil.createDeleteCommentIconButton { reviewDataProvider.deleteComment(EmptyProgressIndicator(), comment.id) }.apply { isVisible = comment.canBeDeleted diff --git a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/GHTextActions.kt b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/GHTextActions.kt index 76659755d4fa..6220de73c34f 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/GHTextActions.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/GHTextActions.kt @@ -2,6 +2,8 @@ package org.jetbrains.plugins.github.pullrequest.ui import com.intellij.CommonBundle +import com.intellij.collaboration.ui.CollaborationToolsUIUtil +import com.intellij.collaboration.ui.codereview.comment.CodeReviewCommentUIUtil import com.intellij.icons.AllIcons import com.intellij.openapi.ui.MessageDialogBuilder import com.intellij.util.ui.InlineIconButton @@ -12,18 +14,6 @@ import java.util.concurrent.CompletableFuture import javax.swing.JComponent internal object GHTextActions { - fun createDeleteButton(delete: () -> CompletableFuture): JComponent { - val icon = CollaborationToolsIcons.Delete - val hoverIcon = CollaborationToolsIcons.DeleteHovered - val button = InlineIconButton(icon, hoverIcon, tooltip = CommonBundle.message("button.delete")) - button.actionListener = ActionListener { - if (MessageDialogBuilder.yesNo(GithubBundle.message("pull.request.review.comment.delete.dialog.title"), - GithubBundle.message("pull.request.review.comment.delete.dialog.msg")).ask(button)) { - delete() - } - } - return button - } fun createEditButton(paneHandle: GHEditableHtmlPaneHandle): InlineIconButton { return createEditButton().apply { diff --git a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/timeline/GHPRTimelineItemComponentFactory.kt b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/timeline/GHPRTimelineItemComponentFactory.kt index 79a0b1c325d7..03848d3c0e55 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/timeline/GHPRTimelineItemComponentFactory.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/timeline/GHPRTimelineItemComponentFactory.kt @@ -220,7 +220,7 @@ class GHPRTimelineItemComponentFactory(private val project: Project, } val actionsPanel = HorizontalListPanel(CodeReviewCommentUIUtil.Actions.HORIZONTAL_GAP).apply { if (comment.viewerCanUpdate) add(GHTextActions.createEditButton(panelHandle)) - if (comment.viewerCanDelete) add(GHTextActions.createDeleteButton { + if (comment.viewerCanDelete) add(CodeReviewCommentUIUtil.createDeleteCommentIconButton { commentsDataProvider.deleteComment(EmptyProgressIndicator(), comment.id) }) } @@ -290,7 +290,7 @@ class GHPRTimelineItemComponentFactory(private val project: Project, val actionsPanel = HorizontalListPanel(CodeReviewCommentUIUtil.Actions.HORIZONTAL_GAP).apply { if (firstComment.canBeUpdated) add(GHTextActions.createEditButton(panelHandle)) - if (firstComment.canBeDeleted) add(GHTextActions.createDeleteButton { + if (firstComment.canBeDeleted) add(CodeReviewCommentUIUtil.createDeleteCommentIconButton { reviewDataProvider.deleteComment(EmptyProgressIndicator(), firstComment.id) }) }