Skip to content

Commit 63b5722

Browse files
authored
Migrate DeployServerlessApplicationPanel to the UI DSL (#2698)
1 parent 9527132 commit 63b5722

File tree

7 files changed

+598
-632
lines changed

7 files changed

+598
-632
lines changed

jetbrains-core/src/software/aws/toolkits/jetbrains/services/lambda/actions/DeployServerlessApplicationAction.kt

+20-19
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import software.aws.toolkits.jetbrains.services.cloudformation.stack.StackWindow
3636
import software.aws.toolkits.jetbrains.services.cloudformation.validateSamTemplateHasResources
3737
import software.aws.toolkits.jetbrains.services.lambda.LambdaHandlerResolver
3838
import software.aws.toolkits.jetbrains.services.lambda.deploy.DeployServerlessApplicationDialog
39+
import software.aws.toolkits.jetbrains.services.lambda.deploy.DeployServerlessApplicationSettings
3940
import software.aws.toolkits.jetbrains.services.lambda.sam.SamCommon
4041
import software.aws.toolkits.jetbrains.services.lambda.sam.SamExecutable
4142
import software.aws.toolkits.jetbrains.services.lambda.steps.DeployLambda
@@ -106,8 +107,7 @@ class DeployServerlessApplicationAction : AnAction(
106107
FileDocumentManager.getInstance().saveAllDocuments()
107108

108109
val stackDialog = DeployServerlessApplicationDialog(project, templateFile)
109-
stackDialog.show()
110-
if (!stackDialog.isOK) {
110+
if (!stackDialog.showAndGet()) {
111111
SamTelemetry.deploy(
112112
project = project,
113113
version = SamCommon.getVersionString(),
@@ -116,27 +116,28 @@ class DeployServerlessApplicationAction : AnAction(
116116
return@runInEdt
117117
}
118118

119-
saveSettings(project, templateFile, stackDialog)
119+
val settings = stackDialog.settings()
120+
saveSettings(project, templateFile, settings)
120121

121-
val stackName = stackDialog.stackName
122-
continueDeployment(project, stackName, templateFile, stackDialog)
122+
val stackName = settings.stackName
123+
continueDeployment(project, stackName, templateFile, settings)
123124
}
124125
}
125126
}
126127

127-
private fun continueDeployment(project: Project, stackName: String, templateFile: VirtualFile, stackDialog: DeployServerlessApplicationDialog) {
128+
private fun continueDeployment(project: Project, stackName: String, templateFile: VirtualFile, settings: DeployServerlessApplicationSettings) {
128129
val workflow = StepExecutor(
129130
project,
130131
message("serverless.application.deploy_in_progress.title", stackName),
131132
createDeployWorkflow(
132133
project,
133134
stackName,
134135
templateFile,
135-
stackDialog.bucket,
136-
stackDialog.ecrRepo,
137-
stackDialog.useContainer,
138-
stackDialog.parameters,
139-
stackDialog.capabilities
136+
settings.bucket,
137+
settings.ecrRepo,
138+
settings.useContainer,
139+
settings.parameters,
140+
settings.capabilities
140141
),
141142
stackName
142143
)
@@ -145,7 +146,7 @@ class DeployServerlessApplicationAction : AnAction(
145146
runBlocking {
146147
val changeSetArn = it.getRequiredAttribute(DeployLambda.CHANGE_SET_ARN)
147148

148-
if (!stackDialog.autoExecute) {
149+
if (!settings.autoExecute) {
149150
val response = withContext(edtContext) { UploadFunctionContinueDialog(project, changeSetArn).showAndGet() }
150151
if (!response) {
151152
// TODO this telemetry needs to be improved. The user can finish the deployment later so we do not know if
@@ -251,16 +252,16 @@ class DeployServerlessApplicationAction : AnAction(
251252
return@runReadAction null
252253
}
253254

254-
private fun saveSettings(project: Project, templateFile: VirtualFile, stackDialog: DeployServerlessApplicationDialog) {
255+
private fun saveSettings(project: Project, templateFile: VirtualFile, settings: DeployServerlessApplicationSettings) {
255256
ModuleUtil.findModuleForFile(templateFile, project)?.let { module ->
256257
relativeSamPath(module, templateFile)?.let { samPath ->
257258
DeploySettings.getInstance(module)?.apply {
258-
setSamStackName(samPath, stackDialog.stackName)
259-
setSamBucketName(samPath, stackDialog.bucket)
260-
setSamEcrRepoUri(samPath, stackDialog.ecrRepo)
261-
setSamAutoExecute(samPath, stackDialog.autoExecute)
262-
setSamUseContainer(samPath, stackDialog.useContainer)
263-
setEnabledCapabilities(samPath, stackDialog.capabilities)
259+
setSamStackName(samPath, settings.stackName)
260+
setSamBucketName(samPath, settings.bucket)
261+
setSamEcrRepoUri(samPath, settings.ecrRepo)
262+
setSamAutoExecute(samPath, settings.autoExecute)
263+
setSamUseContainer(samPath, settings.useContainer)
264+
setEnabledCapabilities(samPath, settings.capabilities)
264265
}
265266
}
266267
}

0 commit comments

Comments
 (0)