Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions changelog.md → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
# SharePointPnP.PowerShell Changelog #
# SharePointPnP.PowerShell Changelog
All notable changes to this project will be documented in this file.

**2018-02-02**
* Added Set-PnPSiteDesign and Set-PnPSiteScript cmdlets
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

**2018-01-05**
* Added Get-PnPTenantAppCatalogUrl, Start-PnPWorkflowInstance, Get-PnPWorkflowInstance
## [Unreleased]
### Added
- Added Get-PnPNavigationNode cmdlet

### Changed
- Changed changelog format
- Updated Remove-PnPNavigationNode cmdlet to support removal by Id

### Deprecated
- Deprecated Remove-PnPNavigationNode -Title -Header parameters. Use Identity instead.

## [2.23.1802.0] - 2018-02-05
### Added
- Added Set-PnPSiteDesign and Set-PnPSiteScript cmdlets

## [2.22.1801.0]
### Added
- Added Get-PnPTenantAppCatalogUrl
- Start-PnPWorkflowInstance
- Get-PnPWorkflowInstance

**2017-12-06**
* Added cmdlets for Site Designs: Add-PnPSiteDesign, Add-PnPSiteScript, Get-PnPSiteDesign, Get-PnPSiteScript, Get-PnPSiteDesignRights, Grant-PnPSiteDesignRights, Remove-PnPSiteDesign, Remove-PnPSiteScript, Revoke-PnPSiteDesignRights
Expand Down
26 changes: 26 additions & 0 deletions Commands/Base/PipeBinds/NavigationNodePipeBind.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SharePointPnP.PowerShell.Commands.Base.PipeBinds
{
public class NavigationNodePipeBind
{
private int _id;

public NavigationNodePipeBind(int id)
{
_id = id;
}

public NavigationNodePipeBind(NavigationNode node)
{
_id = node.Id;
}

public int Id => _id;
}
}
77 changes: 77 additions & 0 deletions Commands/Branding/GetNavigationNode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System;
using System.Management.Automation;
using Microsoft.SharePoint.Client;
using OfficeDevPnP.Core.Enums;
using SharePointPnP.PowerShell.CmdletHelpAttributes;

namespace SharePointPnP.PowerShell.Commands.Branding
{
[Cmdlet(VerbsCommon.Get, "PnPNavigationNode", DefaultParameterSetName = ParameterSet_ALLBYLOCATION)]
[CmdletHelp("Returns all or a specific navigation node",
Category = CmdletHelpCategory.Branding)]
[CmdletExample(
Code = @"PS:> Get-PnPNavigationNode",
Remarks = @"Returns all navigation nodes in the quicklaunch navigation",
SortOrder = 1)]
[CmdletExample(
Code = @"PS:> Get-PnPNavigationNode -QuickLaunch",
Remarks = @"Returns all navigation nodes in the quicklaunch navigation",
SortOrder = 2)]
[CmdletExample(
Code = @"PS:> Get-PnPNavigationNode -TopNavigationBar",
Remarks = @"Returns all navigation nodes in the top navigation bar",
SortOrder = 3)]
[CmdletExample(
Code = @"PS:> $node = Get-PnPNavigationNode -Id 2030
PS> $children = $node.Children",
Remarks = @"Returns the selected navigation node and retrieves any children",
SortOrder = 3)]
public class GetNavigationNode : PnPWebCmdlet
{
private const string ParameterSet_ALLBYLOCATION = "All nodes by location";
private const string ParameterSet_BYID = "A single node by ID";

[Parameter(Mandatory = false, HelpMessage = "The location of the nodes to retrieve. Either TopNavigationBar, QuickLaunch", ParameterSetName = ParameterSet_ALLBYLOCATION)]
public NavigationType Location = NavigationType.QuickLaunch;

[Parameter(Mandatory = false, HelpMessage = "The Id of the node to retrieve", ParameterSetName = ParameterSet_BYID)]
public int Id;

protected override void ExecuteCmdlet()
{
if (ParameterSetName == ParameterSet_ALLBYLOCATION)
{
NavigationNodeCollection nodes = null;
switch (Location)
{
case NavigationType.QuickLaunch:
{
nodes = SelectedWeb.Navigation.QuickLaunch;
break;
}
case NavigationType.TopNavigationBar:
{
nodes = SelectedWeb.Navigation.TopNavigationBar;
break;
}
case NavigationType.SearchNav:
{
nodes = SelectedWeb.Navigation.GetNodeById(1040).Children;
break;
}
}
ClientContext.Load(nodes);
ClientContext.ExecuteQueryRetry();
WriteObject(nodes, true);
}
if (MyInvocation.BoundParameters.ContainsKey("Id"))
{
var node = SelectedWeb.Navigation.GetNodeById(Id);
ClientContext.Load(node);
ClientContext.Load(node, n => n.Children.IncludeWithDefaultProperties());
ClientContext.ExecuteQueryRetry();
WriteObject(node);
}
}
}
}
51 changes: 40 additions & 11 deletions Commands/Branding/RemoveNavigationNode.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,68 @@
using System.Management.Automation;
using System;
using System.Management.Automation;
using Microsoft.SharePoint.Client;
using OfficeDevPnP.Core.Enums;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
using Resources = SharePointPnP.PowerShell.Commands.Properties.Resources;

namespace SharePointPnP.PowerShell.Commands.Branding
{
[Cmdlet(VerbsCommon.Remove, "PnPNavigationNode", SupportsShouldProcess = true)]
[CmdletHelp("Removes a menu item from either the quicklaunch or top navigation",
[Cmdlet(VerbsCommon.Remove, "PnPNavigationNode", DefaultParameterSetName = ParameterSet_BYID, SupportsShouldProcess = true)]
[CmdletHelp("Removes a menu item from either the quicklaunch or top navigation",
Category = CmdletHelpCategory.Branding)]
[CmdletExample(
Code = @"PS:> Remove-PnPNavigationNode -Identity 1032",
Remarks = @"Removes the navigation node with the specified id",
SortOrder = 1)]
[CmdletExample(
Code = @"PS:> $nodes = Get-PnPNavigationNode -QuickLaunch
PS:>$nodes | Select-Object -First 1 | Remove-PnPNavigationNode -Force",
Remarks = @"Retrieves all navigation nodes from the Quick Launch navigation, then removes the first node in the list and it will not ask for a confirmation",
SortOrder = 2)]
[CmdletExample(Code = @"PS:> Remove-PnPNavigationNode -Title Recent -Location QuickLaunch",
Remarks = "Will remove the recent navigation node from the quick launch in the current web.",
SortOrder = 1)]
SortOrder = 3)]
[CmdletExample(Code = @"PS:> Remove-PnPNavigationNode -Title Home -Location TopNavigationBar -Force",
Remarks = "Will remove the home navigation node from the top navigation bar without prompting for a confirmation in the current web.",
SortOrder = 2)]
SortOrder = 4)]
public class RemoveNavigationNode : PnPWebCmdlet
{
[Parameter(Mandatory = true, HelpMessage = "The location from where to remove the node (QuickLaunch, TopNavigationBar")]
private const string ParameterSet_BYNAME = "Remove node by Title";
private const string ParameterSet_BYID = "Remove a node by ID";

[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, HelpMessage = "The Id or node object to delete", ParameterSetName = ParameterSet_BYID)]
public NavigationNodePipeBind Identity;

[Obsolete("Use -Identity with an Id instead.")]
[Parameter(Mandatory = true, Position = 0, HelpMessage = "The location from where to remove the node (QuickLaunch, TopNavigationBar", ParameterSetName = ParameterSet_BYNAME)]
public NavigationType Location;

[Parameter(Mandatory = true, HelpMessage = "The title of the node that needs to be removed")]
[Obsolete("Use -Identity with an Id instead.")]
[Parameter(Mandatory = true, HelpMessage = "The title of the node that needs to be removed", ParameterSetName = ParameterSet_BYNAME)]
public string Title;

[Parameter(Mandatory = false, HelpMessage = "The header where the node is located")]
[Obsolete("Use -Identity with an Id instead.")]
[Parameter(Mandatory = false, HelpMessage = "The header where the node is located", ParameterSetName = ParameterSet_BYNAME)]
public string Header;

[Parameter(Mandatory = false, HelpMessage = "Specifying the Force parameter will skip the confirmation question.")]
[Parameter(Mandatory = false, HelpMessage = "Specifying the Force parameter will skip the confirmation question.", ParameterSetName = ParameterAttribute.AllParameterSets)]
public SwitchParameter Force;

protected override void ExecuteCmdlet()
{
if (Force || ShouldContinue(string.Format(Resources.RemoveNavigationNode0, Title), Resources.Confirm))
if (Force || ShouldContinue("Remove node?", Resources.Confirm))
{
SelectedWeb.DeleteNavigationNode(Title, Header, Location);
if (ParameterSetName == ParameterSet_BYID)
{
var node = SelectedWeb.Navigation.GetNodeById(Identity.Id);
node.DeleteObject();
ClientContext.ExecuteQueryAsync();
}
else
{
SelectedWeb.DeleteNavigationNode(Title, Header, Location);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1230,5 +1230,49 @@
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>NavigationNode</Name>
<ViewSelectedBy>
<TypeName>Microsoft.SharePoint.Client.NavigationNode</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Label>Id</Label>
<Alignment>left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Title</Label>
<Alignment>left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Visible</Label>
<Alignment>left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Url</Label>
<Alignment>left</Alignment>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Id</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Title</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>IsVisible</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Url</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -1230,5 +1230,49 @@
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>NavigationNode</Name>
<ViewSelectedBy>
<TypeName>Microsoft.SharePoint.Client.NavigationNode</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Label>Id</Label>
<Alignment>left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Title</Label>
<Alignment>left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Visible</Label>
<Alignment>left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Url</Label>
<Alignment>left</Alignment>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Id</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Title</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>IsVisible</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Url</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -1540,5 +1540,49 @@
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>NavigationNode</Name>
<ViewSelectedBy>
<TypeName>Microsoft.SharePoint.Client.NavigationNode</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Label>Id</Label>
<Alignment>left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Title</Label>
<Alignment>left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Visible</Label>
<Alignment>left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Url</Label>
<Alignment>left</Alignment>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Id</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Title</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>IsVisible</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Url</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>
2 changes: 2 additions & 0 deletions Commands/SharePointPnP.PowerShell.Commands.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,10 @@
<Compile Include="Admin\GetTenantAppCatalogUrl.cs" />
<Compile Include="Admin\RemoveStorageEntity.cs" />
<Compile Include="Base\PipeBinds\ClientSideWebPartPipeBind.cs" />
<Compile Include="Base\PipeBinds\NavigationNodePipeBind.cs" />
<Compile Include="Base\PipeBinds\TenantSiteScriptPipeBind.cs" />
<Compile Include="Base\PipeBinds\TenantSiteDesignPipeBind.cs" />
<Compile Include="Branding\GetNavigationNode.cs" />
<Compile Include="ClientSidePages\GetClientSideComponent.cs" />
<Compile Include="ClientSidePages\RemoveClientSideComponent.cs" />
<Compile Include="ClientSidePages\MoveClientSideComponent.cs" />
Expand Down
Loading