git-branches-dashboard: add ability to open manage remotes dialog from Remote node...
authorDmitry Zhuravlev <dmitry.zhuravlev@jetbrains.com>
Tue, 4 Aug 2020 11:47:14 +0000 (14:47 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Tue, 11 Aug 2020 14:36:32 +0000 (14:36 +0000)
GitOrigin-RevId: fd6cc3445f0094819b5c3de289ff73838f93528c

plugins/git4idea/src/git4idea/ui/branch/dashboard/BranchesDashboardActions.kt
plugins/git4idea/src/git4idea/ui/branch/dashboard/BranchesTree.kt

index c43f0d13b387fe6283bcfa310891f861ad9a7dd7..0175ff15143ab7f89b45fb49b8dcc16d86b74a29 100644 (file)
@@ -98,6 +98,12 @@ internal object BranchesDashboardActions {
       arrayListOf<AnAction>(EditRemoteAction(currentRepository), RemoveRemoteAction(currentRepository)).toTypedArray()
   }
 
       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()
   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)
       }
 
         return GroupActions(guessRepo)
       }
 
+      val selectedBranchNodes = tree.getSelectedBranchNodes()
+      if (selectedBranchNodes.size == 1 && selectedBranchNodes.first().type == NodeType.REMOTE_ROOT) {
+        return RemoteGlobalActions()
+      }
+
       return null
     }
   }
       return null
     }
   }
index ba9230a42d5f20c80b160d1a18b215c114971a64..ac2f31ff83ab6386d5c701b64c3018cff214386a 100644 (file)
@@ -251,6 +251,8 @@ internal class FilteringBranchesTree(project: Project,
 
   fun getSelectedRemotes() = component.getSelectedRemotes()
 
 
   fun getSelectedRemotes() = component.getSelectedRemotes()
 
+  fun getSelectedBranchNodes() = component.getSelectedNodes().map(BranchTreeNode::getNodeDescriptor).toSet()
+
   private fun restorePreviouslyExpandedPaths() {
     TreeUtil.restoreExpandedPaths(component, expandedPaths.toList())
   }
   private fun restorePreviouslyExpandedPaths() {
     TreeUtil.restoreExpandedPaths(component, expandedPaths.toList())
   }