Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.

Commit 271dc09

Browse files
Merge pull request #1827 from SharePoint/dev
January 2019 Release
2 parents 4f339e6 + 256c87d commit 271dc09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4911
-102
lines changed
Binary file not shown.

Binaries/SharePointPnP.Modernization.Framework.xml

Lines changed: 2297 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

Binaries/release/SharePointPnP.Modernization.Framework.xml

Lines changed: 2297 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
55

66
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
77

8+
## [3.5.1901.0]
9+
10+
### Added
11+
- Added Reset-PnPFileVersion cmdlet
12+
13+
### Changed
14+
15+
- Add-PnPClientSidePageSection: Added support for section the section background of a client side page
16+
- Updated file and folder cmdlets to support special characters
17+
18+
### Deprecated
19+
20+
### Contributors
21+
- Eric Skaggs (skaggej)
22+
- Gautam Sheth (gautamdsheth)
23+
824
## [3.4.1812.0]
925

1026
### Added
@@ -455,7 +471,7 @@ jensotto
455471
**2015-09-21**
456472

457473
* Added -Parameters parameter to Apply-SPOProvisioningTemplate. See help for the cmdlet for more info.
458-
* Renamed PageUrl parameter of Webpart cmdlets to ServerRelativePageUrl. Set PageUrl as parameter alias to not break existing scripts.
474+
* Renamed PageUrl parameter of web part cmdlets to ServerRelativePageUrl. Set PageUrl as parameter alias to not break existing scripts.
459475

460476
**2015-09-17**
461477

@@ -484,7 +500,7 @@ jensotto
484500

485501
**2015-08-10**
486502

487-
* Added Get-SPOWebPartXml cmdlet to export webpart XML from a page.
503+
* Added Get-SPOWebPartXml cmdlet to export web part XML from a page.
488504

489505
**2015-08-07**
490506

@@ -595,7 +611,7 @@ still works as before.
595611

596612
**2015-01-07**
597613

598-
* Introduced new Cmdlet: Get-SPOWebPartProperty to return webpart properties
614+
* Introduced new Cmdlet: Get-SPOWebPartProperty to return web part properties
599615
* Updated Set-SPOWebPartProperty cmdlet to support int values
600616

601617
**2015-01-02**

Commands/Base/ConnectOnline.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
using SharePointPnP.PowerShell.CmdletHelpAttributes;
1+
using Microsoft.Identity.Client;
2+
using Microsoft.SharePoint.Client;
3+
using OfficeDevPnP.Core;
4+
using SharePointPnP.PowerShell.CmdletHelpAttributes;
25
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
6+
using SharePointPnP.PowerShell.Commands.Provider;
37
using System;
8+
using System.Diagnostics;
49
using System.IO;
10+
using System.Linq;
511
using System.Management.Automation;
12+
using System.Net;
13+
using System.Reflection;
614
using System.Security;
7-
using System.Linq;
8-
using Microsoft.SharePoint.Client;
9-
using OfficeDevPnP.Core;
10-
using SharePointPnP.PowerShell.Commands.Provider;
1115
using File = System.IO.File;
12-
using System.Net;
13-
using Microsoft.Identity.Client;
1416
#if NETSTANDARD2_0
1517
using System.IdentityModel.Tokens.Jwt;
1618
#endif
1719
#if !ONPREMISES
18-
using Microsoft.SharePoint.Client.CompliancePolicy;
1920
#endif
2021

2122
namespace SharePointPnP.PowerShell.Commands.Base
@@ -141,6 +142,8 @@ public class ConnectOnline : PSCmdlet
141142
private static readonly Uri GraphAADLogin = new Uri("https://login.microsoftonline.com/");
142143
private static readonly string[] GraphDefaultScope = { "https://graph.microsoft.com/.default" };
143144
#endif
145+
146+
144147
#if ONPREMISES
145148
private const string ParameterSet_HIGHTRUST_CERT = "High Trust using a X509Certificate2 object.";
146149
private const string ParameterSet_HIGHTRUST_PFX = "High Trust using a certificate from a PFX file.";
@@ -469,6 +472,12 @@ public class ConnectOnline : PSCmdlet
469472

470473
protected override void ProcessRecord()
471474
{
475+
var latestVersion = SPOnlineConnectionHelper.GetLatestVersion();
476+
if (!string.IsNullOrEmpty(latestVersion))
477+
{
478+
WriteWarning(latestVersion);
479+
}
480+
472481
if (IgnoreSslErrors)
473482
{
474483
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
@@ -756,6 +765,7 @@ private SPOnlineConnection ConnectGraphDeviceLogin(string accessToken)
756765
}
757766
}
758767

768+
759769
private void ConnectGraphAAD()
760770
{
761771
var appCredentials = new ClientCredential(AppSecret);

Commands/Base/PipeBinds/PagePipeBind.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#if !ONPREMISES
22
using Microsoft.SharePoint.Client;
3+
using OfficeDevPnP.Core.Utilities;
34
using SharePointPnP.PowerShell.Commands.ClientSidePages;
45
using System;
56
using System.Linq;
@@ -45,9 +46,10 @@ public PagePipeBind(string name)
4546
internal ListItem GetPage(Web web)
4647
{
4748
// Get pages library
48-
ListCollection listCollection = web.Lists;
49-
listCollection.EnsureProperties(coll => coll.Include(li => li.BaseTemplate));
50-
var sitePagesLibrary = listCollection.Where(p => p.BaseTemplate == (int)ListTemplateType.WebPageLibrary).FirstOrDefault();
49+
web.EnsureProperty(w => w.ServerRelativeUrl);
50+
var listServerRelativeUrl = UrlUtility.Combine(web.ServerRelativeUrl, "sitepages");
51+
var sitePagesLibrary = web.GetList(listServerRelativeUrl);
52+
5153
if (sitePagesLibrary != null)
5254
{
5355
CamlQuery query = null;

Commands/Base/SPOnlineConnectionHelper.cs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
using System.Reflection;
1818
using System.Text.RegularExpressions;
1919
using System.Diagnostics;
20-
using System.Runtime.InteropServices;
2120
using System.Net.Http;
2221
using System.Security.Cryptography.X509Certificates;
2322
using Newtonsoft.Json;
@@ -28,6 +27,14 @@ namespace SharePointPnP.PowerShell.Commands.Base
2827
{
2928
internal class SPOnlineConnectionHelper
3029
{
30+
31+
#if DEBUG
32+
private static readonly Uri VersionCheckUrl = new Uri("https://raw.githubusercontent.com/SharePoint/PnP-PowerShell/dev/version.txt");
33+
#else
34+
private static readonly Uri VersionCheckUrl = new Uri("https://raw.githubusercontent.com/SharePoint/PnP-PowerShell/master/version.txt");
35+
#endif
36+
private static bool VersionChecked;
37+
3138
#if !NETSTANDARD2_0
3239
public static AuthenticationContext AuthContext { get; set; }
3340
#endif
@@ -692,5 +699,34 @@ private static bool IsTenantAdminSite(ClientRuntimeContext clientContext)
692699
return (result);
693700
},
694701
true);
702+
703+
public static string GetLatestVersion()
704+
{
705+
try
706+
{
707+
if (!VersionChecked)
708+
{
709+
using (var client = new WebClient())
710+
{
711+
SPOnlineConnectionHelper.VersionChecked = true;
712+
var onlineVersion = client.DownloadString(VersionCheckUrl);
713+
onlineVersion = onlineVersion.Trim(new char[] { '\t', '\r', '\n' });
714+
var assembly = Assembly.GetExecutingAssembly();
715+
var currentVersion = ((AssemblyFileVersionAttribute)assembly.GetCustomAttribute(typeof(AssemblyFileVersionAttribute))).Version;
716+
if (Version.TryParse(onlineVersion, out Version availableVersion))
717+
{
718+
if (availableVersion > new Version(currentVersion))
719+
{
720+
return $"A newer version of PnP PowerShell is available: {availableVersion}. Consider upgrading.";
721+
}
722+
}
723+
SPOnlineConnectionHelper.VersionChecked = true;
724+
}
725+
}
726+
}
727+
catch
728+
{ }
729+
return null;
730+
}
695731
}
696732
}

Commands/ClientSidePages/AddClientSidePageSection.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ namespace SharePointPnP.PowerShell.Commands.ClientSidePages
2323
PS> Add-PnPClientSidePageSection -Page $page -SectionTemplate OneColumn",
2424
Remarks = "Adds a new one column section to the Client-Side page 'MyPage'",
2525
SortOrder = 3)]
26+
[CmdletExample(
27+
Code = @"PS:> $page = Add-PnPClientSidePage -Name ""MyPage""
28+
PS> Add-PnPClientSidePageSection -Page $page -SectionTemplate OneColumn -ZoneEmphasis 2",
29+
Remarks = "Adds a new one column section to the Client-Side page 'MyPage' and sets the background to 2 (0 is no background, 3 is highest emphasis)",
30+
SortOrder = 4)]
2631
public class AddClientSidePageSection : PnPWebCmdlet
2732
{
2833
[Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0, HelpMessage = "The name of the page")]
@@ -34,14 +39,17 @@ public class AddClientSidePageSection : PnPWebCmdlet
3439
[Parameter(Mandatory = false, HelpMessage = "Sets the order of the section. (Default = 1)")]
3540
public int Order = 1;
3641

42+
[Parameter(Mandatory = false, HelpMessage = "Sets the background of the section (default = 0)")]
43+
public int ZoneEmphasis = 0;
44+
3745

3846
protected override void ExecuteCmdlet()
3947
{
4048
var clientSidePage = Page?.GetPage(ClientContext);
4149

4250
if (clientSidePage != null)
4351
{
44-
clientSidePage.AddSection(SectionTemplate, Order);
52+
clientSidePage.AddSection(new CanvasSection(clientSidePage, SectionTemplate, Order) { ZoneEmphasis = ZoneEmphasis });
4553
clientSidePage.Save();
4654
}
4755
else

Commands/ClientSidePages/ConvertToClientSidePage.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using SharePointPnP.Modernization.Framework.Transform;
77
using SharePointPnP.PowerShell.Commands.Utilities;
88
using System.Reflection;
9+
using SharePointPnP.Modernization.Framework.Cache;
910

1011
namespace SharePointPnP.PowerShell.Commands.ClientSidePages
1112
{
@@ -21,6 +22,10 @@ namespace SharePointPnP.PowerShell.Commands.ClientSidePages
2122
Code = @"PS:> ConvertTo-PnPClientSidePage -Identity ""somepage.aspx"" -Overwrite -WebPartMappingFile c:\contoso\webpartmapping.xml",
2223
Remarks = "Converts a wiki page named 'somepage' to a client side page using a custom provided mapping file",
2324
SortOrder = 2)]
25+
[CmdletExample(
26+
Code = @"PS:> ConvertTo-PnPClientSidePage -Identity ""somepage.aspx"" -Overwrite -AddPageAcceptBanner",
27+
Remarks = "Converts a wiki page named 'somepage' to a client side page and adds the page accept banner web part on top of the page. This requires that the SPFX solution holding the web part (https://github.com/SharePoint/sp-dev-modernization/blob/master/Solutions/PageTransformationUI/assets/sharepointpnp-pagetransformation-client.sppkg?raw=true) has been installed to the tenant app catalog.",
28+
SortOrder = 3)]
2429
public class ConvertToClientSidePage : PnPWebCmdlet
2530
{
2631
private Assembly modernizationAssembly;
@@ -45,6 +50,12 @@ public class ConvertToClientSidePage : PnPWebCmdlet
4550
[Parameter(Mandatory = false, HelpMessage = "Adds the page accept banner web part. The actual web part is specified in webpartmapping.xml file")]
4651
public SwitchParameter AddPageAcceptBanner = false;
4752

53+
[Parameter(Mandatory = false, HelpMessage = "By default the item level permissions on a page are copied to the created client side page. Use this switch to prevent the copy.")]
54+
public SwitchParameter SkipItemLevelPermissionCopyToClientSidePage = false;
55+
56+
[Parameter(Mandatory = false, HelpMessage = "Clears the page component cache. Can be needed if you've installed a new web part to the site and want to use that in a custom webpartmapping file. Restarting your PS session has the same effect.")]
57+
public SwitchParameter ClearPageComponentCache = false;
58+
4859
protected override void ExecuteCmdlet()
4960
{
5061
string tempPath = null;
@@ -93,12 +104,19 @@ protected override void ExecuteCmdlet()
93104
Overwrite = this.Overwrite,
94105
TargetPageTakesSourcePageName = this.TakeSourcePageName,
95106
ReplaceHomePageWithDefaultHomePage = this.ReplaceHomePageWithDefault,
107+
KeepPageSpecificPermissions = !this.SkipItemLevelPermissionCopyToClientSidePage,
96108
ModernizationCenterInformation = new ModernizationCenterInformation()
97109
{
98110
AddPageAcceptBanner = this.AddPageAcceptBanner
99111
},
100112
};
101113

114+
// Clear the client side component cache
115+
if (this.ClearPageComponentCache)
116+
{
117+
CacheManager.Instance.ClearClientSideComponents();
118+
}
119+
102120
string serverRelativeClientPageUrl = pageTransformator.Transform(pti);
103121

104122
ClientSidePagePipeBind cpb = new ClientSidePagePipeBind(System.IO.Path.GetFileName(serverRelativeClientPageUrl));

0 commit comments

Comments
 (0)