mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 06:50:54 +07:00
[collab/github/space] extract comment edit button
GitOrigin-RevId: 217e331df233c8191e3ab17508e57085f062fc01
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4f5a0850bf
commit
a67ddea9e8
@@ -4,6 +4,7 @@ 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.icons.AllIcons
|
||||
import com.intellij.openapi.editor.colors.EditorColors
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager
|
||||
import com.intellij.openapi.ui.MessageDialogBuilder
|
||||
@@ -55,6 +56,16 @@ object CodeReviewCommentUIUtil {
|
||||
return button
|
||||
}
|
||||
|
||||
fun createEditButton(actionListener: (ActionEvent) -> Unit): InlineIconButton {
|
||||
val icon = AllIcons.General.Inline_edit
|
||||
val hoverIcon = AllIcons.General.Inline_edit_hovered
|
||||
return InlineIconButton(icon, hoverIcon, tooltip = CommonBundle.message("button.edit")).apply {
|
||||
this.actionListener = ActionListener {
|
||||
actionListener(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object Actions {
|
||||
const val HORIZONTAL_GAP = 8
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import org.jetbrains.plugins.github.i18n.GithubBundle
|
||||
import org.jetbrains.plugins.github.pullrequest.comment.GHSuggestedChange
|
||||
import org.jetbrains.plugins.github.pullrequest.data.provider.GHPRReviewDataProvider
|
||||
import org.jetbrains.plugins.github.pullrequest.ui.GHEditableHtmlPaneHandle
|
||||
import org.jetbrains.plugins.github.pullrequest.ui.GHTextActions
|
||||
import org.jetbrains.plugins.github.pullrequest.ui.changes.GHPRSuggestedChangeHelper
|
||||
import org.jetbrains.plugins.github.pullrequest.ui.timeline.GHPRTimelineItemUIUtil
|
||||
import org.jetbrains.plugins.github.ui.avatars.GHAvatarIconsProvider
|
||||
@@ -70,7 +69,9 @@ object GHPRReviewCommentComponent {
|
||||
maxEditorWidth = maxTextWidth
|
||||
}
|
||||
|
||||
val editButton = GHTextActions.createEditButton(editablePaneHandle).apply {
|
||||
val editButton = CodeReviewCommentUIUtil.createEditButton {
|
||||
editablePaneHandle.showAndFocusEditor()
|
||||
}.apply {
|
||||
isVisible = comment.canBeUpdated
|
||||
}
|
||||
val deleteButton = CodeReviewCommentUIUtil.createDeleteCommentIconButton {
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
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
|
||||
import icons.CollaborationToolsIcons
|
||||
import org.jetbrains.plugins.github.i18n.GithubBundle
|
||||
import java.awt.event.ActionListener
|
||||
import java.util.concurrent.CompletableFuture
|
||||
import javax.swing.JComponent
|
||||
|
||||
internal object GHTextActions {
|
||||
|
||||
fun createEditButton(paneHandle: GHEditableHtmlPaneHandle): InlineIconButton {
|
||||
return createEditButton().apply {
|
||||
actionListener = ActionListener {
|
||||
paneHandle.showAndFocusEditor()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun createEditButton(): InlineIconButton {
|
||||
val icon = AllIcons.General.Inline_edit
|
||||
val hoverIcon = AllIcons.General.Inline_edit_hovered
|
||||
return InlineIconButton(icon, hoverIcon, tooltip = CommonBundle.message("button.edit"))
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,6 @@ import org.jetbrains.plugins.github.pullrequest.data.provider.GHPRCommentsDataPr
|
||||
import org.jetbrains.plugins.github.pullrequest.data.provider.GHPRDetailsDataProvider
|
||||
import org.jetbrains.plugins.github.pullrequest.data.provider.GHPRReviewDataProvider
|
||||
import org.jetbrains.plugins.github.pullrequest.ui.GHEditableHtmlPaneHandle
|
||||
import org.jetbrains.plugins.github.pullrequest.ui.GHTextActions
|
||||
import org.jetbrains.plugins.github.pullrequest.ui.changes.GHPRSuggestedChangeHelper
|
||||
import org.jetbrains.plugins.github.pullrequest.ui.timeline.GHPRTimelineItemUIUtil.buildTimelineItem
|
||||
import org.jetbrains.plugins.github.pullrequest.ui.timeline.GHPRTimelineItemUIUtil.createTimelineItem
|
||||
@@ -199,7 +198,9 @@ class GHPRTimelineItemComponentFactory(private val project: Project,
|
||||
}
|
||||
contentPanel = panelHandle.panel
|
||||
actionsPanel = if (details.viewerCanUpdate) HorizontalListPanel(CodeReviewCommentUIUtil.Actions.HORIZONTAL_GAP).apply {
|
||||
add(GHTextActions.createEditButton(panelHandle))
|
||||
add(CodeReviewCommentUIUtil.createEditButton {
|
||||
panelHandle.showAndFocusEditor()
|
||||
})
|
||||
}
|
||||
else null
|
||||
}
|
||||
@@ -220,7 +221,9 @@ class GHPRTimelineItemComponentFactory(private val project: Project,
|
||||
.successOnEdt { textPane.setHtmlBody(it.convertToHtml(project)) }
|
||||
}
|
||||
val actionsPanel = HorizontalListPanel(CodeReviewCommentUIUtil.Actions.HORIZONTAL_GAP).apply {
|
||||
if (comment.viewerCanUpdate) add(GHTextActions.createEditButton(panelHandle))
|
||||
if (comment.viewerCanUpdate) add(CodeReviewCommentUIUtil.createEditButton {
|
||||
panelHandle.showAndFocusEditor()
|
||||
})
|
||||
if (comment.viewerCanDelete) add(CodeReviewCommentUIUtil.createDeleteCommentIconButton {
|
||||
commentsDataProvider.deleteComment(EmptyProgressIndicator(), comment.id)
|
||||
})
|
||||
@@ -290,7 +293,9 @@ class GHPRTimelineItemComponentFactory(private val project: Project,
|
||||
}
|
||||
|
||||
val actionsPanel = HorizontalListPanel(CodeReviewCommentUIUtil.Actions.HORIZONTAL_GAP).apply {
|
||||
if (firstComment.canBeUpdated) add(GHTextActions.createEditButton(panelHandle))
|
||||
if (firstComment.canBeUpdated) add(CodeReviewCommentUIUtil.createEditButton {
|
||||
panelHandle.showAndFocusEditor()
|
||||
})
|
||||
if (firstComment.canBeDeleted) add(CodeReviewCommentUIUtil.createDeleteCommentIconButton {
|
||||
reviewDataProvider.deleteComment(EmptyProgressIndicator(), firstComment.id)
|
||||
})
|
||||
@@ -465,7 +470,9 @@ class GHPRTimelineItemComponentFactory(private val project: Project,
|
||||
}
|
||||
|
||||
val actionsPanel = HorizontalListPanel(8).apply {
|
||||
if (panelHandle != null && review.viewerCanUpdate) add(GHTextActions.createEditButton(panelHandle))
|
||||
if (panelHandle != null && review.viewerCanUpdate) add(CodeReviewCommentUIUtil.createEditButton {
|
||||
panelHandle.showAndFocusEditor()
|
||||
})
|
||||
}
|
||||
|
||||
val stateText = when (review.state) {
|
||||
|
||||
Reference in New Issue
Block a user