[vcs-log] disable "Show Git Log for Command" action for projects with non-git repositories

GitOrigin-RevId: aa3646b5ecd00fa5ee29430a99ce5955c145f5b2
This commit is contained in:
Julia Beliaeva
2023-09-01 20:52:40 +00:00
committed by intellij-monorepo-bot
parent e90c4cf301
commit bc329f9aca
@@ -1,19 +1,33 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package git4idea.log.command
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.components.service
import com.intellij.openapi.project.DumbAwareAction
import com.intellij.openapi.vcs.ProjectLevelVcsManager
import com.intellij.openapi.wm.IdeFocusManager
import com.intellij.vcs.log.impl.VcsLogContentUtil
import com.intellij.vcs.log.impl.VcsLogProjectTabsProperties
import com.intellij.vcs.log.impl.VcsLogTabsManager
import com.intellij.vcs.log.impl.VcsProjectLog
import com.intellij.vcs.log.visible.filters.VcsLogFilterObject
import git4idea.GitVcs
import java.util.*
@Suppress("HardCodedStringLiteral") // internal action
class ShowGitLogCommandAction : DumbAwareAction("Show Git Log for Command") {
override fun update(e: AnActionEvent) {
val project = e.project
if (project == null) {
e.presentation.isEnabledAndVisible = false
return
}
e.presentation.isEnabledAndVisible = ProjectLevelVcsManager.getInstance(project).singleVCS?.keyInstanceMethod == GitVcs.getKey()
}
override fun actionPerformed(e: AnActionEvent) {
val project = e.project!!
VcsProjectLog.runWhenLogIsReady(project) { vcsLogManager ->
@@ -26,4 +40,6 @@ class ShowGitLogCommandAction : DumbAwareAction("Show Git Log for Command") {
IdeFocusManager.getInstance(project).requestFocus(ui.filterUi.textFilterComponent.focusedComponent, true)
}
}
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
}