Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/backend/utils/populator/populator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ export async function populator(
const resourceDecorator = records[0].resource.decorate()
const allProperties = Object.values(resourceDecorator.getFlattenProperties())

const references = allProperties.filter((p) => !!p.reference())

const references = allProperties.filter((p) => !!p.reference() && (p.isVisible('show') || p.isVisible('list') || p.isVisible('edit') || p.isVisible('filter')))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can take it a step further and check isVisible only for the current action since it's available in context:
https://github.com/SoftwareBrothers/adminjs/blob/master/src/backend/actions/action.interface.ts#L54

I'm unsure if we'd like to add this restriction though. In actions isVisible is different than isAccessible. Similarly, someone may want to use the ApiClient to fetch record details (show) and they'd like all populated properties to be present.

Ideally, there should be isAccessible in the property options which would tell whether the API should fetch that reference. Setting isAccessible: false should also automatically override isVisible to false since it wouldn't be available.

await Promise.all(references.map(async (propertyDecorator) => {
await populateProperty(records, propertyDecorator, context)
}))
Expand Down