mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Conda (rename method, remove env duplication)
GitOrigin-RevId: fd658f2ba4411e43e73c6b1c6bdf18093d9bd9c9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c6d6a21b1e
commit
2bf0bfbd11
@@ -27,7 +27,7 @@ import kotlin.coroutines.CoroutineContext
|
||||
* Model for [PyAddCondaPanelView]
|
||||
* Each boundable property ends with "Prop" and either "ro" (view can read it) or "rw" (view can set it)
|
||||
*
|
||||
* First, user fills [condaPathTextBoxRwProp] then clicks [onCondaPathSetOkClicked]
|
||||
* First, user fills [condaPathTextBoxRwProp] then clicks [onLoadEnvsClicked]
|
||||
* (if [showCondaPathSetOkButtonRoProp] is true).
|
||||
*
|
||||
* After path validation [showCondaActionsPanelRoProp] becomes "true", hence radio buttons should be displayed
|
||||
@@ -125,13 +125,13 @@ class PyAddCondaPanelModel(val targetConfiguration: TargetEnvironmentConfigurati
|
||||
private var condaEnvs: Result<CondaInfo> = Result.failure(Exception(PyBundle.message("python.sdk.conda.no.exec")))
|
||||
|
||||
/**
|
||||
* To be called when user sets path to conda and clicks "On".
|
||||
* To be called when user sets path to conda and clicks "Load Envs".
|
||||
*
|
||||
* [uiContext] is for swing.
|
||||
* Result may contain an error
|
||||
*/
|
||||
suspend fun onCondaPathSetOkClicked(uiContext: CoroutineContext,
|
||||
progressSink: ProgressSink? = null): Result<List<PyCondaEnv>> = withContext(uiContext) {
|
||||
suspend fun onLoadEnvsClicked(uiContext: CoroutineContext,
|
||||
progressSink: ProgressSink? = null): Result<List<PyCondaEnv>> = withContext(uiContext) {
|
||||
val path = condaPathTextBoxRwProp.get()
|
||||
progressSink?.text(PyBundle.message("python.sdk.conda.getting.list.envs"))
|
||||
PyCondaEnv.getEnvs(PyCondaCommand(path.trim(), targetConfiguration))
|
||||
@@ -141,6 +141,7 @@ class PyAddCondaPanelModel(val targetConfiguration: TargetEnvironmentConfigurati
|
||||
showCondaActionsPanelRoProp.set(false)
|
||||
}
|
||||
.onSuccess { condaEnvsList ->
|
||||
condaEnvModel.removeAllElements()
|
||||
condaEnvs = Result.success(CondaInfo(path, condaEnvsList))
|
||||
condaEnvModel.addAll(condaEnvsList.map { it.envIdentity })
|
||||
condaEnvModel.selectedItem = condaEnvModel.getElementAt(0)
|
||||
@@ -164,7 +165,7 @@ class PyAddCondaPanelModel(val targetConfiguration: TargetEnvironmentConfigurati
|
||||
withContext(uiContext) {
|
||||
condaPathTextBoxRwProp.set(condaPath)
|
||||
// Since path is set, lets click button on behalf of user
|
||||
onCondaPathSetOkClicked(uiContext, progressSink)
|
||||
onLoadEnvsClicked(uiContext, progressSink)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class PyAddCondaPanelView(private val model: PyAddCondaPanelModel) : PyAddTarget
|
||||
|
||||
button(PyBundle.message("python.add.sdk.panel.load.envs")) {
|
||||
runBlockingModal(model.project, PyBundle.message("python.sdk.conda.getting.list.envs")) {
|
||||
model.onCondaPathSetOkClicked(Dispatchers.EDT, this.progressSink)
|
||||
model.onLoadEnvsClicked(Dispatchers.EDT, this.progressSink)
|
||||
}.onFailure {
|
||||
showError(it.localizedMessage)
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ class PyAddCondaPanelModelTest {
|
||||
fun testCondaUseExistingEnv(): Unit = runTest {
|
||||
val model = PyAddCondaPanelModel(null, emptyList(), projectRule.project)
|
||||
model.condaPathTextBoxRwProp.set(condaRule.condaPath.toString())
|
||||
model.onCondaPathSetOkClicked(coroutineContext)
|
||||
model.onLoadEnvsClicked(coroutineContext)
|
||||
model.condaActionUseExistingEnvRadioRwProp.set(true)
|
||||
model.condaActionCreateNewEnvRadioRwProp.set(false)
|
||||
model.condaEnvModel.selectedItem = model.condaEnvModel.getElementAt(0)
|
||||
@@ -86,11 +86,11 @@ class PyAddCondaPanelModelTest {
|
||||
Assert.assertFalse(model.showCondaPathSetOkButtonRoProp.get())
|
||||
model.condaPathTextBoxRwProp.set("Some random path that doesn't exist")
|
||||
Assert.assertTrue(model.showCondaPathSetOkButtonRoProp.get())
|
||||
model.onCondaPathSetOkClicked(coroutineContext)
|
||||
model.onLoadEnvsClicked(coroutineContext)
|
||||
Assert.assertNotNull("No validation error, but path is incorrect", model.getValidationError())
|
||||
|
||||
model.condaPathTextBoxRwProp.set(condaRule.condaPath.toString())
|
||||
model.onCondaPathSetOkClicked(coroutineContext)
|
||||
model.onLoadEnvsClicked(coroutineContext)
|
||||
Assert.assertNull("Unexpected validation error", model.getValidationError())
|
||||
|
||||
Assert.assertTrue(model.showCondaActionsPanelRoProp.get())
|
||||
|
||||
Reference in New Issue
Block a user