From 18391d04614040996a8e21384157a5f1d5b1bdf7 Mon Sep 17 00:00:00 2001 From: Gunjan Datta Date: Wed, 17 Dec 2025 13:30:11 -0500 Subject: [PATCH 1/2] Added new command to set RCD for a site. --- assets/function-app.ps1 | 19 +++- package.json | 2 +- .../siteAdmin/SiteAdminWebPart.manifest.json | 3 + .../webparts/siteAdmin/SiteAdminWebPart.ts | 4 + spfx/src/webparts/siteAdmin/loc/en-us.js | 1 + .../src/webparts/siteAdmin/loc/mystrings.d.ts | 1 + src/cfg.ts | 3 +- src/ds.ts | 2 + src/tabs/features.ts | 103 ++++++++++-------- src/tabs/index.ts | 33 +++--- 10 files changed, 108 insertions(+), 63 deletions(-) diff --git a/assets/function-app.ps1 b/assets/function-app.ps1 index 51bc707..10c459f 100644 --- a/assets/function-app.ps1 +++ b/assets/function-app.ps1 @@ -372,10 +372,11 @@ if ($item -ne $null) { Write-Host "Setting NoCrawl to $value..."; # See if we are setting turning it off - if($value -eq "true") { + if ($value -eq "true") { # Set the no crawl property Set-PnPWeb -NoCrawl:$true; - } else { + } + else { # Set the no crawl property Set-PnPWeb -NoCrawl:$false; } @@ -386,6 +387,20 @@ if ($item -ne $null) { # Disable custom scripts Set-PnPSite -Identity $siteUrl -NoScriptSite $true; } + "Restrict Content Discovery" { + # Log + Write-Host "Setting RestrictContentOrgWideSearch to $value..."; + + # See if we are setting turning it off + if ($value -eq "true") { + # Set the no crawl property + Set-PnPSite -Identity $siteUrl -RestrictContentOrgWideSearch:$true; + } + else { + # Set the no crawl property + Set-PnPSite -Identity $siteUrl -RestrictContentOrgWideSearch:$false; + } + } "Site Attestation" { # Log Write-Host "Setting NoScriptSite to false..."; diff --git a/package.json b/package.json index e44f2d8..e064054 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "datatables.net": "^2.3.2", "datatables.net-bs5": "^2.3.2", "dattatable": "^2.11.45", - "gd-sprest-bs": "^10.15.16", + "gd-sprest-bs": "^10.15.17", "jquery": "^3.7.1", "moment": "^2.30.1" }, diff --git a/spfx/src/webparts/siteAdmin/SiteAdminWebPart.manifest.json b/spfx/src/webparts/siteAdmin/SiteAdminWebPart.manifest.json index 0e6072d..fc2ee72 100644 --- a/spfx/src/webparts/siteAdmin/SiteAdminWebPart.manifest.json +++ b/spfx/src/webparts/siteAdmin/SiteAdminWebPart.manifest.json @@ -78,6 +78,9 @@ "SitePropNoCrawl": false, "SitePropNoCrawlDescription": "If true, content from this site collection will be excluded from search.", "SitePropNoCrawlLabel": "Remove Site From Search Results:", + "SitePropRestrictContentDiscovery": false, + "SitePropRestrictContentDiscoveryDescription": "If true, content from this site collection will be excluded from global search.", + "SitePropRestrictContentDiscoveryLabel": "Restrict Content Discovery", "SitePropSensitivityLabelId": false, "SitePropSensitivityLabelIdDescription": "Sets the default sensitivity label for this site.", "SitePropSensitivityLabelIdLabel": "Sensitivity Label:", diff --git a/spfx/src/webparts/siteAdmin/SiteAdminWebPart.ts b/spfx/src/webparts/siteAdmin/SiteAdminWebPart.ts index 10fd040..c4c6f5d 100644 --- a/spfx/src/webparts/siteAdmin/SiteAdminWebPart.ts +++ b/spfx/src/webparts/siteAdmin/SiteAdminWebPart.ts @@ -82,6 +82,9 @@ export interface ISiteAdminWebPartProps { SitePropNoCrawl: boolean; SitePropNoCrawlDescription: string; SitePropNoCrawlLabel: string; + SitePropRestrictContentDiscovery: boolean; + SitePropRestrictContentDiscoveryDescription: string; + SitePropRestrictContentDiscoveryLabel: string; SitePropSensitivityLabelId: boolean; SitePropSensitivityLabelIdDescription: string; SitePropSensitivityLabelIdLabel: string; @@ -276,6 +279,7 @@ export default class SiteAdminWebPart extends BaseClientSideWebPart { - // Set the value - this._currValues.ExcludeFromOfflineClient = item ? item.value : null; + let value = item ? true : false; + + // See if we are changing the value + if (this._currValues.DisableCompanyWideSharingLinks != value) { + // Set the value + this._requestItems.DisableCompanyWideSharingLinks = { + key: RequestTypes.DisableCompanyWideSharingLinks, + message: `The request to ${value ? "enable" : "disable"} the restriction from global search will be processed within 5 minutes.`, + value + }; + } else { + // Remove the value + delete this._requestItems.DisableCompanyWideSharingLinks; + } } - } as Components.IFormControlPropsDropdown, + } as Components.IFormControlPropsSwitch, { name: "NoCrawl", label: this._props["NoCrawl"].label, - description: "This will apply to all sites.", + description: "This will remove all content for this site from global search.", isDisabled: this._props["NoCrawl"].disabled, - type: Components.FormControlTypes.Dropdown, - items: [ - { text: "", value: "" }, - { text: "Show", value: "Show" }, - { text: "Hide", value: "Hide" } - ], + type: Components.FormControlTypes.Switch, onChange: item => { - // Set the value - this._currValues.NoCrawl = item ? item.value : null; + let value = item ? true : false; + + // See if we are changing the value + if (this._currValues.NoCrawl != value) { + // Set the value + this._requestItems.DisableCompanyWideSharingLinks = { + key: RequestTypes.NoCrawl, + message: `The request to ${value ? "hide" : "show"} content from search will be processed within 5 minutes.`, + value + }; + } else { + // Remove the value + delete this._requestItems.NoCrawl; + } } - } as Components.IFormControlPropsDropdown, + } as Components.IFormControlPropsSwitch, { name: "SocialBarOnSitePagesDisabled", label: this._props["SocialBarOnSitePagesDisabled"].label, @@ -207,7 +206,23 @@ export class FeaturesTab extends Tab<{ delete this._newValues.SocialBarOnSitePagesDisabled; } } - } as Components.IFormControlPropsSwitch + } as Components.IFormControlPropsSwitch, + { + name: "ExcludeFromOfflineClient", + label: this._props["ExcludeFromOfflineClient"].label, + description: "This will apply to all sites.", + isDisabled: this._props["ExcludeFromOfflineClient"].disabled, + type: Components.FormControlTypes.Dropdown, + items: [ + { text: "", value: "" }, + { text: "Show", value: "Show" }, + { text: "Hide", value: "Hide" } + ], + onChange: item => { + // Set the value + this._currValues.ExcludeFromOfflineClient = item ? item.value : null; + } + } as Components.IFormControlPropsDropdown ] }); } diff --git a/src/tabs/index.ts b/src/tabs/index.ts index 09938a8..afeebfe 100644 --- a/src/tabs/index.ts +++ b/src/tabs/index.ts @@ -189,24 +189,27 @@ export class Tabs { // Method to refresh the web tab refreshWebTab(url: string) { - // Show a loading dialog - LoadingDialog.setHeader("Loading Web"); - LoadingDialog.setBody("Loading the selected web..."); - LoadingDialog.show(); - // Update the requests - this._webRequests = this._webRequests.concat(this._tabWeb.getRequests()); + if (this._tabWeb) { + // Show a loading dialog + LoadingDialog.setHeader("Loading Web"); + LoadingDialog.setBody("Loading the selected web..."); + LoadingDialog.show(); - // Load the web - DataSource.loadWebInfo(url).then(() => { - // Update the tab name - this._elWebTab.innerHTML = DataSource.Site.RootWeb.Id == DataSource.Web.Id ? "Top Site" : "Sub Site"; + // Append the sub-webs + this._webRequests = this._webRequests.concat(this._tabWeb.getRequests()); - // Refresh the web tab - this._tabWeb.refresh(); + // Load the web + DataSource.loadWebInfo(url).then(() => { + // Update the tab name + this._elWebTab.innerHTML = DataSource.Site.RootWeb.Id == DataSource.Web.Id ? "Top Site" : "Sub Site"; - // Hide the loading dialog - LoadingDialog.hide(); - }); + // Refresh the web tab + this._tabWeb.refresh(); + + // Hide the loading dialog + LoadingDialog.hide(); + }); + } } } \ No newline at end of file From d792db349e4dbff10f2c21f984a5992642bff517 Mon Sep 17 00:00:00 2001 From: Gunjan Datta Date: Wed, 17 Dec 2025 13:35:24 -0500 Subject: [PATCH 2/2] Fixed the default setting for the NoCrawl property on the site features. --- src/tabs/features.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tabs/features.ts b/src/tabs/features.ts index dc4ce82..ecf6c90 100644 --- a/src/tabs/features.ts +++ b/src/tabs/features.ts @@ -170,6 +170,7 @@ export class FeaturesTab extends Tab<{ description: "This will remove all content for this site from global search.", isDisabled: this._props["NoCrawl"].disabled, type: Components.FormControlTypes.Switch, + value: this._currValues.NoCrawl, onChange: item => { let value = item ? true : false;