Skip to content

Commit

Permalink
Set-PnPList, added support for Color and Icons (#4409)
Browse files Browse the repository at this point in the history
* πŸ”¨ - Initial work on Set-PnPList Color and Icon paramaters

* πŸ› - Set the int value of color and icon as a string

* Added explaining text to the example

---------

Co-authored-by: Gautam Sheth <[email protected]>
  • Loading branch information
Tanddant and gautamdsheth authored Oct 10, 2024
1 parent cb0fed3 commit 7268de8
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 1 deletion.
39 changes: 38 additions & 1 deletion documentation/Set-PnPList.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Set-PnPList -Identity <ListPipeBind> [-EnableContentTypes <Boolean>] [-BreakRole
[-EnableModeration <Boolean>] [-DraftVersionVisibility <DraftVisibilityType>] [-ReadSecurity <ListReadSecurity>] [-WriteSecurity <ListWriteSecurity>]
[-NoCrawl] [-ExemptFromBlockDownloadOfNonViewableFiles <Boolean>] [-DisableGridEditing <Boolean>] [-DisableCommenting <Boolean>]
[-EnableAutoExpirationVersionTrim <Boolean>] [-ExpireVersionsAfterDays <UInt32>]
[-DefaultSensitivityLabelForLibrary <SensitivityLabelPipeBind>] [-Path <String>] [-OpenDocumentsMode <DocumentLibraryOpenDocumentsInMode>] [-Connection <PnPConnection>]
[-DefaultSensitivityLabelForLibrary <SensitivityLabelPipeBind>] [-Path <String>] [-OpenDocumentsMode <DocumentLibraryOpenDocumentsInMode>] [-Color <ListColor>] [-Icon <ListIcon>] [-Connection <PnPConnection>]
```

## DESCRIPTION
Expand Down Expand Up @@ -108,6 +108,13 @@ 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"
```

Changes the icon of the list to a plane, and the background color of the icon to green.

## PARAMETERS

### -BreakRoleInheritance
Expand Down Expand Up @@ -586,6 +593,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
Expand Down
24 changes: 24 additions & 0 deletions src/Commands/Enums/ListColor.cs
Original file line number Diff line number Diff line change
@@ -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,
}
}
31 changes: 31 additions & 0 deletions src/Commands/Enums/ListIcon.cs
Original file line number Diff line number Diff line change
@@ -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
}
}
18 changes: 18 additions & 0 deletions src/Commands/Lists/SetList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -263,6 +269,18 @@ protected override void ExecuteCmdlet()
updateRequired = true;
}


if (ParameterSpecified(nameof(Color))) {
list.Color = ((int)Color).ToString();
updateRequired = true;
}

if(ParameterSpecified(nameof(Icon)))
{
list.Icon = ((int)Icon).ToString();
updateRequired = true;
}

if (updateRequired)
{
list.Update();
Expand Down

0 comments on commit 7268de8

Please sign in to comment.