From d3529498ab42e11f90fe5579334c51ab0c381f54 Mon Sep 17 00:00:00 2001 From: Ivan Semenov Date: Fri, 4 Jul 2025 18:22:29 +0200 Subject: [PATCH] [gig/github] simplify PR details component GitOrigin-RevId: e63000b465ebb331702b8cb86e6a98675521e322 --- .../GHPRDetailsActionsComponentFactory.kt | 4 +++- .../ui/details/GHPRDetailsComponentFactory.kt | 24 +++++++++++++------ .../GHPRStatusChecksComponentFactory.kt | 4 +++- .../details/model/GHPRReviewFlowViewModel.kt | 2 +- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/details/GHPRDetailsActionsComponentFactory.kt b/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/details/GHPRDetailsActionsComponentFactory.kt index 7d48be7a3ee2..ff991fb7e3f1 100644 --- a/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/details/GHPRDetailsActionsComponentFactory.kt +++ b/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/details/GHPRDetailsActionsComponentFactory.kt @@ -22,6 +22,7 @@ import com.intellij.ui.components.panels.Wrapper import kotlinx.coroutines.* import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map +import org.jetbrains.annotations.ApiStatus import org.jetbrains.plugins.github.i18n.GithubBundle import org.jetbrains.plugins.github.pullrequest.ui.details.action.* import org.jetbrains.plugins.github.pullrequest.ui.details.model.GHPRReviewFlowViewModel @@ -29,7 +30,8 @@ import org.jetbrains.plugins.github.pullrequest.ui.review.GHPRSubmitReviewPopup import javax.swing.JButton import javax.swing.JComponent -internal object GHPRDetailsActionsComponentFactory { +@ApiStatus.Internal +object GHPRDetailsActionsComponentFactory { private const val BUTTONS_GAP = 10 fun create( diff --git a/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/details/GHPRDetailsComponentFactory.kt b/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/details/GHPRDetailsComponentFactory.kt index d5abd27cbcce..04f26571be88 100644 --- a/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/details/GHPRDetailsComponentFactory.kt +++ b/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/details/GHPRDetailsComponentFactory.kt @@ -48,12 +48,20 @@ object GHPRDetailsComponentFactory { scope: CoroutineScope, project: Project, detailsVm: GHPRDetailsViewModel, + withTitle: Boolean = true, ): JComponent { val actionGroup = ActionManager.getInstance().getAction("Github.PullRequest.Details.Popup") as ActionGroup - val title = CodeReviewDetailsTitleComponentFactory.create(scope, detailsVm, GithubBundle.message("open.on.github.action"), actionGroup, - htmlPaneFactory = { SimpleHtmlPane() }) - val timelineLink = ActionLink(CollaborationToolsBundle.message("review.details.view.timeline.action")) { - showTimelineAction(it.source as JComponent) + + val titlePanel = if (withTitle) { + val title = CodeReviewDetailsTitleComponentFactory.create(scope, detailsVm, GithubBundle.message("open.on.github.action"), actionGroup, + htmlPaneFactory = { SimpleHtmlPane() }) + val timelineLink = ActionLink(CollaborationToolsBundle.message("review.details.view.timeline.action")) { + showTimelineAction(it.source as JComponent) + } + ReviewDetailsUIUtil.createTitlePanel(title, timelineLink) + } + else { + null } val commitsAndBranches = createCommitsAndBranchesComponent(project, scope, detailsVm) @@ -70,7 +78,9 @@ object GHPRDetailsComponentFactory { )).apply { isOpaque = false - add(ReviewDetailsUIUtil.createTitlePanel(title, timelineLink), CC().growX().gap(ReviewDetailsUIUtil.TITLE_GAPS)) + if (titlePanel != null) { + add(titlePanel, CC().growX().gap(ReviewDetailsUIUtil.TITLE_GAPS)) + } add(commitsAndBranches, CC().growX().gap(ReviewDetailsUIUtil.COMMIT_POPUP_BRANCHES_GAPS)) add(createCommitsInfoComponent(project, scope, detailsVm), CC().growX().gap(ReviewDetailsUIUtil.COMMIT_INFO_GAPS)) add(createCommitFilesBrowserComponent(scope, detailsVm.changesVm), CC().grow().shrinkPrioY(200)) @@ -94,7 +104,7 @@ object GHPRDetailsComponentFactory { }) } - fun createCommitsAndBranchesComponent(project: Project, cs: CoroutineScope, detailsVm: GHPRDetailsViewModel): JComponent { + private fun createCommitsAndBranchesComponent(project: Project, cs: CoroutineScope, detailsVm: GHPRDetailsViewModel): JComponent { return JPanel(MigLayout(LC().emptyBorders().fill(), AC().gap("push"))).apply { isOpaque = false add(CodeReviewDetailsCommitsComponentFactory.create(cs, detailsVm.changesVm) { commit: GHCommit -> @@ -121,7 +131,7 @@ object GHPRDetailsComponentFactory { ) - fun createCommitFilesBrowserComponent(cs: CoroutineScope, changesVm: GHPRChangesViewModel): JComponent { + private fun createCommitFilesBrowserComponent(cs: CoroutineScope, changesVm: GHPRChangesViewModel): JComponent { return Wrapper(LoadingLabel()).apply { bindContentIn(cs, changesVm.changeListVm) { res -> res.result?.let { diff --git a/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/details/GHPRStatusChecksComponentFactory.kt b/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/details/GHPRStatusChecksComponentFactory.kt index f3871be65c69..87dacb51599d 100644 --- a/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/details/GHPRStatusChecksComponentFactory.kt +++ b/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/details/GHPRStatusChecksComponentFactory.kt @@ -24,6 +24,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.map import kotlinx.coroutines.withContext +import org.jetbrains.annotations.ApiStatus import org.jetbrains.plugins.github.ai.GHPRAIReviewExtension import org.jetbrains.plugins.github.api.data.GHRepositoryPermissionLevel import org.jetbrains.plugins.github.i18n.GithubBundle @@ -37,7 +38,8 @@ import java.awt.event.ActionListener import javax.swing.JComponent import javax.swing.JScrollPane -internal object GHPRStatusChecksComponentFactory { +@ApiStatus.Internal +object GHPRStatusChecksComponentFactory { fun create( parentScope: CoroutineScope, project: Project, diff --git a/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/details/model/GHPRReviewFlowViewModel.kt b/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/details/model/GHPRReviewFlowViewModel.kt index eee00f107fa2..7f6d5be1f77a 100644 --- a/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/details/model/GHPRReviewFlowViewModel.kt +++ b/plugins/github/github-core/src/org/jetbrains/plugins/github/pullrequest/ui/details/model/GHPRReviewFlowViewModel.kt @@ -10,7 +10,7 @@ import org.jetbrains.plugins.github.pullrequest.data.service.GHPRSecurityService import org.jetbrains.plugins.github.pullrequest.ui.review.GHPRReviewViewModel import javax.swing.JComponent -internal interface GHPRReviewFlowViewModel : CodeReviewFlowViewModel, GHPRReviewViewModel { +interface GHPRReviewFlowViewModel : CodeReviewFlowViewModel, GHPRReviewViewModel { val isBusy: Flow val requestedReviewers: Flow> val reviewState: Flow