1
1
package com.jetbrains.edu.fleet.frontend.actions
2
2
3
- import fleet.api.child
4
3
import com.jetbrains.edu.fleet.common.CourseEntity
5
4
import com.jetbrains.edu.fleet.common.generation.CourseProjectGenerator
6
5
import com.jetbrains.edu.fleet.common.marketplace.MarketplaceConnector
7
6
import com.jetbrains.edu.fleet.common.yaml.YamlFormatSynchronizer
8
7
import com.jetbrains.edu.fleet.frontend.EduTriggers
9
8
import com.jetbrains.edu.fleet.frontend.ui.newCourseTreeView
10
9
import com.jetbrains.edu.fleet.frontend.ui.showCourseIdDialog
10
+ import fleet.api.child
11
11
import fleet.frontend.actions.FleetDataKeys
12
- import fleet.frontend.actions.kernel
13
12
import fleet.frontend.actions.sagaAction
14
13
import fleet.frontend.actions.windowEntity
15
14
import fleet.frontend.fsd.showSelectFolderDialog
@@ -18,37 +17,36 @@ import fleet.frontend.layout.ShowOpts
18
17
import fleet.frontend.layout.WindowEntity
19
18
import fleet.frontend.layout.openTool
20
19
import fleet.frontend.navigation.attachToWorkspace
21
- import fleet.kernel.Kernel
22
20
import fleet.kernel.change
21
+ import fleet.kernel.plugins.PluginScope
23
22
import fleet.kernel.saga
24
23
import noria.model.Action
25
24
import noria.model.ActionPresentation
26
25
27
- internal fun createImportMarketplaceCourseAction (): Action {
26
+ internal fun createImportMarketplaceCourseAction (pluginScope : PluginScope ): Action {
28
27
return Action (
29
28
perform = sagaAction { actionContext ->
30
29
val window = actionContext.windowEntity
31
- val kernel = actionContext.kernel
32
- kernel.changeAsync {
30
+ pluginScope.changeAsync {
33
31
showCourseIdDialog(window) {
34
- kernel .saga {
35
- createCourse(it, window, kernel )
32
+ pluginScope .saga {
33
+ createCourse(it, window, pluginScope )
36
34
}
37
35
}
38
36
}
39
37
},
40
38
identifier = " import-marketplace-course" ,
41
- requirements = setOf (FleetDataKeys .Kernel , FleetDataKeys . Window ),
39
+ requirements = setOf (FleetDataKeys .Window ),
42
40
triggers = setOf (EduTriggers .ImportMarketplace ),
43
41
defaultPresentation = ActionPresentation (" Import Marketplace Course" ))
44
42
}
45
43
46
- private suspend fun createCourse (id : String? , window : WindowEntity , kernel : Kernel ) {
44
+ private suspend fun createCourse (id : String? , window : WindowEntity , pluginScope : PluginScope ) {
47
45
val courseId = id?.toInt() ? : return
48
46
MarketplaceConnector .loadCourse(courseId) { course ->
49
- kernel .saga {
47
+ pluginScope .saga {
50
48
showSelectFolderDialog(window) { item, showValidationError ->
51
- kernel .saga {
49
+ pluginScope .saga {
52
50
val fileAddress = item.child(course.name)
53
51
val success = CourseProjectGenerator ().createCourse(fileAddress, course)
54
52
if (success) {
0 commit comments