git-branches-dashboard: add ability to open manage remotes dialog from Remote node...
[idea/community.git] / plugins / git4idea / src / git4idea / ui / branch / dashboard / BranchesDashboardActions.kt
index c43f0d13b387fe6283bcfa310891f861ad9a7dd7..0175ff15143ab7f89b45fb49b8dcc16d86b74a29 100644 (file)
@@ -98,6 +98,12 @@ internal object BranchesDashboardActions {
       arrayListOf<AnAction>(EditRemoteAction(currentRepository), RemoveRemoteAction(currentRepository)).toTypedArray()
   }
 
+  class RemoteGlobalActions : ActionGroup(), DumbAware {
+
+    override fun getChildren(e: AnActionEvent?): Array<AnAction> =
+      arrayListOf<AnAction>(ActionManager.getInstance().getAction("Git.Configure.Remotes")).toTypedArray()
+  }
+
   class BranchActionsBuilder(private val project: Project, private val tree: FilteringBranchesTree) {
     fun build(): ActionGroup? {
       val selectedBranches = tree.getSelectedBranches()
@@ -122,6 +128,11 @@ internal object BranchesDashboardActions {
         return GroupActions(guessRepo)
       }
 
+      val selectedBranchNodes = tree.getSelectedBranchNodes()
+      if (selectedBranchNodes.size == 1 && selectedBranchNodes.first().type == NodeType.REMOTE_ROOT) {
+        return RemoteGlobalActions()
+      }
+
       return null
     }
   }