Skip to content

Commit

Permalink
refactor(autocrud): update progress indicator messages #81
Browse files Browse the repository at this point in the history
- Update progress indicator messages in AutoCrudAction.kt and AutoDevRunProfileState.kt to use the "autocrud" prefix instead of "devti".
- Update the corresponding message keys in AutoDevBundle.properties to use the "autocrud" prefix instead of "devti".
  • Loading branch information
phodal committed Jan 26, 2024
1 parent 0f17403 commit 0263a7b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ interface AutoPage : TaskFlow<String> {
var userTask: String

/**
* Get all routes in the project, including the routes in the submodules
* @return list of routes
* Retrieves all routes in the project, including the routes in the submodules.
*
* @return A map of routes, where the key represents the route name and the value represents the route URL.
*/
fun getRoutes(): List<String>
fun getRoutes(): Map<String, String>

/**
* Get all pages in the project, based on the naming convention, like the PascalCase under `src/pages`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class ReactAutoPage(
override var userTask: String,
private val editor: Editor
) : AutoPage {
private val routes: List<String> = emptyList()
// todo: add post routes design
private val routes: MutableMap<RouterFile, JSFile> = mutableMapOf()
private val pages: MutableList<DsComponent> = mutableListOf()
private val components: MutableList<DsComponent> = mutableListOf()

Expand All @@ -39,10 +40,6 @@ class ReactAutoPage(

init {
val searchScope: GlobalSearchScope = ProjectScope.getContentScope(project)
// todo: find .umirc.ts in root, find in modules
val umirc = FileTypeIndex.getFiles(TypeScriptJSXFileType.INSTANCE, searchScope).firstOrNull {
it.name == ".umirc.ts"
}
val psiManager = com.intellij.psi.PsiManager.getInstance(project)

val virtualFiles =
Expand All @@ -69,6 +66,10 @@ class ReactAutoPage(

else -> {
if (root.findChild(file.name) != null) {
RouterFile.values().filter { it.filename == file.name }.map {
routes += it to jsFile
}

configs.add(jsFile)
}
}
Expand All @@ -92,14 +93,29 @@ class ReactAutoPage(
}
dsComponents
}

else -> {
logger<ReactAutoPage>().warn("unknown language: ${jsFile.language}")
null
}
}
}

override fun getRoutes(): List<String> = routes
override fun getRoutes(): Map<String, String> {
return this.routes.map {
when (it.key) {
RouterFile.UMI -> emptyMap()
RouterFile.NEXT -> {
pages.associate { page ->
val route = page.name.replace(Regex("([A-Z])"), "-$1").lowercase()
route to route
}
}

RouterFile.VITE -> emptyMap()
}
}.reduce { acc, map -> acc + map }
}

// load prompts/context/ds.json from project root
override fun getDesignSystemComponents(): List<DsComponent> {
Expand Down Expand Up @@ -129,7 +145,7 @@ class ReactAutoPage(
TODO("Not yet implemented")
}

fun filterComponents(components: List<String>) : List<DsComponent> {
fun filterComponents(components: List<String>): List<DsComponent> {
val comps = this.pages + this.components
return components.mapNotNull { component ->
comps.find { it.name == component }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ data class AutoPageContext(
pageNames = reactAutoPage.getPages().map { it.name },
components = reactAutoPage.getComponents().map { it.format() },
componentNames = reactAutoPage.getComponents().map { it.name },
routes = reactAutoPage.getRoutes(),
routes = reactAutoPage.getRoutes().map { "${it.key}${it.value}" },
)
}
}
Expand Down

0 comments on commit 0263a7b

Please sign in to comment.