Hide 'Usage' tabs for bundles without usage

Created on 21 December 2022, about 2 years ago
Updated 26 August 2024, 4 months ago

Problem/Motivation

Hide 'Usage' tab where the bundle in context does not have any usages for any entities in the bundle. Presently the visibility of 'Usage' tab is configured by entity type, and is not backed by actual data.

Proposed resolution

Simply track whether a bundle has at least one usage, and put the values of these flags in an invalidatable cache. So when new bundles are added/removed we can simply invalidate and rebuild it.

We could have hidden the usage tab for entities if just the entity in context did not have usage, but I decided that its more useful for the tab to be present and display zero usages on the page than for it to be inexplicably missing for some entities.

Other notes

Currently Entity Usage project doesn't track bundle stats.

EU should probably track bundle in a new column in {entity_usage}, in the same manner as field tables do in order to efficiently delete data when a bundle is deleted.

In any case this optimisation can be made in another issue, there are ways to determine usage with SQL joins, though the logic is not foolproof.

Remaining tasks

Review

User interface changes

Usage tab visibility may hide automatically.

API changes

New service. Implementation introduces it but does not provide a finalised API (interface). See @internal notes on service.

Data model changes

Makes use of cache API, so new cache table will be created automatically if using database backed caching.

Feature request
Status

Postponed

Version

4.0

Component

Code

Created by

🇦🇺Australia dpi Perth, Australia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024