Skip to content

Commit

Permalink
fix(intellij): use generate ui button in toolbar instead of run anyth…
Browse files Browse the repository at this point in the history
…ing (#2239)
  • Loading branch information
MaxKless authored Aug 28, 2024
1 parent 40f96d0 commit 29235e4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions .idea/ktfmt.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package dev.nx.console.generate.actions

import com.intellij.openapi.actionSystem.ActionPlaces
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.icons.AllIcons
import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.components.service
import com.intellij.openapi.diagnostic.logger
import com.intellij.util.application
import dev.nx.console.generate.NxGenerateService
import dev.nx.console.nx_toolwindow.NxToolWindowPanel
import dev.nx.console.telemetry.TelemetryEvent
import dev.nx.console.telemetry.TelemetryEventSource
import dev.nx.console.telemetry.TelemetryService
Expand All @@ -17,6 +16,15 @@ import kotlinx.coroutines.launch
private val logger = logger<NxGenerateUiAction>()

class NxGenerateUiAction : AnAction() {
override fun getActionUpdateThread() = ActionUpdateThread.BGT

override fun update(e: AnActionEvent) {
super.update(e)
if (e.place == NxToolWindowPanel.NX_TOOLBAR_PLACE) {
e.presentation.icon = AllIcons.Actions.AddList
}
}

override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package dev.nx.console.generate.actions

import com.intellij.icons.AllIcons
import com.intellij.openapi.actionSystem.ActionPlaces
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.application.EDT
import com.intellij.openapi.project.Project
import dev.nx.console.generate.NxGenerateService
Expand All @@ -26,6 +23,8 @@ open class NxReMoveProjectActionBase(val mode: String) : AnAction() {
require(mode == "move" || mode == "remove")
}

override fun getActionUpdateThread() = ActionUpdateThread.BGT

override fun update(e: AnActionEvent) {
super.update(e)

Expand All @@ -47,7 +46,7 @@ open class NxReMoveProjectActionBase(val mode: String) : AnAction() {
"source" to
if (ActionPlaces.isPopupPlace(e.place)) "explorer-context-menu"
else "command"
)
),
)

val nxProjectNameFromEventData =
Expand Down Expand Up @@ -111,7 +110,7 @@ open class NxReMoveProjectActionBase(val mode: String) : AnAction() {
moveGenerators,
preselectedProjectName,
projectsWithType,
workspaceLayoutPair
workspaceLayoutPair,
) {
runReMoveGenerator(it, runGeneratorManager, dryRun = true)
}
Expand All @@ -124,13 +123,10 @@ open class NxReMoveProjectActionBase(val mode: String) : AnAction() {
private fun runReMoveGenerator(
dialog: NxReMoveProjectDialog,
runGeneratorManager: RunGeneratorManager,
dryRun: Boolean = false
dryRun: Boolean = false,
) {
val result = dialog.getResult()
val args =
mutableListOf<String>(
"--projectName=${result.project}",
)
val args = mutableListOf<String>("--projectName=${result.project}")
if (mode == "move") {
args.add("--destination=${result.directory}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class NxToolWindowPanel(private val project: Project) : SimpleToolWindowPanel(tr
actionGroup.addAction(refreshAction)
actionGroup.addSeparator()
actionGroup.add(
actionManager.getAction("dev.nx.console.run.actions.NxRunAnythingAction")
actionManager.getAction("dev.nx.console.generate.actions.NxGenerateUiAction")
)
actionGroup.add(
actionManager.getAction("dev.nx.console.graph.actions.NxGraphSelectAllAction")
Expand Down

0 comments on commit 29235e4

Please sign in to comment.