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 'Get Script' -Content {
                        New-UDElement -Tag 'div' -Attributes @{
                            style = @{
                                height = "620px"
                            }
                        } -Content {
                            New-UDParagraph -Text "Get Script Content"
                            New-UDCodeEditor -Id 'NewSecretManagerGetScriptBlockEditor' -Language 'powershell' -Code '#Enter Script Here!' -Theme 'vs-dark' -Autosize
                        }
                }

                New-UDTab -Text 'Set Script' -Content {
                    New-UDElement -Tag 'div' -Attributes @{
                        style = @{
                            height = "620px"
                        }
                    } -Content {
                        New-UDParagraph -Text "Set Script Content"
                        New-UDCodeEditor -Id 'NewSecretManagerSetScriptBlockEditor' -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 "Required PowerShell Version" -Option {
                            New-UDSelectOption -Name "Default" -Value "Any"
                            $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"])
                            $RequiredPowerShellVersion = ((Get-UDElement -Id 'NewSecretManagerModalSelectPowerShellVersion').Attributes["value"])
                            $GetScriptBlock = [ScriptBlock]::Create((Get-UDElement -Id 'NewSecretManagerGetScriptBlockEditor').Attributes["code"])
                            $SetScriptBlock = [ScriptBlock]::Create((Get-UDElement -Id 'NewSecretManagerSetScriptBlockEditor').Attributes["code"])
                            
                            # Null Checks
                            if ($null -eq $GetScriptBlock -or $GetScriptBlock -eq "" -or $GetScriptBlock -eq " " -or $GetScriptBlock -eq "null"){$GetScriptBlock = [ScriptBlock]::Create("#Script")}
                            if ($null -eq $SetScriptBlock -or $SetScriptBlock -eq "" -or $SetScriptBlock -eq " " -or $SetScriptBlock -eq "null"){$SetScriptBlock = [ScriptBlock]::Create("#Script")}

                            if($RequiredPowerShellVersion -eq "Any" -or $RequiredPowerShellVersion -eq "null")
                            {
                                $RequiredPowerShellVersion = $null
                            }

                            # Create SCript
                            $NewUASecretManager = New-UASecretManager -Name $Name -Description $Description -Get ($GetScriptBlock) -Set ($SetScriptBlock) -RequiredPowerShellVersion $RequiredPowerShellVersion
                                    
                            # Grid Sync
                            Sync-UDElement -Id "SecretsGrid" -Broadcast
                            Hide-UDModal
                            
                        }
                    }
                }

        }
    }
}