DASH-1272 Allow registered data sources to gate picker visibility by context - #129
Draft
stefanscholz wants to merge 1 commit into
Draft
DASH-1272 Allow registered data sources to gate picker visibility by context#129stefanscholz wants to merge 1 commit into
stefanscholz wants to merge 1 commit into
Conversation
…context Adds a generic, opt-in visibility hook to the data-source registry so a registering plugin can hide one of its data sources from the block builder picker based on the editing context, without block_dash knowing anything about that plugin's rules. - data_source_factory::is_visible_in_context($identifier, $context): if the registry entry carries a 'visible' => callable($identifier, $context): bool, it is consulted; entries without one stay visible (no behaviour change for existing data sources). - edit_form::dash_features_list(): the datasource and widget picker loops now also honour is_visible_in_context(), so a gated entry is omitted for users the callback rejects. Authoring-time only — build_data_source()/render are untouched, so already configured blocks keep rendering. First consumer is dashaddon_repository's per-preset "block builder" role audience.
stefanscholz
marked this pull request as draft
July 24, 2026 10:22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a small, generic extension point to the block_dash data-source registry: a registering plugin can now hide one of its data sources from the block builder's "choose feature" picker based on the editing context, without block_dash needing to know anything about that plugin's rules.
This is the block_dash half of a cross-repo change. The first (and currently only) consumer is
dashaddon_repository, which uses it to enforce a new per-preset "block builder" role audience — i.e. who may select a repository preset when adding a Dash block, decided by the user's roles in the context where the block is being added.What changed
data_source_factory::is_visible_in_context($identifier, $context)— new helper. If a registry entry carries an optional'visible' => callable($identifier, $context): bool, it is invoked and its result returned. Entries without avisiblecallback are always visible, so every existing data source and widget is unaffected.edit_form::dash_features_list()— the datasource and widget picker loops now additionally checkis_visible_in_context($id, $context)alongside the existingblock_dash_visible_addons($id)check, so a gated entry is omitted for users the callback rejects.Design notes for review
dashaddon_repository.build_data_source()and the render path are deliberately not gated, so blocks that already reference a now-restricted data source keep rendering for all viewers. No existing block changes behaviour.visiblekey is optional; absence = visible. Core data sources, widgets and other addons are untouched.$contextis the block's context, already available indash_features_list()and already used for the surrounding capability checks (block/dash:managedatasource/managewidget).Companion change
dashaddon_repository(committed to itsdevbranch) registers each preset with'visible' => [repository_factory::class, 'is_selectable'], which resolves the preset'sadd_rolesaudience against the editing context. Without this block_dash PR, that callback is simply ignored and presets show unconditionally (i.e. today's behaviour), so the two can merge independently.Testing
php -lclean on both changed files; no lines over 132 chars.dash_features_list()picker contents; happy to add coverage if preferred.