diff --git a/invert-report/src/jsMain/kotlin/com/squareup/invert/common/ReportDataRepo.kt b/invert-report/src/jsMain/kotlin/com/squareup/invert/common/ReportDataRepo.kt index 2d2ec50..25d92f0 100644 --- a/invert-report/src/jsMain/kotlin/com/squareup/invert/common/ReportDataRepo.kt +++ b/invert-report/src/jsMain/kotlin/com/squareup/invert/common/ReportDataRepo.kt @@ -16,6 +16,7 @@ import com.squareup.invert.models.js.CollectedStatTotalsJsReportModel import com.squareup.invert.models.js.HistoricalData import com.squareup.invert.models.js.MetadataJsReportModel import com.squareup.invert.models.js.PluginsJsReportModel +import com.squareup.invert.models.js.StatJsReportModel import com.squareup.invert.models.js.StatsJsReportModel import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow @@ -45,10 +46,10 @@ class ReportDataRepo( val historicalData: Flow?> = collectedDataRepo.historicalData.mapLatest { it } - val statInfos: Flow?> = collectedDataRepo.statsData.mapLatest { it?.statInfos?.values } - val statTotals: Flow = collectedDataRepo.statTotals + val statInfos: Flow?> = statTotals.mapLatest { it?.statTotals?.values?.map { it.metadata } } + val collectedPluginInfoReport: Flow = collectedDataRepo.collectedPluginInfoReport val moduleToOwnerMap: Flow?> = collectedDataRepo.ownersInfo.mapLatest { @@ -101,6 +102,9 @@ class ReportDataRepo( it?.allConfigurationNames } + fun statForKey(statKey: StatKey): Flow = + collectedDataRepo.statData(statKey).mapLatest { it?.get(statKey) } + val pluginIdToAllModulesMap: Flow>?> = collectedDataRepo.collectedPluginInfoReport .mapLatest { diff --git a/invert-report/src/jsMain/kotlin/com/squareup/invert/common/pages/InvertedDependenciesReportPage.kt b/invert-report/src/jsMain/kotlin/com/squareup/invert/common/pages/InvertedDependenciesReportPage.kt index 1ee9799..8f9e679 100644 --- a/invert-report/src/jsMain/kotlin/com/squareup/invert/common/pages/InvertedDependenciesReportPage.kt +++ b/invert-report/src/jsMain/kotlin/com/squareup/invert/common/pages/InvertedDependenciesReportPage.kt @@ -92,13 +92,13 @@ object InvertedDependenciesReportPage : InvertReportPage = InvertedDependenciesNavRoute::class override val composableContent: @Composable (InvertedDependenciesNavRoute) -> Unit = { navRoute -> - InverteDependenciesComposable(navRoute) + InvertDependenciesComposable(navRoute) } } @Composable -fun InverteDependenciesComposable( +fun InvertDependenciesComposable( navRoute: InvertedDependenciesNavRoute, reportDataRepo: ReportDataRepo = DependencyGraph.reportDataRepo, navRouteRepo: NavRouteRepo = DependencyGraph.navRouteRepo, @@ -111,7 +111,6 @@ fun InverteDependenciesComposable( BootstrapLoadingMessageWithSpinner() return } - println("1") if (allConfigurationNames!!.isEmpty()) { H1 { Text("No analyzed configurations found.") } return @@ -123,7 +122,6 @@ fun InverteDependenciesComposable( if (navRoute.pluginGroupByFilter.isEmpty() || navRoute.configurations.isEmpty()) { BootstrapJumbotron( headerContent = { -// BootstrapIcon("exclamation-triangle", 48) Text(" Inverted Dependency Search") } ) { diff --git a/invert-report/src/jsMain/kotlin/com/squareup/invert/common/pages/OwnerBreakdownReportPage.kt b/invert-report/src/jsMain/kotlin/com/squareup/invert/common/pages/OwnerBreakdownReportPage.kt index dd5873c..e327b4a 100644 --- a/invert-report/src/jsMain/kotlin/com/squareup/invert/common/pages/OwnerBreakdownReportPage.kt +++ b/invert-report/src/jsMain/kotlin/com/squareup/invert/common/pages/OwnerBreakdownReportPage.kt @@ -20,6 +20,7 @@ import com.squareup.invert.models.Stat import com.squareup.invert.models.Stat.CodeReferencesStat.CodeReference import com.squareup.invert.models.StatDataType import com.squareup.invert.models.StatKey +import com.squareup.invert.models.StatMetadata import org.jetbrains.compose.web.attributes.ATarget import org.jetbrains.compose.web.attributes.target import org.jetbrains.compose.web.css.px @@ -35,6 +36,7 @@ import org.jetbrains.compose.web.dom.Text import org.jetbrains.compose.web.dom.Ul import ui.BootstrapColumn import ui.BootstrapLoadingMessageWithSpinner +import ui.BootstrapLoadingSpinner import ui.BootstrapRow import ui.BootstrapSelectDropdown import ui.BootstrapSelectOption @@ -100,17 +102,15 @@ object OwnerBreakdownReportPage : InvertReportPage { } private fun getCodeReferenceOwnerToModulePlusCodeReferencesList( - statKey: StatKey, + statMetadata: StatMetadata, moduleToOwnerMap: Map, - statsByModuleParam: Map> + moduleToStat: Map, ): Map>> { val toReturnOwnerNameToModuleAndCodeReferencesMap = mutableMapOf>>() - statsByModuleParam.entries.forEach { (modulePath: ModulePath, moduleStatsByKey: Map) -> + moduleToStat.entries.forEach { (modulePath: ModulePath, stat: Stat) -> val moduleOwner = moduleToOwnerMap[modulePath] ?: "" - val codeReferences = - (moduleStatsByKey.entries.firstOrNull { it.key == statKey }?.value as? Stat.CodeReferencesStat)?.value - + val codeReferences = (stat as? Stat.CodeReferencesStat)?.value codeReferences?.forEach { newCodeReference: CodeReference -> val owner = newCodeReference.owner ?: moduleOwner @@ -136,7 +136,6 @@ fun ByOwnerComposable( reportDataRepo: ReportDataRepo = DependencyGraph.reportDataRepo, navRouteRepo: NavRouteRepo = DependencyGraph.navRouteRepo ) { - val statsOrig by reportDataRepo.statsData.collectAsState(null) val statInfosOrig by reportDataRepo.statInfos.collectAsState(null) val moduleToOwnerMapOrig by reportDataRepo.moduleToOwnerMap.collectAsState(null) val allOwnerNames by reportDataRepo.allOwnerNames.collectAsState(null) @@ -146,7 +145,6 @@ fun ByOwnerComposable( allOwnerNames, moduleToOwnerMapOrig, statInfosOrig, - statsOrig ).any { it == null } ) { BootstrapLoadingMessageWithSpinner() @@ -277,12 +275,18 @@ fun ByOwnerComposable( BootstrapTabPane( codeReferenceStatTypesFilteredByNavParams .mapNotNull { statKey -> + val statInfoForKey by reportDataRepo.statForKey(statKey).collectAsState(null) + if (statInfoForKey == null) { + BootstrapLoadingSpinner() + return + } + val statMetadata = statInfosOrig!!.firstOrNull { it.key == statKey } val ownerToModulePathToCodeReferences: Map>> = getCodeReferenceOwnerToModulePlusCodeReferencesList( - statKey = statKey, + statMetadata = statMetadata!!, moduleToOwnerMap = moduleToOwnerMapOrig!!, - statsByModuleParam = statsOrig!!.statsByModule + moduleToStat = statInfoForKey!!.statsByModule ) val filteredByOwners = ownerToModulePathToCodeReferences.filter { if (!ownerParamValue.isNullOrBlank()) { diff --git a/invert-report/src/jsMain/kotlin/ui/NavBarComposable.kt b/invert-report/src/jsMain/kotlin/ui/NavBarComposable.kt index d4e5efa..1060961 100644 --- a/invert-report/src/jsMain/kotlin/ui/NavBarComposable.kt +++ b/invert-report/src/jsMain/kotlin/ui/NavBarComposable.kt @@ -14,20 +14,28 @@ import org.jetbrains.compose.web.dom.Text @Composable fun NavBarComposable(loadingProgressFlow: Flow>) { - val outstandingCalls by loadingProgressFlow.collectAsState(listOf()) - if (outstandingCalls.isNotEmpty()) { - H4 { - Span({ classes("pe-4") }) { Text("Loading... ${outstandingCalls.map { it }}") } - Div({ - classes("spinner-border text-light".split(" ")) - attr("role", "status") - }) { - Span({ - classes("visually-hidden") - }) { - Text("Loading...") - } + val outstandingCalls by loadingProgressFlow.collectAsState(listOf()) + if (outstandingCalls.isNotEmpty()) { + H4 { + Span({ classes("pe-4") }) { + Text( + "Loading... ${ + outstandingCalls.map { fileKey -> + JsReportFileKey.entries.firstOrNull { it.key == fileKey }?.description ?: fileKey } + }" + ) + } + Div({ + classes("spinner-border text-light".split(" ")) + attr("role", "status") + }) { + Span({ + classes("visually-hidden") + }) { + Text("Loading...") } + } } + } } \ No newline at end of file