Default Entitlement
Summary
- By default every Module has an AccessLevel of Full (unless overridden)
- This default AccessLevel can be changed by developers using either a hard-coded value or a function
Developers can set the Default Access Level for Module Entitlements in AdapTable.
This is the Entitlement AccessLevel that will be used if not overridden through explicitly-set Module Entitlements.
The Default Entitlement can be one of 3 values:
ReadOnlyHiddenFull
The property is set using the defaultAccessLevel property in Entitlement Options and it offers 2 ways to provide Entitlements:
- Hard Coded Value - an explicitly provided Default
AccessLevel - Function - a Default
AccessLevelreturned from a custom function
Caution
If this property is not provided, the default Entitlement set by AdapTable for every Module is Full.
Hard Coded Value
This is a value that is set once at design time and doesnt require any run-time evaluation.
- In this example we set the Default Entitlement to
Hidden, so most Modules are not available - We override Layout and FormatColum to be
ReadOnly- so users can see the Format Columns and can switch between Layouts - but not edit them - We override SettingsPanel and Dashboard to
Full- so they are fully viewable and usable
See how the Default Entitlement is provided
JavaScript Function
The other way to set the Default Access Level is via a Function.
This receives a DefaultAccessLevelContext object (which contains the username and the adaptableId of the current instance) and returns an AccessLevel.
This allows you to provide a different Default Access Level depending on the User's role.
export default {
// Set default Module Entitlement as 'Full' for Admins and 'ReadOnly' for everyone else
const adaptableOptions: AdaptableOptions = {
entitlementOptions: {
defaultAccessLevel: (accessLevelContext: DefaultAccessLevelContext)=>{
return (mockEntitlementService.isAdmin(accessLevelContext.userName))? 'Full': 'ReadOnly';
},
},
};Hint
If defaultAccessLevel is set to Hidden, make sure to enable the Settings Panel for access to AdapTable functionality