From 4a3e630fcbae7849495fccd5e5e8d37225d042ed Mon Sep 17 00:00:00 2001 From: Rival Abdrakhmanov Date: Mon, 12 Aug 2024 13:54:53 +0200 Subject: [PATCH] Disable linux target for NetFramework apps --- .../appservice/AppServiceInfoAdvancedPanel.kt | 4 +++- .../legacy/appservice/AppServiceInfoBasicPanel.kt | 2 ++ .../function/runner/deploy/FunctionAppComboBox.kt | 4 +++- .../runner/deploy/FunctionAppCreationDialog.kt | 9 ++++++--- .../runner/deploy/FunctionAppInfoAdvancedPanel.kt | 3 ++- .../deploy/FunctionDeploymentSettingsEditor.kt | 14 ++++++++++++-- .../legacy/webapp/runner/webApp/WebAppComboBox.kt | 4 +++- .../webapp/runner/webApp/WebAppCreationDialog.kt | 9 ++++++--- .../webapp/runner/webApp/WebAppSettingEditor.kt | 13 +++++++++++-- 9 files changed, 48 insertions(+), 14 deletions(-) diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/appservice/AppServiceInfoAdvancedPanel.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/appservice/AppServiceInfoAdvancedPanel.kt index 7f50cf5f6da..accb1e38d22 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/appservice/AppServiceInfoAdvancedPanel.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/appservice/AppServiceInfoAdvancedPanel.kt @@ -37,6 +37,7 @@ import javax.swing.JPanel open class AppServiceInfoAdvancedPanel( private val projectName: String, + targetProjectOnNetFramework: Boolean = false, private val defaultConfigSupplier: Supplier ) : JPanel(), Disposable, AzureFormPanel where T : AppServiceConfig { companion object { @@ -104,8 +105,9 @@ open class AppServiceInfoAdvancedPanel( operatingSystemGroup = buttonsGroup { row("Operating System:") { windowsRadioButton = radioButton("Windows", OperatingSystem.WINDOWS) - linuxRadioButton = radioButton("Linux", OperatingSystem.LINUX) windowsRadioButton.component.addItemListener { onOperatingSystemChanged(it) } + linuxRadioButton = radioButton("Linux", OperatingSystem.LINUX) + .enabled(!targetProjectOnNetFramework) dockerRadioButton = radioButton("Docker", OperatingSystem.DOCKER) .visible(false) } diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/appservice/AppServiceInfoBasicPanel.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/appservice/AppServiceInfoBasicPanel.kt index 491bf655bf7..27c6c03d657 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/appservice/AppServiceInfoBasicPanel.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/appservice/AppServiceInfoBasicPanel.kt @@ -23,6 +23,7 @@ import java.util.function.Supplier import javax.swing.JPanel class AppServiceInfoBasicPanel( + targetProjectOnNetFramework: Boolean = false, private val defaultConfigSupplier: Supplier ) : JPanel(), Disposable, AzureFormPanel where T : AppServiceConfig { @@ -54,6 +55,7 @@ class AppServiceInfoBasicPanel( row("Operating System:") { windowsRadioButton = radioButton("Windows", OperatingSystem.WINDOWS) linuxRadioButton = radioButton("Linux", OperatingSystem.LINUX) + .enabled(!targetProjectOnNetFramework) dockerRadioButton = radioButton("Docker", OperatingSystem.DOCKER) .visible(false) } 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/FunctionAppComboBox.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionAppComboBox.kt index af0a81ec75a..c16f20aa3d2 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionAppComboBox.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionAppComboBox.kt @@ -22,6 +22,8 @@ import java.util.function.Supplier import java.util.stream.Collectors class FunctionAppComboBox(project: Project) : AppServiceComboBox(project) { + var targetProjectOnNetFramework: Boolean = false + override fun refreshItems() { Azure.az(AzureFunctions::class.java).refresh() super.refreshItems() @@ -69,7 +71,7 @@ class FunctionAppComboBox(project: Project) : AppServiceComboBox = Action.Id.of("user/function.create_app.app") 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/FunctionAppCreationDialog.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionAppCreationDialog.kt index 78b9f156566..c93bf1c2368 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionAppCreationDialog.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionAppCreationDialog.kt @@ -20,7 +20,10 @@ import com.microsoft.azure.toolkit.lib.auth.IAccountActions import com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException import javax.swing.JPanel -class FunctionAppCreationDialog(project: Project) : ConfigDialog(project), Disposable { +class FunctionAppCreationDialog( + project: Project, + targetProjectOnNetFramework: Boolean +) : ConfigDialog(project), Disposable { private val basicPanel: AppServiceInfoBasicPanel private val advancedPanel: FunctionAppInfoAdvancedPanel private val panel: JPanel @@ -36,12 +39,12 @@ class FunctionAppCreationDialog(project: Project) : ConfigDialog -) : AppServiceInfoAdvancedPanel(projectName, defaultConfigSupplier) { +) : AppServiceInfoAdvancedPanel(projectName, targetProjectOnNetFramework, defaultConfigSupplier) { private lateinit var storageAccountComboBox: Cell 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/FunctionDeploymentSettingsEditor.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentSettingsEditor.kt index e0373a982bb..3aace9377df 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentSettingsEditor.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/FunctionDeploymentSettingsEditor.kt @@ -11,6 +11,7 @@ import com.intellij.openapi.ui.LabeledComponent import com.intellij.openapi.util.Disposer import com.intellij.ui.components.JBCheckBox import com.intellij.ui.dsl.builder.* +import com.jetbrains.rider.model.PublishableProjectModel import com.jetbrains.rider.model.publishableProjectsModel import com.jetbrains.rider.projectView.solution import com.jetbrains.rider.run.configurations.publishing.PublishRuntimeSettingsCoreHelper @@ -70,8 +71,10 @@ class FunctionDeploymentSettingsEditor(private val project: Project) : } } - dotnetProjectComboBox.component.reloadItems() - + dotnetProjectComboBox.component.apply { + reloadItems() + addValueChangedListener(::onSelectProject) + } functionAppComboBox.component.apply { addValueChangedListener(::onSelectFunctionApp) } @@ -80,6 +83,13 @@ class FunctionDeploymentSettingsEditor(private val project: Project) : } } + private fun onSelectProject(value: PublishableProjectModel) { + if (isLoading) return + + val onNetFramework = !value.isDotNetCore || value.projectOutputs.all { it.tfmInMsbuildFormat == "net48" } + functionAppComboBox.component.targetProjectOnNetFramework = onNetFramework + } + private fun onSelectFunctionApp(value: FunctionAppConfig?) { if (isLoading) return diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webApp/WebAppComboBox.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webApp/WebAppComboBox.kt index edd3cda0565..6bf2cd4b068 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webApp/WebAppComboBox.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webApp/WebAppComboBox.kt @@ -21,6 +21,8 @@ import java.util.function.Supplier import java.util.stream.Collectors open class WebAppComboBox(project: Project) : AppServiceComboBox(project) { + var targetProjectOnNetFramework: Boolean = false + override fun refreshItems() { Azure.az(AzureWebApp::class.java).refresh() super.refreshItems() @@ -68,7 +70,7 @@ open class WebAppComboBox(project: Project) : AppServiceComboBox = Action.Id.of("user/webapp.create_app.app") dialog.setOkAction( diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webApp/WebAppCreationDialog.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webApp/WebAppCreationDialog.kt index a5281e813b7..2c81ba3bca8 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webApp/WebAppCreationDialog.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webApp/WebAppCreationDialog.kt @@ -22,7 +22,10 @@ import com.microsoft.azure.toolkit.lib.auth.IAccountActions import com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException import javax.swing.JPanel -class WebAppCreationDialog(project: Project) : ConfigDialog(project), Disposable { +class WebAppCreationDialog( + project: Project, + targetProjectOnNetFramework: Boolean +) : ConfigDialog(project), Disposable { private val basicPanel: AppServiceInfoBasicPanel private val advancedPanel: AppServiceInfoAdvancedPanel private val panel: JPanel @@ -38,12 +41,12 @@ class WebAppCreationDialog(project: Project) : ConfigDialog(pr } val projectName = removeInvalidCharacters(project.name) - basicPanel = AppServiceInfoBasicPanel { + basicPanel = AppServiceInfoBasicPanel(targetProjectOnNetFramework) { WebAppConfigProducer.getInstance().generateDefaultConfig() } Disposer.register(this, basicPanel) - advancedPanel = AppServiceInfoAdvancedPanel(projectName) { + advancedPanel = AppServiceInfoAdvancedPanel(projectName, targetProjectOnNetFramework) { AppServiceConfig() } Disposer.register(this, advancedPanel) diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webApp/WebAppSettingEditor.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webApp/WebAppSettingEditor.kt index 9fc245d0bcf..0439e5a0390 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webApp/WebAppSettingEditor.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/webapp/runner/webApp/WebAppSettingEditor.kt @@ -12,6 +12,7 @@ import com.intellij.openapi.util.Disposer import com.intellij.openapi.util.SystemInfo import com.intellij.ui.components.JBCheckBox import com.intellij.ui.dsl.builder.* +import com.jetbrains.rider.model.PublishableProjectModel import com.jetbrains.rider.model.publishableProjectsModel import com.jetbrains.rider.projectView.solution import com.jetbrains.rider.run.configurations.publishing.PublishRuntimeSettingsCoreHelper @@ -70,8 +71,10 @@ class WebAppSettingEditor(private val project: Project) : SettingsEditor