Skip to content

Commit

Permalink
Disable linux target for NetFramework apps
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelldi committed Aug 12, 2024
1 parent f08f9ea commit 4a3e630
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import javax.swing.JPanel

open class AppServiceInfoAdvancedPanel<T>(
private val projectName: String,
targetProjectOnNetFramework: Boolean = false,
private val defaultConfigSupplier: Supplier<T>
) : JPanel(), Disposable, AzureFormPanel<T> where T : AppServiceConfig {
companion object {
Expand Down Expand Up @@ -104,8 +105,9 @@ open class AppServiceInfoAdvancedPanel<T>(
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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import java.util.function.Supplier
import javax.swing.JPanel

class AppServiceInfoBasicPanel<T>(
targetProjectOnNetFramework: Boolean = false,
private val defaultConfigSupplier: Supplier<T>
) : JPanel(), Disposable, AzureFormPanel<T> where T : AppServiceConfig {

Expand Down Expand Up @@ -54,6 +55,7 @@ class AppServiceInfoBasicPanel<T>(
row("Operating System:") {
windowsRadioButton = radioButton("Windows", OperatingSystem.WINDOWS)
linuxRadioButton = radioButton("Linux", OperatingSystem.LINUX)
.enabled(!targetProjectOnNetFramework)
dockerRadioButton = radioButton("Docker", OperatingSystem.DOCKER)
.visible(false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import java.util.function.Supplier
import java.util.stream.Collectors

class FunctionAppComboBox(project: Project) : AppServiceComboBox<FunctionAppConfig>(project) {
var targetProjectOnNetFramework: Boolean = false

override fun refreshItems() {
Azure.az(AzureFunctions::class.java).refresh()
super.refreshItems()
Expand Down Expand Up @@ -69,7 +71,7 @@ class FunctionAppComboBox(project: Project) : AppServiceComboBox<FunctionAppConf
}

override fun createResource() {
val dialog = FunctionAppCreationDialog(project)
val dialog = FunctionAppCreationDialog(project, targetProjectOnNetFramework)
Disposer.register(this, dialog)
dialog.data = FunctionAppConfigProducer.getInstance().generateDefaultConfig()
val actionId: Action.Id<FunctionAppConfig> = Action.Id.of("user/function.create_app.app")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<FunctionAppConfig>(project), Disposable {
class FunctionAppCreationDialog(
project: Project,
targetProjectOnNetFramework: Boolean
) : ConfigDialog<FunctionAppConfig>(project), Disposable {
private val basicPanel: AppServiceInfoBasicPanel<FunctionAppConfig>
private val advancedPanel: FunctionAppInfoAdvancedPanel
private val panel: JPanel
Expand All @@ -36,12 +39,12 @@ class FunctionAppCreationDialog(project: Project) : ConfigDialog<FunctionAppConf
}

val projectName = removeInvalidCharacters(project.name)
basicPanel = AppServiceInfoBasicPanel {
basicPanel = AppServiceInfoBasicPanel(targetProjectOnNetFramework) {
FunctionAppConfigProducer.getInstance().generateDefaultConfig()
}
Disposer.register(this, basicPanel)

advancedPanel = FunctionAppInfoAdvancedPanel(projectName) {
advancedPanel = FunctionAppInfoAdvancedPanel(projectName, targetProjectOnNetFramework) {
FunctionAppConfig()
}
Disposer.register(this, advancedPanel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import java.util.function.Supplier

class FunctionAppInfoAdvancedPanel(
projectName: String,
targetProjectOnNetFramework: Boolean,
defaultConfigSupplier: Supplier<FunctionAppConfig>
) : AppServiceInfoAdvancedPanel<FunctionAppConfig>(projectName, defaultConfigSupplier) {
) : AppServiceInfoAdvancedPanel<FunctionAppConfig>(projectName, targetProjectOnNetFramework, defaultConfigSupplier) {

private lateinit var storageAccountComboBox: Cell<StorageAccountComboBox>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -70,8 +71,10 @@ class FunctionDeploymentSettingsEditor(private val project: Project) :
}
}

dotnetProjectComboBox.component.reloadItems()

dotnetProjectComboBox.component.apply {
reloadItems()
addValueChangedListener(::onSelectProject)
}
functionAppComboBox.component.apply {
addValueChangedListener(::onSelectFunctionApp)
}
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import java.util.function.Supplier
import java.util.stream.Collectors

open class WebAppComboBox(project: Project) : AppServiceComboBox<AppServiceConfig>(project) {
var targetProjectOnNetFramework: Boolean = false

override fun refreshItems() {
Azure.az(AzureWebApp::class.java).refresh()
super.refreshItems()
Expand Down Expand Up @@ -68,7 +70,7 @@ open class WebAppComboBox(project: Project) : AppServiceComboBox<AppServiceConfi
}

override fun createResource() {
val dialog = WebAppCreationDialog(project)
val dialog = WebAppCreationDialog(project, targetProjectOnNetFramework)
Disposer.register(this, dialog)
val actionId: Action.Id<AppServiceConfig> = Action.Id.of("user/webapp.create_app.app")
dialog.setOkAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<AppServiceConfig>(project), Disposable {
class WebAppCreationDialog(
project: Project,
targetProjectOnNetFramework: Boolean
) : ConfigDialog<AppServiceConfig>(project), Disposable {
private val basicPanel: AppServiceInfoBasicPanel<AppServiceConfig>
private val advancedPanel: AppServiceInfoAdvancedPanel<AppServiceConfig>
private val panel: JPanel
Expand All @@ -38,12 +41,12 @@ class WebAppCreationDialog(project: Project) : ConfigDialog<AppServiceConfig>(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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -70,8 +71,10 @@ class WebAppSettingEditor(private val project: Project) : SettingsEditor<WebAppC
}
}

dotnetProjectComboBox.component.reloadItems()

dotnetProjectComboBox.component.apply {
reloadItems()
addValueChangedListener(::onSelectProject)
}
webAppComboBox.component.apply {
addValueChangedListener(::onSelectWebApp)
}
Expand All @@ -80,6 +83,12 @@ class WebAppSettingEditor(private val project: Project) : SettingsEditor<WebAppC
}
}

private fun onSelectProject(value: PublishableProjectModel) {
if (isLoading) return

webAppComboBox.component.targetProjectOnNetFramework = !value.isDotNetCore
}

private fun onSelectWebApp(value: AppServiceConfig?) {
if (isLoading) return

Expand Down

0 comments on commit 4a3e630

Please sign in to comment.