controls/secretmanager-create-modal.ps1
function New-UDCreateSecretManagerModal { Show-UDModal -Width "75%" -Content { New-UDPageHeader -Text ("Create a New Secret Manager") New-UDParagraph -Text " " #Spacer New-UDTabContainer -Tabs { New-UDTab -Text 'General' -Content { New-UDParagraph -Text "General Secret Manager Settings" New-UDCard -Content { New-UDTextbox -Id "NewSecretManagerModalTextBoxName" -Label "Name" -Type text New-UDTextbox -Id "NewSecretManagerModalTextBoxDescription" -Label "Description" -Type text } } New-UDTab -Text 'ScriptBlock' -Content { New-UDElement -Tag 'div' -Attributes @{ style = @{ height = "620px" } } -Content { New-UDParagraph -Text "Script Content" New-UDCodeEditor -Id 'NewSecretManagerScriptBlockEditor' -Language 'powershell' -Code '#Enter Script Here!' -Theme 'vs-dark' -Autosize } } New-UDTab -Text "Execution Options" -Content { New-UDParagraph -Text "Execution Options" New-UDCard -Content { $PowerShellVersions = Get-UAPowerShellVersion New-UDSelect -Id "NewSecretManagerModalSelectPowerShellVersion" -Label "PowerShell Version" -Option { New-UDSelectOption -Name "Default" -Value 0 $PowerShellVersions | ForEach-Object { New-UDSelectOption -Name $_.Version -Value $_.Version } } -OnChange { } } } New-UDTab -Text 'Finalize' -Content { New-UDParagraph -Text "Secret Manager Finalization" New-UDElement -Tag div -Attributes @{ style = @{ textAlign = "right" } } -Content { New-UDButton -Text "Create Secret Manager" -Icon folder_plus -OnClick { # Get Input Data $Name = ((Get-UDElement -Id 'NewSecretManagerModalTextBoxName').Attributes["value"]) $Description = ((Get-UDElement -Id 'NewSecretManagerModalTextBoxDescription').Attributes["value"]) #$CommitMessage = ((Get-UDElement -Id 'NewSecretManagerModalTextBoxCommitMessage').Attributes["value"]) $RequiredPowerShellVersion = ((Get-UDElement -Id 'NewSecretManagerModalSelectPowerShellVersion').Attributes["value"]) $ScriptBlock = [ScriptBlock]::Create((Get-UDElement -Id 'NewSecretManagerScriptBlockEditor').Attributes["code"]) # Null Checks if ($null -eq $ScriptBlock -or $ScriptBlock -eq "" -or $ScriptBlock -eq " " -or $ScriptBlock -eq "null"){$ScriptBlock = [ScriptBlock]::Create("#Script")} #Todo Update Default Version Call $RequiredPowerShellVersion = if (!$RequiredPowerShellVersion -or $RequiredPowerShellVersion -eq "" -or $RequiredPowerShellVersion -eq "0") {$DefaultPowerShellVersion.Version} else {$RequiredPowerShellVersion} # Create SCript $NewUASecretManager = New-UASecretManager -Name $Name -Description $Description -Get ($ScriptBlock) -RequiredPowerShellVersion $RequiredPowerShellVersion # Grid Sync Sync-UDElement -Id "identity-grid" -Broadcast Sync-UDElement -Id "secretmanager-grid" -Broadcast Hide-UDModal } } } } } } |