Let us look, how the SPFx web part property configurations changes can be controlled by user permissions.
Let us assume a scenario, where administrators can only change the SPFx web part property values.
The following steps helps achieving the requirement.
This could be achieved, using the WebpartContext property and SPPermission class.
The object is initialized, using the current user permission details, and then site permission is checked for user.
let permission = new SPPermission(this.context.pageContext.web.permissions.value);
let isAdmin = permission.hasPermission(SPPermission.manageWeb);
Let us assume a scenario, where administrators can only change the SPFx web part property values.
The following steps helps achieving the requirement.
- The permissions of logged in user details could be identified using the context/page context.
- While rendering the property pane configurations, the current user permissions could be checked.
- So the properties could be enabled based on the permissions, i.e., properties will be editable, if user has admin access to the site.
This could be achieved, using the WebpartContext property and SPPermission class.
The object is initialized, using the current user permission details, and then site permission is checked for user.
let permission = new SPPermission(this.context.pageContext.web.permissions.value);
let isAdmin = permission.hasPermission(SPPermission.manageWeb);