Problem/Motivation

In #3557882: Support "placeholder" dashboard blocks we actually added "placeholder blocks". Its purpose is being used in recipes.
We forgot there to actually restrict that an editor can actually create them, because there's no way we can provide a good UI for those anyway.

Proposed resolution

Restrict them from layout builder and block UI.

Remaining tasks

Fix + tests

User interface changes

No weird blocks show up when placing blocks.

API changes

None.

Data model changes

None.

Issue fork dashboard-3566753

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

penyaskito created an issue. See original summary.

penyaskito’s picture

Assigned: Unassigned » phenaproxima
Status: Active » Needs review
penyaskito’s picture

@phenaproxima I'm guessing you have some recipe for adding placeholder blocks for testing. Can you test this, and/or even better, paste a recipe example here?
I want to ensure that they can ONLY be created through a recipe, and not in the UI.

phenaproxima’s picture

In a recipe, you would probably add a placeholder block with a config action:

 config:
    actions:
        dashboard.dashboard.testing:
            addComponentToLayout:
                section: 0
                position: 1
                component:
                    region: first
                    configuration:
                        id: dashboard_placeholder
                        decorates: 'views_block:my_pages-block'
                        items_per_page: 6
                        more: ['configuration', 'options', 'here']

Drupal CMS's Admin UI recipe just embeds them directly: https://git.drupalcode.org/project/drupal_cms/-/blob/2.x/recipes/drupal_...

So to test it, I would just apply the config action programmatically, and skip messing with a recipe at all. Something like:

\Drupal::service('plugin.manager.config_action')
    ->applyAction('dashboard.dashboard.test', 'addComponentToLayout', [
        'section' => 0,
        'position' => 1,
        'component' => [
            'region' => 'first',
            'configuration' => [
                'id' => 'dashboard_placeholder',
                'decorates' => 'block_content:TEST_BLOCK_UUID',
                'label_display' => '0',
            ],
        ],
    ]);

Similar to how the addComponentToLayout action is tested in core: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/layou...

penyaskito’s picture

Unrelated, but release blocking:

I'd expect you cannot edit the block. But actually the form works!
However, when you save it you actually lose the block!

phenaproxima’s picture

That makes sense. I think what needs to happen is that buildConfigurationForm() and related methods need to be turned into no-ops. The configuration form should probably just always show a message that says "This is a placeholder block and cannot be edited in the UI."

penyaskito’s picture

That was my intent, but Drupal CMS editors would be too confused if some blocks can be edited, and others cannot.
And I actually made this work :D Will open a new MR in the original issue, and leave this for just hiding the block from the UI.

penyaskito’s picture

Assigned: phenaproxima » penyaskito
Status: Needs review » Reviewed & tested by the community
penyaskito’s picture

Title: Ensure placeholder blocks cannot be placed in any UI » [PP-1] Ensure placeholder blocks cannot be placed in any UI
Status: Reviewed & tested by the community » Postponed
penyaskito’s picture

Status: Postponed » Reviewed & tested by the community
penyaskito’s picture

Title: [PP-1] Ensure placeholder blocks cannot be placed in any UI » Ensure placeholder blocks cannot be placed in any UI

  • penyaskito committed d12580fb on 2.x
    fix: #3566753 Ensure placeholder blocks cannot be placed in any UI
    
    By:...
penyaskito’s picture

Status: Reviewed & tested by the community » Fixed

Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

penyaskito’s picture

Assigned: penyaskito » Unassigned
penyaskito’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.