cli-microsoft365 icon indicating copy to clipboard operation
cli-microsoft365 copied to clipboard

New command: πŸ” spo web roleinheritance break

Open Adam-it opened this issue 3 years ago β€’ 19 comments

Usage

m365 spo web roleinheritance break [options]

Description

break inheritance of subsite. Keeping existing permissions is the default behavior.

Options

Option Description
-u, --webUrl <webUrl> URL of the site
-c --clearExistingPermissions Flag if used clears all roles from the web
--confirm Don't prompt for confirmation

Examples

break role inheritance on web with keeping existing permissions

m365 spo web roleinheritance break  --webUrl "https://contoso.sharepoint.com/sites/contoso-sales"

break role inheritance on web with clearing existing permissions

m365 spo web roleinheritance break  --webUrl "https://contoso.sharepoint.com/sites/contoso-sales" --clearExistingPermissions

Additional Info

I did some research and for this command we may use the POST request

/_api/web/breakroleinheritance(${TrueOrFalseHere})

Adam-it avatar Aug 02 '22 22:08 Adam-it

i want to use this command, how to? the @next version seems don't have it

quantrpeter avatar Aug 03 '22 05:08 quantrpeter

@quantrpeter thanks for reaching out πŸ‘ This is still an opened issue so it means it was not developed yet and we plan to do so in near future by either one of the maintainers or our awesome contributors 🀩. Currently CLI supports breaking role inheritance on list/lib πŸ‘‰ https://pnp.github.io/cli-microsoft365/cmd/spo/list/list-roleinheritance-break/ and listitem/file/folder/page level πŸ‘‰https://pnp.github.io/cli-microsoft365/cmd/spo/listitem/listitem-roleinheritance-break/

please feel free to join the discussion abut this command if you see something lacking. When this issue spec is formally expected by some other @pnp/cli-for-microsoft-365-maintainers then this issue will be also opened to be developed πŸ˜‰

Adam-it avatar Aug 03 '22 06:08 Adam-it

Shall I pickup the dev? My customer need this command. If yes please tell me how to start? any dev guide?

quantrpeter avatar Aug 03 '22 06:08 quantrpeter

Shall I pickup the dev? My customer need this command. If yes please tell me how to start? any dev guide?

quantrpeter avatar Aug 03 '22 06:08 quantrpeter

@quantrpeter this one is not yet ready to start development. Let's give it 1-2 days more for any other maintainer to give it a check and lets see if we should correct/add something to the spec or we can start working on this one. It will be labeled with 'help wanted' label when this one is ready to be developed. πŸ‘

πŸ“š Here is some general guidance on how to contribute to our repo and add a new command https://github.com/pnp/cli-microsoft365/blob/main/CONTRIBUTING.md https://github.com/pnp/cli-microsoft365/wiki/Adding-a-command

πŸ‘©β€πŸ’» as for the main code for this command I believe it will be like 95% similar to already developed one on the list level (https://github.com/pnp/cli-microsoft365/blob/main/src/m365/spo/commands/list/list-roleinheritance-break.ts) the only difference is that will have less options and web api endpoint won't target list by id or title but just the web itself πŸ€”. At least this is what I was aiming πŸ˜‰

Adam-it avatar Aug 03 '22 07:08 Adam-it

Spec seems solid. Let's do it! πŸš€

waldekmastykarz avatar Aug 03 '22 07:08 waldekmastykarz

@quantrpeter this one is ready to be developed. Are you still interested in coding this one? Should I assign it to you? Let me know if you will need any help to start πŸ‘

Adam-it avatar Aug 03 '22 08:08 Adam-it

yes, please, very interest

quantrpeter avatar Aug 03 '22 08:08 quantrpeter

yes, please, very interest

done βœ”. let me know if you will need any help to start πŸ‘

Adam-it avatar Aug 03 '22 10:08 Adam-it

sorry is these steps correct?

  1. i fork this repo
  2. create a file call "web-break-inhreitance.ts" in src/m365/spo/commands/web
  3. fire a pull request
  4. done

quantrpeter avatar Aug 08 '22 15:08 quantrpeter

@quantrpeter almost good πŸ˜‰.

  1. yes βœ…
  2. not enough. the command file name should be web-roleinheritance-break.ts. And also this is not the only file/change required. Please double check the Adding new command wiki page. Also a couple of days ego I created a very similar PR for the reset command so you may also double check with this one what is required web-roleinheritance-reset PR. We need changes in 5 files. Doc.md file + add it to the list, add a new command to the list, add the command action and the test with 100% test coverage for it πŸ‘.
  3. yes βœ…. after your done and you tested it on your end and runed the tests you should open a PR πŸ‘please check the Submitting-a-PR wiki page. If your are interested how the review process will be taken care of please check What-to-expect-during-a-Pull-request-review
  4. if the PR is ok and you have no review comments to resolve then yes. It is done and the merging is on us πŸ˜‰

let me know if you need any additional info/help πŸ‘

Adam-it avatar Aug 08 '22 18:08 Adam-it

will send pull request this week, thx

quantrpeter avatar Aug 22 '22 11:08 quantrpeter

will send pull request this week, thx

great news 🀩. no rush πŸ‘. Let me know if you will need any help πŸ‘

Adam-it avatar Aug 22 '22 13:08 Adam-it

Updated the specs to add an extra option --confirm. Discussed here: https://github.com/pnp/cli-microsoft365/issues/3593#issuecomment-1234828680

milanholemans avatar Sep 02 '22 08:09 milanholemans

We have updated the code, what we should do? fire a new pull request? thanks

quantrpeter avatar Sep 13 '22 10:09 quantrpeter

We have updated the code, what we should do? fire a new pull request? thanks

Hey @quantrpeter

Creating a new PR is not needed. All you have to do is push your new code to the same branch you worked on previously. Your old PR will be updated automatically. If I'm not mistaken, last time you worked on your main branch. Tip for next time: create a new branch based on your main branch to work on one issue.

milanholemans avatar Sep 13 '22 11:09 milanholemans

sorry for the dumb question, If I switch to a new branch. Will the PR follow? If no, I need to submit a new PR. Thank you very much

quantrpeter avatar Sep 13 '22 12:09 quantrpeter

As you can see here, your current PR is linked with your main branch. image

This means that every change you push to your main branch will be visible in the PR. If you work on another branch, these changes will not show up in this PR. So if you made your changes on a different branch, you should create a new PR.

This is the reason why I said that you should make a new branch next time for each issue you are working on. By doing this, you can switch branches quite easy without impacting your other PRs.

If you have any questions, feel free to ask. In the beginning it is always a bit harder that's normal. 😊

milanholemans avatar Sep 13 '22 12:09 milanholemans

thanks @milanholemans

quantrpeter avatar Sep 14 '22 10:09 quantrpeter

yeah, we finally make it, thanks @milanholemans

quantrpeter avatar Oct 29 '22 03:10 quantrpeter