Skip to content

Bug-fix: spo site remove#5955

Closed
MathijsVerbeeck wants to merge 1 commit intopnp:mainfrom
MathijsVerbeeck:bug-fix-spo-site-remove
Closed

Bug-fix: spo site remove#5955
MathijsVerbeeck wants to merge 1 commit intopnp:mainfrom
MathijsVerbeeck:bug-fix-spo-site-remove

Conversation

@MathijsVerbeeck
Copy link
Copy Markdown
Contributor

Closes #5218

@milanholemans
Copy link
Copy Markdown
Contributor

Thanks @MathijsVerbeeck, we'll have a look at it ASAP!

@MathijsVerbeeck
Copy link
Copy Markdown
Contributor Author

Please keep in mind to create a new issue to remove the wait option in v8.

@milanholemans
Copy link
Copy Markdown
Contributor

Please keep in mind to create a new issue to remove the wait option in v8.

Thanks for the reminder.

@milanholemans milanholemans self-assigned this Apr 6, 2024
Copy link
Copy Markdown
Contributor

@milanholemans milanholemans left a comment

Choose a reason for hiding this comment

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

Nice work @MathijsVerbeeck, command looks a whole lot better already. Could you have a look at the comments I made before we continue?

Comment thread src/m365/spo/commands/site/site-remove.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.ts
Comment thread src/m365/spo/commands/site/site-remove.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.ts
Comment thread src/m365/spo/commands/site/site-remove.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.ts Outdated
Comment thread docs/docs/cmd/spo/site/site-remove.mdx
@milanholemans milanholemans marked this pull request as draft April 21, 2024 16:25
@MathijsVerbeeck
Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review. Could you have another look?

@MathijsVerbeeck MathijsVerbeeck marked this pull request as ready for review April 21, 2024 20:36
@MathijsVerbeeck MathijsVerbeeck force-pushed the bug-fix-spo-site-remove branch from 75cf2aa to 594a2a8 Compare April 21, 2024 20:48
Copy link
Copy Markdown
Contributor

@milanholemans milanholemans left a comment

Choose a reason for hiding this comment

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

The command is getting a nice shape. Unfortunately, I encountered some issues which we should definitely have a look at. Could you have a look at the comments I made before I do another test run?

Comment thread src/m365/spo/commands/site/site-remove.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.spec.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.spec.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.spec.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.spec.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.spec.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.spec.ts Outdated
@milanholemans milanholemans marked this pull request as draft April 23, 2024 22:53
@MathijsVerbeeck MathijsVerbeeck marked this pull request as ready for review April 24, 2024 13:35
Copy link
Copy Markdown
Contributor

@milanholemans milanholemans left a comment

Choose a reason for hiding this comment

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

Did another review. Command is working almost perfectly, few more changes are needed.

Comment thread src/m365/spo/commands/site/site-remove.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.spec.ts
Comment thread src/m365/spo/commands/site/site-remove.spec.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.spec.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.spec.ts Outdated
Comment thread src/m365/spo/commands/site/site-remove.spec.ts Outdated
@milanholemans milanholemans marked this pull request as draft May 4, 2024 20:42
@MathijsVerbeeck MathijsVerbeeck marked this pull request as ready for review May 5, 2024 19:18
@MathijsVerbeeck MathijsVerbeeck force-pushed the bug-fix-spo-site-remove branch from 1ad309a to 86c439a Compare May 5, 2024 19:46
@milanholemans milanholemans force-pushed the bug-fix-spo-site-remove branch from 86c439a to 62ff25b Compare May 5, 2024 20:06
Copy link
Copy Markdown
Contributor

@milanholemans milanholemans left a comment

Choose a reason for hiding this comment

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

Great work, made a few last changes while merging.

if (options.skipRecycleBin) {
if (this.verbose) {
await logger.logToStderr(`Site group doesn't exist. Searching in the Microsoft 365 deleted groups.`);
await logger.logToStderr(`Checking if group '${siteDetails.GroupId}' is already permanently deleted from recycle bin.`);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since we added another verbose log in the function itself, we can remove this one.

let amountOfPolls = 0;

await this.deleteOrphanedSite(logger, args.options.url);
while (!isGroupInRecycleBin && amountOfPolls < 23) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

23 looks like an arbitrary number, no?


if (options.fromRecycleBin) {
if (!siteDetails.TimeDeleted) {
throw `Site is currently not in the recycle bin. Do not specify --fromRecycleBin if you want to try to remove it from the active sites.`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's sound a bit more confident :)

Suggested change
throw `Site is currently not in the recycle bin. Do not specify --fromRecycleBin if you want to try to remove it from the active sites.`;
throw `Site is currently not in the recycle bin. Remove --fromRecycleBin if you want to remove it as active site.`;


}
}
it('deletes a group site, deletes the m365 group from entra id and immediately deletes the site from the recycle bin, but skips deletion of the m365 group when it does not exist in Entra', async () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reading the title, we should check if delete was not called instead of amountOfPolls.


throw 'Invalid request';
});
it('aborts removing the site when prompt not confirmed', async () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's also check for the remove request.

]);
}
}
it('fails validation if siteUrl is a valid url', async () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Invalid*

assert.notStrictEqual(actual, true);
});

it('fails validation if both fromRecycleBin and skipRecycleBin is specified is a valid url', async () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
it('fails validation if both fromRecycleBin and skipRecycleBin is specified is a valid url', async () => {
it('fails validation if both fromRecycleBin and skipRecycleBin are specified', async () => {

Comment thread src/utils/urlUtil.ts
* @param url The URL to process.
* @returns The URL without trailing slash.
*/
removeTrailingSlash(url: string): string {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's rename to removeTrailingSlashes since it removes multiple slashes.

@milanholemans
Copy link
Copy Markdown
Contributor

Merged manually, thanks for fixing this issue!

@MathijsVerbeeck MathijsVerbeeck deleted the bug-fix-spo-site-remove branch May 25, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug report - 'spo site remove' - Removing sites and groupified sites does not work correctly

2 participants