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

Command update - spo tenant settings set #5352

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ganesh-sanap
Copy link
Contributor

Type

  • Bug Fix
  • New Feature
  • Sample

Related Issues?

Closes #5034

What is in this Pull Request ?

Added around 33 new options/parameters to spo tenant settings set cmdlet as discussed in issue #5034.

@nicodecleyre
Copy link
Contributor

Amazing work @ganesh-sanap 👏 Looking forward in using these new options (especially IsLoopEnabled 🤭). You rock 🤩

@milanholemans
Copy link
Contributor

Thank you @ganesh-sanap, we'll try to review it ASAP!

@ganesh-sanap
Copy link
Contributor Author

@milanholemans Any update on this PR?

@milanholemans
Copy link
Contributor

@ganesh-sanap not yet no. As you can see, we have quite some PRs to process at the moment and we only do this in our free time. Also, I haven't really had time for the past few days. We will try to process it ASAP.

Thank you for being so patient.

@milanholemans milanholemans self-assigned this Sep 4, 2023
@ganesh-sanap
Copy link
Contributor Author

Hi @milanholemans, Any updates on this PR? Thank you!

@milanholemans
Copy link
Contributor

Hi @ganesh-sanap we had a busy month to release the new major version of CLI. Because this PR is quite large I wasn't able to include it in that release. Will try my best in the coming weeks to review it. Sorry for the delay.

@milanholemans
Copy link
Contributor

Hi, @ganesh-sanap it's been a while since this PR was raised. The last couple of months were quite busy for me. During this time, some PRs were merged and changed stuff to CLI. Could you rebase with the latest main version and fix the few errors?
This will speed up the review process which I'll try to complete in the coming weeks.

Thanks!

@milanholemans milanholemans marked this pull request as draft December 25, 2023 12:40
@ganesh-sanap
Copy link
Contributor Author

@milanholemans Can you help with the steps or commands for rebasing with latest main branch to my local branch (spo-tenant-settings-set-bulk) without loosing changes made to my local branch?

@milanholemans
Copy link
Contributor

milanholemans commented Dec 30, 2023

Hi @ganesh-sanap definitely!

The best way to do this is by syncing your fork on GitHub with the latest changes and pulling these changes locally on your main branch.

Then you switch back to your feature branch and:

# Rebase to main
git rebase main

# Fix merge conflicts in VS Code, when ready click 'Continue' in VS Code.

# When done, push to GitHub, force flag is important! Don't push using VS Code.
git push --force

You can add commits that are added later as usual.

@ganesh-sanap ganesh-sanap marked this pull request as ready for review December 31, 2023 10:05
@ganesh-sanap
Copy link
Contributor Author

Thank you @milanholemans! I have done all the changes and marked this PR for your review.

@milanholemans
Copy link
Contributor

Thank you @ganesh-sanap! Will start reviewing in the coming days (looking at the size of the PR, it will take awhile).

Copy link
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.

Fantastic work so far @ganesh-sanap! Love to see all the new options. Because this PR will take some time to complete, I will review it in pieces.
Right now I've only reviewed the docs. I made a few comments along the way. Could you take a look at them, please?

One small point of attention, let's try to end every description with a period (.), because they are all sentences.

Will try to review the code part of the PR ASAP in the coming weeks.

docs/docs/cmd/spo/tenant/tenant-settings-set.mdx Outdated Show resolved Hide resolved
docs/docs/cmd/spo/tenant/tenant-settings-set.mdx Outdated Show resolved Hide resolved
@milanholemans milanholemans marked this pull request as draft January 17, 2024 23:28
@ganesh-sanap ganesh-sanap marked this pull request as ready for review January 25, 2024 11:21
Copy link
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.

Hi @ganesh-sanap

I did a second review of the docs. I feel we're almost there, could you make these few adjustments before we proceed to the code?

Thank you for the awesome work! It's much appreciated.

docs/docs/cmd/spo/tenant/tenant-settings-set.mdx Outdated Show resolved Hide resolved
docs/docs/cmd/spo/tenant/tenant-settings-set.mdx Outdated Show resolved Hide resolved
: Allowed values `Edit`, `View`, `LimitedEdit`, `LimitedView`, `ManageList`, `None`, `Owner`, `RestrictedView`, `Review`, `Submit`

`--ContainerLoopDefaultShareLinkRole [ContainerLoopDefaultShareLinkRole]`
: Allowed values `Edit`, `View`, `LimitedEdit`, `LimitedView`, `ManageList`, `None`, `Owner`, `RestrictedView`, `Review`, `Submit`
Copy link
Contributor

Choose a reason for hiding this comment

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

There's indeed not much information. But since we have the description for ContainerDefaultShareLinkRole I think this setting is the same but for Loop components.

docs/docs/cmd/spo/tenant/tenant-settings-set.mdx Outdated Show resolved Hide resolved
: Allowed values `Anyone`, `Organization`, `SpecificPeople`, `Uninitialized`

`--ContainerLoopDefaultShareLinkScope [ContainerLoopDefaultShareLinkScope]`
: Allowed values `Anyone`, `Organization`, `SpecificPeople`, `Uninitialized`
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we have the description for ContainerDefaultShareLinkScope, we can use that one, only this setting is about Loop components.

docs/docs/cmd/spo/tenant/tenant-settings-set.mdx Outdated Show resolved Hide resolved
docs/docs/cmd/spo/tenant/tenant-settings-set.mdx Outdated Show resolved Hide resolved
docs/docs/cmd/spo/tenant/tenant-settings-set.mdx Outdated Show resolved Hide resolved
@milanholemans milanholemans marked this pull request as draft February 4, 2024 22:32
@ganesh-sanap ganesh-sanap marked this pull request as ready for review February 8, 2024 11:55
@ganesh-sanap
Copy link
Contributor Author

@milanholemans Pushed commit with required changes, thanks for review!

Copy link
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.

Hi @ganesh-sanap review number 3 is here 😊
Please could you check the comments I made so far? Haven't been able to test all options yet. Tested the first 20 options and encountered 10 options with issues. Seems like we have the most issues with ...Role options. So it could be a good idea to recheck all these options.

Thanks again for the great work so far!

src/m365/spo/commands/tenant/tenant-settings-set.ts Outdated Show resolved Hide resolved
docs/docs/cmd/spo/tenant/tenant-settings-set.mdx Outdated Show resolved Hide resolved
docs/docs/cmd/spo/tenant/tenant-settings-set.mdx Outdated Show resolved Hide resolved
src/m365/spo/commands/tenant/tenant-settings-set.ts Outdated Show resolved Hide resolved
src/m365/spo/commands/tenant/tenant-settings-set.ts Outdated Show resolved Hide resolved
src/m365/spo/commands/tenant/tenant-settings-set.ts Outdated Show resolved Hide resolved
src/m365/spo/commands/tenant/tenant-settings-set.ts Outdated Show resolved Hide resolved
src/m365/spo/commands/tenant/tenant-settings-set.ts Outdated Show resolved Hide resolved
@milanholemans milanholemans marked this pull request as draft February 13, 2024 20:18
@milanholemans
Copy link
Contributor

@ganesh-sanap don't want to put any stress on you at all, but did you find some time to look at the comments I made? Maybe you have lost sight of this? I wouldn't want this valuable work to be lost.

@ganesh-sanap
Copy link
Contributor Author

I will have a look and work on it @milanholemans.

@milanholemans
Copy link
Contributor

Hi @ganesh-sanap did you lose track of this? Don't want to put any pressure just double-checking.

@milanholemans
Copy link
Contributor

Hi @ganesh-sanap do you still want to work on this? No problem if you don't have enough time, we can always open it up for someone else.

@ganesh-sanap
Copy link
Contributor Author

@milanholemans sorry for delay. I am working on it. I have few questions about changes requested, will ask separately. Thanks!

Copy link
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.

Hi @ganesh-sanap, this is a bit annoying, but I would really like to include a few useful options:

  • ExpireVersionsAfterDays (number)
  • MajorVersionLimit (number)
  • EnableAutoExpirationVersionTrim (boolean)

You can find more info about them here: https://learn.microsoft.com/en-us/powershell/module/sharepoint-online/set-spotenant?view=sharepoint-ps

@ganesh-sanap
Copy link
Contributor Author

@milanholemans sure, I will look into those options.

@milanholemans
Copy link
Contributor

@ganesh-sanap are you still willing to work on this? How do you see this issue? Is it too big/too much work? Is it unclear? Are you still interested in it? You are welcome to answer honestly so we can find a way out.

@ganesh-sanap
Copy link
Contributor Author

ganesh-sanap commented May 7, 2024

Hi @milanholemans, I have completed all PR review changes except restricting enum values for ~LinkRole options, currently working on it. Hopefully I will complete it by this week and send it again for your review.

Regarding adding new options (ExpireVersionsAfterDays, MajorVersionLimit, EnableAutoExpirationVersionTrim), I checked the logic in PnP PowerShell code and I think these options requires checking existing tenant setting values & adding some rules/errors based on it - this will take more time. Shall we do this in separate issue/PR? Thanks!

@milanholemans
Copy link
Contributor

Regarding adding new options (ExpireVersionsAfterDays, MajorVersionLimit, EnableAutoExpirationVersionTrim), I checked the logic in PnP PowerShell code and I think these options requires checking existing tenant setting values & adding some rules/errors based on it - this will take more time. Shall we do this in separate issue/PR? Thanks!

Is it that complicated? Aren't these just number and boolean fields?

@ganesh-sanap
Copy link
Contributor Author

@milanholemans while passing the options (ExpireVersionsAfterDays and MajorVersionLimit) to the command, first we have to check the existing value of EnableAutoExpirationVersionTrim tenant property. We have to allow updating ExpireVersionsAfterDays and MajorVersionLimit properties only when EnableAutoExpirationVersionTrim property is set to false.

I think we will have to do the GET call to tenant settings for adding these type of validation rules before updating the property values using this command. So, this will not be a simple change like other number and boolean fields.

@ganesh-sanap ganesh-sanap marked this pull request as ready for review May 8, 2024 17:21
@milanholemans
Copy link
Contributor

@milanholemans while passing the options (ExpireVersionsAfterDays and MajorVersionLimit) to the command, first we have to check the existing value of EnableAutoExpirationVersionTrim tenant property. We have to allow updating ExpireVersionsAfterDays and MajorVersionLimit properties only when EnableAutoExpirationVersionTrim property is set to false.

Technically speaking, we should indeed. But is this really limited by the API itself? Does it throw an error if you don't?
This command is so gigantic that it's nearly impossible to build validations for every command. Also would it make it quite unclear in my opinion.

@milanholemans
Copy link
Contributor

Hi @ganesh-sanap. I know this PR is taking a while, but I haven't forgotten about it. We're currently preparing a V8 release with CLI which consumed quite some time from my side. I will try to find some time to do another review for this big PR. Maybe in the meantime you could rebase with the latest main and resolve the merge conflict to make it go a little bit faster?

Copy link
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.

I did another partial review of the command logic @ganesh-sanap. Could you take a look at the comments I made, please?
Pardon me for the long silent period.
Can you also make sure that the code is rebased with the latest main, please?

SharingCapability: string; // <SharingCapabilities>
NoAccessRedirectUrl?: string;
ArchiveRedirectUrl?: string;
ConditionalAccessPolicyErrorHelpLink?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm unable to clear this value:
image

NoAccessRedirectUrl?: string;
ArchiveRedirectUrl?: string;
ConditionalAccessPolicyErrorHelpLink?: string;
CustomizedExternalSharingServiceUrl?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we set this value to null when an empty string is passed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This comment is for which option/parameter exactly?

Copy link
Contributor

Choose a reason for hiding this comment

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

Comments always apply to the last line displayed, so in this case, it should be CustomizedExternalSharingServiceUrl.

ArchiveRedirectUrl?: string;
ConditionalAccessPolicyErrorHelpLink?: string;
CustomizedExternalSharingServiceUrl?: string;
LabelMismatchEmailHelpLink?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we set this value to null when an empty string is passed?

@@ -179,36 +326,70 @@ class SpoTenantSettingsSetCommand extends SpoCommand {
#initTelemetry(): void {
this.telemetry.push((args: CommandArgs) => {
const telemetryProps: any = {
Copy link
Contributor

Choose a reason for hiding this comment

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

From what I can see, we're missing some telemetry options:

CoreRequestFilesLinkEnabled
OneDriveRequestFilesLinkEnabled
DisableDocumentLibraryDefaultLabeling
DisableVivaConnectionsAnalytics
DisplayNamesOfFileViewersInSpo
EnableAIPIntegration
EnableRestrictedAccessControl
ExternalUserExpirationRequired
HideSyncButtonOnDocLib
IncludeAtAGlanceInShareEmails
InformationBarriersSuspension
IsFluidEnabled
IsWBFluidEnabled
IsCollabMeetingNotesFluidEnabled
IsEnableAppAuthPopUpEnabled
IsLoopEnabled
OneDriveDefaultLinkToExistingAccess
ContainerDefaultLinkToExistingAccess
ReduceTempTokenLifetimeEnabled
ShowOpenInDesktopOptionForSyncedFiles
ShowPeoplePickerGroupSuggestionsForIB
SiteOwnerManageLegacyServicePrincipalEnabled
StopNew2010Workflows
StopNew2013Workflows
ViewersCanCommentOnMediaDisabled
AllowEveryoneExceptExternalUsersClaimInPrivateSite
AnyoneLinkTrackUsers
HasAdminCompletedCUConfiguration
HasIntelligentContentServicesCapability
HasTopicExperiencesCapability
MachineLearningCaptureEnabled
MassDeleteNotificationDisabled
MobileFriendlyUrlEnabledInTenant
EnableAutoNewsDigest
AllowCommentsTextOnEmailEnabled
CommentsOnFilesDisabled
DisableAddToOneDrive
DisableBackToClassic
DisablePersonalListCreation
ViewInFileExplorerEnabled
AllowGuestUserShareToUsersNotInSiteCollection
BlockSendLabelMismatchEmail
CoreDefaultLinkToExistingAccess

Comment on lines 1074 to 782
public getAllEnumOptions(): string[] {
return ['SharingCapability', 'SharingDomainRestrictionMode', 'DefaultSharingLinkType', 'ODBMembersCanShare', 'ODBAccessRequests', 'FileAnonymousLinkType', 'FolderAnonymousLinkType', 'DefaultLinkPermission', 'ConditionalAccessPolicy', 'LimitedAccessFileType', 'SpecialCharactersStateInFileFolderNames'];
return ['SharingCapability', 'CoreSharingCapability', 'ODBSharingCapability', 'ContainerSharingCapability', 'CoreDefaultShareLinkRole', 'CoreLoopDefaultSharingLinkRole', 'ContainerDefaultShareLinkRole', 'ContainerLoopDefaultShareLinkRole', 'OneDriveDefaultShareLinkRole', 'OneDriveLoopDefaultSharingLinkRole', 'CoreDefaultShareLinkScope', 'CoreLoopDefaultSharingLinkScope', 'ContainerDefaultShareLinkScope', 'ContainerLoopDefaultShareLinkScope', 'OneDriveDefaultShareLinkScope', 'OneDriveLoopDefaultSharingLinkScope', 'SharingDomainRestrictionMode', 'DefaultSharingLinkType', 'ODBMembersCanShare', 'ODBAccessRequests', 'AllowAnonymousMeetingParticipantsToAccessWhiteboards', 'FileAnonymousLinkType', 'FolderAnonymousLinkType', 'DefaultLinkPermission', 'ConditionalAccessPolicy', 'LimitedAccessFileType', 'MediaTranscription', 'MediaTranscriptionAutomaticFeatures', 'ImageTaggingOption', 'MarkNewFilesSensitiveByDefault', 'OCRModeForAdminSites', 'OCRModeForComplianceODBs', 'OCRModeForComplianceSites', 'SpecialCharactersStateInFileFolderNames'];
}

public getAllRoleOptions(): string[] {
return ['CoreDefaultShareLinkRole', 'CoreLoopDefaultSharingLinkRole', 'ContainerDefaultShareLinkRole', 'ContainerLoopDefaultShareLinkRole', 'OneDriveDefaultShareLinkRole', 'OneDriveLoopDefaultSharingLinkRole'];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of functions, can't we use just an array like we do with boolean options?

Comment on lines 1092 to 1097
private getMediaTranscriptionPolicyType(): string[] { return ['Enabled', 'Disabled']; }
private getMediaTranscriptionAutomaticFeaturesPolicyType(): string[] { return ['Enabled', 'Disabled']; }
private getImageTaggingChoice(): string[] { return ['Disabled', 'Basic', 'Enhanced']; }
private getSensitiveByDefaultState(): string[] { return ['AllowExternalSharing', 'BlockExternalSharing']; }
private getObjectCharacterRecognitionMode(): string[] { return ['Disabled', 'InclusionList', 'ExclusionList']; }
private getSharingScope(): string[] { return ['Uninitialized', 'Anyone', 'Organization', 'SpecificPeople']; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of functions, let's use private variables.

Comment on lines 1047 to 1052
this.getAllRoleOptions().indexOf(propertyKey) > -1) {
const role: Role = Role[(propertyValue.trim() as keyof typeof Role)];
if (role === undefined || role === null) {
return `${propertyKey} option has invalid value of "${propertyValue}". Allowed values are: ${this.RoleMap.join(", ")}.`;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this? Normally all values listed in the autocomplete property should be correct input.

Comment on lines 1119 to 1122
if (this.getAllRoleOptions().indexOf(optionKey) > -1) {
// map enum values to int
optionValue = Role[(args.options[optionKey].trim() as keyof typeof Role)].valueOf();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we just treat these values as enums? This logic is already present.

propsXml += `<SetProperty Id="${id++}" ObjectPathId="7" Name="${optionKey}"><Parameter Type="String">${optionValue}</Parameter></SetProperty>`;
}
else {
propsXml += `<SetProperty Id="${id++}" ObjectPathId="7" Name="${optionKey}"><Parameter Type="Null">${null}</Parameter></SetProperty>`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we simplify this?

Suggested change
propsXml += `<SetProperty Id="${id++}" ObjectPathId="7" Name="${optionKey}"><Parameter Type="Null">${null}</Parameter></SetProperty>`;
propsXml += `<SetProperty Id="${id++}" ObjectPathId="7" Name="${optionKey}"><Parameter Type="Null" /></SetProperty>`;

@@ -637,6 +1137,15 @@ class SpoTenantSettingsSetCommand extends SpoCommand {
});
propsXml += `<SetProperty Id="${id++}" ObjectPathId="7" Name="${optionKey}"><Parameter Type="Array">${valuesXml}</Parameter></SetProperty><Method Name="Update" Id="${id++}" ObjectPathId="7" />`;
}
else if (['LabelMismatchEmailHelpLink'].indexOf(optionKey) > -1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this something we could apply to all options instead of just this one?

@milanholemans milanholemans marked this pull request as draft August 5, 2024 00:10
@milanholemans
Copy link
Contributor

Hi @ganesh-sanap, are you still willing to continue this PR?

@ganesh-sanap
Copy link
Contributor Author

Yes, I will look into review comments.

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.

[Enhancement] - Add more options to spo tenant settings set
4 participants