feat: Add support for flyout menu mode in MegaMenu
- Introduced `MegaMenuMode` type and `normalizeMegaMenuMode` function to handle menu modes. - Updated `MegaMenuApplicationCustomizer` to accept `menuMode` property. - Enhanced `MegaMenuRenderer` to render flyout menus based on the selected mode. - Created new HTML previews for both flyout and mega menu modes. - Removed unused mock services and user custom action service interfaces.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[Alias('WebUrl')]
|
||||
[string]$SiteUrl,
|
||||
|
||||
[string]$TermSetName = '',
|
||||
@@ -10,6 +9,9 @@ param(
|
||||
[ValidateRange(1, 1440)]
|
||||
[int]$CacheMinutes = 15,
|
||||
|
||||
[ValidateSet('megaMenu', 'flyout')]
|
||||
[string]$MenuMode = 'megaMenu',
|
||||
|
||||
[switch]$EnableDebug,
|
||||
|
||||
[string]$Description = 'MSFT-Custom-Solution:MegaMenu'
|
||||
@@ -29,107 +31,85 @@ if (-not (Get-Command -Name Get-SPSite -ErrorAction SilentlyContinue)) {
|
||||
|
||||
$componentId = [Guid]'c0abbffb-355d-4d4e-bd38-9e15fb811506'
|
||||
$legacyComponentId = [Guid]'abc3361f-bb2d-491f-aba3-cd51c19a299b'
|
||||
$location = 'ClientSideExtension.ApplicationCustomizer'
|
||||
$configurationProperty = 'PortalSettings.MegaMenu.Configuration'
|
||||
$legacyPropertyName = 'PortalSettings.MegaMenu.Configuration'
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($TermSetId) -and [string]::IsNullOrWhiteSpace($TermSetName)) {
|
||||
throw 'Bitte TermSetId oder TermSetName angeben.'
|
||||
}
|
||||
|
||||
$properties = [string](@{
|
||||
termSetName = $TermSetName
|
||||
termSetId = $TermSetId
|
||||
termSetName = $TermSetName.Trim()
|
||||
termSetId = $TermSetId.Trim()
|
||||
cacheMinutes = $CacheMinutes
|
||||
menuMode = $MenuMode
|
||||
debug = [bool]$EnableDebug.IsPresent
|
||||
} | ConvertTo-Json -Depth 10 -Compress)
|
||||
|
||||
$site = Get-SPSite -Identity $SiteUrl
|
||||
|
||||
try {
|
||||
$rootWeb = $site.RootWeb
|
||||
$rootWeb.AllProperties[$configurationProperty] = [string]$properties
|
||||
$rootWeb.Update()
|
||||
|
||||
$siteActions = @(
|
||||
$site.UserCustomActions |
|
||||
Where-Object {
|
||||
$_.ClientSideComponentId -eq $componentId -or
|
||||
$_.ClientSideComponentId -eq $legacyComponentId
|
||||
}
|
||||
)
|
||||
|
||||
foreach ($siteAction in $siteActions) {
|
||||
$siteAction.Delete()
|
||||
@($site.UserCustomActions | Where-Object {
|
||||
$_.ClientSideComponentId -eq $componentId -or
|
||||
$_.ClientSideComponentId -eq $legacyComponentId
|
||||
}) | ForEach-Object {
|
||||
Write-Host ('Entferne alte Site-Action: ' + $_.Id)
|
||||
$_.Delete()
|
||||
}
|
||||
|
||||
$created = 0
|
||||
$updated = 0
|
||||
$removedLegacy = 0
|
||||
try {
|
||||
if ($site.RootWeb.AllProperties.ContainsKey($legacyPropertyName)) {
|
||||
$site.RootWeb.AllProperties.Remove($legacyPropertyName)
|
||||
$site.RootWeb.Update()
|
||||
Write-Host ('Alte Property-Bag-Konfiguration entfernt: ' + $legacyPropertyName)
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Warning ('Die alte Property-Bag-Konfiguration konnte nicht entfernt werden: ' + $_.Exception.Message)
|
||||
}
|
||||
|
||||
foreach ($web in $site.AllWebs) {
|
||||
try {
|
||||
$webUrl = $web.Url
|
||||
$userCustomActions = $web.UserCustomActions
|
||||
$actions = @($web.UserCustomActions | Where-Object {
|
||||
$_.ClientSideComponentId -eq $componentId -or
|
||||
$_.ClientSideComponentId -eq $legacyComponentId
|
||||
})
|
||||
|
||||
if ($null -eq $userCustomActions) {
|
||||
throw ('UserCustomActions konnten fuer das Web nicht geladen werden: ' + $webUrl)
|
||||
foreach ($action in $actions) {
|
||||
Write-Host ('Entferne alte Web-Action: ' + $webUrl + ' / ' + $action.Id)
|
||||
$action.Delete()
|
||||
}
|
||||
|
||||
$actions = @(
|
||||
$userCustomActions |
|
||||
Where-Object {
|
||||
$_.ClientSideComponentId -eq $componentId -or
|
||||
$_.ClientSideComponentId -eq $legacyComponentId
|
||||
}
|
||||
)
|
||||
|
||||
$currentAction = $actions |
|
||||
Where-Object {
|
||||
$_.ClientSideComponentId -eq $componentId
|
||||
} |
|
||||
Select-Object -First 1
|
||||
|
||||
foreach ($existingAction in $actions) {
|
||||
if ($currentAction -and $existingAction.Id -eq $currentAction.Id) {
|
||||
continue
|
||||
}
|
||||
|
||||
$existingAction.Delete()
|
||||
$removedLegacy++
|
||||
}
|
||||
|
||||
if (-not $currentAction) {
|
||||
$currentAction = $userCustomActions.Add()
|
||||
$currentAction.Name = [Guid]::NewGuid().ToString('B')
|
||||
$created++
|
||||
}
|
||||
else {
|
||||
$updated++
|
||||
}
|
||||
|
||||
$currentAction.Title = 'MegaMenu Application Customizer'
|
||||
$currentAction.Description = $Description
|
||||
$currentAction.Location = $location
|
||||
$currentAction.ClientSideComponentId = $componentId
|
||||
$currentAction.ClientSideComponentProperties = $properties
|
||||
$currentAction.Sequence = 100
|
||||
$currentAction.Update()
|
||||
$web.Update()
|
||||
|
||||
Write-Host ('MegaMenu synchronisiert: ' + $webUrl) -ForegroundColor Green
|
||||
}
|
||||
finally {
|
||||
$web.Dispose()
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host ''
|
||||
Write-Host 'MegaMenu wurde fuer die gesamte Site Collection konfiguriert.' -ForegroundColor Green
|
||||
Write-Host ('Zentrale Konfiguration: ' + $configurationProperty)
|
||||
Write-Host ('Neu registrierte Webs: ' + $created)
|
||||
Write-Host ('Aktualisierte Webs: ' + $updated)
|
||||
Write-Host ('Entfernte alte oder doppelte Registrierungen: ' + $removedLegacy)
|
||||
Write-Host ('Properties: ' + $properties)
|
||||
Write-Host 'Neue Unterwebs koennen durch erneutes Ausfuehren idempotent synchronisiert werden.' -ForegroundColor Yellow
|
||||
}
|
||||
finally {
|
||||
if ($site) {
|
||||
$site.Dispose()
|
||||
}
|
||||
$site.Dispose()
|
||||
}
|
||||
|
||||
$site = Get-SPSite -Identity $SiteUrl
|
||||
|
||||
try {
|
||||
$action = $site.UserCustomActions.Add()
|
||||
$action.Name = [Guid]::NewGuid().ToString('B')
|
||||
$action.Title = 'MegaMenu Application Customizer'
|
||||
$action.Description = $Description
|
||||
$action.Location = 'ClientSideExtension.ApplicationCustomizer'
|
||||
$action.ClientSideComponentId = $componentId
|
||||
$action.ClientSideComponentProperties = $properties
|
||||
$action.Sequence = 100
|
||||
$action.Update()
|
||||
|
||||
Write-Host ''
|
||||
Write-Host 'MegaMenu wurde zentral fuer die Site Collection registriert.' -ForegroundColor Green
|
||||
Write-Host ('Site Collection: ' + $site.Url)
|
||||
Write-Host ('Action-ID: ' + $action.Id)
|
||||
Write-Host ('Menu mode: ' + $MenuMode)
|
||||
Write-Host ('Properties: ' + $properties)
|
||||
Write-Host 'Das MegaMenu-SPFx-Paket muss im App Catalog zentral bereitgestellt sein.' -ForegroundColor Yellow
|
||||
}
|
||||
finally {
|
||||
$site.Dispose()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user