From ea8de654a5e92f4a76ff6be03b2a127ad83e8eda Mon Sep 17 00:00:00 2001 From: David Lysenko Date: Thu, 10 Apr 2025 15:48:52 +0200 Subject: [PATCH] [pycharm] Hide uv promo popup on interpreter selection GitOrigin-RevId: 372ddce2561ffe89cc760d1750a96ab4b04c6ace --- .../add/v2/PythonAddNewEnvironmentPanel.kt | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/python/src/com/jetbrains/python/sdk/add/v2/PythonAddNewEnvironmentPanel.kt b/python/src/com/jetbrains/python/sdk/add/v2/PythonAddNewEnvironmentPanel.kt index d79a5c463a70..1845b11a9025 100644 --- a/python/src/com/jetbrains/python/sdk/add/v2/PythonAddNewEnvironmentPanel.kt +++ b/python/src/com/jetbrains/python/sdk/add/v2/PythonAddNewEnvironmentPanel.kt @@ -76,6 +76,15 @@ internal class PythonAddNewEnvironmentPanel( // PY-79134: an anchor to display the promo notification on // TODO: remove after promo ends private lateinit var popupAnchor: Cell<*> + private val promoPopup: GotItTooltip = GotItTooltip("python.uv.promo.tooltip", message("sdk.create.custom.uv.promo.text")) + .withShowCount(1) + .withLink(message("sdk.create.custom.uv.promo.link")) { + selectedMode.set(CUSTOM) + custom.newInterpreterManager.set(UV) + promoPopup.gotIt() + promoPopup.hidePopup() + } + .withTimeout(15_000) private suspend fun updateVenvLocationHint(): Unit = withContext(Dispatchers.EDT) { val get = selectedMode.get() @@ -175,18 +184,13 @@ internal class PythonAddNewEnvironmentPanel( return@withLock } - lateinit var popup: GotItTooltip - popup = GotItTooltip("python.uv.promo.tooltip", message("sdk.create.custom.uv.promo.text")) - .withShowCount(1) - .withLink(message("sdk.create.custom.uv.promo.link")) { - selectedMode.set(CUSTOM) - custom.newInterpreterManager.set(UV) - popup.gotIt() - popup.hidePopup() + promoPopup.show(customButton, GotItTooltip.BOTTOM_MIDDLE) + custom.newInterpreterManager.afterChange(promoPopup) { + if (promoPopup.wasCreated()) { + promoPopup.gotIt() + promoPopup.hidePopup() } - .withTimeout(15_000) - - popup.show(customButton, GotItTooltip.BOTTOM_MIDDLE) + } } } }