Skip to content

Commit

Permalink
Merge pull request #877 from JetBrains/rival/small-fixes
Browse files Browse the repository at this point in the history
Small fixes
  • Loading branch information
rafaelldi authored Aug 12, 2024
2 parents 09014bf + 4a3e630 commit e1e1ccb
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ class CreateOrUpdateDotNetFunctionAppTask(

//Enables your function app to run from a package file, which can be locally mounted or deployed to an external URL.
//see: https://learn.microsoft.com/en-us/azure/azure-functions/run-functions-from-deployment-package
if (config.runtime.os == OperatingSystem.WINDOWS) {
if (config.runtime.os == OperatingSystem.WINDOWS ||
(config.runtime.os == OperatingSystem.LINUX && config.pricingTier != PricingTier.CONSUMPTION)
) {
put(WEBSITE_RUN_FROM_PACKAGE, "1")
}

Expand Down
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 @@ -81,7 +82,7 @@ open class AppServiceInfoAdvancedPanel<T>(
private lateinit var dockerRadioButton: Cell<JBRadioButton>

init {
operatingSystem = OperatingSystem.LINUX
operatingSystem = OperatingSystem.WINDOWS

Disposer.register(this, textName)

Expand All @@ -103,9 +104,10 @@ open class AppServiceInfoAdvancedPanel<T>(
}
operatingSystemGroup = buttonsGroup {
row("Operating System:") {
linuxRadioButton = radioButton("Linux", OperatingSystem.LINUX)
windowsRadioButton = radioButton("Windows", OperatingSystem.WINDOWS)
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 All @@ -40,7 +41,7 @@ class AppServiceInfoBasicPanel<T>(
private lateinit var dockerRadioButton: Cell<JBRadioButton>

init {
operatingSystem = OperatingSystem.LINUX
operatingSystem = OperatingSystem.WINDOWS

Disposer.register(this, textName)

Expand All @@ -52,8 +53,9 @@ class AppServiceInfoBasicPanel<T>(
}
operatingSystemGroup = buttonsGroup {
row("Operating System:") {
linuxRadioButton = radioButton("Linux", OperatingSystem.LINUX)
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 @@ -27,7 +27,7 @@ class FunctionAppConfigProducer {
val rgName = group?.name ?: "rg-$appName"
val result = FunctionAppConfig.buildDefaultFunctionConfig(rgName, appName)
result.appSettings = mutableMapOf()
result.runtime = RuntimeConfig().apply { os = OperatingSystem.LINUX }
result.runtime = RuntimeConfig().apply { os = OperatingSystem.WINDOWS }
subscription?.let { result.subscriptionId = it.id }
group?.let { result.region = it.region }

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 @@ -29,7 +29,7 @@ class WebAppConfigProducer {
val result = AppServiceConfig.buildDefaultWebAppConfig(rgName, appName, "zip")
result.appSettings = mutableMapOf()
result.pricingTier = PricingTier.FREE_F1
result.runtime = RuntimeConfig().apply { os = OperatingSystem.LINUX }
result.runtime = RuntimeConfig().apply { os = OperatingSystem.WINDOWS }
subscription?.let { result.subscriptionId = it.id }
group?.let { result.region = it.region }

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 e1e1ccb

Please sign in to comment.