From f22615bf009213860f8a6bc82f713a6026dbe6e2 Mon Sep 17 00:00:00 2001 From: Rival Abdrakhmanov Date: Wed, 20 Dec 2023 12:45:23 +0100 Subject: [PATCH 1/5] Remove configuration factory --- .../FunctionDeploymentConfigurationFactory.kt | 32 ------------------- .../FunctionDeploymentConfigurationType.kt | 18 ++++++++--- .../WebAppContainersConfigurationType.kt | 2 +- 3 files changed, 15 insertions(+), 37 deletions(-) delete mode 100644 PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentConfigurationFactory.kt diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentConfigurationFactory.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentConfigurationFactory.kt deleted file mode 100644 index 417860c345..0000000000 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentConfigurationFactory.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2018-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the MIT license. - */ - -package com.microsoft.azure.toolkit.intellij.legacy.function.runner.deploy - -import com.intellij.execution.configurations.ConfigurationFactory -import com.intellij.execution.configurations.ConfigurationType -import com.intellij.execution.configurations.RunConfiguration -import com.intellij.openapi.project.Project -import com.microsoft.azure.toolkit.ide.common.icon.AzureIcons -import com.microsoft.azure.toolkit.intellij.common.IntelliJAzureIcons -import javax.swing.Icon - -class FunctionDeploymentConfigurationFactory(type: ConfigurationType) : ConfigurationFactory(type) { - companion object { - private const val FACTORY_ID = "Azure - Deploy Function" - private const val FACTORY_NAME = "Deploy Function" - } - - override fun getId() = FACTORY_ID - - override fun getIcon(): Icon = IntelliJAzureIcons.getIcon(AzureIcons.FunctionApp.DEPLOY) - - override fun getName() = FACTORY_NAME - - override fun createTemplateConfiguration(project: Project) = - FunctionDeploymentConfiguration(project, this, project.name) - - override fun createConfiguration(name: String?, template: RunConfiguration) = - FunctionDeploymentConfiguration(template.project, this, name) -} \ No newline at end of file diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentConfigurationType.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentConfigurationType.kt index 46353c5b3b..c7240031a5 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentConfigurationType.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentConfigurationType.kt @@ -4,17 +4,27 @@ package com.microsoft.azure.toolkit.intellij.legacy.function.runner.deploy -import com.intellij.execution.configurations.ConfigurationTypeBase +import com.intellij.execution.configurations.ConfigurationTypeUtil +import com.intellij.execution.configurations.RunConfiguration +import com.intellij.execution.configurations.SimpleConfigurationType +import com.intellij.openapi.project.Project +import com.intellij.openapi.util.NotNullLazyValue import com.microsoft.azure.toolkit.ide.common.icon.AzureIcons import com.microsoft.azure.toolkit.intellij.common.IntelliJAzureIcons -class FunctionDeploymentConfigurationType : ConfigurationTypeBase( +class FunctionDeploymentConfigurationType : SimpleConfigurationType( "AzureFunctionAppPublish", "Azure - Function App", "Azure Publish Function App configuration", - IntelliJAzureIcons.getIcon(AzureIcons.FunctionApp.DEPLOY) + NotNullLazyValue.createValue { IntelliJAzureIcons.getIcon(AzureIcons.FunctionApp.DEPLOY) } ) { init { - addFactory(FunctionDeploymentConfigurationFactory(this)) + fun getInstance() = ConfigurationTypeUtil.findConfigurationType(FunctionDeploymentConfigurationType::class.java) } + + override fun createTemplateConfiguration(project: Project) = + FunctionDeploymentConfiguration(project, this, project.name) + + override fun createConfiguration(name: String?, template: RunConfiguration) = + FunctionDeploymentConfiguration(template.project, this, name) } \ No newline at end of file diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappcontainers/WebAppContainersConfigurationType.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappcontainers/WebAppContainersConfigurationType.kt index 81e82f4233..79f6c02422 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappcontainers/WebAppContainersConfigurationType.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappcontainers/WebAppContainersConfigurationType.kt @@ -18,7 +18,7 @@ class WebAppContainersConfigurationType : SimpleConfigurationType( "AzureWebAppContainersPublish", "Azure - Web App for Containers", "Azure Publish Web App for Containers configuration", - NotNullLazyValue.createValue {IntelliJAzureIcons.getIcon(AzureIcons.WebApp.MODULE) } + NotNullLazyValue.createValue { IntelliJAzureIcons.getIcon(AzureIcons.WebApp.MODULE) } ) { companion object { fun getInstance() = ConfigurationTypeUtil.findConfigurationType(WebAppContainersConfigurationType::class.java) From 572759a7be0809fa86a87f7c6ea22c01ea860680 Mon Sep 17 00:00:00 2001 From: Rival Abdrakhmanov Date: Wed, 20 Dec 2023 12:57:06 +0100 Subject: [PATCH 2/5] Formatting --- .../deploy/DotNetFunctionDeployModel.kt | 2 +- .../deploy/FunctionDeploymentConfiguration.kt | 8 +- .../FunctionDeploymentConfigurationType.kt | 2 +- .../legacy/webapp/WebAppCreationDialog.kt | 10 ++- .../webapp/runner/WebAppArtifactService.kt | 84 ++++++++++--------- .../PublishableProjectModelExtensions.kt | 2 +- .../webappconfig/WebAppConfiguration.kt | 2 +- .../WebAppDeployConfigurationPanel.kt | 6 +- .../webappconfig/WebAppSettingEditor.kt | 3 +- .../DockerPushConfiguration.kt | 15 ---- 10 files changed, 67 insertions(+), 67 deletions(-) delete mode 100644 PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappcontainers/DockerPushConfiguration.kt diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/DotNetFunctionDeployModel.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/DotNetFunctionDeployModel.kt index 25c35d2188..a6d40e3a1d 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/DotNetFunctionDeployModel.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/DotNetFunctionDeployModel.kt @@ -6,7 +6,7 @@ package com.microsoft.azure.toolkit.intellij.legacy.function.runner.deploy import com.jetbrains.rider.model.PublishableProjectModel -class DotNetFunctionDeployModel: FunctionDeployModel() { +class DotNetFunctionDeployModel : FunctionDeployModel() { var publishableProject: PublishableProjectModel? = null var projectConfiguration: String = "" var projectPlatform: String = "" diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentConfiguration.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentConfiguration.kt index 2ffc4a0dda..33d2bd64d9 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentConfiguration.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentConfiguration.kt @@ -52,7 +52,7 @@ class FunctionDeploymentConfiguration(private val project: Project, factory: Con functionDeploymentModel.publishableProject = projectModel } - fun getConfig(): FunctionAppConfig? = functionDeploymentModel.functionAppConfig + fun getConfig(): FunctionAppConfig? = functionDeploymentModel.functionAppConfig fun saveConfig(config: FunctionAppConfig) { functionDeploymentModel.functionAppConfig = config @@ -64,9 +64,11 @@ class FunctionDeploymentConfiguration(private val project: Project, factory: Con override fun checkConfiguration() { checkAzurePreconditions() val functionAppConfig = functionDeploymentModel.functionAppConfig - if (functionAppConfig.resourceId.isNullOrEmpty() && functionAppConfig.name.isNullOrEmpty()) throw ConfigurationException("Please specify target function") + if (functionAppConfig.resourceId.isNullOrEmpty() && functionAppConfig.name.isNullOrEmpty()) throw ConfigurationException( + "Please specify target function" + ) if (functionAppConfig.runtime.operatingSystem == OperatingSystem.DOCKER) throw ConfigurationException("Invalid target, docker function is currently not supported") - if (functionAppConfig.servicePlan == null) throw ConfigurationException("Meta-data of target function app is still loading...") + if (functionAppConfig.servicePlan == null) throw ConfigurationException("Meta-data of target function app is still loading...") } override fun getState(executor: Executor, environment: ExecutionEnvironment) = diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentConfigurationType.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentConfigurationType.kt index c7240031a5..fcb57e0800 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentConfigurationType.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentConfigurationType.kt @@ -16,7 +16,7 @@ class FunctionDeploymentConfigurationType : SimpleConfigurationType( "AzureFunctionAppPublish", "Azure - Function App", "Azure Publish Function App configuration", - NotNullLazyValue.createValue { IntelliJAzureIcons.getIcon(AzureIcons.FunctionApp.DEPLOY) } + NotNullLazyValue.createValue { IntelliJAzureIcons.getIcon(AzureIcons.FunctionApp.MODULE) } ) { init { fun getInstance() = ConfigurationTypeUtil.findConfigurationType(FunctionDeploymentConfigurationType::class.java) diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/WebAppCreationDialog.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/WebAppCreationDialog.kt index f4d4943288..e899fc37fe 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/WebAppCreationDialog.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/WebAppCreationDialog.kt @@ -31,10 +31,16 @@ open class WebAppCreationDialog(project: Project) : ConfigDialog(p val selectedSubscriptions = Azure.az(AzureAccount::class.java).account().selectedSubscriptions if (selectedSubscriptions.isEmpty()) { this.close() - throw AzureToolkitRuntimeException("There are no subscriptions selected in your account.", IAccountActions.SELECT_SUBS) + throw AzureToolkitRuntimeException( + "There are no subscriptions selected in your account.", + IAccountActions.SELECT_SUBS + ) } - basicPanel = AppServiceInfoBasicPanel(project, selectedSubscriptions[0]) { WebAppConfig.getWebAppDefaultConfig(project.name) } + basicPanel = AppServiceInfoBasicPanel( + project, + selectedSubscriptions[0] + ) { WebAppConfig.getWebAppDefaultConfig(project.name) } advancedPanel = AppServiceInfoAdvancedPanel(project) { WebAppConfig.getWebAppDefaultConfig(project.name) } panel = panel { diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/WebAppArtifactService.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/WebAppArtifactService.kt index c03c30a57f..067f737ece 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/WebAppArtifactService.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/WebAppArtifactService.kt @@ -36,10 +36,10 @@ class WebAppArtifactService(private val project: Project) { } fun prepareArtifact( - publishableProject: PublishableProjectModel, - configuration: String, - platform: String, - processHandler: RunProcessHandler + publishableProject: PublishableProjectModel, + configuration: String, + platform: String, + processHandler: RunProcessHandler ): File { processHandler.setText("Collecting ${publishableProject.projectName} project artifacts...") if (configuration.isNotEmpty() && platform.isNotEmpty()) { @@ -63,23 +63,28 @@ class WebAppArtifactService(private val project: Project) { * @return [File] to project content to be published */ private fun collectProjectArtifacts( - publishableProject: PublishableProjectModel, - configuration: String?, - platform: String? + publishableProject: PublishableProjectModel, + configuration: String?, + platform: String? ): File { val publishService = MsBuildPublishingService.getInstance(project) val (tempDirMsBuildProperty, outPath) = publishService.getPublishToTempDirParameterAndPath() val extraProperties = mutableListOf() - if (!configuration.isNullOrEmpty()) extraProperties.add(CustomTargetExtraProperty("Configuration", configuration)) + if (!configuration.isNullOrEmpty()) extraProperties.add( + CustomTargetExtraProperty( + "Configuration", + configuration + ) + ) if (!platform.isNullOrEmpty()) extraProperties.add(CustomTargetExtraProperty("Platform", platform)) val buildStatus = - if (publishableProject.isDotNetCore) { - invokeMsBuild(publishableProject, listOf(tempDirMsBuildProperty) + extraProperties, false, true, true) - } else { - webPublishToFileSystem(publishableProject.projectFilePath, outPath, extraProperties, false, true) - } + if (publishableProject.isDotNetCore) { + invokeMsBuild(publishableProject, listOf(tempDirMsBuildProperty) + extraProperties, false, true, true) + } else { + webPublishToFileSystem(publishableProject.projectFilePath, outPath, extraProperties, false, true) + } val buildResult = buildStatus.buildResultKind if (buildResult != BuildResultKind.Successful && buildResult != BuildResultKind.HasWarnings) { @@ -94,36 +99,37 @@ class WebAppArtifactService(private val project: Project) { } private fun invokeMsBuild( - projectModel: PublishableProjectModel, - extraProperties: List, - diagnosticsMode: Boolean, - silentMode: Boolean = false, - noRestore: Boolean = false + projectModel: PublishableProjectModel, + extraProperties: List, + diagnosticsMode: Boolean, + silentMode: Boolean = false, + noRestore: Boolean = false ): BuildStatus { val buildParameters = BuildParameters( - CustomTargetWithExtraProperties( - "Publish", - extraProperties - ), listOf(projectModel.projectFilePath), diagnosticsMode, silentMode, noRestore = noRestore + CustomTargetWithExtraProperties( + "Publish", + extraProperties + ), listOf(projectModel.projectFilePath), diagnosticsMode, silentMode, noRestore = noRestore ) return BuildTaskThrottler.getInstance(project).buildSequentiallySync(buildParameters) } private fun webPublishToFileSystem( - pathToProject: String, - outPath: Path, - extraProperties: List, - diagnosticsMode: Boolean = false, - silentMode: Boolean = false + pathToProject: String, + outPath: Path, + extraProperties: List, + diagnosticsMode: Boolean = false, + silentMode: Boolean = false ): BuildStatus { val buildParameters = BuildParameters( - CustomTargetWithExtraProperties( - "WebPublish", - extraProperties + listOf( - CustomTargetExtraProperty("WebPublishMethod", "FileSystem"), - CustomTargetExtraProperty("PublishUrl", outPath.toString())) - ), listOf(pathToProject), diagnosticsMode, silentMode + CustomTargetWithExtraProperties( + "WebPublish", + extraProperties + listOf( + CustomTargetExtraProperty("WebPublishMethod", "FileSystem"), + CustomTargetExtraProperty("PublishUrl", outPath.toString()) + ) + ), listOf(pathToProject), diagnosticsMode, silentMode ) return BuildTaskThrottler.getInstance(project).buildSequentiallySync(buildParameters) @@ -145,9 +151,9 @@ class WebAppArtifactService(private val project: Project) { } private fun zipProjectArtifacts( - fromFile: File, - processHandler: RunProcessHandler, - deleteOriginal: Boolean = true + fromFile: File, + processHandler: RunProcessHandler, + deleteOriginal: Boolean = true ): File { if (!fromFile.exists()) throw FileNotFoundException("Original file '${fromFile.path}' not found") @@ -170,9 +176,9 @@ class WebAppArtifactService(private val project: Project) { } private fun packToZip( - fileToZip: File, - zipFileToCreate: File, - filter: FileFilter? = null + fileToZip: File, + zipFileToCreate: File, + filter: FileFilter? = null ) { if (!fileToZip.exists()) { val message = "Source file or directory '${fileToZip.path}' does not exist" diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/PublishableProjectModelExtensions.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/PublishableProjectModelExtensions.kt index 74dd5ecd21..a8efc55226 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/PublishableProjectModelExtensions.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/PublishableProjectModelExtensions.kt @@ -36,7 +36,7 @@ fun PublishableProjectModel.getStackAndVersion( } else { val version = if (dotnetVersion != null) NetFrameworkVersion.fromString("v$dotnetVersion") - else NetFrameworkVersion.fromString("v8.0") + else NetFrameworkVersion.fromString("v8.0") return null to version } diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppConfiguration.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppConfiguration.kt index 26e081539d..6d04daa5b5 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppConfiguration.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppConfiguration.kt @@ -121,7 +121,7 @@ class WebAppConfiguration(private val project: Project, factory: ConfigurationFa set(value) { webAppPublishModel.saveRuntime(value) } - var operatingSystem : OperatingSystem + var operatingSystem: OperatingSystem get() = OperatingSystem.fromString(webAppPublishModel.operatingSystem) set(value) { webAppPublishModel.operatingSystem = value.toString() diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppDeployConfigurationPanel.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppDeployConfigurationPanel.kt index 0c198b7dca..63979c201b 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppDeployConfigurationPanel.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppDeployConfigurationPanel.kt @@ -200,9 +200,9 @@ class WebAppDeployConfigurationPanel(private val project: Project) : AzureFormPa currentAppSettingKeys.clear() if (selectedWebApp.resourceId.isNullOrEmpty()) { selectedWebApp.appSettings - } - else { - val currentSettings = Azure.az(AzureWebApp::class.java).webApp(selectedWebApp.resourceId)?.appSettings + } else { + val currentSettings = + Azure.az(AzureWebApp::class.java).webApp(selectedWebApp.resourceId)?.appSettings if (currentSettings != null) { currentAppSettingKeys.addAll(currentSettings.keys) } diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppSettingEditor.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppSettingEditor.kt index c0fd016745..2750115015 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppSettingEditor.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppSettingEditor.kt @@ -8,7 +8,8 @@ import com.intellij.openapi.project.Project import com.microsoft.azure.toolkit.intellij.legacy.common.RiderAzureSettingsEditor class WebAppSettingEditor(project: Project, configuration: WebAppConfiguration) : - RiderAzureSettingsEditor() { + RiderAzureSettingsEditor() { + private val panel = WebAppSettingPanel(project, configuration) override fun getPanel() = panel } \ No newline at end of file diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappcontainers/DockerPushConfiguration.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappcontainers/DockerPushConfiguration.kt deleted file mode 100644 index d83c05a449..0000000000 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappcontainers/DockerPushConfiguration.kt +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright 2018-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the MIT license. - */ - -package com.microsoft.azure.toolkit.intellij.legacy.webapp.runner.webappcontainers - -import com.microsoft.azure.toolkit.intellij.common.DockerImageModel - -data class DockerPushConfiguration( - val registryAddress: String?, - val repositoryName: String?, - val tagName: String?, - val dockerImage: DockerImageModel?, - val dockerServer: String? -) \ No newline at end of file From 64c343e77b37ba0890e0e9cfe6ee0483fe83e674 Mon Sep 17 00:00:00 2001 From: Rival Abdrakhmanov Date: Wed, 20 Dec 2023 14:54:06 +0100 Subject: [PATCH 3/5] Define appSettingsToRemove in Task --- .../webapp/CreateOrUpdateDotNetWebAppTask.kt | 16 +++++++++------- .../runner/webappconfig/WebAppConfiguration.kt | 5 ----- .../WebAppDeployConfigurationPanel.kt | 16 +--------------- .../webapp/runner/webappconfig/WebAppRunState.kt | 2 -- .../runner/webappconfig/WebAppSettingPanel.kt | 2 -- 5 files changed, 10 insertions(+), 31 deletions(-) diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/appservice/webapp/CreateOrUpdateDotNetWebAppTask.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/appservice/webapp/CreateOrUpdateDotNetWebAppTask.kt index d15a6182a4..a2e269ca28 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/appservice/webapp/CreateOrUpdateDotNetWebAppTask.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/appservice/webapp/CreateOrUpdateDotNetWebAppTask.kt @@ -52,9 +52,8 @@ class CreateOrUpdateDotNetWebAppTask(private val config: DotNetAppServiceConfig) val slotDraft = target.slots() .updateOrCreate(config.deploymentSlotName(), config.resourceGroup()) .toDotNetWebAppDeploymentSlotDraft() - val slotExists = slotDraft.exists() - return if (slotExists) updateDeploymentSlot(slotDraft) + return if (slotDraft.exists()) updateDeploymentSlot(slotDraft) else createDeploymentSlot(slotDraft) } } @@ -77,8 +76,8 @@ class CreateOrUpdateDotNetWebAppTask(private val config: DotNetAppServiceConfig) appDraft.dotNetRuntime = getRuntime(config.dotnetRuntime) appDraft.dockerConfiguration = getDockerConfiguration(config.dotnetRuntime) appDraft.diagnosticConfig = config.diagnosticConfig() + appDraft.appSettingsToRemove = emptySet() appDraft.appSettings = config.appSettings() - appDraft.appSettingsToRemove = config.appSettingsToRemove() return appDraft.createIfNotExist() } @@ -96,8 +95,8 @@ class CreateOrUpdateDotNetWebAppTask(private val config: DotNetAppServiceConfig) appDraft.dotNetRuntime = getRuntime(config.dotnetRuntime) appDraft.dockerConfiguration = getDockerConfiguration(config.dotnetRuntime) appDraft.diagnosticConfig = config.diagnosticConfig() + appDraft.appSettingsToRemove = getAppSettingsToRemove(webApp.appSettings ?: emptyMap(), config.appSettings()) appDraft.appSettings = config.appSettings() - appDraft.appSettingsToRemove = config.appSettingsToRemove() val result = appDraft.updateIfExist() ?: throw AzureToolkitRuntimeException("Unable to update Web App") @@ -114,7 +113,7 @@ class CreateOrUpdateDotNetWebAppTask(private val config: DotNetAppServiceConfig) return draft } - private fun WebAppDeploymentSlotDraft.toDotNetWebAppDeploymentSlotDraft(): DotNetWebAppDeploymentSlotDraft{ + private fun WebAppDeploymentSlotDraft.toDotNetWebAppDeploymentSlotDraft(): DotNetWebAppDeploymentSlotDraft { val draftOrigin = origin val draft = if (draftOrigin != null) DotNetWebAppDeploymentSlotDraft(draftOrigin) @@ -128,8 +127,8 @@ class CreateOrUpdateDotNetWebAppTask(private val config: DotNetAppServiceConfig) draft.dockerConfiguration = getDockerConfiguration(config.dotnetRuntime) draft.diagnosticConfig = config.diagnosticConfig() draft.configurationSource = config.deploymentSlotConfigurationSource() + draft.appSettingsToRemove = emptySet() draft.appSettings = config.appSettings() - draft.appSettingsToRemove = config.appSettingsToRemove() return draft.commit() } @@ -138,8 +137,8 @@ class CreateOrUpdateDotNetWebAppTask(private val config: DotNetAppServiceConfig) draft.dotNetRuntime = getRuntime(config.dotnetRuntime) draft.dockerConfiguration = getDockerConfiguration(config.dotnetRuntime) draft.diagnosticConfig = config.diagnosticConfig() + draft.appSettingsToRemove = getAppSettingsToRemove(draft.appSettings ?: emptyMap(), config.appSettings()) draft.appSettings = config.appSettings() - draft.appSettingsToRemove = config.appSettingsToRemove() return draft.commit() } @@ -178,6 +177,9 @@ class CreateOrUpdateDotNetWebAppTask(private val config: DotNetAppServiceConfig) private fun isDeployToDeploymentSlot() = !config.deploymentSlotName().isNullOrEmpty() + private fun getAppSettingsToRemove(targetSettings: Map, newSettings: Map) = + targetSettings.keys.filter { !newSettings.containsKey(it) }.toSet() + override fun doExecute(): WebAppBase<*, *, *> { var result: Any? = null for (task in subTasks) { diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppConfiguration.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppConfiguration.kt index 6d04daa5b5..f14a3327a9 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppConfiguration.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppConfiguration.kt @@ -111,11 +111,6 @@ class WebAppConfiguration(private val project: Project, factory: ConfigurationFa set(value) { webAppPublishModel.appSettingsKey = value } - var appSettingsToRemove: Set - get() = webAppPublishModel.appSettingsToRemove - set(value) { - webAppPublishModel.appSettingsToRemove = value - } var runtime: Runtime? get() = webAppPublishModel.runtime set(value) { diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppDeployConfigurationPanel.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppDeployConfigurationPanel.kt index 63979c201b..15ca615d6a 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppDeployConfigurationPanel.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppDeployConfigurationPanel.kt @@ -51,8 +51,6 @@ class WebAppDeployConfigurationPanel(private val project: Project) : AzureFormPa private val formatter = DateTimeFormatter.ofPattern("yyMMddHHmmss") - private val currentAppSettingKeys = mutableListOf() - val panel: JPanel private lateinit var webAppComboBox: Cell @@ -197,16 +195,10 @@ class WebAppDeployConfigurationPanel(private val project: Project) : AzureFormPa } } else if (selectedWebApp != before) { appSettingsTable.loadAppSettings { - currentAppSettingKeys.clear() if (selectedWebApp.resourceId.isNullOrEmpty()) { selectedWebApp.appSettings } else { - val currentSettings = - Azure.az(AzureWebApp::class.java).webApp(selectedWebApp.resourceId)?.appSettings - if (currentSettings != null) { - currentAppSettingKeys.addAll(currentSettings.keys) - } - currentSettings + Azure.az(AzureWebApp::class.java).webApp(selectedWebApp.resourceId)?.appSettings } } } @@ -293,15 +285,9 @@ class WebAppDeployConfigurationPanel(private val project: Project) : AzureFormPa if (webAppComboBox.component.value?.appSettings?.containsKey(RIDER_PROJECT_PLATFORM) == true) webAppComboBox.component.value?.appSettings?.remove(RIDER_PROJECT_PLATFORM) - val appSettings = appSettingsTable.appSettings - val settingsToRemove = currentAppSettingKeys - .filter { !appSettings.containsKey(it) } - .toSet() - val webAppConfig = webAppComboBox.component.value ?.toBuilder() ?.appSettings(appSettingsTable.appSettings) - ?.appSettingsToRemove(settingsToRemove) ?.deploymentSlot(slotConfig) ?.build() diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppRunState.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppRunState.kt index c4b2a08632..d194b040df 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppRunState.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppRunState.kt @@ -77,7 +77,6 @@ class WebAppRunState(project: Project, private val webAppConfiguration: WebAppCo runtime(createRuntimeConfig()) dotnetRuntime = createDotNetRuntimeConfig(publishableProject) appSettings(webAppConfiguration.applicationSettings) - appSettingsToRemove(webAppConfiguration.appSettingsToRemove) val slotName = if (webAppConfiguration.isDeployToSlot) webAppConfiguration.newSlotName ?: webAppConfiguration.slotName else null @@ -130,7 +129,6 @@ class WebAppRunState(project: Project, private val webAppConfiguration: WebAppCo webAppId = app.id } applicationSettings = app.appSettings ?: emptyMap() - appSettingsToRemove = emptySet() webAppName = app.name resourceGroup = app.resourceGroupName appServicePlanName = app.getAppServicePlan()?.name diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppSettingPanel.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppSettingPanel.kt index 47aae8d031..596d0aba96 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppSettingPanel.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppSettingPanel.kt @@ -56,7 +56,6 @@ class WebAppSettingPanel(private val project: Project, configuration: WebAppConf configuration.webAppName = it.name configuration.runtime = it.runtime configuration.applicationSettings = it.appSettings - configuration.appSettingsToRemove = it.appSettingsToRemove configuration.isCreatingNew = it.resourceId.isNullOrEmpty() if (configuration.isCreatingNew) { @@ -142,7 +141,6 @@ class WebAppSettingPanel(private val project: Project, configuration: WebAppConf .servicePlan(plan) .deploymentSlot(slotConfig) .appSettings(configuration.applicationSettings) - .appSettingsToRemove(configuration.appSettingsToRemove) val webAppConfig = if (configuration.isCreatingNew) configBuilder.region(region).pricingTier(pricingTier).build() else configBuilder.build() From 8a26b1b7fdc8089f98d3adefab86a6ece0e76014 Mon Sep 17 00:00:00 2001 From: Rival Abdrakhmanov Date: Wed, 20 Dec 2023 15:11:50 +0100 Subject: [PATCH 4/5] Refactoring --- .../deploy/FunctionDeploymentSettingsPanel.kt | 40 +++++-------------- .../WebAppDeployConfigurationPanel.kt | 19 ++------- .../runner/webappconfig/WebAppSettingPanel.kt | 3 +- .../PublishConfigurationComboBoxExtensions.kt | 22 ++++++++++ 4 files changed, 37 insertions(+), 47 deletions(-) create mode 100644 PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-lib-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/common/PublishConfigurationComboBoxExtensions.kt diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentSettingsPanel.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentSettingsPanel.kt index cfb53acb61..74126afef2 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentSettingsPanel.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentSettingsPanel.kt @@ -16,10 +16,7 @@ import com.jetbrains.rider.projectView.solution import com.jetbrains.rider.run.configurations.publishing.PublishRuntimeSettingsCoreHelper import com.microsoft.azure.toolkit.ide.appservice.function.FunctionAppConfig import com.microsoft.azure.toolkit.ide.appservice.model.DeploymentSlotConfig -import com.microsoft.azure.toolkit.intellij.common.AzureDotnetProjectComboBox -import com.microsoft.azure.toolkit.intellij.common.AzureFormPanel -import com.microsoft.azure.toolkit.intellij.common.configurationAndPlatformComboBox -import com.microsoft.azure.toolkit.intellij.common.dotnetProjectComboBox +import com.microsoft.azure.toolkit.intellij.common.* import com.microsoft.azure.toolkit.intellij.legacy.appservice.table.AppSettingsTable import com.microsoft.azure.toolkit.intellij.legacy.appservice.table.AppSettingsTableUtils import com.microsoft.azure.toolkit.intellij.legacy.common.RiderAzureSettingPanel @@ -34,12 +31,11 @@ import java.util.* import javax.swing.JPanel class FunctionDeploymentSettingsPanel(private val project: Project, configuration: FunctionDeploymentConfiguration) : - RiderAzureSettingPanel(), AzureFormPanel { + RiderAzureSettingPanel() { + private val panel: JPanel private var appSettingsKey: String = configuration.appSettingsKey ?: UUID.randomUUID().toString() - private var appSettingsResourceId: String? = null - private lateinit var functionAppComboBox: Cell private lateinit var deployToSlotCheckBox: Cell private lateinit var deploymentSlotComboBox: Cell @@ -162,8 +158,9 @@ class FunctionDeploymentSettingsPanel(private val project: Project, configuratio configuration.appSettingsKey = appSettingsKey configuration.setAppSettings(appSettingsTable.appSettings) dotnetProjectComboBox.component.value?.let { configuration.saveProject(it) } - configuration.projectConfiguration = getSelectedConfiguration() - configuration.projectPlatform = getSelectedPlatform() + val (projectConfiguration, projectPlatform) = configurationAndPlatformComboBox.component.component.getPublishConfiguration() + configuration.projectConfiguration = projectConfiguration + configuration.projectPlatform = projectPlatform val functionConfig = functionAppComboBox.component.value val isDeploymentSlotSelected = deployToSlotCheckBox.component.isSelected val deploymentSlotConfig = deploymentSlotComboBox.component.value @@ -201,31 +198,14 @@ class FunctionDeploymentSettingsPanel(private val project: Project, configuratio .firstOrNull { p -> p.projectModelId == projectId } ?.let { p -> dotnetProjectComboBox.component.setProject(p) } } - setConfigurationAndPlatform(configuration.projectConfiguration, configuration.projectPlatform) + configurationAndPlatformComboBox.component.component.setPublishConfiguration( + configuration.projectConfiguration, + configuration.projectPlatform + ) } override fun getMainPanel() = panel override fun disposeEditor() { } - - override fun setValue(data: FunctionDeploymentConfiguration) = reset(data) - - override fun getInputs() = - listOf(functionAppComboBox.component, deploymentSlotComboBox.component, dotnetProjectComboBox.component) - - private fun getSelectedConfiguration() = getSelectedConfigurationAndPlatform()?.configuration ?: "" - private fun getSelectedPlatform() = getSelectedConfigurationAndPlatform()?.platform ?: "" - private fun getSelectedConfigurationAndPlatform(): PublishRuntimeSettingsCoreHelper.ConfigurationAndPlatform? = - configurationAndPlatformComboBox.component.component.selectedItem as? PublishRuntimeSettingsCoreHelper.ConfigurationAndPlatform - - fun setConfigurationAndPlatform(configuration: String, platform: String) { - for (i in 0 until configurationAndPlatformComboBox.component.component.model.size) { - val item = configurationAndPlatformComboBox.component.component.model.getElementAt(i) - if (item?.configuration == configuration && item.platform == platform) { - configurationAndPlatformComboBox.component.component.selectedItem = item - break - } - } - } } \ No newline at end of file diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppDeployConfigurationPanel.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppDeployConfigurationPanel.kt index 15ca615d6a..2db32c80ca 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppDeployConfigurationPanel.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppDeployConfigurationPanel.kt @@ -21,11 +21,8 @@ import com.microsoft.azure.toolkit.ide.appservice.model.AzureArtifactConfig import com.microsoft.azure.toolkit.ide.appservice.model.DeploymentSlotConfig import com.microsoft.azure.toolkit.ide.appservice.webapp.model.WebAppConfig import com.microsoft.azure.toolkit.ide.appservice.webapp.model.WebAppDeployRunConfigurationModel -import com.microsoft.azure.toolkit.intellij.common.AzureDotnetProjectComboBox -import com.microsoft.azure.toolkit.intellij.common.AzureFormPanel +import com.microsoft.azure.toolkit.intellij.common.* import com.microsoft.azure.toolkit.intellij.common.component.UIUtils -import com.microsoft.azure.toolkit.intellij.common.configurationAndPlatformComboBox -import com.microsoft.azure.toolkit.intellij.common.dotnetProjectComboBox import com.microsoft.azure.toolkit.intellij.legacy.appservice.table.AppSettingsTable import com.microsoft.azure.toolkit.intellij.legacy.appservice.table.AppSettingsTableUtils import com.microsoft.azure.toolkit.intellij.legacy.webapp.WebAppCreationDialog.Companion.RIDER_PROJECT_CONFIGURATION @@ -247,13 +244,7 @@ class WebAppDeployConfigurationPanel(private val project: Project) : AzureFormPa } fun setConfigurationAndPlatform(configuration: String, platform: String) { - for (i in 0 until configurationAndPlatformComboBox.component.component.model.size) { - val item = configurationAndPlatformComboBox.component.component.model.getElementAt(i) - if (item?.configuration == configuration && item.platform == platform) { - configurationAndPlatformComboBox.component.component.selectedItem = item - break - } - } + configurationAndPlatformComboBox.component.component.setPublishConfiguration(configuration, platform) } override fun getValue(): WebAppDeployRunConfigurationModel { @@ -300,10 +291,8 @@ class WebAppDeployConfigurationPanel(private val project: Project) : AzureFormPa .build() } - fun getSelectedConfiguration() = getSelectedConfigurationAndPlatform()?.configuration ?: "" - fun getSelectedPlatform() = getSelectedConfigurationAndPlatform()?.platform ?: "" - private fun getSelectedConfigurationAndPlatform(): PublishRuntimeSettingsCoreHelper.ConfigurationAndPlatform? = - configurationAndPlatformComboBox.component.component.selectedItem as? PublishRuntimeSettingsCoreHelper.ConfigurationAndPlatform + fun getConfigurationAndPlatform(): Pair = + configurationAndPlatformComboBox.component.component.getPublishConfiguration() override fun getInputs() = listOf(webAppComboBox.component, dotnetProjectComboBox.component) diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppSettingPanel.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppSettingPanel.kt index 596d0aba96..3cc2ede2e7 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppSettingPanel.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webappconfig/WebAppSettingPanel.kt @@ -40,8 +40,7 @@ class WebAppSettingPanel(private val project: Project, configuration: WebAppConf override fun apply(configuration: WebAppConfiguration) { val runConfigurationModel = webAppPanel.value - val projectConfiguration = webAppPanel.getSelectedConfiguration() - val projectPlatform = webAppPanel.getSelectedPlatform() + val (projectConfiguration, projectPlatform) = webAppPanel.getConfigurationAndPlatform() val publishableProject = runConfigurationModel.artifactConfig?.let { val artifactId = it.artifactIdentifier.toIntOrNull() ?: return@let null project.solution.publishableProjectsModel.publishableProjects.values diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-lib-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/common/PublishConfigurationComboBoxExtensions.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-lib-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/common/PublishConfigurationComboBoxExtensions.kt new file mode 100644 index 0000000000..d616086a72 --- /dev/null +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-lib-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/common/PublishConfigurationComboBoxExtensions.kt @@ -0,0 +1,22 @@ +package com.microsoft.azure.toolkit.intellij.common + +import com.intellij.openapi.ui.ComboBox +import com.jetbrains.rider.run.configurations.publishing.PublishRuntimeSettingsCoreHelper + +fun ComboBox.setPublishConfiguration( + configuration: String, + platform: String +) { + for (i in 0 until model.size) { + val item = model.getElementAt(i) + if (item?.configuration == configuration && item.platform == platform) { + selectedItem = item + break + } + } +} + +fun ComboBox.getPublishConfiguration(): Pair { + val item = selectedItem as? PublishRuntimeSettingsCoreHelper.ConfigurationAndPlatform + return (item?.configuration ?: "") to (item?.platform ?: "") +} \ No newline at end of file From ebd66fef3dd9bdbe35794b6ecbc4db3889749c19 Mon Sep 17 00:00:00 2001 From: Rival Abdrakhmanov Date: Thu, 28 Dec 2023 17:18:05 +0100 Subject: [PATCH 5/5] Publish function app --- .../azure-toolkit-for-rider/.idea/misc.xml | 2 +- .../appservice/{webapp => }/DotNetRuntime.kt | 4 +- .../{webapp => }/DotNetRuntimeConfig.kt | 4 +- .../{webapp => }/DotNetRuntimeExtensions.kt | 7 +- .../CreateOrUpdateDotNetFunctionAppTask.kt | 269 ++++++++++++++ .../functionapp/DotNetFunctionAppConfig.kt | 12 + .../DotNetFunctionAppDeploymentSlotDraft.kt | 299 ++++++++++++++++ .../functionapp/DotNetFunctionAppDraft.kt | 327 ++++++++++++++++++ .../webapp/CreateOrUpdateDotNetWebAppTask.kt | 8 +- .../webapp/DotNetAppServiceConfig.kt | 1 + .../webapp/DotNetWebAppDeploymentSlotDraft.kt | 27 +- .../appservice/webapp/DotNetWebAppDraft.kt | 20 +- ...pArtifactService.kt => ArtifactService.kt} | 14 +- .../PublishableProjectModelExtensions.kt | 32 +- .../appservice/AppServiceInfoAdvancedPanel.kt | 4 +- .../appservice/AppServiceInfoBasicPanel.kt | 4 +- .../FunctionCoreToolsMsBuildService.kt | 2 +- .../deploy/FunctionDeploymentConfiguration.kt | 94 +++-- .../deploy/FunctionDeploymentSettingsPanel.kt | 63 ++-- .../runner/deploy/FunctionDeploymentState.kt | 79 ++++- ...DeployModel.kt => FunctionPublishModel.kt} | 5 +- .../localsettings/FunctionLocalSettings.kt | 10 +- .../FunctionLocalSettingsUtil.kt | 17 +- .../webapp/action/CreateWebAppAction.kt | 10 +- .../WebAppDeployConfigurationPanel.kt | 1 + .../runner/webappconfig/WebAppPublishModel.kt | 1 - .../runner/webappconfig/WebAppRunState.kt | 17 +- .../WebAppContainersRunState.kt | 2 +- 28 files changed, 1204 insertions(+), 131 deletions(-) rename PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/appservice/{webapp => }/DotNetRuntime.kt (74%) rename PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/appservice/{webapp => }/DotNetRuntimeConfig.kt (73%) rename PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/appservice/{webapp => }/DotNetRuntimeExtensions.kt (87%) create mode 100644 PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/appservice/functionapp/CreateOrUpdateDotNetFunctionAppTask.kt create mode 100644 PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/appservice/functionapp/DotNetFunctionAppConfig.kt create mode 100644 PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/appservice/functionapp/DotNetFunctionAppDeploymentSlotDraft.kt create mode 100644 PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/appservice/functionapp/DotNetFunctionAppDraft.kt rename PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/{webapp/runner/WebAppArtifactService.kt => ArtifactService.kt} (94%) rename PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/{webapp/runner/webappconfig => }/PublishableProjectModelExtensions.kt (68%) rename PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/{DotNetFunctionDeployModel.kt => FunctionPublishModel.kt} (61%) diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/.idea/misc.xml b/PluginsAndFeatures/azure-toolkit-for-rider/.idea/misc.xml index f3cfb80af4..96aa33fce9 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/.idea/misc.xml +++ b/PluginsAndFeatures/azure-toolkit-for-rider/.idea/misc.xml @@ -19,7 +19,7 @@