Skip to content

Adds m365 spo page control set. Closes #1934#1935

Closed
estruyf wants to merge 5 commits intopnp:masterfrom
estruyf:command/1934
Closed

Adds m365 spo page control set. Closes #1934#1935
estruyf wants to merge 5 commits intopnp:masterfrom
estruyf:command/1934

Conversation

@estruyf
Copy link
Copy Markdown
Member

@estruyf estruyf commented Nov 6, 2020

Closes #1934

This PR contains the new command to set the control properties / data on a modern page.

Usage: m365 spo page control set --webUrl <siteUrl> --name <name> --id <control id> --webPartData '{}'

@estruyf estruyf changed the title Adds `m365 spo page control set. Closes #1934 Adds m365 spo page control set. Closes #1934 Nov 6, 2020
@waldekmastykarz
Copy link
Copy Markdown
Member

Nice! We'll review it shortly 👏

Copy link
Copy Markdown
Member

@waldekmastykarz waldekmastykarz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding an .md file with command's help and linking to it from mkdocs.yml?

@waldekmastykarz waldekmastykarz marked this pull request as draft November 6, 2020 11:57
@estruyf
Copy link
Copy Markdown
Member Author

estruyf commented Nov 6, 2020

@waldekmastykarz added the documentation page.

@waldekmastykarz waldekmastykarz marked this pull request as ready for review November 6, 2020 13:57
Accidentally made the optional properties `webPartData` and `webPartProperties` required.
@waldekmastykarz waldekmastykarz self-assigned this Nov 13, 2020
Copy link
Copy Markdown
Member

@waldekmastykarz waldekmastykarz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nicely done with a few minor fixes I've done when merging the PR 👏

@@ -0,0 +1,114 @@
export const mockPage = {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should exclude this file from our coverage testing. It doesn't influence the coverage right now, but you never know 🙂

resolve(ClientSidePage.fromHtml(res.ListItemAllFields.CanvasContent1));
}
catch (e) {
} catch (e) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not reformat code if not necessary

logger.log(`Checking out ${name} page...`);
}

let pageName: string = this.getPageNameWithExtension(name);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since pageName is not re-assigned, it could be const

return;
}

let pageName: string = this.getPageNameWithExtension(name);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since pageName is not re-assigned, it could be const

Page
.getPage(args.options.name, args.options.webUrl, logger, this.debug, this.verbose)
.then((clientSidePage: ClientSidePage): Promise<ClientSidePageProperties> => {
let control: ClientSidePart | null = clientSidePage.findControlById(args.options.id);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since control is not re-assigned it could be const

};

if (this.verbose) {
logger.log('Updated webpart data:');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's spell web part as two words consistently


if (args.options.webPartProperties) {
if (this.verbose) {
logger.log('webPartProperties data:');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's spell web part as two words consistently

};

if (this.verbose) {
logger.log('Updated webpart properties:');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's spell web part as two words consistently

@@ -0,0 +1,55 @@
# spo page control set

Allows you to set or update control web part data or properties on a modern page.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the context of CLI set and update are the same, so let's use just update for simplicity and consistency with other set commands


`--webPartProperties [webPartProperties]`
: JSON string with web part data as retrieved from the web part maintenance mode. Specify webPartProperties or webPartData but not both

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing query and output properties

@waldekmastykarz
Copy link
Copy Markdown
Member

Merged manually. Thank you! 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New command: m365 spo page control set - to allow webpart updates

2 participants