XperienceCommunity.WidgetFilter 13.0.2

dotnet add package XperienceCommunity.WidgetFilter --version 13.0.2                
NuGet\Install-Package XperienceCommunity.WidgetFilter -Version 13.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XperienceCommunity.WidgetFilter" Version="13.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add XperienceCommunity.WidgetFilter --version 13.0.2                
#r "nuget: XperienceCommunity.WidgetFilter, 13.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install XperienceCommunity.WidgetFilter as a Cake Addin
#addin nuget:?package=XperienceCommunity.WidgetFilter&version=13.0.2

// Install XperienceCommunity.WidgetFilter as a Cake Tool
#tool nuget:?package=XperienceCommunity.WidgetFilter&version=13.0.2                

XperienceCommunity.WidgetFilter

Ability to have widgets designated to "Sets" as well as limit widgets based on user, role, or site.

Requirements

Kentico Xperience 13 on .Net core 3.1 or above

Installation

  1. On your Xperience MVC Site, install the XperienceCommunity.WidgetFilter nuget package.
  2. In your startup, call services.AddWidgetFilter()
  3. Add @addTagHelper *, XperienceCommunity.WidgetFilter to your _ViewImports.cshtml or whichever view you wish to get the tag helper.

Usage

There are 2 new assembly attributes, [assembly: RegisterWidgetToSets] and [assembly: RegisterWidgetPermissions].

There should be only one RegisterWidgetToSets and one RegisterWidgetPermissions per widget max.

Widget Sets

Add [assembly: RegisterWidgetToSets] to any widget you wish to designate to a set. If a widget has no RegisterWidgetToSets attribute, it's considered a general widget.

Add widget-sets (along with optional include-general-widgets='true') to your <editable-area/> tag.

Example: <editable-area area-identifier="main" widget-sets="@(new string[] { SiteWidgetSets.BANNERS })" include-general-widgets=true />

By default, if you specify any widget sets, general widgets will be excluded unless you specifically call include-general-widgets=true, likewise if you do not specify any widget sets, general widgets are always shown.

Widget Permission

Add [assembly: RegisterWidgetPermissions] to any widget widget you wish to limit by User type, Role, or Site. If a widget has no RegisterWidgetPermissions attribute, then it will not get filtered out by permission.

Widget identity and the widgetPermissionMinimumUserType required, the user type is a minimum so WidgetPermissionMinimumUserType.Editor means editors and above can add (all inclusive). Roles can be an empty array, same for sites, but if you provide then the user either needs to be in the role for roles, or the current site is listed in the sites (site code names) to display.

Existing Widgets

If a widget is added prior to being excluded, or if a widget that a user doesn't have permission to add is already on the page, that widget is still editable. However, you cannot copy / paste it and you cannot add a new widget unless the widget is in the widget set or the user has permission.

So be aware that while you may set a widget to only be usable by Global Administrators, for example, once a Global Administrator adds the widget it can be edited by anyone.

Mixing area-options-allowed-widgets and widget-sets

If you hardcode area-options-allowed-widgets on the editable area, please note that the Include Generic Widgets will be defaulted to false unless specified, otherwise Generic widgets will be included. Your hard coded widgets will be included as long as the widget permissions allow them to be included.

Contributions

If you find a bug, please feel free to submit a pull request!

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
13.0.2 11,456 5/31/2022
13.0.1 2,491 2/26/2022

Adjusted to keep Widget Identity capitilization (bug where Copied widgets would not be allowed due to case sensitive check in page-builder.js), also added logic to allow area-options-allowed-widgets to be included and appended to any sets, with including Generic Widgets defaulting to false if any specified.