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

New command: spo commandset set #4338

Closed
Tracked by #4219
martinlingstuyl opened this issue Jan 11, 2023 · 10 comments
Closed
Tracked by #4219

New command: spo commandset set #4338

martinlingstuyl opened this issue Jan 11, 2023 · 10 comments

Comments

@martinlingstuyl
Copy link
Contributor

martinlingstuyl commented Jan 11, 2023

Usage

spo commandset set [options]

Description

Updates a ListView Command Set on a site.

Options

Option Description
-u, --webUrl <webUrl> The site to update the ListView Command Set on.
-t, --title [title] The title of the ListView Command Set to update. Specify either title, id or clientSideComponentId.
-i, --id [id] The id of the ListView Command Set to update. Specify either title, id or clientSideComponentId.
-c, --clientSideComponentId [clientSideComponentId] The Client Side Component Id (GUID) of the ListView Command Set to update. Specify either title, id or clientSideComponentId.
--newTitle [newTitle] The new title of the ListView Command Set.
-l, --listType [listType] The list or library type to register the Command Set on. Allowed values List or Library.
--clientSideComponentProperties [clientSideComponentProperties] The Client Side Component properties of the ListView Command Set.
-s, --scope [scope] The scope where to lookup the ListView Command Set: at site level or web level. Allowed values: Site, Web, All. Defaults to All.
--location [location] The location of the ListView Command Set. Allowed values ContextMenu, CommandBar or Both.

Examples

Updates the title and location of a ListView Command Set on the sales site.

m365 spo commandset  set --clientSideComponentId  799883f5-7962-4384-a10a-105adaec6ffc --newTitle "Some new title" --location Both --webUrl https://contoso.sharepoint.com/sites/sales --scope Site

Updates a ListView Command Set on the sales site with some properties.

m365 spo commandset set --title "Some customizer" --clientSideComponentProperties '{ "someProperty": "Some value" }' --webUrl https://contoso.sharepoint.com/sites/sales --scope Site

Remarks

Add the following notice (like on https://pnp.github.io/cli-microsoft365/cmd/spo/customaction/customaction-add/)

Escaping JSON in PowerShell When using the --clientSideComponentProperties option it's possible to enter a JSON string. In PowerShell 5 to 7.2 specific escaping rules apply due to an issue. Remember that you can also use file tokens instead.

Additional Info

While developing we want to reuse the getCustomActions and getCustomActionById functions of the spo util class.

  • If the found custom action is not an command set: throw an error.
  • If two or more command set custom actions are found: prompt the user to disambiguate.

We can use the shared code to only query the commandset customaction we want: with a location value of ClientSideExtension.ListViewCommandSet, ClientSideExtension.ListViewCommandSet.CommandBar or ClientSideExtension.ListViewCommandSet.ContextMenu based on the value that's used.

The listType value maps to --registrationId of the custom action. List maps to 100, Library maps to 101

@waldekmastykarz
Copy link
Member

For --scope, we can't specify a default value. If we did and the user wouldn't specify a value, it would overwrite the existing value which would lead to undesired side-effects.

@martinlingstuyl
Copy link
Contributor Author

martinlingstuyl commented Jan 15, 2023

That's not entirely true @waldekmastykarz, scope is not a value we set. It's where the command is executed: on site level or web level.
But there is a chance a customaction of the same name or componentId is registered on both scopes, so I'll update the spec to make sure people will not inadvertently execute a set on a wrong customaction.

@martinlingstuyl martinlingstuyl removed the needs peer review Needs second pair of eyes to review the spec or PR label Jan 15, 2023
@waldekmastykarz
Copy link
Member

That's not entirely true @waldekmastykarz, scope is not a value we set. It's where the command is executed: on site level or web level.
But there is a chance a customaction of the same name or componentId is registered on both scopes, so I'll update the spec to make sure people will not inadvertently execute a set on a wrong customaction.

Ah, got it. So it's meant to lookup the command set, not to update its scope. Let's be sure we clarify that in the description of the option to avoid confusion.

@martinlingstuyl
Copy link
Contributor Author

Better like this?

@nicodecleyre
Copy link
Contributor

Would love to work on this one

@milanholemans
Copy link
Contributor

All yours!

@martinlingstuyl
Copy link
Contributor Author

Hi @nicodecleyre, I updated the scope option to be optional with a default value of All. Could you take that into account? I also added some extra remarks.

@nicodecleyre
Copy link
Contributor

Hi @nicodecleyre, I updated the scope option to be optional with a default value of All. Could you take that into account? I also added some extra remarks.

Definitely, thank you for letting me know!

@nicodecleyre
Copy link
Contributor

Hi @martinlingstuyl, i guess --newTitle should be --newTitle [newTitle] in the specs?

@martinlingstuyl
Copy link
Contributor Author

Yes!

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

Successfully merging a pull request may close this issue.

5 participants