Files
CurrentNavigation/deployment/add-currentnavigation.ps1
T
Torsten Brendgen 0a3219117a Add Current Navigation Application Customizer
- Created a new SPFx Application Customizer for current navigation.
- Implemented core functionality to fetch and render navigation items from a SharePoint term set.
- Added styles for the navigation component using SCSS.
- Included localization support for English and German languages.
- Developed unit tests for core navigation functionalities.
- Configured TypeScript and TSLint settings for the project.
- Added validation scripts for static assets and package configuration.
2026-08-18 17:13:35 +02:00

59 lines
2.7 KiB
PowerShell

param(
[Parameter(Mandatory = $true)][string]$SiteUrl,
[Parameter(Mandatory = $true)][string]$TermSetId,
[int]$CacheMinutes = 15,
[string]$CacheVersion = '1',
[ValidateRange(1, 8)][int]$MaxDepth = 3,
[switch]$ShowRoot,
[switch]$EnableDebug
)
if (-not (Get-Command -Name Get-SPSite -ErrorAction SilentlyContinue)) {
if (Get-Module -ListAvailable -Name Microsoft.SharePoint.PowerShell) {
Import-Module Microsoft.SharePoint.PowerShell -DisableNameChecking
} elseif (Get-PSSnapin -Registered -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) {
Add-PSSnapin Microsoft.SharePoint.PowerShell
} else { throw 'Bitte in der SharePoint Management Shell ausführen.' }
}
$componentId = [Guid]'e37b828f-4315-461a-b1b0-fcf991deda3d'
$parsedTermSetId = [Guid]::Empty
if (-not [Guid]::TryParse($TermSetId, [ref]$parsedTermSetId)) { throw 'TermSetId ist keine gültige GUID.' }
$properties = @{
schemaVersion = 1
portalSettings = @{ providerKey = 'currentnavigation'; contractVersion = 1; minimumPortalSettingsVersion = '3.1.0' }
termSetId = $parsedTermSetId.ToString()
termSetName = ''
cacheMinutes = [Math]::Min([Math]::Max($CacheMinutes, 1), 1440)
cacheVersion = $(if ([string]::IsNullOrWhiteSpace($CacheVersion)) { '1' } else { $CacheVersion.Trim() })
maxDepth = $MaxDepth
showRoot = [bool]$ShowRoot.IsPresent
debug = [bool]$EnableDebug.IsPresent
}
$site = Get-SPSite -Identity $SiteUrl
try {
$actions = @($site.UserCustomActions | Where-Object {
$_.Location -eq 'ClientSideExtension.ApplicationCustomizer' -and $_.ClientSideComponentId -eq $componentId
})
$action = $actions | Select-Object -First 1
if (-not $action) { $action = $site.UserCustomActions.Add() }
$action.Name = 'CurrentNavigation'
$action.Title = 'Current Navigation Application Customizer'
$action.Description = 'MSFT-Custom-Solution:CurrentNavigation'
$action.Location = 'ClientSideExtension.ApplicationCustomizer'
$action.Sequence = 110
$action.ClientSideComponentId = $componentId
$action.ClientSideComponentProperties = $properties | ConvertTo-Json -Depth 10 -Compress
$action.Update()
@($actions | Select-Object -Skip 1) | ForEach-Object { $_.Delete() }
foreach ($web in $site.AllWebs) {
try {
@($web.UserCustomActions | Where-Object {
$_.Location -eq 'ClientSideExtension.ApplicationCustomizer' -and $_.ClientSideComponentId -eq $componentId
}) | ForEach-Object { $_.Delete() }
} finally { $web.Dispose() }
}
Write-Host 'CurrentNavigation wurde für die Site Collection registriert.' -ForegroundColor Green
} finally { if ($site) { $site.Dispose() } }