Skip to content

Commit 532f66d

Browse files
authored
Merge pull request #2873 from KoenZomers/OpenDocumentsInLibrary
Added `-OpenDocumentsIn` option to `Set-PnPList`
2 parents bf10581 + ea25bf0 commit 532f66d

File tree

4 files changed

+77
-3
lines changed

4 files changed

+77
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
4646
- Added `-UserAssignedManagedIdentityAzureResourceId` and `-UserAssignedManagedIdentityClientId` as alternatives to `-UserAssignedManagedIdentityObjectId` for `Connect-PnPOnline -ManagedIdentity` to provide an user managed identity to authenticate with. [#2813](https://github.com/pnp/powershell/pull/2813)
4747
- Added clearer error message when connecting using an expired client secret and trying to execute a command.[#2828](https://github.com/pnp/powershell/pull/2828)
4848
- Added `Undo-PnPFileCheckedOut` which allows a checked out file to discard its changes and revert to the last checked in version. [#2837](https://github.com/pnp/powershell/pull/2837)
49+
- Added `-OpenDocumentsMode` option to `Set-PnPList` which allows configuring if documents should be opened in the browser or in the local client [#2873](https://github.com/pnp/powershell/pull/2873)
4950
- Added `-Properties` parameter to `Get-PnPUserProfileProperty` cmdlet which allows retrieval of specific properties if specified. [#2840](https://github.com/pnp/powershell/pull/2840)
5051
- Added support for specifying the `-ContentUrl` configuration in `Add-PnPTeamsTab` cmdlet when trying to add a Planner as a tab in Teams channel. [#2850](https://github.com/pnp/powershell/pull/2850)
5152

documentation/Set-PnPList.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Set-PnPList -Identity <ListPipeBind> [-EnableContentTypes <Boolean>] [-BreakRole
2222
[-EnableMinorVersions <Boolean>] [-MajorVersions <UInt32>] [-MinorVersions <UInt32>]
2323
[-EnableModeration <Boolean>] [-DraftVersionVisibility <DraftVisibilityType>] [-ReadSecurity <ListReadSecurity>] [-WriteSecurity <ListWriteSecurity>]
2424
[-NoCrawl] [-ExemptFromBlockDownloadOfNonViewableFiles <Boolean>] [-DisableGridEditing <Boolean>] [-DefaultSensitivityLabelForLibrary <SensitivityLabelPipeBind>]
25-
[-Path <String>] [-Connection <PnPConnection>] [<CommonParameters>]
25+
[-Path <String>] [-OpenDocumentsMode <DocumentLibraryOpenDocumentsInMode>] [-Connection <PnPConnection>]
2626
```
2727

2828
## DESCRIPTION
@@ -369,6 +369,21 @@ Accept pipeline input: False
369369
Accept wildcard characters: False
370370
```
371371
372+
### -OpenDocumentsMode
373+
Allows configuring the opening documents in the browser advanced setting on document libraries. Set to ClientApplication to have documents being opened in the locally installed Word, PowerPoint or Excel client or set to Browser to have documents being opened in the browser. It is not possible to set it to "Use the server default mode".
374+
375+
```yaml
376+
Type: DocumentLibraryOpenDocumentsInMode
377+
Parameter Sets: (All)
378+
Accepted values: ClientApplication, Browser
379+
380+
Required: False
381+
Position: Named
382+
Default value: None
383+
Accept pipeline input: False
384+
Accept wildcard characters: False
385+
```
386+
372387
### -ReadSecurity
373388
Sets the read security for the list
374389
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace PnP.PowerShell.Commands.Enums
2+
{
3+
/// <summary>
4+
/// Defines the modes that can be set on a Document Library for how to open documents
5+
/// </summary>
6+
public enum DocumentLibraryOpenDocumentsInMode : short
7+
{
8+
/// <summary>
9+
/// Opens the document in the client application, i.e. Word, Excel, PowerPoint, etc. on the local desktop
10+
/// </summary>
11+
ClientApplication = 0,
12+
13+
/// <summary>
14+
/// Opens the document in the browser
15+
/// </summary>
16+
Browser = 1
17+
}
18+
}

src/Commands/Lists/SetList.cs

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ public class SetList : PnPWebCmdlet
8787
public string Path;
8888

8989
[Parameter(Mandatory = false)]
90-
public SensitivityLabelPipeBind DefaultSensitivityLabelForLibrary;
90+
public SensitivityLabelPipeBind DefaultSensitivityLabelForLibrary;
91+
92+
[Parameter(Mandatory = false)]
93+
public DocumentLibraryOpenDocumentsInMode OpenDocumentsMode;
9194

9295
protected override void ExecuteCmdlet()
9396
{
@@ -240,7 +243,7 @@ protected override void ExecuteCmdlet()
240243

241244
if (list.EnableVersioning)
242245
{
243-
// list or doclib?
246+
// Is this for a list or a document library
244247
if (list.BaseType == BaseType.DocumentLibrary)
245248
{
246249
if (ParameterSpecified(nameof(MajorVersions)))
@@ -307,6 +310,43 @@ protected override void ExecuteCmdlet()
307310
}
308311
}
309312

313+
if(ParameterSpecified(nameof(OpenDocumentsMode)))
314+
{
315+
// Is this for a list or a document library
316+
if (list.BaseType == BaseType.DocumentLibrary)
317+
{
318+
WriteVerbose($"Configuring document library to use default open mode to be '{OpenDocumentsMode}'");
319+
320+
switch(OpenDocumentsMode)
321+
{
322+
case DocumentLibraryOpenDocumentsInMode.Browser:
323+
list.DefaultItemOpenInBrowser = true;
324+
break;
325+
326+
case DocumentLibraryOpenDocumentsInMode.ClientApplication:
327+
list.DefaultItemOpenInBrowser = false;
328+
break;
329+
}
330+
updateRequired = true;
331+
}
332+
else
333+
{
334+
WriteWarning($"{nameof(OpenDocumentsMode)} is only supported for document libraries");
335+
}
336+
337+
switch(OpenDocumentsMode)
338+
{
339+
case DocumentLibraryOpenDocumentsInMode.Browser:
340+
list.DefaultItemOpenInBrowser = true;
341+
break;
342+
343+
case DocumentLibraryOpenDocumentsInMode.ClientApplication:
344+
list.DefaultItemOpenInBrowser = false;
345+
break;
346+
}
347+
updateRequired = true;
348+
}
349+
310350
if (updateRequired)
311351
{
312352
list.Update();

0 commit comments

Comments
 (0)