diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowCommitOptionsAction.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowCommitOptionsAction.kt index 53f4a2e5d3ce..f80fe1332f48 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowCommitOptionsAction.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowCommitOptionsAction.kt @@ -14,7 +14,7 @@ class ShowCommitOptionsAction : AnAction() { } override fun update(e: AnActionEvent) { - e.presentation.isEnabled = e.getProjectCommitWorkflowHandler() != null + e.presentation.isEnabled = e.getProjectCommitWorkflowHandler()?.isActive == true } override fun actionPerformed(e: AnActionEvent) { diff --git a/platform/vcs-impl/src/com/intellij/vcs/commit/AbstractCommitWorkflowHandler.kt b/platform/vcs-impl/src/com/intellij/vcs/commit/AbstractCommitWorkflowHandler.kt index 4f917e3bcc1e..bbaa2a1bb4ee 100644 --- a/platform/vcs-impl/src/com/intellij/vcs/commit/AbstractCommitWorkflowHandler.kt +++ b/platform/vcs-impl/src/com/intellij/vcs/commit/AbstractCommitWorkflowHandler.kt @@ -69,7 +69,7 @@ abstract class AbstractCommitWorkflowHandler + protected open fun createDataProvider() = DataProvider { dataId -> when { COMMIT_WORKFLOW_HANDLER.`is`(dataId) -> this Refreshable.PANEL_KEY.`is`(dataId) -> commitPanel diff --git a/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitPanel.kt b/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitPanel.kt index a0641c484693..3b02e32c09ef 100644 --- a/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitPanel.kt +++ b/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitPanel.kt @@ -180,9 +180,7 @@ class ChangesViewCommitPanel(private val changesView: ChangesListView, private v private fun setupShortcuts(component: JComponent) { DefaultCommitAction().registerCustomShortcutSet(DEFAULT_COMMIT_ACTION_SHORTCUT, component, this) - DumbAwareAction.create { - if (commitButton.isEnabled) commitButton.showPopup() - }.registerCustomShortcutSet(getDefaultShowPopupShortcut(), component, this) + ShowCustomCommitActions().registerCustomShortcutSet(getDefaultShowPopupShortcut(), component, this) } override fun globalSchemeChange(scheme: EditorColorsScheme?) { @@ -325,9 +323,17 @@ class ChangesViewCommitPanel(private val changesView: ChangesListView, private v inner class DefaultCommitAction : DumbAwareAction() { override fun update(e: AnActionEvent) { - e.presentation.isEnabledAndVisible = defaultCommitAction.isEnabled + e.presentation.isEnabledAndVisible = isActive && defaultCommitAction.isEnabled } override fun actionPerformed(e: AnActionEvent) = fireDefaultExecutorCalled() } + + private inner class ShowCustomCommitActions : DumbAwareAction() { + override fun update(e: AnActionEvent) { + e.presentation.isEnabledAndVisible = isActive && commitButton.isEnabled + } + + override fun actionPerformed(e: AnActionEvent) = commitButton.showPopup() + } } \ No newline at end of file diff --git a/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitWorkflowHandler.kt b/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitWorkflowHandler.kt index 5d9d9d0c69e8..7d2c44e4ae2b 100644 --- a/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitWorkflowHandler.kt +++ b/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitWorkflowHandler.kt @@ -2,14 +2,12 @@ package com.intellij.vcs.commit import com.intellij.openapi.Disposable -import com.intellij.openapi.actionSystem.ActionGroup -import com.intellij.openapi.actionSystem.ActionManager -import com.intellij.openapi.actionSystem.AnAction -import com.intellij.openapi.actionSystem.DataContext +import com.intellij.openapi.actionSystem.* import com.intellij.openapi.util.Disposer import com.intellij.openapi.vcs.CheckinProjectPanel import com.intellij.openapi.vcs.FilePath import com.intellij.openapi.vcs.VcsConfiguration +import com.intellij.openapi.vcs.VcsDataKeys.COMMIT_WORKFLOW_HANDLER import com.intellij.openapi.vcs.VcsException import com.intellij.openapi.vcs.changes.* import com.intellij.openapi.vcs.changes.actions.DefaultCommitExecutorAction @@ -53,6 +51,14 @@ class ChangesViewCommitWorkflowHandler( vcsesChanged() // as currently vcses are set before handler subscribes to corresponding event } + override fun createDataProvider(): DataProvider = object : DataProvider { + private val superProvider = super@ChangesViewCommitWorkflowHandler.createDataProvider() + + override fun getData(dataId: String): Any? = + if (COMMIT_WORKFLOW_HANDLER.`is`(dataId)) this@ChangesViewCommitWorkflowHandler.takeIf { it.isActive } + else superProvider.getData(dataId) + } + private fun ensureCommitOptions(): CommitOptions { if (!areCommitOptionsCreated) { areCommitOptionsCreated = true