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

Commit

Permalink
Merge pull request #2325 from SharePoint/dev
Browse files Browse the repository at this point in the history
October 2019 Intermediate Release 1
  • Loading branch information
erwinvanhunen authored Oct 22, 2019
2 parents 0e128ea + dd0ee53 commit e062ec4
Show file tree
Hide file tree
Showing 13 changed files with 280 additions and 27 deletions.
Binary file modified Binaries/SharePointPnP.Modernization.Framework.dll
Binary file not shown.
9 changes: 8 additions & 1 deletion Binaries/SharePointPnP.Modernization.Framework.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Binaries/release/SharePointPnP.Modernization.Framework.dll
Binary file not shown.
9 changes: 8 additions & 1 deletion Binaries/release/SharePointPnP.Modernization.Framework.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ All notable changes to this project will be documented in this file.

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

## [Unreleased]

### Added

### Changed

### Contributors

## [3.14.1910.1]

### Added

- ConvertTo-PnPClientSidePage: Added support for logging to console via `-LogType Console`
- Copy-PnPFile: Fixes (#2300)
- ConvertTo-PnPClientSidePage: Added support for controlling the target page name is any cross site transformation (so wiki, web part, blog in addition the already existing option for publishing pages) via the `-TargetPageName` parameter

### Changed

### Contributors

## [3.14.1910.0]

### Added
Expand All @@ -18,6 +38,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Changed

- Several documentation fixes
- Add-PnPClientSideWebPart now also works for SP2019
- Added -List parameter to Get-PnPFolder to retrieve all folders in a list
- Added owner paramter to New-PnPSite when create Communications site
Expand All @@ -28,11 +49,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Contributors

- Aleksandr SaPozhkov [shurick81]
- Garry Trinder [garrytrinder]
- Koen Zomers [KoenZomers]
- Gautam Sheth [gautamdsheth]
- Giacomo Pozzoni [jackpoz]
- Paul Bullock [pkbullock]
- Andres Mariano Gorzelany [get-itips]

## [3.13.1909.0]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public enum ClientSidePageTransformatorLogType
None = 0,
File = 1,
SharePoint = 2,
Console = 3,
}
}
#endif
41 changes: 31 additions & 10 deletions Commands/ClientSidePages/ConvertToClientSidePage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ namespace SharePointPnP.PowerShell.Commands.ClientSidePages
Category = CmdletHelpCategory.ClientSidePages, SupportedPlatform = CmdletSupportedPlatform.Online)]
[CmdletExample(
Code = @"PS:> ConvertTo-PnPClientSidePage -Identity ""somepage.aspx"" -Overwrite",
Remarks = "Converts a wiki page named 'somepage' to a client side page",
Remarks = "Converts a wiki/web part page named 'somepage' to a client side page",
SortOrder = 1)]
[CmdletExample(
Code = @"PS:> ConvertTo-PnPClientSidePage -Identity ""somepage.aspx"" -Overwrite -WebPartMappingFile c:\contoso\webpartmapping.xml",
Remarks = "Converts a wiki page named 'somepage' to a client side page using a custom provided mapping file",
Remarks = "Converts a wiki/web part page named 'somepage' to a client side page using a custom provided mapping file",
SortOrder = 2)]
[CmdletExample(
Code = @"PS:> ConvertTo-PnPClientSidePage -Identity ""somepage.aspx"" -Overwrite -AddPageAcceptBanner",
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",
Remarks = "Converts a wiki/web part 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",
SortOrder = 3)]
[CmdletExample(
Code = @"PS:> ConvertTo-PnPClientSidePage -Identity ""somepage.aspx"" -Overwrite -CopyPageMetadata",
Remarks = "Converts a wiki page named 'somepage' to a client side page, including the copying of the page metadata (if any)",
Remarks = "Converts a wiki/web part page named 'somepage' to a client side page, including the copying of the page metadata (if any)",
SortOrder = 4)]
[CmdletExample(
Code = @"PS:> ConvertTo-PnPClientSidePage -Identity ""somepage.aspx"" -PublishingPage -Overwrite -TargetWebUrl https://contoso.sharepoint.com/sites/targetmodernsite",
Expand All @@ -55,16 +55,20 @@ namespace SharePointPnP.PowerShell.Commands.ClientSidePages
SortOrder = 8)]
[CmdletExample(
Code = @"PS:> ConvertTo-PnPClientSidePage -Identity ""somepage.aspx"" -Overwrite -TargetWebUrl https://contoso.sharepoint.com/sites/targetmodernsite",
Remarks = "Converts a wiki page named 'somepage' to a client side page in the https://contoso.sharepoint.com/sites/targetmodernsite site",
Remarks = "Converts a wiki/web part page named 'somepage' to a client side page in the https://contoso.sharepoint.com/sites/targetmodernsite site",
SortOrder = 9)]
[CmdletExample(
Code = @"PS:> ConvertTo-PnPClientSidePage -Identity ""somepage.aspx"" -LogType File -LogFolder c:\temp -LogVerbose -Overwrite",
Remarks = "Converts a web part page named 'somepage' and creates a log file in c:\\temp using verbose logging",
Remarks = "Converts a wiki/web part page named 'somepage' and creates a log file in c:\\temp using verbose logging",
SortOrder = 10)]
[CmdletExample(
Code = @"PS:> ConvertTo-PnPClientSidePage -Identity ""somepage.aspx"" -LogType SharePoint -LogSkipFlush",
Remarks = "Converts a web part page named 'somepage' and creates a log file in SharePoint but skip the actual write. Use this option to make multiple ConvertTo-PnPClientSidePage invocations create a single log",
Remarks = "Converts a wiki/web part page named 'somepage' and creates a log file in SharePoint but skip the actual write. Use this option to make multiple ConvertTo-PnPClientSidePage invocations create a single log",
SortOrder = 11)]
[CmdletExample(
Code = @"PS:> ConvertTo-PnPClientSidePage -Identity ""My post title"" -BlogPage -LogType Console -Overwrite -TargetWebUrl https://contoso.sharepoint.com/sites/targetmodernsite",
Remarks = "Converts a blog page with a title starting with 'my post title' to a client side page in the https://contoso.sharepoint.com/sites/targetmodernsite site",
SortOrder = 12)]
public class ConvertToClientSidePage : PnPWebCmdlet
{
private static string rootFolder = "<root>";
Expand Down Expand Up @@ -165,6 +169,9 @@ public class ConvertToClientSidePage : PnPWebCmdlet
[Parameter(Mandatory = false, HelpMessage = "Name for the target page (only applies to publishing page transformation)")]
public string PublishingTargetPageName = "";

[Parameter(Mandatory = false, HelpMessage = "Name for the target page (only applies when doing cross site page transformation)")]
public string TargetPageName = "";

[Parameter(Mandatory = false, HelpMessage = "Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.")] // do not remove '#!#99'
public SPOnlineConnection TargetConnection = null;

Expand Down Expand Up @@ -246,6 +253,8 @@ protected override void ExecuteCmdlet()
throw new Exception($"Provided pagelayout mapping file {this.PageLayoutMapping} does not exist");
}

bool crossSiteTransformation = TargetConnection != null || !string.IsNullOrEmpty(TargetWebUrl);

// Create target client context (when needed)
ClientContext targetContext = null;
if (TargetConnection == null)
Expand Down Expand Up @@ -337,6 +346,17 @@ protected override void ExecuteCmdlet()
pageTransformator.RegisterObserver(new MarkdownToSharePointObserver(targetContext ?? this.ClientContext, includeVerbose: this.LogVerbose, includeDebugEntries: this.LogVerbose));
}
}
else if (this.LogType == ClientSidePageTransformatorLogType.Console)
{
if (this.PublishingPage)
{
publishingPageTransformator.RegisterObserver(new ConsoleObserver(includeDebugEntries: this.LogVerbose));
}
else
{
pageTransformator.RegisterObserver(new ConsoleObserver(includeDebugEntries: this.LogVerbose));
}
}

// Clear the client side component cache
if (this.ClearCache)
Expand All @@ -356,7 +376,7 @@ protected override void ExecuteCmdlet()
KeepPageCreationModificationInformation = this.KeepPageCreationModificationInformation,
PostAsNews = this.PostAsNews,
DisablePageComments = this.DisablePageComments,
TargetPageName = this.PublishingTargetPageName,
TargetPageName = !string.IsNullOrEmpty(this.PublishingTargetPageName) ? this.PublishingTargetPageName : this.TargetPageName,
SkipUrlRewrite = this.SkipUrlRewriting,
SkipDefaultUrlRewrite = this.SkipDefaultUrlRewriting,
UrlMappingFile = this.UrlMappingFile,
Expand All @@ -374,7 +394,7 @@ protected override void ExecuteCmdlet()
finally
{
// Flush log
if (this.LogType != ClientSidePageTransformatorLogType.None && !this.LogSkipFlush)
if (this.LogType != ClientSidePageTransformatorLogType.None && this.LogType != ClientSidePageTransformatorLogType.Console && !this.LogSkipFlush)
{
publishingPageTransformator.FlushObservers();
}
Expand Down Expand Up @@ -406,6 +426,7 @@ protected override void ExecuteCmdlet()
SetAuthorInPageHeader = this.SetAuthorInPageHeader,
PostAsNews = this.PostAsNews,
DisablePageComments = this.DisablePageComments,
TargetPageName = crossSiteTransformation ? this.TargetPageName : "",
SkipUrlRewrite = this.SkipUrlRewriting,
SkipDefaultUrlRewrite = this.SkipDefaultUrlRewriting,
UrlMappingFile = this.UrlMappingFile,
Expand All @@ -427,7 +448,7 @@ protected override void ExecuteCmdlet()
finally
{
// Flush log
if (this.LogType != ClientSidePageTransformatorLogType.None && !this.LogSkipFlush)
if (this.LogType != ClientSidePageTransformatorLogType.None && this.LogType != ClientSidePageTransformatorLogType.Console && !this.LogSkipFlush)
{
pageTransformator.FlushObservers();
}
Expand Down
2 changes: 1 addition & 1 deletion Commands/ClientSidePages/ExportClientSidePage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected override void ProcessRecord()
private void ExtractTemplate(string dirName, string fileName, ExtractConfiguration configuration)
{
var outputTemplate = new ProvisioningTemplate();
outputTemplate.Id = Guid.NewGuid().ToString("N");
outputTemplate.Id = $"TEMPLATE-{Guid.NewGuid():N}".ToUpper();
var helper = new OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.Utilities.ClientSidePageContentsHelper();
ProvisioningTemplateCreationInformation ci = null;
if (configuration != null)
Expand Down
25 changes: 17 additions & 8 deletions Commands/Files/CopyFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ protected override void ExecuteCmdlet()
file = _sourceContext.Web.GetFileByServerRelativePath(ResourcePath.FromDecodedUrl(SourceUrl));
#endif
file.EnsureProperties(f => f.Name, f => f.Exists);
isFile = file.Exists;
}
catch
{
Expand Down Expand Up @@ -168,17 +169,17 @@ protected override void ExecuteCmdlet()

_targetContext = ClientContext.Clone(targetWebUri.AbsoluteUri);
var dstWeb = _targetContext.Web;
dstWeb.EnsureProperty(s => s.Url);
dstWeb.EnsureProperties(s => s.Url, s => s.ServerRelativeUrl);
if (srcWeb.Url == dstWeb.Url)
{
try
{
var targetFile = UrlUtility.Combine(TargetUrl, file.Name);
var targetFile = UrlUtility.Combine(TargetUrl, file?.Name);
// If src/dst are on the same Web, then try using CopyTo - backwards compability
#if ONPREMISES
file.CopyTo(targetFile, OverwriteIfAlreadyExists);
file?.CopyTo(targetFile, OverwriteIfAlreadyExists);
#else
file.CopyToUsingPath(ResourcePath.FromDecodedUrl(targetFile), OverwriteIfAlreadyExists);
file?.CopyToUsingPath(ResourcePath.FromDecodedUrl(targetFile), OverwriteIfAlreadyExists);
#endif
_sourceContext.ExecuteQueryRetry();
return;
Expand All @@ -196,11 +197,15 @@ protected override void ExecuteCmdlet()
bool targetFolderExists = false;
try
{
#if ONPREMISES
targetFolder = _targetContext.Web.GetFolderByServerRelativeUrl(TargetUrl);
#else
targetFolder = _targetContext.Web.GetFolderByServerRelativePath(ResourcePath.FromDecodedUrl(TargetUrl));
#endif
#if !SP2013
targetFolder.EnsureProperties(f => f.Name, f => f.Exists);
if (!targetFolder.Exists) throw new Exception("TargetUrl is an existing file, not folder");
targetFolderExists = true;
targetFolderExists = true;
#else
targetFolder.EnsureProperties(f => f.Name);
try
Expand All @@ -226,8 +231,12 @@ protected override void ExecuteCmdlet()
foreach (List targetList in lists)
{
if (!TargetUrl.StartsWith(targetList.RootFolder.ServerRelativeUrl, StringComparison.InvariantCultureIgnoreCase)) continue;
fileOrFolderName = Regex.Replace(TargetUrl, targetList.RootFolder.ServerRelativeUrl, "", RegexOptions.IgnoreCase).Trim('/');
targetFolder = srcIsFolder ? targetList.RootFolder.EnsureFolder(fileOrFolderName) : targetList.RootFolder;
fileOrFolderName = Regex.Replace(TargetUrl, _targetContext.Web.ServerRelativeUrl, "", RegexOptions.IgnoreCase).Trim('/');
targetFolder = srcIsFolder
? _targetContext.Web.EnsureFolderPath(fileOrFolderName)
: targetList.RootFolder;
//fileOrFolderName = Regex.Replace(TargetUrl, targetList.RootFolder.ServerRelativeUrl, "", RegexOptions.IgnoreCase).Trim('/');
//targetFolder = srcIsFolder ? targetList.RootFolder.EnsureFolder(fileOrFolderName) : targetList.RootFolder;
break;
}
}
Expand Down Expand Up @@ -310,7 +319,7 @@ private File UploadFileWithSpecialCharacters(Folder folder, string fileName, Sys
{
throw new ArgumentException("Filename is required");
}

// Create the file
var newFileInfo = new FileCreationInformation()
{
Expand Down
4 changes: 2 additions & 2 deletions Commands/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.14.1910.0")]
[assembly: AssemblyFileVersion("3.14.1910.0")]
[assembly: AssemblyVersion("3.14.1910.1")]
[assembly: AssemblyFileVersion("3.14.1910.1")]
[assembly: InternalsVisibleTo("SharePointPnP.PowerShell.Tests")]
1 change: 1 addition & 0 deletions Commands/Provisioning/Site/GetProvisioningTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ private void ExtractTemplate(XMLPnPSchemaVersion schema, string path, string pac
var percentage = Convert.ToInt32((100 / Convert.ToDouble(total)) * Convert.ToDouble(step));

WriteProgress(new ProgressRecord(0, $"Extracting Template from {SelectedWeb.Url}", message) { PercentComplete = percentage });
WriteProgress(new ProgressRecord(1, " ", " ") { RecordType = ProgressRecordType.Completed });
};
creationInformation.MessagesDelegate = (message, type) =>
{
Expand Down
Loading

0 comments on commit e062ec4

Please sign in to comment.