From 5e6999ef5f352cd413525fd2e9fe13ec098fd169 Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Wed, 23 Apr 2025 23:48:45 +0200 Subject: [PATCH] PY-79535: Obey `runWithSudo` checkbox for Conda/SSH. Targets are written against v1 widgets (aka `PyAddSdkView`). With these widgets each interpreter type has its own UI (so does the conda). In addition to this UI, each panel might have optional `targetExtension`. This extension, if set, should be called against target-aware data of newly created SDK: ``` com.jetbrains.python.sdk.add.v1.TargetPanelExtension.applyToAdditionalData ``` SSH extension provides `runWithSudo` button (ironically, WSL extension doesn't). Extension was called from `PyAddSystemWideInterpreterPanel` and `PyAddVirtualEnvPanel` but *NOT* from `PyAddCondaPanelView` We now call it from conda the same way we do that from other panels. Writing the test might take a week for now due to high UI coupling. GitOrigin-RevId: dd055bf37bf4c2371b711b160b5a6b5eb868b969 --- .../python/sdk/add/v1/PyAddCondaPanelView.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/python/src/com/jetbrains/python/sdk/add/v1/PyAddCondaPanelView.kt b/python/src/com/jetbrains/python/sdk/add/v1/PyAddCondaPanelView.kt index 9becd8f0e889..32ab2325491b 100644 --- a/python/src/com/jetbrains/python/sdk/add/v1/PyAddCondaPanelView.kt +++ b/python/src/com/jetbrains/python/sdk/add/v1/PyAddCondaPanelView.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.jetbrains.python.sdk.add.v1 import com.intellij.execution.target.TargetBrowserHints @@ -6,6 +6,7 @@ import com.intellij.openapi.Disposable import com.intellij.openapi.application.EDT import com.intellij.openapi.application.ModalityState import com.intellij.openapi.application.asContextElement +import com.intellij.openapi.application.writeAction import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.observable.util.bind import com.intellij.openapi.projectRoots.Sdk @@ -21,6 +22,7 @@ import com.jetbrains.python.run.PythonInterpreterTargetEnvironmentFactory.Compan import com.jetbrains.python.sdk.add.PyAddSdkDialogFlowAction import com.jetbrains.python.sdk.add.PyAddSdkStateListener import com.jetbrains.python.sdk.add.PyAddSdkView +import com.jetbrains.python.target.PyTargetAwareAdditionalData import kotlinx.coroutines.Dispatchers import org.jetbrains.annotations.Nls import java.awt.Component @@ -132,6 +134,15 @@ internal class PyAddCondaPanelView(private val model: PyAddCondaPanelModel) : Py showError( PyBundle.message("python.sdk.conda.cant.create.title"), PyBundle.message("python.sdk.conda.cant.create.body", it.localizedMessage)) + }.onSuccess { sdk -> + with(sdk.sdkModificator) { + writeAction { + (sdkAdditionalData as? PyTargetAwareAdditionalData)?.let { targetAwareAdditionalData -> + targetPanelExtension?.applyToAdditionalData(targetAwareAdditionalData) + } + commitChanges() + } + } }.getOrNull() } }