UI for publishing/unpublishing block_content blocks

Created on 10 December 2016, about 8 years ago
Updated 27 August 2024, 4 months ago

Problem/Motivation

In #2820848: Make BlockContent entities publishable blocks got a publishing status field, but no UI. We should provide a way for users to (un)publish blocks when editing/creating them.

Changes to the block library page have been split off to to #2909435: Update block library page to adapt publishable block content implementation

Proposed resolution

  • Add the published checkbox to the block edit form like on other editorial content entities.
  • Published status on block_content views that is on route /admin/content/block
  • Add new block_content_publish_action and block_content_unpublish_action action plugins.
  • Add above mentioned plugins on bulk actions on block_content views to allow mass (un)publishing block content.
  • If a block is unpublished it wont be rendered for users without administer blocks permission.
  • Users with administer blocks permission will have visual cue of block content being on unpublished state on front-end.

Remaining tasks

  • - it will not appear
  • - I'm going to say no as I can't think of what usefulness that would be. Or should be a follow up
  • Add additional test coverage for the UI implications of what happens if a block content entity is unpublished (see #87)
  • Add test coverage for block content translations (see #87 and #187)
  • Add visual cue that block is unpublished when rendered on page, take example from node--unpublished #87
  • Adjust the code if 🐛 Make exposure of translation meta fields conditional Needs work lands first.
  • Reviews
  • Manual testing of patch
  • Commit

User interface changes

Yes.

Status checkbox on the block content form

API changes

None.

Data model changes

None.

Feature request
Status

Needs work

Version

11.0 🔥

Component
Block content 

Last updated 20 days ago

Created by

🇫🇷France dixon_ France

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

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.

  • 🇮🇪Ireland frankdesign

    Might be worth noting, at the moment it is not possible to create a View of blocks and filter it by 'Enabled'. E.g. if a have a number of Custom Blocks which I have added to my Block Layout and some of them are Enabled and some are Disabled. If I create a View of Custom Blocks and filter them by Published, all the blocks appear in the list as all are considered Published by Views. There is no filter option to filter by Enabled.

    Even if I remove a Custom Block from the Block Layout - it will still appear in my Views list.

    If this issue is fixed, will it solve this problem too? Or is that a separate problem that I need to create a new issue?

  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    Hi @frankdesign I think you're conflating two different concepts there

    We have Block placements - these are config entities that you see at Admin > Structure > Block. These are configured block plugins that include the block-type, the region it is placed in and the theme. They can be blocks made from content (more on that below) but they can also be system blocks like menus, views etc

    We also have Block content entities, these are what you see at Admin > Structure > Block > Block Library on 10.0 and below and Admin > Content > Blocks for 10.1 and above.

    Block placements can be disabled and enabled

    Block content entities can be published and unpublished (and even have drafts).

    This is about adding a UI for publishing and unpublishing the block content entities.

    They are two different concepts and unfortunately views has no visibility of the block placements which is where the enabled/disabled state comes from. It can only track the content entities.

  • last update over 1 year ago
    Build Successful
  • last update over 1 year ago
    Build Successful
  • last update over 1 year ago
    29,493 pass, 8 fail
  • 🇺🇸United States smustgrave

    1. Add additional test coverage for the UI implications of what happens if a block content entity is unpublished (see #87)
    TODO - dependent on answer to 2-4

    2. Confirm how this impacts translations (see #87)
    Not sure how to verify this. But translation appears to be working

    3. Confirm what occurs if a block config entity (placement) references an unpublished block
    Updated getEntity() to check status before returning. So unpublished content won't appear.

    4. Consider if we need to add a 'view unpublished' permission per #13
    Not sure the use case.

  • last update over 1 year ago
    29,497 pass, 5 fail
  • last update over 1 year ago
    29,504 pass
  • Status changed to Needs review over 1 year ago
  • 🇺🇸United States smustgrave

    Updated issue summary.

    With the changes to the tests I wonder if that covers the change of the block not appearing when status is unpublished.

    Putting to review for general feedback.

  • Status changed to Needs work over 1 year ago
  • The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • last update over 1 year ago
    30,064 pass, 2 fail
  • Status changed to Needs review over 1 year ago
  • 🇺🇸United States smustgrave

    Moved logic to blockAccess ready for review again.

  • last update over 1 year ago
    30,158 pass, 5 fail
  • Pipeline finished with Failed
    over 1 year ago
    Total: 1361s
    #21165
  • last update over 1 year ago
    30,169 pass
  • Pipeline finished with Failed
    over 1 year ago
    Total: 395s
    #21194
  • last update over 1 year ago
    29,470 pass, 12 fail
  • 🇺🇦Ukraine savkaviktor16@gmail.com

    I have rerolled the last version of MR !4213 to D10.1.3 !THIS PATCH DOESN'T CONTAIN TESTS!

  • 🇺🇸United States smustgrave

    Hiding patch

  • Status changed to Needs work about 1 year ago
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    Left a review on the MR, thanks for picking this up again 🥰

  • 🇺🇸United States smustgrave

    Addressed some feedback. Leaving NW for the open questions and other open threads.

  • last update about 1 year ago
    Build Successful
  • Pipeline finished with Failed
    about 1 year ago
    #24853
  • last update about 1 year ago
    30,275 pass, 4 fail
  • last update about 1 year ago
    Custom Commands Failed
  • Pipeline finished with Failed
    about 1 year ago
    Total: 172s
    #25990
  • last update about 1 year ago
    30,343 pass, 62 fail
  • Pipeline finished with Failed
    about 1 year ago
    Total: 670s
    #29714
  • Status changed to Needs review about 1 year ago
  • 🇺🇸United States smustgrave

    All threads I believe have been resolved.

  • last update about 1 year ago
    30,399 pass
  • Pipeline finished with Success
    about 1 year ago
    Total: 714s
    #29720
  • last update about 1 year ago
    30,442 pass
  • Pipeline finished with Success
    about 1 year ago
    Total: 623s
    #38558
  • 🇧🇪Belgium borisson_ Mechelen, 🇧🇪

    Posted a few nitpicks to the MR, I think @larowlan's questsions have all been answered?

  • Status changed to Needs work about 1 year ago
  • 🇧🇪Belgium BramDriesen Belgium 🇧🇪

    Added a few nits. Setting to NW for the possible valid todo.

  • Pipeline finished with Success
    about 1 year ago
    #49707
  • Status changed to Needs review about 1 year ago
  • 🇺🇸United States smustgrave

    Addressed feedback and cleanup CR.

  • Pipeline finished with Success
    about 1 year ago
    Total: 1129s
    #49714
  • Status changed to RTBC about 1 year ago
  • 🇧🇪Belgium borisson_ Mechelen, 🇧🇪

    I'm not sure if this needs product manager or ux team feedback, but if it doesn't this looks good to go.

  • last update about 1 year ago
    30,556 pass
  • last update about 1 year ago
    30,174 pass, 72 fail
  • last update about 1 year ago
    30,607 pass
  • last update about 1 year ago
    30,610 pass
  • last update about 1 year ago
    30,605 pass, 2 fail
  • last update about 1 year ago
    30,672 pass, 1 fail
  • last update about 1 year ago
    30,681 pass
  • last update about 1 year ago
    30,689 pass
  • last update about 1 year ago
    30,693 pass
  • last update about 1 year ago
    30,693 pass
  • last update about 1 year ago
    30,693 pass
  • last update about 1 year ago
    30,701 pass
  • last update about 1 year ago
    30,703 pass
  • last update about 1 year ago
    30,717 pass
  • last update about 1 year ago
    30,729 pass
  • last update about 1 year ago
    30,769 pass
  • last update about 1 year ago
    30,771 pass
  • last update about 1 year ago
    25,917 pass, 1,782 fail
  • 9:07
    43:07
    Running
  • last update 12 months ago
    25,954 pass, 1,823 fail
  • last update 12 months ago
    25,935 pass, 1,820 fail
  • last update 12 months ago
    25,942 pass, 1,824 fail
  • last update 12 months ago
    26,906 pass, 1,643 fail
  • last update 12 months ago
    25,906 pass, 1,819 fail
  • last update 12 months ago
    25,934 pass, 1,833 fail
  • last update 12 months ago
    25,977 pass, 1,833 fail
  • last update 12 months ago
    26,003 pass, 1,803 fail
  • last update 12 months ago
    CI aborted
  • 🇫🇮Finland lauriii Finland

    Based on the number of followers and participants, this seems like a feature that several folks would like to have. I'm not sure I understand when is this feature used and I didn't find any discussion about this from the thread. It would be helpful if folks could comment here / update the issue summary to explain what are the use cases for this feature. 😊

  • 🇮🇪Ireland frankdesign

    @lauriii

    I have a number of blocks on a website that are click button links for membership renewal. The links are to an external third party website, who are handling the actual renewals and payments etc... As a result, I don't have access to publishing/unpublishing those pages/products.

    The membership renewal window is only open for a few months each year. So I need to be able to allow content editors to show/hide the blocks with the button links. I don't want the same content editors to have access to the Block Layout page as there are loads of other blocks that I don't want them interfering with. So the only solution that I can see is to be able to publish/unpublish the block as the window open/closes.

    At the moment, as site admin, I am managing the visibility of the blocks for them, not ideal but it works. I'd rather that they manage it themselves.

    F

  • 🇩🇪Germany mrshowerman Munich

    Re #163
    We use this feature for a kind of "breaking news" block that is displayed on each page on our site.
    When the news is outdated, we're unpublishing the block.

  • 🇫🇮Finland lauriii Finland

    Thank you @frankdesign and @mrshowerman! Based on #164 and #165 +1 on the feature from me. I haven't looked at the actual code though.

  • 🇺🇸United States smustgrave

    Just fyi if there's an issue with the view updates for adding the filters I'm going to just remove those. Based on how I've seen tickets for content view where the view ships with the changes but no update hook for it.

  • Status changed to Needs work 11 months ago
  • The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • Pipeline finished with Failed
    11 months ago
    Total: 577s
    #84986
  • Pipeline finished with Success
    11 months ago
    Total: 500s
    #84988
  • Status changed to Needs review 11 months ago
  • 🇺🇸United States smustgrave

    Rebased and removed the update hook for adding filters/columns to existing views. Based on how I've seen issues committed for main content view without update hook believe that's one hurdle we can just remove here.

  • Status changed to Needs work 10 months ago
  • The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • Status changed to Needs review 10 months ago
  • 🇺🇸United States smustgrave

    Rebased

  • Pipeline finished with Failed
    10 months ago
    Total: 171s
    #106119
  • Pipeline finished with Success
    10 months ago
    Total: 673s
    #106124
  • Status changed to Needs work 10 months ago
  • The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • Pipeline finished with Success
    10 months ago
    Total: 491s
    #112966
  • Status changed to Needs review 10 months ago
  • 🇺🇸United States smustgrave

    Rebased

  • Status changed to Needs work 10 months ago
  • The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • Status changed to Needs review 10 months ago
  • 🇺🇸United States smustgrave

    Rebased

  • Pipeline finished with Success
    10 months ago
    Total: 696s
    #116863
  • Status changed to Needs work 9 months ago
  • The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • First commit to issue fork.
  • 🇮🇳India sakthi_dev

    Rebased with 11.x and resolved conflicts.

  • Pipeline finished with Failed
    9 months ago
    Total: 227s
    #118263
  • Pipeline finished with Failed
    9 months ago
    Total: 137s
    #126448
  • Pipeline finished with Failed
    9 months ago
    Total: 193s
    #126452
  • Pipeline finished with Failed
    9 months ago
    #126461
  • Pipeline finished with Canceled
    9 months ago
    Total: 237s
    #126469
  • Pipeline finished with Failed
    9 months ago
    Total: 533s
    #126472
  • Pipeline finished with Success
    9 months ago
    Total: 496s
    #126482
  • Status changed to Needs review 9 months ago
  • 🇺🇸United States smustgrave

    Reverted back to before rebase to commit 53e960c6f5e42c0e42cbb24aa727811b817e3236 and rebased from there. Seems there was previous rebase errors even before that so fixed that too

  • Status changed to Needs work 9 months ago
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    Left some comments on the MR

    I think we also need to check if we need a views wizard plugin change here, we probably want to add a status = 1 filter by default to any new view of block content entities. But we might not even have a views wizard plugin for block content, so if that's the case, nothing to do

  • Pipeline finished with Canceled
    8 months ago
    Total: 113s
    #150648
  • Pipeline finished with Failed
    8 months ago
    #150650
  • Pipeline finished with Canceled
    8 months ago
    Total: 14s
    #150659
  • Pipeline finished with Failed
    8 months ago
    Total: 1005s
    #150660
  • Pipeline finished with Canceled
    8 months ago
    Total: 129s
    #150669
  • Pipeline finished with Failed
    8 months ago
    Total: 1108s
    #150670
  • Pipeline finished with Success
    8 months ago
    Total: 992s
    #151113
  • Pipeline finished with Failed
    7 months ago
    Total: 590s
    #190102
  • Pipeline finished with Success
    7 months ago
    Total: 678s
    #190123
  • 🇦🇺Australia acbramley

    The MR seems to cover a huge amount more than what is described in the IS (seeing action plugins, views filter changes, bulk operations, etc)

  • 🇦🇺Australia acbramley

    From the IS

    If a block is unpublished it does not appear.

    Are we not doing the access/rendering changes here? Also saw a comment on the MR about access handler changes but I'm not seeing them?

  • 🇨🇭Switzerland berdir Switzerland
  • First commit to issue fork.
  • Pipeline finished with Failed
    5 months ago
    Total: 156s
    #245604
  • Pipeline finished with Failed
    5 months ago
    Total: 189s
    #245619
  • 🇧🇪Belgium kriboogh

    Rebased MR for latest 11.x
    Added patch of MR for use in composer.
    Applies to 11.x and 10.3.x.

  • Pipeline finished with Failed
    5 months ago
    Total: 150s
    #245636
  • Pipeline finished with Success
    5 months ago
    Total: 444s
    #245644
  • 🇧🇪Belgium kriboogh

    Update of MR patch reflecting last fix (remove double status key in config).

  • 🇫🇮Finland sokru

    I did my best to update the issue summary, tried to split the remaining tasks.
    IMHO this should include an upgrade path for views block_content that is on route /admin/content/block.

    This needs work for translations: Block content has translation, but translation unpublished, the source language is rendered. Something like this fixed the issue, but probably would better to be done at BlockContentBlock::getEntity()

    --- a/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php
    +++ b/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php
    @@ -185,7 +185,9 @@ protected function blockAccess(AccountInterface $account) {
        * {@inheritdoc}
        */
       public function build() {
    -    if ($block = $this->getEntity()) {
    +    $currentLangcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
    +    $block = $this->getEntity();
    +    if ($block && $block->language()->getId() === $currentLangcode) {
    
Production build 0.71.5 2024