From 9dc7581a774a5ad8d9cee1705872a51c9d594ecd Mon Sep 17 00:00:00 2001 From: Gautam Sheth Date: Thu, 29 Jun 2023 22:16:49 +0300 Subject: [PATCH] Feature: add ListsShowHeaderAndNavigation property to PnPTenantSite and PnPSite cmdlets --- documentation/Set-PnPSite.md | 15 +++++++++++++++ documentation/Set-PnPTenantSite.md | 15 +++++++++++++++ src/Commands/Admin/SetTenantSite.cs | 9 +++++++++ src/Commands/Base/ConnectOnline.cs | 2 +- src/Commands/Site/SetSite.cs | 12 +++++++++++- 5 files changed, 51 insertions(+), 2 deletions(-) diff --git a/documentation/Set-PnPSite.md b/documentation/Set-PnPSite.md index c5c7e213f..6ac4b9a3d 100644 --- a/documentation/Set-PnPSite.md +++ b/documentation/Set-PnPSite.md @@ -46,6 +46,7 @@ Set-PnPSite [-Identity ] [-ScriptSafeDomainName ] [-BlockDownloadPolicy ] [-ExcludeBlockDownloadPolicySiteOwners ] [-ExcludedBlockDownloadGroupIds ] + [-ListsShowHeaderAndNavigation ] [-Connection ] ``` @@ -584,6 +585,20 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -ListsShowHeaderAndNavigation +Set a property on a site collection to make all lists always load with the site elements intact. + +```yaml +Type: Boolean +Parameter Sets: Set Properties + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Wait Wait for the operation to complete diff --git a/documentation/Set-PnPTenantSite.md b/documentation/Set-PnPTenantSite.md index 43e656c27..4e568a964 100644 --- a/documentation/Set-PnPTenantSite.md +++ b/documentation/Set-PnPTenantSite.md @@ -36,6 +36,7 @@ Set-PnPTenantSite [-Identity] [-Title ] [-LocaleId ] [- [-MediaTranscription ] [-BlockDownloadPolicy ] [-ExcludeBlockDownloadPolicySiteOwners ] [-ExcludedBlockDownloadGroupIds ] + [-ListsShowHeaderAndNavigation ] [-Wait] [-Connection ] ``` @@ -722,6 +723,20 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -ListsShowHeaderAndNavigation +Set a property on a site collection to make all lists always load with the site elements intact. + +```yaml +Type: Boolean +Parameter Sets: Set Properties + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Wait Wait for the operation to complete diff --git a/src/Commands/Admin/SetTenantSite.cs b/src/Commands/Admin/SetTenantSite.cs index 01273fbe3..3421bf524 100644 --- a/src/Commands/Admin/SetTenantSite.cs +++ b/src/Commands/Admin/SetTenantSite.cs @@ -174,6 +174,9 @@ public class SetTenantSite : PnPAdminCmdlet [Parameter(Mandatory = false, ParameterSetName = ParameterSet_PROPERTIES)] public Guid[] ExcludedBlockDownloadGroupIds; + [Parameter(Mandatory = false, ParameterSetName = ParameterSet_PROPERTIES)] + public bool? ListsShowHeaderAndNavigation; + [Parameter(Mandatory = false)] public SwitchParameter Wait; @@ -528,6 +531,12 @@ private void SetSiteProperties(Func timeoutFunctio updateRequired = true; } + if (ParameterSpecified(nameof(ListsShowHeaderAndNavigation)) && ListsShowHeaderAndNavigation.HasValue) + { + props.ListsShowHeaderAndNavigation = ListsShowHeaderAndNavigation.Value; + updateRequired = true; + } + if (updateRequired) { var op = props.Update(); diff --git a/src/Commands/Base/ConnectOnline.cs b/src/Commands/Base/ConnectOnline.cs index 5c2f9714f..0188b7571 100644 --- a/src/Commands/Base/ConnectOnline.cs +++ b/src/Commands/Base/ConnectOnline.cs @@ -723,7 +723,7 @@ private static bool PingHost(string nameOrAddress) } return false; } - catch(Exception ex) + catch { return false; } diff --git a/src/Commands/Site/SetSite.cs b/src/Commands/Site/SetSite.cs index 90f0f6e01..9e6043da0 100644 --- a/src/Commands/Site/SetSite.cs +++ b/src/Commands/Site/SetSite.cs @@ -121,6 +121,9 @@ public class SetSite : PnPSharePointCmdlet [Parameter(Mandatory = false, ParameterSetName = ParameterSet_PROPERTIES)] public Guid[] ExcludedBlockDownloadGroupIds; + [Parameter(Mandatory = false, ParameterSetName = ParameterSet_PROPERTIES)] + public bool? ListsShowHeaderAndNavigation; + [Parameter(Mandatory = false, ParameterSetName = ParameterSet_LOCKSTATE)] public SwitchParameter Wait; @@ -397,6 +400,12 @@ protected override void ExecuteCmdlet() executeQueryRequired = true; } + if (ParameterSpecified(nameof(ListsShowHeaderAndNavigation)) && ListsShowHeaderAndNavigation.HasValue) + { + siteProperties.ListsShowHeaderAndNavigation = ListsShowHeaderAndNavigation.Value; + executeQueryRequired = true; + } + if (executeQueryRequired) { siteProperties.Update(); @@ -451,6 +460,7 @@ private bool IsTenantProperty() => RequestFilesLinkEnabled.HasValue || BlockDownloadPolicy.HasValue || ExcludeBlockDownloadPolicySiteOwners.HasValue || - ParameterSpecified(nameof(ExcludedBlockDownloadGroupIds)); + ParameterSpecified(nameof(ExcludedBlockDownloadGroupIds)) || + ListsShowHeaderAndNavigation.HasValue; } }