From 004380d788e2272c2b8e115fc4d684301162cd37 Mon Sep 17 00:00:00 2001 From: Reshmee Auckloo Date: Wed, 28 May 2025 07:14:51 +0100 Subject: [PATCH 1/3] fix for bug #4943 --- src/Commands/Admin/UnregisterHubSite.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/Admin/UnregisterHubSite.cs b/src/Commands/Admin/UnregisterHubSite.cs index ad32a8f4d..efa5f1c5a 100644 --- a/src/Commands/Admin/UnregisterHubSite.cs +++ b/src/Commands/Admin/UnregisterHubSite.cs @@ -26,7 +26,7 @@ protected override void ExecuteCmdlet() } else { - props = hubSitesProperties.Single(h => h.SiteUrl.Equals(Site.Url, StringComparison.OrdinalIgnoreCase)); + props = hubSitesProperties.Single(h => !string.IsNullOrEmpty(h.SiteUrl) && h.SiteUrl.Equals(Site.Url, StringComparison.OrdinalIgnoreCase)); } Tenant.UnregisterHubSiteById(props.ID); AdminContext.ExecuteQueryRetry(); From 01ebf1e57baf25278d2d62646c33cac35b88d583 Mon Sep 17 00:00:00 2001 From: Reshmee Auckloo Date: Wed, 16 Jul 2025 19:47:22 +0100 Subject: [PATCH 2/3] fix for bug 4827 --- src/Commands/Admin/SetHomeSite.cs | 68 +++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/src/Commands/Admin/SetHomeSite.cs b/src/Commands/Admin/SetHomeSite.cs index 549fbb8eb..085e5b8b8 100644 --- a/src/Commands/Admin/SetHomeSite.cs +++ b/src/Commands/Admin/SetHomeSite.cs @@ -27,6 +27,49 @@ public class SetHomeSite : PnPSharePointOnlineAdminCmdlet protected override void ExecuteCmdlet() { Tenant.EnsureProperties(t => t.IsMultipleVivaConnectionsFlightEnabled, t => t.IsVivaHomeFlightEnabled); + HomeSiteConfigurationParam configurationParam; + + bool hasVivaConnectionsDefaultStart = ParameterSpecified(nameof(VivaConnectionsDefaultStart)); + bool hasDraftMode = ParameterSpecified(nameof(DraftMode)); + + if (hasVivaConnectionsDefaultStart && hasDraftMode) + { + configurationParam = new() + { + vivaConnectionsDefaultStart = VivaConnectionsDefaultStart, + IsVivaConnectionsDefaultStartPresent = true, + isInDraftMode = DraftMode, + IsInDraftModePresent = true + }; + } + else if (hasVivaConnectionsDefaultStart) + { + configurationParam = new() + { + vivaConnectionsDefaultStart = VivaConnectionsDefaultStart, + IsVivaConnectionsDefaultStartPresent = true + }; + } + else if (hasDraftMode) + { + configurationParam = new() + { + isInDraftMode = DraftMode, + IsInDraftModePresent = true + }; + } + else if (ParameterSpecified(nameof(DraftMode))) + { + configurationParam = new() + { + isInDraftMode = DraftMode, + IsInDraftModePresent = true + }; + } + else + { + configurationParam = null; + } if (Tenant.IsMultipleVivaConnectionsFlightEnabled) { @@ -34,12 +77,10 @@ protected override void ExecuteCmdlet() { IEnumerable enumerable = Tenant.GetTargetedSitesDetails()?.Where((TargetedSiteDetails hs) => !hs.IsVivaBackendSite); AdminContext.ExecuteQueryRetry(); - bool flag = false; if (enumerable == null || enumerable.Count() == 0) { Tenant.AddHomeSite(HomeSiteUrl, 1, null); AdminContext.ExecuteQueryRetry(); - flag = true; } else if (enumerable.Count() == 1 && !IsSameSiteUrl(enumerable.First().Url, HomeSiteUrl)) { @@ -47,16 +88,10 @@ protected override void ExecuteCmdlet() AdminContext.ExecuteQueryRetry(); Tenant.AddHomeSite(HomeSiteUrl, 1, null); AdminContext.ExecuteQueryRetry(); - flag = true; } - HomeSiteConfigurationParam configurationParam = new() - { - vivaConnectionsDefaultStart = VivaConnectionsDefaultStart, - IsVivaConnectionsDefaultStartPresent = VivaConnectionsDefaultStart, - isInDraftMode = DraftMode, - IsInDraftModePresent = DraftMode || flag - }; + ClientResult clientResult = Tenant.UpdateTargetedSite(HomeSiteUrl, configurationParam); + AdminContext.ExecuteQueryRetry(); WriteObject(clientResult.Value); } @@ -64,18 +99,7 @@ protected override void ExecuteCmdlet() else if (Force || ShouldContinue("Before you set a Home site, make sure you review the documentation at https://aka.ms/homesites.", Properties.Resources.Confirm)) { Tenant.ValidateVivaHomeParameterExists(VivaConnectionsDefaultStart); - HomeSiteConfigurationParam configuration = null; - if (VivaConnectionsDefaultStart || DraftMode) - { - configuration = new HomeSiteConfigurationParam - { - vivaConnectionsDefaultStart = VivaConnectionsDefaultStart, - IsVivaConnectionsDefaultStartPresent = VivaConnectionsDefaultStart, - isInDraftMode = DraftMode, - IsInDraftModePresent = DraftMode - }; - } - ClientResult clientResult = Tenant.SetSPHSiteWithConfiguration(HomeSiteUrl, configuration); + ClientResult clientResult = Tenant.SetSPHSiteWithConfiguration(HomeSiteUrl, configurationParam); AdminContext.ExecuteQueryRetry(); WriteObject(clientResult.Value); } From 84436d61615555dd7bd134afea99986e93f912a5 Mon Sep 17 00:00:00 2001 From: Reshmee Auckloo Date: Thu, 17 Jul 2025 20:06:58 +0100 Subject: [PATCH 3/3] refactor code --- src/Commands/Admin/SetHomeSite.cs | 47 +++++++++---------------------- 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/src/Commands/Admin/SetHomeSite.cs b/src/Commands/Admin/SetHomeSite.cs index 085e5b8b8..1cf65a227 100644 --- a/src/Commands/Admin/SetHomeSite.cs +++ b/src/Commands/Admin/SetHomeSite.cs @@ -32,43 +32,22 @@ protected override void ExecuteCmdlet() bool hasVivaConnectionsDefaultStart = ParameterSpecified(nameof(VivaConnectionsDefaultStart)); bool hasDraftMode = ParameterSpecified(nameof(DraftMode)); - if (hasVivaConnectionsDefaultStart && hasDraftMode) - { - configurationParam = new() - { - vivaConnectionsDefaultStart = VivaConnectionsDefaultStart, - IsVivaConnectionsDefaultStartPresent = true, - isInDraftMode = DraftMode, - IsInDraftModePresent = true - }; - } - else if (hasVivaConnectionsDefaultStart) - { - configurationParam = new() - { - vivaConnectionsDefaultStart = VivaConnectionsDefaultStart, - IsVivaConnectionsDefaultStartPresent = true - }; - } - else if (hasDraftMode) + // Replace the current configurationParam assignment block with the following: + + configurationParam = null; + if (hasVivaConnectionsDefaultStart || hasDraftMode) { - configurationParam = new() + configurationParam = new(); + if (hasVivaConnectionsDefaultStart) { - isInDraftMode = DraftMode, - IsInDraftModePresent = true - }; - } - else if (ParameterSpecified(nameof(DraftMode))) - { - configurationParam = new() + configurationParam.vivaConnectionsDefaultStart = VivaConnectionsDefaultStart; + configurationParam.IsVivaConnectionsDefaultStartPresent = true; + } + if (hasDraftMode) { - isInDraftMode = DraftMode, - IsInDraftModePresent = true - }; - } - else - { - configurationParam = null; + configurationParam.isInDraftMode = DraftMode; + configurationParam.IsInDraftModePresent = true; + } } if (Tenant.IsMultipleVivaConnectionsFlightEnabled)