Skip to content

Commit b8b8f15

Browse files
Jwaegebaertmilanholemans
authored andcommitted
Updates default value of 'paged' option of command 'spo list view add'. Closes #6741
1 parent 67627a6 commit b8b8f15

File tree

6 files changed

+52
-21
lines changed

6 files changed

+52
-21
lines changed

docs/docs/cmd/spo/list/list-view-add.mdx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ m365 spo list view add [options]
6363
`--default`
6464
: View will be set as default view, if specified.
6565

66-
`--paged`
67-
: View supports paging, if specified (recommended to use this).
66+
`--paged [paged]`
67+
: View supports paging. Valid values are `true`, `false`. Defaults to `true`.
6868

6969
`--rowLimit [rowLimit]`
7070
: Sets the number of items to display for the view. Default value is 30.
@@ -76,7 +76,7 @@ m365 spo list view add [options]
7676

7777
:::tip
7878

79-
We recommend using the `paged` option. When specified, the view supports displaying more items page by page (default behavior). When not specified, the `rowLimit` is absolute, and there is no link to see more items.
79+
We recommend using the `paged` option. Paging is enabled by default: the view shows items page by page, up to the specified `rowLimit` per page. To disable paging, set `paged` to `false`; in a non-paged view, the `rowLimit` is absolute and there is no link to see more items.
8080

8181
:::
8282

@@ -85,43 +85,43 @@ We recommend using the `paged` option. When specified, the view supports display
8585
Add a list view called to a list with specific title.
8686

8787
```sh
88-
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listTitle "Customers" --title "All customers" --fields "LinkTitle,Country,Sector,Country,Address,Contact" --paged
88+
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listTitle "Customers" --title "All customers" --fields "LinkTitle,Country,Sector,Country,Address,Contact"
8989
```
9090

9191
Add a gallery view as default view to a list with a specific URL.
9292

9393
```sh
94-
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listUrl "/Lists/Customers" --title "All customers" --type gallery --fields "LinkTitle,Country,Sector,Country,Address,Contact" --paged --default
94+
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listUrl "/Lists/Customers" --title "All customers" --type gallery --fields "LinkTitle,Country,Sector,Country,Address,Contact" --default
9595
```
9696

9797
Add a view with defined filter and sorting.
9898

9999
```sh
100-
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listTitle "Customers" --title "Transport customers" --fields "LinkTitle,Country,Country,Address,Contact" --viewQuery "<OrderBy><FieldRef Name='LinkTitle' Ascending='TRUE' /></OrderBy><Where><Eq><FieldRef Name='Sector' /><Value Type='Text'>Transportation</Value></Eq></Where>" --paged
100+
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listTitle "Customers" --title "Transport customers" --fields "LinkTitle,Country,Country,Address,Contact" --viewQuery "<OrderBy><FieldRef Name='LinkTitle' Ascending='TRUE' /></OrderBy><Where><Eq><FieldRef Name='Sector' /><Value Type='Text'>Transportation</Value></Eq></Where>"
101101
```
102102

103103
Add a gallery view as personal view.
104104

105105
```sh
106-
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listTitle "Customers" --title "All customers" --type gallery --fields "LinkTitle,Country,Sector,Country,Address,Contact" --paged --personal
106+
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listTitle "Customers" --title "All customers" --type gallery --fields "LinkTitle,Country,Sector,Country,Address,Contact" --personal
107107
```
108108

109109
Add a calendar view with month layout.
110110

111111
```sh
112-
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listTitle "Events" --title "All events" --type calendar --fields "EventType,InternalExternal" --calendarStartDateField EventStartDate --calendarEndDateField EventEndDate --calendarTitleField LinkTitle --paged
112+
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listTitle "Events" --title "All events" --type calendar --fields "EventType,InternalExternal" --calendarStartDateField EventStartDate --calendarEndDateField EventEndDate --calendarTitleField LinkTitle
113113
```
114114

115115
Add a calendar view with week layout and subtitle.
116116

117117
```sh
118-
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listTitle "Events" --title "All events" --type calendar --fields "EventType,InternalExternal" --calendarStartDateField EventStartDate --calendarEndDateField EventEndDate --calendarTitleField LinkTitle --calendarSubTitleField Location --calendarDefaultLayout week --paged
118+
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listTitle "Events" --title "All events" --type calendar --fields "EventType,InternalExternal" --calendarStartDateField EventStartDate --calendarEndDateField EventEndDate --calendarTitleField LinkTitle --calendarSubTitleField Location --calendarDefaultLayout week
119119
```
120120

121121
Add a Kanban board view.
122122

123123
```sh
124-
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listTitle "Tasks" --title "All tasks" --type kanban --fields "Title,AssignedTo" --kanbanBucketField Status --paged
124+
m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --listTitle "Tasks" --title "All tasks" --type kanban --fields "Title,AssignedTo" --kanbanBucketField Status
125125
```
126126

127127
## Response
@@ -252,7 +252,7 @@ m365 spo list view add --webUrl https://contoso.sharepoint.com/sites/Sales --lis
252252
<TabItem value="Markdown">
253253

254254
```md
255-
# spo list view add --webUrl "https://contoso.sharepoint.com" --listTitle "Test" --title "All events" --fields "FieldName1" --viewQuery "<OrderBy><FieldRef Name='Created' Ascending='FALSE' /></OrderBy><Where><Eq><FieldRef Name='TextFieldName' /><Value Type='Text'>Field value</Value></Eq></Where>" --paged "true"
255+
# spo list view add --webUrl "https://contoso.sharepoint.com" --listTitle "Test" --title "All events" --fields "FieldName1" --viewQuery "<OrderBy><FieldRef Name='Created' Ascending='FALSE' /></OrderBy><Where><Eq><FieldRef Name='TextFieldName' /><Value Type='Text'>Field value</Value></Eq></Where>"
256256

257257
Date: 2/20/2023
258258

docs/docs/sample-scripts/spo/manage-news-page-types/assets/sample.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"metadata": [
2222
{
2323
"key": "CLI-FOR-MICROSOFT365",
24-
"value": "6.4.0"
24+
"value": "11.0.0"
2525
}
2626
],
2727
"thumbnails": [

docs/docs/sample-scripts/spo/manage-news-page-types/index.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ The following script shows how to create custom views to differentiate News type
3333
}
3434
3535
Write-Host "Creating view - All News"
36-
m365 spo list view add --webUrl $WebUrl --listTitle $ListTitle --title "All News" --fields "Title,Name,Editor,Modified" --viewQuery "<Where><Eq><FieldRef Name='PromotedState'></FieldRef><Value Type='Number'>2</Value></Eq></Where>" --paged | Out-Null
36+
m365 spo list view add --webUrl $WebUrl --listTitle $ListTitle --title "All News" --fields "Title,Name,Editor,Modified" --viewQuery "<Where><Eq><FieldRef Name='PromotedState'></FieldRef><Value Type='Number'>2</Value></Eq></Where>" | Out-Null
3737
3838
Write-Host "Creating view - SharePoint News"
39-
m365 spo list view add --webUrl $WebUrl --listTitle $ListTitle --title "SharePoint News" --fields "Title,Name,Editor,Modified" --viewQuery "<Where><And><Eq><FieldRef Name='PromotedState' /><Value Type='Number'>2</Value></Eq><Eq><FieldRef Name='PageLayoutType' /><Value Type='Text'>Article</Value></Eq></And></Where>" --paged | Out-Null
39+
m365 spo list view add --webUrl $WebUrl --listTitle $ListTitle --title "SharePoint News" --fields "Title,Name,Editor,Modified" --viewQuery "<Where><And><Eq><FieldRef Name='PromotedState' /><Value Type='Number'>2</Value></Eq><Eq><FieldRef Name='PageLayoutType' /><Value Type='Text'>Article</Value></Eq></And></Where>" | Out-Null
4040
4141
Write-Host "Creating view - News Link"
42-
m365 spo list view add --webUrl $WebUrl --listTitle $ListTitle --title "News Link" --fields "Title,Name,Editor,Modified" --viewQuery "<Where><And><Eq><FieldRef Name='PromotedState' /><Value Type='Number'>2</Value></Eq><Eq><FieldRef Name='PageLayoutType' /><Value Type='Text'>RepostPage</Value></Eq></And></Where>" --paged | Out-Null
42+
m365 spo list view add --webUrl $WebUrl --listTitle $ListTitle --title "News Link" --fields "Title,Name,Editor,Modified" --viewQuery "<Where><And><Eq><FieldRef Name='PromotedState' /><Value Type='Number'>2</Value></Eq><Eq><FieldRef Name='PageLayoutType' /><Value Type='Text'>RepostPage</Value></Eq></And></Where>" | Out-Null
4343
}
4444
catch {
4545
Write-Host -f Red "Error generating test documents: " $_.Exception.Message

docs/docs/v11-upgrade-guidance.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ The [spo homesite set](./cmd/spo/homesite/homesite-set.mdx) command has been upd
1616
- **For adding new home sites**: Use the new [spo homesite add](./cmd/spo/homesite/homesite-add.mdx) command instead
1717
- **For updating existing home sites**: Continue using [spo homesite set](./cmd/spo/homesite/homesite-set.mdx) as before with required option `siteUrl`.
1818

19+
### `spo list view add` default paged option changed
20+
21+
The [spo list view add](./cmd/spo/list/list-view-add.mdx) command has been updated to change the default value of the `paged` option from `false` to `true`. This change reflects the common usage pattern where most views allow paging and fetch new items while scrolling down.
22+
23+
#### What action do I need to take?
24+
25+
- **If you want paged views (most common)**: No action required as this is now the default behavior.
26+
- **If you want static views**: Explicitly specify `--paged false` when creating views that should not fetch new items while scrolling.
27+
1928
## Teams
2029

2130
### Ensure list output for `teams report` commands

src/m365/spo/commands/list/list-view-add.spec.ts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,28 @@ describe(commands.LIST_VIEW_ADD, () => {
336336
assert.strictEqual(actual.success, true);
337337
});
338338

339+
it('correctly sets default paged value when paged option is not specified', async () => {
340+
const postStub = sinon.stub(request, 'post').callsFake(async (opts) => {
341+
if (opts.url === `${validWebUrl}/_api/web/lists/getByTitle('${formatting.encodeQueryParameter(validListTitle)}')/views/add`) {
342+
return viewCreationResponse;
343+
}
344+
345+
throw 'Invalid request';
346+
});
347+
348+
await command.action(logger, {
349+
options: {
350+
webUrl: validWebUrl,
351+
listTitle: validListTitle,
352+
title: validTitle,
353+
fields: validFieldsInput
354+
}
355+
});
356+
357+
// Verify that Paged defaults to true when not specified
358+
assert.strictEqual(postStub.lastCall.args[0].data.parameters.Paged, true);
359+
});
360+
339361
it('correctly logs an output', async () => {
340362
sinon.stub(request, 'post').callsFake(async (opts) => {
341363
if (opts.url === `${validWebUrl}/_api/web/lists/getByTitle('${formatting.encodeQueryParameter(validListTitle)}')/views/add`) {
@@ -383,7 +405,7 @@ describe(commands.LIST_VIEW_ADD, () => {
383405
Query: undefined,
384406
PersonalView: false,
385407
SetAsDefaultView: false,
386-
Paged: false,
408+
Paged: true,
387409
RowLimit: 30
388410
});
389411
});
@@ -418,7 +440,7 @@ describe(commands.LIST_VIEW_ADD, () => {
418440
ViewData: '<FieldRef Name="Status" Type="KanbanPivotColumn" />',
419441
PersonalView: false,
420442
SetAsDefaultView: false,
421-
Paged: false,
443+
Paged: true,
422444
RowLimit: 30,
423445
ViewType2: 'KANBAN'
424446
});
@@ -454,7 +476,7 @@ describe(commands.LIST_VIEW_ADD, () => {
454476
Query: undefined,
455477
PersonalView: false,
456478
SetAsDefaultView: false,
457-
Paged: false,
479+
Paged: true,
458480
RowLimit: 100,
459481
ViewType2: 'TILES'
460482
});
@@ -492,7 +514,7 @@ describe(commands.LIST_VIEW_ADD, () => {
492514
CustomFormatter: undefined,
493515
PersonalView: false,
494516
SetAsDefaultView: false,
495-
Paged: false,
517+
Paged: true,
496518
RowLimit: 30,
497519
ViewType2: 'MODERNCALENDAR'
498520
});
@@ -534,7 +556,7 @@ describe(commands.LIST_VIEW_ADD, () => {
534556
CustomFormatter: JSON.stringify({ someProperty: 'someValue' }),
535557
PersonalView: false,
536558
SetAsDefaultView: false,
537-
Paged: false,
559+
Paged: true,
538560
RowLimit: 30,
539561
ViewType2: 'MODERNCALENDAR'
540562
});

src/m365/spo/commands/list/list-view-add.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class SpoListViewAddCommand extends SpoCommand {
129129
Query: args.options.viewQuery,
130130
PersonalView: !!args.options.personal,
131131
SetAsDefaultView: !!args.options.default,
132-
Paged: !!args.options.paged,
132+
Paged: args.options.paged ?? true,
133133
RowLimit: args.options.rowLimit ?? 30,
134134
CustomFormatter: args.options.customFormatter
135135
}

0 commit comments

Comments
 (0)