Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set-PnPList, added support for Color and Icons #4409

Merged
merged 4 commits into from
Oct 10, 2024
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
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
Loading