Closed donlent closed 1 month ago
This is by design. The main script only runs on app startup so there are no roles defined.
Use -LoadNavigation to work around this.
https://docs.powershelluniversal.com/userinterfaces/components/pages#dynamic-navigation
$LoadNavigation = {
if ($Roles -contains "User") {
$Navigation = @(
New-UDListItem -Label "Home" -Href '/Home' -Icon (New-UDIcon -Icon "home" -Size lg)
New-UDListItem -Label "My Connections" -Href '/My-Connections' -Icon (New-UDIcon -Icon "network-wired" -Size lg)
)
}
if ($Roles -contains "Admin") {
$Navigation += @(
New-UDListItem -Label "Administration" -Icon (New-UDIcon -Icon "gears" -Size lg) -Children {
New-UDListItem -Label "Customers" -Href '/Customers' -Icon (New-UDIcon -Icon "id-card-clip" -Size lg -Style @{"padding-left" = "15px" } )
New-UDListItem -Label "Workloads" -Href '/Workloads' -Icon (New-UDIcon -Icon "desktop" -Size lg -Style @{"padding-left" = "15px" } )
}
New-UDListItem -Label "Logs" -Icon (New-UDIcon -Icon "file-lines" -Size lg) -Children {
New-UDListItem -Label "Management Logs" -Href '/ManagementLogs' -Icon (New-UDIcon -Icon "file-shield" -Size lg -Style @{"padding-left" = "15px" } )
New-UDListItem -Label "Customer Activity Logs" -Href '/CustomerActivityLogs' -Icon (New-UDIcon -Icon "clock-rotate-left" -Size lg -Style @{"padding-left" = "15px" } )
}
)
}
$Navigation
}
$Pages = @(
Get-UDPage -Name "Home"
Get-UDPage -Name "My Connections"
Get-UDPage -Name 'Administration'
Get-UDPage -Name 'Customers'
Get-UDPage -Name 'Workloads'
Get-UDPage -Name 'ManagementLogs'
Get-UDPage -Name 'CustomerActivityLogs'
)
New-UDApp -Title 'Test' -Pages $Pages -Theme $Theme -LoadNavigation $LoadNavigation
Thank you so much @adamdriscoll !! :-D
Version
4.3.2
Severity
High
Environment
msi
Steps to Reproduce
Expected behavior
Actual behavior
Additional Environment data
No response
Screenshots/Animations
No response