Skip to content

Commit

Permalink
feat:trigger workflow-dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
cunla committed Nov 23, 2023
1 parent d9e3a71 commit 71d8c3d
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.dsoftware.ghmanager.actions
import com.dsoftware.ghmanager.api.GithubApi
import com.dsoftware.ghmanager.api.model.WorkflowType
import com.dsoftware.ghmanager.data.RepositoryCoordinates
import com.dsoftware.ghmanager.data.WorkflowRunSelectionContext
import com.intellij.icons.AllIcons
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
Expand All @@ -14,8 +15,9 @@ import org.jetbrains.plugins.github.util.GithubUrlUtil
import javax.swing.Icon

abstract class PostUrlAction(
val text: String, description: String?, icon: Icon, private val data: Any? = null,
private val text: String, description: String?, icon: Icon,
) : DumbAwareAction(text, description, icon) {
private var context: WorkflowRunSelectionContext? = null
override fun getActionUpdateThread(): ActionUpdateThread {
return ActionUpdateThread.BGT
}
Expand All @@ -32,13 +34,16 @@ abstract class PostUrlAction(
val context = e.getRequiredData(ActionKeys.ACTION_DATA_CONTEXT)
val future = context.dataLoader.createDataProvider(request).request
future.thenApply {
context.resetAllData()
afterPostUrl()
}
}
}

abstract fun getUrl(dataContext: DataContext): String?
open fun getData(dataContext: DataContext): Any = Object()
open fun afterPostUrl() {
context.let { it?.resetAllData() }
}
}

class CancelWorkflowAction : PostUrlAction("Cancel Workflow", null, AllIcons.Actions.Cancel) {
Expand Down Expand Up @@ -86,4 +91,7 @@ class WorkflowDispatchAction(private val workflowType: WorkflowType) :
val context = dataContext.getData(ActionKeys.ACTION_DATA_CONTEXT) ?: return Object()
return mapOf("ref" to context.repositoryMapping.gitRepository.currentBranch?.name)
}

override fun afterPostUrl() {
}
}

0 comments on commit 71d8c3d

Please sign in to comment.