Skip to content

Commit

Permalink
Removed "Code References" from the left-nav. It is now just part of t…
Browse files Browse the repository at this point in the history
…he "All Stats" page.
  • Loading branch information
handstandsam committed Dec 6, 2024
1 parent 92c9015 commit 2dd09a3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ object DefaultNavItems {
),
NavPageGroup(
"Collected Stats", setOf(
CodeReferencesReportPage.navPage.toNavItem(),
AllStatsNavRoute().navPage.toNavItem(),
OwnerBreakdownReportPage.navPage.toNavItem()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ fun AllStatsComposable(
val statTotalsOrig by reportDataRepo.statTotals.collectAsState(null)
val moduleToOwnerMapFlowValue by reportDataRepo.moduleToOwnerMap.collectAsState(null)

H1({ classes("text-center") }) { Text("Stat Totals") }

if (moduleToOwnerMapFlowValue == null) {
BootstrapLoadingSpinner()
return
Expand All @@ -103,7 +101,7 @@ fun AllStatsComposable(
StatDataType.entries.forEach { statDataType: StatDataType ->
val statsOfType = statTotals.statTotals.values.filter { it.metadata.dataType == statDataType }
if (statsOfType.isNotEmpty()) {
H1 { Text("${statDataType.displayName} Stat Counts") }
H1 { Text("${statDataType.displayName} Stats") }
StatTiles(statsOfType) { statKey ->
navRouteRepo.updateNavRoute(
if (statDataType == StatDataType.CODE_REFERENCES) {
Expand All @@ -121,19 +119,6 @@ fun AllStatsComposable(
}
}

BootstrapButton(
"View All",
BootstrapButtonType.PRIMARY,
onClick = {
navRouteRepo.updateNavRoute(
StatDetailNavRoute(
pluginIds = listOf(),
statKeys = statInfos.map { it.key }
)
)
}
)

val stats = statsData.statInfos.values

val statTotalsMap: Map<StatKey, StatTotalAndMetadata>? = statTotalsOrig?.statTotals
Expand Down Expand Up @@ -173,6 +158,19 @@ fun AllStatsComposable(

}
)

BootstrapButton(
"View All, Grouped By Module",
BootstrapButtonType.SECONDARY,
onClick = {
navRouteRepo.updateNavRoute(
StatDetailNavRoute(
pluginIds = listOf(),
statKeys = statInfos.map { it.key }
)
)
}
)
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.squareup.invert.common.charts.ChartJsLineChartComposable
import com.squareup.invert.common.charts.ChartsJs
import com.squareup.invert.common.charts.PlotlyTreeMapComposable
import com.squareup.invert.common.navigation.NavPage
import com.squareup.invert.common.navigation.NavRoute
import com.squareup.invert.common.navigation.NavRouteRepo
import com.squareup.invert.common.navigation.routes.BaseNavRoute
import com.squareup.invert.common.pages.CodeReferencesNavRoute.Companion.parser
Expand All @@ -31,6 +32,7 @@ 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.BootstrapButton
import ui.BootstrapColumn
import ui.BootstrapLoadingMessageWithSpinner
import ui.BootstrapLoadingSpinner
Expand All @@ -41,7 +43,7 @@ import ui.BootstrapTable
import kotlin.reflect.KClass

data class CodeReferencesNavRoute(
val statKey: String? = null,
val statKey: String,
val owner: String? = null,
val module: String? = null,
val treemap: Boolean? = null,
Expand All @@ -50,7 +52,7 @@ data class CodeReferencesNavRoute(

override fun toSearchParams(): Map<String, String> = toParamsWithOnlyPageId(this)
.also { params ->
statKey?.let {
statKey.let {
params[STATKEY_PARAM] = it
}
if (!owner.isNullOrBlank()) {
Expand All @@ -75,7 +77,7 @@ data class CodeReferencesNavRoute(
private const val MODULE_PARAM = "module"
private const val TREEMAP_PARAM = "treemap"

fun parser(params: Map<String, String?>): CodeReferencesNavRoute {
fun parser(params: Map<String, String?>): NavRoute {
val statKey = params[STATKEY_PARAM]
val owner = params[OWNER_PARAM]?.trim()?.let {
if (it.isNotBlank()) {
Expand Down Expand Up @@ -105,13 +107,17 @@ data class CodeReferencesNavRoute(
null
}
}
return CodeReferencesNavRoute(
statKey = statKey,
owner = owner,
module = module,
treemap = treemap,
chart = chart,
)
return if (statKey == null) {
AllStatsNavRoute()
} else {
CodeReferencesNavRoute(
statKey = statKey,
owner = owner,
module = module,
treemap = treemap,
chart = chart,
)
}
}
}
}
Expand Down Expand Up @@ -154,7 +160,10 @@ fun CodeReferencesComposable(

val currentStatMetadata: StatMetadata? = statInfos.firstOrNull { it.key == codeReferencesNavRoute.statKey }
if (currentStatMetadata == null) {
H1 { Text("No stat with key ${codeReferencesNavRoute.statKey} found") }
H1 { Text("No stat with key '${codeReferencesNavRoute.statKey}' found") }
BootstrapButton("View All Stats") {
navRouteRepo.updateNavRoute(AllStatsNavRoute())
}
return
}

Expand Down

0 comments on commit 2dd09a3

Please sign in to comment.