mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
[gitlab] fix git branch popup review actions
do no try to cheat the action system and just hope for the best apparently data context is now recreated between update and action perform #IDEA-346815 fixed GitOrigin-RevId: 29d2cb0558cdcceb373db007dc496a3d4b0d0fe9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0e11284ee1
commit
5619489449
@@ -12,7 +12,6 @@ import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.components.serviceIfCreated
|
||||
import com.intellij.openapi.project.DumbAwareAction
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import git4idea.branch.GitBranchSyncStatus
|
||||
import git4idea.branch.GitBranchUtil
|
||||
@@ -83,16 +82,11 @@ class GitLabMergeRequestOnCurrentBranchService(project: Project, cs: CoroutineSc
|
||||
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
val action = e.project?.serviceIfCreated<GitLabMergeRequestOnCurrentBranchService>()?.mergeRequestReviewVmState?.value?.let {
|
||||
{ it.showMergeRequest(GitLabStatistics.ToolWindowOpenTabActionPlace.ACTION) }
|
||||
}
|
||||
e.presentation.isEnabledAndVisible = action != null
|
||||
// required for thread safety
|
||||
e.presentation.putClientProperty(actionKey, action)
|
||||
e.presentation.isEnabledAndVisible = e.project?.let(::getCurrentVm) != null
|
||||
}
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
e.presentation.getClientProperty(actionKey)?.invoke()
|
||||
e.project?.let(::getCurrentVm)?.showMergeRequest(GitLabStatistics.ToolWindowOpenTabActionPlace.ACTION)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,19 +94,12 @@ class GitLabMergeRequestOnCurrentBranchService(project: Project, cs: CoroutineSc
|
||||
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
val action = e.project?.serviceIfCreated<GitLabMergeRequestOnCurrentBranchService>()?.mergeRequestReviewVmState?.value
|
||||
?.takeIf {
|
||||
it.localRepositorySyncStatus.value?.getOrNull()?.incoming == true
|
||||
}?.let {
|
||||
{ it.updateBranch() }
|
||||
}
|
||||
e.presentation.isEnabledAndVisible = action != null
|
||||
// required for thread safety
|
||||
e.presentation.putClientProperty(actionKey, action)
|
||||
e.presentation.isEnabledAndVisible =
|
||||
e.project?.let(::getCurrentVm)?.localRepositorySyncStatus?.value?.getOrNull()?.incoming == true
|
||||
}
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
e.presentation.getClientProperty(actionKey)?.invoke()
|
||||
e.project?.let(::getCurrentVm)?.updateBranch()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,21 +107,20 @@ class GitLabMergeRequestOnCurrentBranchService(project: Project, cs: CoroutineSc
|
||||
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
val vm = e.project?.serviceIfCreated<GitLabMergeRequestOnCurrentBranchService>()?.mergeRequestReviewVmState?.value
|
||||
val vm = e.project?.let(::getCurrentVm)
|
||||
if (vm == null || vm.localRepositorySyncStatus.value?.getOrNull()?.incoming == true) {
|
||||
e.presentation.isEnabledAndVisible = false
|
||||
e.presentation.putClientProperty(actionKey, null)
|
||||
return
|
||||
}
|
||||
|
||||
Toggleable.setSelected(e.presentation, vm.discussionsViewOption.value != DiscussionsViewOption.DONT_SHOW)
|
||||
e.presentation.putClientProperty(actionKey) { vm.toggleReviewMode() }
|
||||
}
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
e.presentation.getClientProperty(actionKey)?.invoke()
|
||||
e.project?.let(::getCurrentVm)?.toggleReviewMode()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val actionKey = Key.create<() -> Unit>("ShowAction.Action")
|
||||
private fun getCurrentVm(project: Project): GitLabMergeRequestEditorReviewViewModel? =
|
||||
project.serviceIfCreated<GitLabMergeRequestOnCurrentBranchService>()?.mergeRequestReviewVmState?.value
|
||||
|
||||
Reference in New Issue
Block a user