controls/powershell-verison-edit-modal.ps1
function New-UDEditPowerShellVersionModal { param ( [Parameter(Mandatory = $true)] $PowerShellVersion ) Show-UDModal -Width "50%" -Content { New-UDPageHeader -Text ("Edit PowerShell Version") New-UDParagraph -Text "Updating PowerShell Version: $($PowerShellVersion.Version)" New-UDTextbox -Id "EditPowerShellVersionTextBoxVersion" -Label "Version" -Type text -Value $PowerShellVersion.Version New-UDTextbox -Id "EditPowerShellVersionTextBoxPath" -Label "Path" -Type text -Value $PowerShellVersion.Path New-UDTextbox -Id "EditPowerShellVersionTextBoxArguments" -Label "Arguments" -Type text -Value $PowerShellVersion.Arguments New-UDElement -Tag div -Attributes @{ style = @{ textAlign = "right" } } -Content { New-UDButton -Text "Edit PowerShell Version" -Icon edit -OnClick { # Get Input Data $Version = ((Get-UDElement -Id 'EditPowerShellVersionTextBoxVersion').Attributes["value"]) $Path = ((Get-UDElement -Id 'EditPowerShellVersionTextBoxPath').Attributes["value"]) $Arguments = ((Get-UDElement -Id 'EditPowerShellVersionTextBoxArguments').Attributes["value"]) # Null Checks $Arguments = if (!$Arguments -or $Arguments -eq "" -or $Arguments -eq "null") {""} else { $Arguments } #TODO Validation! # IF BAD # TOAST ERROR # QUIT # IF OK - Continue # Update Script $PowerShellVersion | Set-UAPowerShellVersion -Version $Version -Path $Path -Arguments $Arguments # Grid Sync Sync-UDElement -Id "PowerShellVersionsGrid" -Broadcast Hide-UDModal } } } } |