diff --git a/invert-report/src/jsMain/kotlin/com/squareup/invert/common/pages/CodeReferencesReportPage.kt b/invert-report/src/jsMain/kotlin/com/squareup/invert/common/pages/CodeReferencesReportPage.kt index 7f8bd99..46edc9b 100644 --- a/invert-report/src/jsMain/kotlin/com/squareup/invert/common/pages/CodeReferencesReportPage.kt +++ b/invert-report/src/jsMain/kotlin/com/squareup/invert/common/pages/CodeReferencesReportPage.kt @@ -19,10 +19,12 @@ import com.squareup.invert.models.OwnerName import com.squareup.invert.models.StatDataType import com.squareup.invert.models.js.StatTotalAndMetadata import org.jetbrains.compose.web.dom.A -import org.jetbrains.compose.web.dom.H1 import org.jetbrains.compose.web.dom.H3 import org.jetbrains.compose.web.dom.H4 +import org.jetbrains.compose.web.dom.Li +import org.jetbrains.compose.web.dom.P import org.jetbrains.compose.web.dom.Text +import org.jetbrains.compose.web.dom.Ul import ui.BootstrapColumn import ui.BootstrapLoadingMessageWithSpinner import ui.BootstrapLoadingSpinner @@ -127,48 +129,74 @@ fun CodeReferencesComposable( } val metadata by reportDataRepo.reportMetadata.collectAsState(null) - H1 { - Text(buildString { - append("Code References") - codeReferencesNavRoute.statKey?.let { statKey -> - val statInfo = statInfosOrig?.filter { it.key == codeReferencesNavRoute.statKey }?.firstOrNull() - append(" for ${statInfo?.description ?: statKey} (${codeReferencesNavRoute.statKey})") - } - }) - } - H4 { - codeReferencesNavRoute.statKey?.let { statKey -> - A("#", { - onClick { - navRouteRepo.updateNavRoute(StatDetailNavRoute(statKeys = listOf(statKey))) - } - }) { - Text("View Grouped by Module") + BootstrapRow { + BootstrapColumn(8) { + H4 { + Text(buildString { + append("Code References") + codeReferencesNavRoute.statKey?.let { statKey -> + val statInfo = statInfosOrig?.filter { it.key == codeReferencesNavRoute.statKey }?.firstOrNull() + append(" for ${statInfo?.description ?: statKey} (${codeReferencesNavRoute.statKey})") + } + }) } + } + BootstrapColumn(4) { - Text(" ") - A("#", { - onClick { - navRouteRepo.updateNavRoute( - codeReferencesNavRoute.copy( - treemap = if (codeReferencesNavRoute.treemap != null) { - !codeReferencesNavRoute.treemap - } else { - true + codeReferencesNavRoute.statKey?.let { statKey -> + P { + Ul { + Li { + A("#", { + onClick { + navRouteRepo.updateNavRoute(StatDetailNavRoute(statKeys = listOf(statKey))) + } + }) { + Text("View Grouped by Module") } - ) - ) - } - }) { - if (codeReferencesNavRoute.treemap == true) { - Text("Hide Treemap") - } else { - Text("Show Treemap") + } + Li { + A("#", { + onClick { + navRouteRepo.updateNavRoute( + codeReferencesNavRoute.copy( + treemap = if (codeReferencesNavRoute.treemap != null) { + !codeReferencesNavRoute.treemap + } else { + true + } + ) + ) + } + }) { + if (codeReferencesNavRoute.treemap == true) { + Text("Hide Treemap") + } else { + Text("Show Treemap") + } + } + } + Li { + A("#", { + onClick { + navRouteRepo.updateNavRoute( + OwnerBreakdownNavRoute( + statKey = codeReferencesNavRoute.statKey, + owner = codeReferencesNavRoute.owner, + ) + ) + } + }) { + Text("View Owner Breakdown") + } + } + } } } } } + if (moduleToOwnerMapFlowValue == null || metadata == null) { BootstrapLoadingSpinner() return 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 f865bad..5ce0b53 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 @@ -26,7 +26,8 @@ import org.jetbrains.compose.web.css.px import org.jetbrains.compose.web.dom.A import org.jetbrains.compose.web.dom.Br import org.jetbrains.compose.web.dom.H1 -import org.jetbrains.compose.web.dom.H3 +import org.jetbrains.compose.web.dom.H5 +import org.jetbrains.compose.web.dom.H6 import org.jetbrains.compose.web.dom.Hr import org.jetbrains.compose.web.dom.Li import org.jetbrains.compose.web.dom.P @@ -42,7 +43,6 @@ import ui.BootstrapTabPane import ui.BootstrapTable import kotlin.reflect.KClass - data class OwnerBreakdownNavRoute( val owner: String?, val statKey: StatKey?, @@ -177,24 +177,47 @@ fun ByOwnerComposable( .sortedBy { it.description } BootstrapRow { - BootstrapColumn(6) { - H3 { - Text("Filter by Owner") - BootstrapSelectDropdown( - placeholderText = "-- All Owners --", - currentValue = ownerParamValue, - options = allOwnerNames!!.map { BootstrapSelectOption(it, it) } - ) { - navRouteRepo.updateNavRoute( - navRoute.copy( - owner = it?.value + BootstrapColumn(classes = listOf("text-center")) { + H5 { + Text("Owner Breakdown") + if (!navRoute.statKey.isNullOrBlank()) { + Text(" (") + A(href = "#", { + onClick { + navRouteRepo.updateNavRoute( + navRoute.copy( + owner = null, + statKey = null, + ) + ) + } + }) { Text("View All") } + Text(")") + } + } + } + } + BootstrapRow { + if (navRoute.statKey?.isNotBlank() == true) { + BootstrapColumn(6) { + H6 { + Text("Filter by Owner") + BootstrapSelectDropdown( + placeholderText = "-- All Owners --", + currentValue = ownerParamValue, + options = allOwnerNames!!.map { BootstrapSelectOption(it, it) } + ) { + navRouteRepo.updateNavRoute( + navRoute.copy( + owner = it?.value + ) ) - ) + } } } } BootstrapColumn(6) { - H3 { + H6 { Text("Filter by Stat") BootstrapSelectDropdown( placeholderText = "-- All Stats --", @@ -228,21 +251,23 @@ fun ByOwnerComposable( } .map { it.key } - if(navRoute.statKey.isNullOrBlank()){ - + if (navRoute.statKey.isNullOrBlank()) { + val codeReferencesByCategory = codeReferenceStatTypes.groupBy { it.category } - H3{ - Text("Select a Stat to view Owner Breakdown") - } - Ul { - codeReferenceStatTypes.forEach {statMetadata -> - Li { - A("#", { - onClick { - navRouteRepo.updateNavRoute(navRoute.copy(statKey = statMetadata.key)) + codeReferencesByCategory.entries.sortedBy { it.key }.forEach { (category, codeReferenceStatTypes) -> + H6 { + Text(category) + } + Ul { + codeReferenceStatTypes.forEach { statMetadata -> + Li { + A("#", { + onClick { + navRouteRepo.updateNavRoute(navRoute.copy(statKey = statMetadata.key)) + } + }) { + Text(statMetadata.description + " (" + statMetadata.key + ")") } - }) { - Text(statMetadata.description + " (" + statMetadata.key + ")") } } }