Disable export until a system has components
The Overview share menu offered a wiring diagram and a full report even for an empty system. Gate it on loads, batteries or chargers being present (iOS + Android) and add UI tests for both states.
This commit is contained in:
@@ -157,7 +157,7 @@ fun SystemDetailScreen(
|
||||
strokeWidth = 2.dp,
|
||||
)
|
||||
} else {
|
||||
IconButton(onClick = { showOverviewMenu = true }) {
|
||||
IconButton(onClick = { showOverviewMenu = true }, enabled = state.hasComponents) {
|
||||
Icon(Icons.Outlined.IosShare, contentDescription = stringResource(R.string.overview_share_pdf))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@ data class DetailState(
|
||||
val chargers: List<SavedCharger> = emptyList(),
|
||||
) {
|
||||
val metrics: SystemMetrics get() = SystemMetrics(loads, batteries, chargers)
|
||||
|
||||
val hasComponents: Boolean
|
||||
get() = loads.isNotEmpty() || batteries.isNotEmpty() || chargers.isNotEmpty()
|
||||
}
|
||||
|
||||
class SystemDetailViewModel(
|
||||
|
||||
Reference in New Issue
Block a user