Product: PowerShell Universal
Version: 5.0.8
I have a card, whose body I am rendering like so:
$DeviceCardBody = New-UDCardBody -Content {
New-UDDynamic -Content {
New-UDTabs -Tabs {
foreach ($DataSource in $Entity.PSObject.Properties) {
if ($DataSource.Name -ne "LastCommunication") {
$DataSourceTable = [System.Collections.ArrayList]@()
foreach ($Property in $DataSource.Value.PSObject.Properties) {
[void]($DataSourceTable.Add(@{ $Property.Name = $Property.Value }))
}
$DataDisplay = New-UDTypography -Text "$($DataSource.Name) data will be displayed here."
New-UDTab -Dynamic -Text $DataSource.Name -Content {
New-UDElement -Tag div -Content {
$DataDisplay
}
}
}
}
# New-UDTab -Dynamic -Text "Other" -Content { New-UDTypography -Style @{ fontStyle = "italic" } -Text "No data to display."}
}
} -LoadingComponent {
New-UDProgress -Circular -Label "Loading Device Data..." -Size Large
}
}
When rendering the tabs within the card, however, different objects have different data source counts. If we are rendering an object with a single tab, the content within the tab doesn’t load, as per this image:
But as soon as I uncomment the line,above containing an additional New-UDTab
, the data renders as expected:
Removing the
-Dynamic
flag has no effect.
So, with that all being said, what less intrusive ways can I ensure that if a single tab is present, it will display the data in the same way? I am looking specifically for the same tab header to appear (or something that looks similar enough to it). There is another top-level property, “LastCommunication”, that is present on some devices but not all, which is conditionally filtered out but causes the $DataSources.Count
to sometimes equal 2 when there is only one tab actually being rendered.
I can account for all of these cases, but my thinking is that there has to be an easier way than a massive if/else conditional and recreating the MUI component manually through HTML for styling.
Any creative ideas?
Also, @adam, this seems to potentially be a bug? I haven’t submitted it to GH at this point as I can see an argument for restricting tab rendering behavior to only perform when multiple data sets actually need to be rendered.