From 2145ace5c8a3281a1b95e7659c789b78d465a711 Mon Sep 17 00:00:00 2001 From: Rival Abdrakhmanov Date: Thu, 8 Feb 2024 20:59:11 +0100 Subject: [PATCH 1/2] Move actions to dashboard module --- .../aspire/actions/{ => dashboard}/AspireHelpAction.kt | 2 +- .../actions/{ => dashboard}/AspireSettingsAction.kt | 2 +- .../actions/{ => dashboard}/OpenAspireDashboardAction.kt | 2 +- .../aspire/actions/{ => dashboard}/ShowDiagramAction.kt | 2 +- src/main/resources/META-INF/plugin.xml | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) rename src/main/kotlin/me/rafaelldi/aspire/actions/{ => dashboard}/AspireHelpAction.kt (83%) rename src/main/kotlin/me/rafaelldi/aspire/actions/{ => dashboard}/AspireSettingsAction.kt (94%) rename src/main/kotlin/me/rafaelldi/aspire/actions/{ => dashboard}/OpenAspireDashboardAction.kt (97%) rename src/main/kotlin/me/rafaelldi/aspire/actions/{ => dashboard}/ShowDiagramAction.kt (97%) diff --git a/src/main/kotlin/me/rafaelldi/aspire/actions/AspireHelpAction.kt b/src/main/kotlin/me/rafaelldi/aspire/actions/dashboard/AspireHelpAction.kt similarity index 83% rename from src/main/kotlin/me/rafaelldi/aspire/actions/AspireHelpAction.kt rename to src/main/kotlin/me/rafaelldi/aspire/actions/dashboard/AspireHelpAction.kt index 10683022..e3f20acd 100644 --- a/src/main/kotlin/me/rafaelldi/aspire/actions/AspireHelpAction.kt +++ b/src/main/kotlin/me/rafaelldi/aspire/actions/dashboard/AspireHelpAction.kt @@ -1,4 +1,4 @@ -package me.rafaelldi.aspire.actions +package me.rafaelldi.aspire.actions.dashboard import com.intellij.ide.actions.ContextHelpAction import com.intellij.openapi.actionSystem.DataContext diff --git a/src/main/kotlin/me/rafaelldi/aspire/actions/AspireSettingsAction.kt b/src/main/kotlin/me/rafaelldi/aspire/actions/dashboard/AspireSettingsAction.kt similarity index 94% rename from src/main/kotlin/me/rafaelldi/aspire/actions/AspireSettingsAction.kt rename to src/main/kotlin/me/rafaelldi/aspire/actions/dashboard/AspireSettingsAction.kt index d00812f3..858f1d6c 100644 --- a/src/main/kotlin/me/rafaelldi/aspire/actions/AspireSettingsAction.kt +++ b/src/main/kotlin/me/rafaelldi/aspire/actions/dashboard/AspireSettingsAction.kt @@ -1,4 +1,4 @@ -package me.rafaelldi.aspire.actions +package me.rafaelldi.aspire.actions.dashboard import com.intellij.openapi.actionSystem.ActionUpdateThread import com.intellij.openapi.actionSystem.AnAction diff --git a/src/main/kotlin/me/rafaelldi/aspire/actions/OpenAspireDashboardAction.kt b/src/main/kotlin/me/rafaelldi/aspire/actions/dashboard/OpenAspireDashboardAction.kt similarity index 97% rename from src/main/kotlin/me/rafaelldi/aspire/actions/OpenAspireDashboardAction.kt rename to src/main/kotlin/me/rafaelldi/aspire/actions/dashboard/OpenAspireDashboardAction.kt index 09fbc4a0..b90aacee 100644 --- a/src/main/kotlin/me/rafaelldi/aspire/actions/OpenAspireDashboardAction.kt +++ b/src/main/kotlin/me/rafaelldi/aspire/actions/dashboard/OpenAspireDashboardAction.kt @@ -1,4 +1,4 @@ -package me.rafaelldi.aspire.actions +package me.rafaelldi.aspire.actions.dashboard import com.intellij.ide.BrowserUtil import com.intellij.openapi.actionSystem.ActionUpdateThread diff --git a/src/main/kotlin/me/rafaelldi/aspire/actions/ShowDiagramAction.kt b/src/main/kotlin/me/rafaelldi/aspire/actions/dashboard/ShowDiagramAction.kt similarity index 97% rename from src/main/kotlin/me/rafaelldi/aspire/actions/ShowDiagramAction.kt rename to src/main/kotlin/me/rafaelldi/aspire/actions/dashboard/ShowDiagramAction.kt index 89faf6bc..a8b2fee3 100644 --- a/src/main/kotlin/me/rafaelldi/aspire/actions/ShowDiagramAction.kt +++ b/src/main/kotlin/me/rafaelldi/aspire/actions/dashboard/ShowDiagramAction.kt @@ -1,4 +1,4 @@ -package me.rafaelldi.aspire.actions +package me.rafaelldi.aspire.actions.dashboard import com.intellij.openapi.actionSystem.ActionUpdateThread import com.intellij.openapi.actionSystem.AnAction diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 0e78f6de..730c8c6f 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -38,15 +38,15 @@ + class="me.rafaelldi.aspire.actions.dashboard.AspireHelpAction"/> Date: Thu, 8 Feb 2024 21:30:55 +0100 Subject: [PATCH 2/2] Add generate manifest action to Dashboard --- .../actions/dashboard/AspireManifestAction.kt | 43 +++++++++++++++++++ .../aspire/run/AspireHostProgramRunner.kt | 3 ++ .../services/AspireHostServiceContributor.kt | 1 + .../aspire/services/SessionHostServiceData.kt | 2 + .../sessionHost/AspireSessionHostConfig.kt | 3 ++ .../sessionHost/AspireSessionHostManager.kt | 1 + src/main/resources/META-INF/plugin.xml | 7 ++- .../messages/AspireBundle.properties | 6 ++- 8 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 src/main/kotlin/me/rafaelldi/aspire/actions/dashboard/AspireManifestAction.kt diff --git a/src/main/kotlin/me/rafaelldi/aspire/actions/dashboard/AspireManifestAction.kt b/src/main/kotlin/me/rafaelldi/aspire/actions/dashboard/AspireManifestAction.kt new file mode 100644 index 00000000..5ee5b077 --- /dev/null +++ b/src/main/kotlin/me/rafaelldi/aspire/actions/dashboard/AspireManifestAction.kt @@ -0,0 +1,43 @@ +package me.rafaelldi.aspire.actions.dashboard + +import com.intellij.openapi.actionSystem.ActionUpdateThread +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import me.rafaelldi.aspire.manifest.ManifestService +import me.rafaelldi.aspire.sessionHost.AspireSessionHostManager +import me.rafaelldi.aspire.util.SESSION_HOST_ID + +class AspireManifestAction : AnAction() { + override fun actionPerformed(event: AnActionEvent) { + val project = event.project ?: return + val sessionHostId = event.getData(SESSION_HOST_ID) ?: return + val sessionHost = AspireSessionHostManager + .getInstance(project) + .getSessionHost(sessionHostId) + ?: return + val hostPath = sessionHost.hostData.hostPath ?: return + + ManifestService.getInstance(project).generateManifest(hostPath) + } + + override fun update(event: AnActionEvent) { + val project = event.project + val sessionHostId = event.getData(SESSION_HOST_ID) + if (project == null || sessionHostId == null) { + event.presentation.isEnabledAndVisible = false + return + } + + val hostAvailable = AspireSessionHostManager + .getInstance(project) + .isSessionHostAvailable(sessionHostId) + if (!hostAvailable) { + event.presentation.isEnabledAndVisible = false + return + } + + event.presentation.isEnabledAndVisible = true + } + + override fun getActionUpdateThread() = ActionUpdateThread.BGT +} \ No newline at end of file diff --git a/src/main/kotlin/me/rafaelldi/aspire/run/AspireHostProgramRunner.kt b/src/main/kotlin/me/rafaelldi/aspire/run/AspireHostProgramRunner.kt index fbaedf9d..597f04d5 100644 --- a/src/main/kotlin/me/rafaelldi/aspire/run/AspireHostProgramRunner.kt +++ b/src/main/kotlin/me/rafaelldi/aspire/run/AspireHostProgramRunner.kt @@ -19,6 +19,7 @@ import me.rafaelldi.aspire.sessionHost.AspireSessionHostConfig import me.rafaelldi.aspire.sessionHost.AspireSessionHostManager import org.jetbrains.concurrency.Promise import org.jetbrains.concurrency.asPromise +import kotlin.io.path.Path class AspireHostProgramRunner : DotNetProgramRunner() { companion object { @@ -57,6 +58,7 @@ class AspireHostProgramRunner : DotNetProgramRunner() { val parameters = (environment.runnerAndConfigurationSettings?.configuration as? AspireHostConfiguration)?.parameters + val hostPath = parameters?.projectFilePath?.let { Path(it) } val dashboardUrl = parameters?.startBrowserParameters?.url val aspireHostLifetime = environment.project.lifetime.createNested() @@ -66,6 +68,7 @@ class AspireHostProgramRunner : DotNetProgramRunner() { val config = AspireSessionHostConfig( debugSessionToken, runProfileName, + hostPath, isDebug, debugSessionPort, openTelemetryPort, diff --git a/src/main/kotlin/me/rafaelldi/aspire/services/AspireHostServiceContributor.kt b/src/main/kotlin/me/rafaelldi/aspire/services/AspireHostServiceContributor.kt index 2f387cd5..01cb2cdb 100644 --- a/src/main/kotlin/me/rafaelldi/aspire/services/AspireHostServiceContributor.kt +++ b/src/main/kotlin/me/rafaelldi/aspire/services/AspireHostServiceContributor.kt @@ -19,6 +19,7 @@ class AspireHostServiceContributor(val hostData: SessionHostServiceData) : object : SimpleServiceViewDescriptor(hostData.hostName, AspireIcons.Service), DataProvider { private val toolbarActions = DefaultActionGroup( ActionManager.getInstance().getAction("Aspire.Dashboard"), + ActionManager.getInstance().getAction("Aspire.Manifest"), ActionManager.getInstance().getAction("Aspire.Diagram"), Separator(), ActionManager.getInstance().getAction("Aspire.Settings"), diff --git a/src/main/kotlin/me/rafaelldi/aspire/services/SessionHostServiceData.kt b/src/main/kotlin/me/rafaelldi/aspire/services/SessionHostServiceData.kt index 6334ab2e..6a40b725 100644 --- a/src/main/kotlin/me/rafaelldi/aspire/services/SessionHostServiceData.kt +++ b/src/main/kotlin/me/rafaelldi/aspire/services/SessionHostServiceData.kt @@ -2,10 +2,12 @@ package me.rafaelldi.aspire.services import com.jetbrains.rd.util.lifetime.Lifetime import me.rafaelldi.aspire.generated.AspireSessionHostModel +import java.nio.file.Path data class SessionHostServiceData( val id: String, val hostName: String, + val hostPath: Path?, val dashboardUrl: String?, val sessionHostModel: AspireSessionHostModel, val sessionHostLifetime: Lifetime diff --git a/src/main/kotlin/me/rafaelldi/aspire/sessionHost/AspireSessionHostConfig.kt b/src/main/kotlin/me/rafaelldi/aspire/sessionHost/AspireSessionHostConfig.kt index 1c01add9..fe31a839 100644 --- a/src/main/kotlin/me/rafaelldi/aspire/sessionHost/AspireSessionHostConfig.kt +++ b/src/main/kotlin/me/rafaelldi/aspire/sessionHost/AspireSessionHostConfig.kt @@ -1,8 +1,11 @@ package me.rafaelldi.aspire.sessionHost +import java.nio.file.Path + data class AspireSessionHostConfig( val id: String, val hostName: String, + val hostPath: Path?, val isDebug: Boolean, val debugSessionPort: Int, val openTelemetryPort: Int, diff --git a/src/main/kotlin/me/rafaelldi/aspire/sessionHost/AspireSessionHostManager.kt b/src/main/kotlin/me/rafaelldi/aspire/sessionHost/AspireSessionHostManager.kt index 9993ae0f..79f4aaf0 100644 --- a/src/main/kotlin/me/rafaelldi/aspire/sessionHost/AspireSessionHostManager.kt +++ b/src/main/kotlin/me/rafaelldi/aspire/sessionHost/AspireSessionHostManager.kt @@ -62,6 +62,7 @@ class AspireSessionHostManager(private val project: Project) { val sessionHostData = SessionHostServiceData( sessionHostConfig.id, sessionHostConfig.hostName, + sessionHostConfig.hostPath, sessionHostConfig.dashboardUrl, sessionHostModel, sessionHostLifetime.lifetime diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 730c8c6f..294ecb19 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -45,12 +45,15 @@ + - + icon="AllIcons.FileTypes.Json"> diff --git a/src/main/resources/messages/AspireBundle.properties b/src/main/resources/messages/AspireBundle.properties index 40380332..cd3149e1 100644 --- a/src/main/resources/messages/AspireBundle.properties +++ b/src/main/resources/messages/AspireBundle.properties @@ -6,10 +6,12 @@ action.Aspire.Help.text=Aspire Help action.Aspire.Help.description=Open plugin help action.Aspire.Dashboard.text=Open Aspire Dashboard action.Aspire.Dashboard.description=Open Aspire dashboard in browser -action.Aspire.Diagram.text=Show Diagram -action.Aspire.Diagram.description=Show distributed traces diagram action.Aspire.Manifest.text=Generate Aspire Manifest action.Aspire.Manifest.description=Generate .NET Aspire manifest +action.Aspire.Diagram.text=Show Diagram +action.Aspire.Diagram.description=Show distributed traces diagram +action.Aspire.Solution.Manifest.text=Generate Aspire Manifest +action.Aspire.Solution.Manifest.description=Generate .NET Aspire manifest run.editor.project=Project: run.editor.environment.variables=Environment variables: