Commit 1b8c945f authored by Chris Lemaire's avatar Chris Lemaire Committed by intellij-monorepo-bot
Browse files

[gitlab] Fix condition for submitting review (IDEA-337325)

#IDEA-337325 Fixed

Follow-up: eb6d4013b9a4144b33b8880fb9c6ec05edcc87d0

(cherry picked from commit d88fba3562799cea28fae854cf164be2099f469c)
(cherry picked from commit e566ed564a824392168a354ed02818f4b7e2eedd)

IJ-CR-124130

GitOrigin-RevId: d39222359d3734bae642d3239fe1624d25c482dc
parent 094efad9
Branches unavailable Tags unavailable
No related merge requests found
Showing with 13 additions and 6 deletions
+13 -6
......@@ -119,6 +119,14 @@ fun JComponent.bindVisibilityIn(scope: CoroutineScope, visibilityFlow: Flow<Bool
}
}
fun JComponent.bindEnabledIn(scope: CoroutineScope, enabledFlow: Flow<Boolean>) {
scope.launch(start = CoroutineStart.UNDISPATCHED) {
enabledFlow.collect {
isEnabled = it
}
}
}
fun JComponent.bindDisabledIn(scope: CoroutineScope, disabledFlow: Flow<Boolean>) {
scope.launch(start = CoroutineStart.UNDISPATCHED) {
disabledFlow.collect {
......
......@@ -5,10 +5,7 @@ import com.intellij.collaboration.async.inverted
import com.intellij.collaboration.messages.CollaborationToolsBundle
import com.intellij.collaboration.ui.HorizontalListPanel
import com.intellij.collaboration.ui.SimpleHtmlPane
import com.intellij.collaboration.ui.util.bindChildIn
import com.intellij.collaboration.ui.util.bindDisabledIn
import com.intellij.collaboration.ui.util.bindTextIn
import com.intellij.collaboration.ui.util.bindVisibilityIn
import com.intellij.collaboration.ui.util.*
import com.intellij.icons.AllIcons
import com.intellij.ide.plugins.newui.InstallButton
import com.intellij.openapi.editor.actions.IncrementalFindAction
......@@ -40,6 +37,7 @@ import javax.swing.JButton
import javax.swing.JComponent
import javax.swing.JLabel
import javax.swing.JPanel
import kotlin.coroutines.cancellation.CancellationException
import kotlin.coroutines.resume
internal object GitLabMergeRequestSubmitReviewPopup {
......@@ -106,8 +104,9 @@ internal object GitLabMergeRequestSubmitReviewPopup {
private val submitButton = JButton(CollaborationToolsBundle.message("review.submit.action")).apply {
isOpaque = false
toolTipText = GitLabBundle.message("merge.request.submit.action.tooltip")
bindDisabledIn(cs, combine(vm.isBusy, vm.text) { busy, text ->
busy || text.isEmpty()
bindEnabledIn(cs, combine(vm.isBusy, vm.text, vm.draftCommentsCount) { busy, text, draftComments ->
// Is enabled when not busy and: the text is not blank, or there are draft comments to submit
!busy && (text.isNotBlank() || draftComments > 0)
})
addActionListener {
vm.submit()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment