-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Problem
When an application sets restrictive default permission rules (e.g., READ_INSERT_EDIT_DELETE_PERMISSIONS with DenyBehavior.HIDDEN), child record list widgets created by ChildRecordListWidgetFromRecordEntityGenericMetaDataProducer get filtered out in MetaDataAction because they have null permission rules.
Root Cause
ChildRecordListRenderer.widgetMetaDataBuilder() creates a QWidgetMetaData but does not set permissionRules. When PermissionsHelper.getEffectivePermissionRules() is called for these widgets, it returns the instance's default permission rules (line 467):
if(metaDataWithPermissionRules.getPermissionRules() == null)
{
LOG.warn("Null permission rules on meta data object...");
return (instance.getDefaultPermissionRules());
}If those default rules are restrictive and the user doesn't have the required permissions, the widget gets filtered out in MetaDataAction at line 180-184.
Suggested Fix
Set NOT_PROTECTED permission rules on child record list widgets by default in ChildRecordListRenderer.widgetMetaDataBuilder():
public static Builder widgetMetaDataBuilder(QJoinMetaData join)
{
return (new Builder(new QWidgetMetaData()
.withName(join.getName())
.withIsCard(true)
.withCodeReference(new QCodeReference(ChildRecordListRenderer.class))
.withType(WidgetType.CHILD_RECORD_LIST.getType())
.withDefaultValue("joinName", join.getName())
.withValidatorPlugin(new ChildRecordListWidgetValidator())
.withPermissionRules(new QPermissionRules().withLevel(PermissionLevel.NOT_PROTECTED)) // ADD THIS
));
}This makes sense because:
- Child record list widgets are displayed within a parent record's detail page
- Access to the parent record already requires permissions on the parent table
- The widget queries the child table, which has its own permission checks
- The widget itself doesn't need additional permission gating
Workaround
Applications can work around this by adding a post-processor that sets permission rules on widgets with null rules:
qInstance.getWidgets().values().forEach(widget -> {
if(widget.getPermissionRules() == null) {
widget.setPermissionRules(new QPermissionRules()
.withLevel(PermissionLevel.NOT_PROTECTED));
}
});Environment
- QQQ version: 0.40.0-SNAPSHOT