From 4fdff92ad80ff9ddaefdd58a2cf10f60714ff90a Mon Sep 17 00:00:00 2001 From: Dan Toft Date: Wed, 9 Oct 2024 18:07:56 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=94=A8=20-=20Initial=20work=20on=20Se?= =?UTF-8?q?t-PnPList=20Color=20and=20Icon=20paramaters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- documentation/Set-PnPList.md | 38 ++++++++++++++++++++++++++++++++- src/Commands/Enums/ListColor.cs | 24 +++++++++++++++++++++ src/Commands/Enums/ListIcon.cs | 31 +++++++++++++++++++++++++++ src/Commands/Lists/SetList.cs | 18 ++++++++++++++++ 4 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 src/Commands/Enums/ListColor.cs create mode 100644 src/Commands/Enums/ListIcon.cs diff --git a/documentation/Set-PnPList.md b/documentation/Set-PnPList.md index 122d0f24e..e9369473f 100644 --- a/documentation/Set-PnPList.md +++ b/documentation/Set-PnPList.md @@ -23,7 +23,7 @@ Set-PnPList -Identity [-EnableContentTypes ] [-BreakRole [-EnableModeration ] [-DraftVersionVisibility ] [-ReadSecurity ] [-WriteSecurity ] [-NoCrawl] [-ExemptFromBlockDownloadOfNonViewableFiles ] [-DisableGridEditing ] [-DisableCommenting ] [-EnableAutoExpirationVersionTrim ] [-ExpireVersionsAfterDays ] - [-DefaultSensitivityLabelForLibrary ] [-Path ] [-OpenDocumentsMode ] [-Connection ] + [-DefaultSensitivityLabelForLibrary ] [-Path ] [-OpenDocumentsMode ] [-Color ] [-Icon ] [-Connection ] ``` ## DESCRIPTION @@ -108,6 +108,12 @@ Set-PnPList -Identity "Demo List" -DefaultSensitivityLabelForLibrary "Confidenti Sets the default sensitivity label for a document library to Confidential. +### EXAMPLE 12 +```powershell +Set-PnPList -Identity "Demo List" -Color Green -Icon "Plane" +``` + + ## PARAMETERS ### -BreakRoleInheritance @@ -586,6 +592,36 @@ Enable modern audience targeting in a SharePoint list. Please make sure the foll Type: Boolean Parameter Sets: (All) +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Icon +The icon of the list. + +```yaml +Type: ListIcon +Parameter Sets: (All) + +Accepted values: Bug, Calendar, Target, Clipboard, Plane, Rocket, ColorPalette, Lightbulb, Cube, Beaker, Robot, PiggyBank, Playlist, Hospital, Bank, MapPin, CoffeCup, ShoppingCart, BirthdayCake +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Color +The background color of the list icon. + +```yaml +Type: ListColor +Parameter Sets: (All) + +Accepted values: DarkRed, Red, Orange, Green, DarkGreen, Teal, Blue, NavyBlue, BluePurple, DarkBlue, Lavender , Pink Required: False Position: Named Default value: None diff --git a/src/Commands/Enums/ListColor.cs b/src/Commands/Enums/ListColor.cs new file mode 100644 index 000000000..c8a6188e1 --- /dev/null +++ b/src/Commands/Enums/ListColor.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PnP.PowerShell.Commands.Enums +{ + public enum ListColor : short + { + DarkRed = 0, + Red = 1, + Orange = 2, + Green = 3, + DarkGreen = 4, + Teal = 5, + Blue = 6, + NavyBlue = 7, + BluePurple = 8, + DarkBlue = 9, + Lavender = 10, + Pink = 11, + } +} diff --git a/src/Commands/Enums/ListIcon.cs b/src/Commands/Enums/ListIcon.cs new file mode 100644 index 000000000..6837e955d --- /dev/null +++ b/src/Commands/Enums/ListIcon.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PnP.PowerShell.Commands.Enums +{ + public enum ListIcon : short + { + Bug = 0, + Calendar = 1, + Target = 2, + Clipboard = 3, + Plane = 4, + Rocket = 5, + ColorPalette = 6, + Lightbulb = 7, + Cube = 8, + Beaker = 9, + Robot = 10, + PiggyBank = 11, + Playlist = 12, + Hospital = 13, + Bank = 14, + MapPin = 15, + CoffeCup = 16, + ShoppingCart = 17, + BirthdayCake = 18 + } +} diff --git a/src/Commands/Lists/SetList.cs b/src/Commands/Lists/SetList.cs index 11f167f20..0590d1de4 100644 --- a/src/Commands/Lists/SetList.cs +++ b/src/Commands/Lists/SetList.cs @@ -110,6 +110,12 @@ public class SetList : PnPWebCmdlet [Parameter(Mandatory = false)] public bool EnableModernAudienceTargeting; + [Parameter(Mandatory = false)] + public ListColor Color; + + [Parameter(Mandatory = false)] + public ListIcon Icon; + protected override void ExecuteCmdlet() { var list = Identity.GetList(CurrentWeb); @@ -263,6 +269,18 @@ protected override void ExecuteCmdlet() updateRequired = true; } + + if (ParameterSpecified(nameof(Color))) { + list.Color = Color.ToString(); + updateRequired = true; + } + + if(ParameterSpecified(nameof(Icon))) + { + list.Icon = Icon.ToString(); + updateRequired = true; + } + if (updateRequired) { list.Update(); From 1ea2cbaecfc7057e52b4a0ddf9f26e1a8bb84d39 Mon Sep 17 00:00:00 2001 From: Dan Toft Date: Wed, 9 Oct 2024 18:30:57 +0200 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=90=9B=20-=20Set=20the=20int=20value?= =?UTF-8?q?=20of=20color=20and=20icon=20as=20a=20string?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Commands/Lists/SetList.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/Lists/SetList.cs b/src/Commands/Lists/SetList.cs index 0590d1de4..886c051d6 100644 --- a/src/Commands/Lists/SetList.cs +++ b/src/Commands/Lists/SetList.cs @@ -271,13 +271,13 @@ protected override void ExecuteCmdlet() if (ParameterSpecified(nameof(Color))) { - list.Color = Color.ToString(); + list.Color = ((int)Color).ToString(); updateRequired = true; } if(ParameterSpecified(nameof(Icon))) { - list.Icon = Icon.ToString(); + list.Icon = ((int)Icon).ToString(); updateRequired = true; } From 85612db5a3dbb67a7b595e9632ef098869f072e9 Mon Sep 17 00:00:00 2001 From: Dan Toft Date: Thu, 10 Oct 2024 10:26:53 +0200 Subject: [PATCH 3/3] Added explaining text to the example --- documentation/Set-PnPList.md | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation/Set-PnPList.md b/documentation/Set-PnPList.md index e9369473f..1b90af313 100644 --- a/documentation/Set-PnPList.md +++ b/documentation/Set-PnPList.md @@ -113,6 +113,7 @@ Sets the default sensitivity label for a document library to Confidential. Set-PnPList -Identity "Demo List" -Color Green -Icon "Plane" ``` +Changes the icon of the list to a plane, and the background color of the icon to green. ## PARAMETERS