Skip to content

Commit

Permalink
Merge pull request #58 from rafaelldi/dashboard-manifest-action
Browse files Browse the repository at this point in the history
Dashboard manifest action
  • Loading branch information
rafaelldi authored Feb 8, 2024
2 parents cb7b3ff + bb187bd commit 0ef66d4
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
Expand All @@ -66,6 +68,7 @@ class AspireHostProgramRunner : DotNetProgramRunner() {
val config = AspireSessionHostConfig(
debugSessionToken,
runProfileName,
hostPath,
isDebug,
debugSessionPort,
openTelemetryPort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class AspireSessionHostManager(private val project: Project) {
val sessionHostData = SessionHostServiceData(
sessionHostConfig.id,
sessionHostConfig.hostName,
sessionHostConfig.hostPath,
sessionHostConfig.dashboardUrl,
sessionHostModel,
sessionHostLifetime.lifetime
Expand Down
15 changes: 9 additions & 6 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,22 @@

<actions>
<action id="Aspire.Settings"
class="me.rafaelldi.aspire.actions.AspireSettingsAction"
class="me.rafaelldi.aspire.actions.dashboard.AspireSettingsAction"
icon="AllIcons.General.Settings"/>
<action id="Aspire.Help"
class="me.rafaelldi.aspire.actions.AspireHelpAction"/>
class="me.rafaelldi.aspire.actions.dashboard.AspireHelpAction"/>
<action id="Aspire.Dashboard"
class="me.rafaelldi.aspire.actions.OpenAspireDashboardAction"
class="me.rafaelldi.aspire.actions.dashboard.OpenAspireDashboardAction"
icon="AllIcons.General.Web"/>
<action id="Aspire.Manifest"
class="me.rafaelldi.aspire.actions.dashboard.AspireManifestAction"
icon="AllIcons.FileTypes.Json"/>
<action id="Aspire.Diagram"
class="me.rafaelldi.aspire.actions.ShowDiagramAction"
class="me.rafaelldi.aspire.actions.dashboard.ShowDiagramAction"
icon="AllIcons.FileTypes.Diagram"/>
<action id="Aspire.Manifest"
<action id="Aspire.Solution.Manifest"
class="me.rafaelldi.aspire.actions.ManifestGenerationAction"
icon="AllIcons.Actions.PrettyPrint">
icon="AllIcons.FileTypes.Json">
<add-to-group group-id="SolutionExplorerPopupMenu.Tools"/>
</action>
</actions>
Expand Down
6 changes: 4 additions & 2 deletions src/main/resources/messages/AspireBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 0ef66d4

Please sign in to comment.