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.

If a block is unpublished it does not appear.

Remaining tasks

  • Combine with #2909435: Update block library page to adapt publishable block content implementation (see #106, #107)
  • Add additional test coverage for the UI implications of what happens if a block content entity is unpublished (see #87)
  • Confirm how this impacts translations (see #87)
  • Confirm what occurs if a block config entity (placement) references an unpublished block
  • - it will not appear

  • Consider if we need to add a 'view unpublished' permission per #13 - I'm going to say no as I can't think of what usefulness that would be. Or should be a follow up
  • Reviews
  • Manual testing of patch
  • Commit

User interface changes

Yes.

Status checkbox on the block content form

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#176 2834546-nr-bot.txt90 bytesneeds-review-queue-bot
#174 2834546-nr-bot.txt90 bytesneeds-review-queue-bot
#172 2834546-nr-bot.txt90 bytesneeds-review-queue-bot
#170 2834546-nr-bot.txt12.16 KBneeds-review-queue-bot
#168 2834546-nr-bot.txt90 bytesneeds-review-queue-bot
#153 2834546-153.patch20.88 KBsavkaviktor16@gmail.com
#151 2834546-nr-bot.txt90 bytesneeds-review-queue-bot
#142 2834546-142.patch42.24 KBsmustgrave
#142 interdiff-134-142.txt25.55 KBsmustgrave
#134 2834546-134.patch15.94 KBsmustgrave
#134 interdiff-132-134.txt6.1 KBsmustgrave
#132 2834546-132.patch16.05 KBsmustgrave
#132 interdiff-130-132.txt0 bytessmustgrave
#130 2834546-130.patch14.92 KBsmustgrave
#130 interdiff-126-130.txt0 bytessmustgrave
#127 2834546-127.patch18.3 KBhardikpandya
#126 2834546-126.patch16.25 KBamateescu
#118 2834546-118.patch16.27 KBManuel Garcia
#118 interdiff-2834546-116-118.txt3.81 KBManuel Garcia
#116 2834546-116.patch16.19 KBManuel Garcia
#116 interdiff-2834546-114-116.txt635 bytesManuel Garcia
#114 2834546-114.patch16.19 KBManuel Garcia
#114 interdiff-2834546-112-114.txt1.34 KBManuel Garcia
#112 2834546-112.patch15 KBManuel Garcia
#112 interdiff-2834546-110-112.txt865 bytesManuel Garcia
#110 interdiff-2834546-101-110.diff.txt3.33 KBszeidler
#110 2834546-110.patch15.07 KBszeidler
#109 block_content_published_translation.gif1.77 MBszeidler
#101 2834546-101.patch12.64 KBManuel Garcia
#101 interdiff-2834546-99-101.txt5.85 KBManuel Garcia
#99 2834546-99.patch9.34 KBManuel Garcia
#99 reroll-diff-2834546-94-99.txt1.98 KBManuel Garcia
#94 2834546-94.patch9.1 KBManuel Garcia
#94 interdiff-2834546-90-94.txt1.56 KBManuel Garcia
#90 2834546-90.patch8.98 KBManuel Garcia
#90 interdiff-2834546-85-90.txt1.59 KBManuel Garcia
#85 2834546-85.patch8.66 KBManuel Garcia
#81 2834546-81.patch8.13 KBManuel Garcia
#81 interdiff-2834546-80-81.txt4.32 KBManuel Garcia
#80 2834546-80.patch8.66 KBManuel Garcia
#80 interdiff-2834546-77-80.txt1.76 KBManuel Garcia
#77 2834546-77.patch8.83 KBManuel Garcia
#77 interdiff-2834546-75-77.txt613 bytesManuel Garcia
#75 2834546-75.patch8.61 KBManuel Garcia
#75 interdiff-2834546-71-75.txt2.58 KBManuel Garcia
#71 2834546-71.patch6.03 KBManuel Garcia
#71 interdiff-2834546-68-71.txt1.48 KBManuel Garcia
#68 2834546-68.patch4.55 KBManuel Garcia
#68 interdiff-2834546-62-68.txt1.22 KBManuel Garcia
#62 2834546-62.patch4.37 KBManuel Garcia
#62 interdiff-2834546-59-62.txt1.41 KBManuel Garcia
#59 2834546-59.patch2.96 KBManuel Garcia
#59 2834546-test-only-59.patch940 bytesManuel Garcia
#59 interdiff-2834546-56-59.txt2.09 KBManuel Garcia
#56 2834546-56.patch4.58 KBvijaycs85
#56 2834546-test-only-56.patch2.54 KBvijaycs85
#51 block_content-and-actions-published-do-not-test.patch14.6 KBManuel Garcia
#50 2834546-50.patch2.04 KBManuel Garcia
#50 interdiff.txt14.67 KBManuel Garcia
#43 2834546-43.patch16.69 KBManuel Garcia
#43 interdiff.txt2.81 KBManuel Garcia
#34 interdiff.txt701 bytesamateescu
#34 2834546-34-combined.patch29.25 KBamateescu
#34 2834546-34.patch17.62 KBamateescu
#33 2834546-33.patch30.41 KBtimmillwood
#33 interdiff-2834546-33.txt2.65 KBtimmillwood
#31 2834546-31-combined.patch30.99 KBtimmillwood
#31 2834546-31.patch19.74 KBtimmillwood
#31 interdiff-2834546-31.txt5.9 KBtimmillwood
#29 2834546-29-combined.patch28.41 KBtimmillwood
#29 2834546-29.patch17.16 KBtimmillwood
#25 2834546-20_2820848-129_combined.patch29.11 KBManuel Garcia
#20 Screenshot from 2017-08-03 17-46-07.png9.13 KBManuel Garcia
#20 2834546-20.patch16.4 KBManuel Garcia
#20 interdiff.txt5.16 KBManuel Garcia
#19 2834546-19.patch16.95 KBManuel Garcia
#8 interdiff.txt728 bytesManuel Garcia
#8 2834546-8.patch16.81 KBManuel Garcia
#6 block-content-form.png92.81 KBManuel Garcia
#6 block-content-view.png44.81 KBManuel Garcia
#6 2834546-5.patch16.1 KBManuel Garcia

Issue fork drupal-2834546

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dixon_ created an issue. See original summary.

dixon_’s picture

Title: UI for publishing/unpublishing blocks » Concept for publishing/unpublishing blocks
Issue summary: View changes
dixon_’s picture

Title: Concept for publishing/unpublishing blocks » UI for publishing/unpublishing blocks

Sorry, can't decide on the title :P

dixon_’s picture

Issue summary: View changes
Manuel Garcia’s picture

Component: block.module » block_content.module
Assigned: Unassigned » Manuel Garcia
Manuel Garcia’s picture

Title: UI for publishing/unpublishing blocks » UI for publishing/unpublishing block_content blocks
Assigned: Manuel Garcia » Unassigned
Issue summary: View changes
Status: Active » Needs review
FileSize
16.1 KB
44.81 KB
92.81 KB

Attached patch does the following:

Changes to block_content view:

  • Added a new Published column
  • Added a new exposed filter for Published
  • Added integration with bulk operations for publishing / unpublishing block_content blocks

admin/structure/block/block-content

Changes to the block_content form:

  • Added buttons for saving as published / unpublished (following the same pattern we have in nodes).

Block content form

Status: Needs review » Needs work

The last submitted patch, 6: 2834546-5.patch, failed testing.

Manuel Garcia’s picture

Status: Needs work » Needs review
FileSize
16.81 KB
728 bytes

It was missing the publish & unpublish actions configuration schemas...

Status: Needs review » Needs work

The last submitted patch, 8: 2834546-8.patch, failed testing.

Manuel Garcia’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 8: 2834546-8.patch, failed testing.

Manuel Garcia’s picture

The rest of the failing tests are probably because this patch requires #2820848: Make BlockContent entities publishable to be in (I hope).

Gábor Hojtsy’s picture

Another question is whether we need permissions to deal with this? Like "View unpublished content", etc.

Manuel Garcia’s picture

re #13: we should imho, but now I'm thinking we should tackle this globally for all "unpublishable entities", possibly as part of #2809177: Introduce entity permission providers or?

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Manuel Garcia’s picture

We should probably follow what's being done on the added related issue, and use a "Published" checkbox instead.

Manuel Garcia’s picture

Status: Needs work » Postponed
Parent issue: » #2820848: Make BlockContent entities publishable
Related issues: -#2820848: Make BlockContent entities publishable

Postponing until BlockContent entities are publishable. We should focus for now on that.

Also, #2068063: Change "Save and keep un-/published" buttons to a "Published" checkbox and an included "Save" button is now in, so we must use a checkbox for publishing blocks here.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Manuel Garcia’s picture

#2820848: Make BlockContent entities publishable is getting really close I think, so lets work on this a bit.

First a straight reroll of #8, manually fixed conflicts on:

  • core/modules/block_content/tests/src/Functional/BlockContentListViewsTest.php
  • core/modules/block_content/src/BlockContentViewsData.php
  • core/modules/block_content/src/BlockContentForm.php
Manuel Garcia’s picture

  • Switching to the published checkbox as we do now on node forms.
  • Using the methods setPublished / setUnpublished on the actions and avoiding saving the blocks if there is no need for it.
  • Some other minor cleaning up.

It's working perfectly already, so that's good news =)

It'd be great if we could get #2892304: Introduce footer region to ContentEntityForm in, to accomodate for the published checbox here as well, for now adding another region like we do on node.

Manuel Garcia’s picture

Self review:

+++ b/core/modules/block_content/src/Plugin/Action/PublishBlockContent.php
@@ -20,8 +20,10 @@ class PublishBlockContent extends ActionBase {
-    $entity->status = 1;
-    $entity->save();
+     if ($entity->isPublished()) {
+      return;
+    }
+    $entity->setPublished()->save();

Indentation is off here, oops..

timmillwood’s picture

Issue summary: View changes

Updating issue summary with latest screenshot.

Manuel Garcia’s picture

Issue summary: View changes

Added screenshot of the block content view showing the bulk operations for publishing/unpublishing and the new column showing the published state.

Status: Needs review » Needs work

The last submitted patch, 20: 2834546-20.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Manuel Garcia’s picture

Status: Needs work » Needs review
FileSize
29.11 KB

Here is the combined patch to see what the bot would say.

Status: Needs review » Needs work

The last submitted patch, 25: 2834546-20_2820848-129_combined.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

amateescu’s picture

Bojhan’s picture

This was exactly the approach I would propose, following the node method should suffice quite well.

However how do we represent this on the place blocks page, and we should expose it in the contextual sidebar?

timmillwood’s picture

Re-roll of #25, before I start trying to fix the issues.

Combined patch includes #148 from #2820848: Make BlockContent entities publishable.

timmillwood’s picture

Assigned: Unassigned » timmillwood
Status: Needs review » Needs work

Now to try and fix the test fails.

timmillwood’s picture

Title: UI for publishing/unpublishing block_content blocks » [PP-1] UI for publishing/unpublishing block_content blocks
Assigned: timmillwood » Unassigned
Status: Needs work » Needs review
FileSize
5.9 KB
19.74 KB
30.99 KB

This should fix the failing tests and the coding standards issues.

Added [PP-1] because this is really blocked / postponed on #2820848: Make BlockContent entities publishable.

amateescu’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/block_content/config/install/system.action.block_content_publish_action.yml
    @@ -0,0 +1,10 @@
    +plugin: block_content_publish_action
    
    +++ b/core/modules/block_content/config/install/system.action.block_content_unpublish_action.yml
    @@ -0,0 +1,10 @@
    +plugin: block_content_unpublish_action
    
    +++ b/core/modules/block_content/src/Plugin/Action/PublishBlockContent.php
    @@ -0,0 +1,40 @@
    +class PublishBlockContent extends ActionBase {
    
    +++ b/core/modules/block_content/src/Plugin/Action/UnpublishBlockContent.php
    @@ -0,0 +1,40 @@
    +class UnpublishBlockContent extends ActionBase {
    

    We should have some kind of EntityPublishedActionBase base class for all these action plugins.

  2. +++ b/core/modules/block_content/src/BlockContentForm.php
    @@ -33,6 +33,16 @@ public function form(array $form, FormStateInterface $form_state) {
    +    $form['#entity_builders']['update_status'] = '::updateStatus';
    
    @@ -86,4 +96,30 @@ public function save(array $form, FormStateInterface $form_state) {
    +  /**
    +   * Entity builder updating the block content status with the submitted value.
    +   *
    +   * @param string $entity_type_id
    +   *   The entity type identifier.
    +   * @param \Drupal\block_content\BlockContentInterface $block_content
    +   *   The block content updated with the submitted values.
    +   * @param array $form
    +   *   The complete form array.
    +   * @param \Drupal\Core\Form\FormStateInterface $form_state
    +   *   The current state of the form.
    +   *
    +   * @see \Drupal\block_content\BlockContentForm::form()
    +   */
    +  public function updateStatus($entity_type_id, BlockContentInterface $block_content, array $form, FormStateInterface $form_state) {
    +    $element = $form_state->getTriggeringElement();
    +    if (isset($element['#published_status'])) {
    +      if ($element['#published_status'] == TRUE) {
    +        $block_content->setPublished();
    +      }
    +      else {
    +        $block_content->setUnPublished();
    +      }
    +    }
    +  }
    

    We are now displaying the status field in entity form, so this shouldn't be needed anymore?

  3. +++ b/core/modules/block_content/src/BlockContentForm.php
    @@ -33,6 +33,16 @@ public function form(array $form, FormStateInterface $form_state) {
    +    $form['footer'] = [
    +      '#type' => 'container',
    +      '#weight' => 99,
    +      '#attributes' => [
    +        'class' => ['block-content-form-footer']
    +      ]
    +    ];
    +    $form['status']['#group'] = 'footer';
    

    I'd vote for postponing this issue on #2892304: Introduce footer region to ContentEntityForm as well, no need to introduce code that will be removed shortly after.

  4. +++ b/core/modules/block_content/src/Entity/BlockContent.php
    @@ -193,6 +203,17 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    +    $fields['revision_created'] = BaseFieldDefinition::create('created')
    +      ->setLabel(t('Revision create time'))
    +      ->setDescription(t('The time that the current revision was created.'))
    +      ->setRevisionable(TRUE);
    +
    +    $fields['revision_user'] = BaseFieldDefinition::create('entity_reference')
    +      ->setLabel(t('Revision user'))
    +      ->setDescription(t('The user ID of the author of the current revision.'))
    +      ->setSetting('target_type', 'user')
    +      ->setRevisionable(TRUE);
    

    #2820848: Make BlockContent entities publishable is removing these definitions because they are already provided by EditorialContentEntityBase, why are we adding them back?

timmillwood’s picture

Status: Needs work » Needs review
FileSize
2.65 KB
30.41 KB

#32.1 - Added #2907075: Add EntityPublishedActionBase as a base class for all publishing status actions with we can do as a follow up / soft dependency.
#32.2 - Removed.
#32.3 - I'd kinda hope #2892304: Introduce footer region to ContentEntityForm is committed before this issue, so sounds fair.
#32.4 - Not sure, removed.

Just adding a combined patch for now.

amateescu’s picture

The dependency needed a reroll and #2892304: Introduce footer region to ContentEntityForm was committed so we can fix #32.3 now :)

Manuel Garcia’s picture

Brilliant, thanks all for pushing this forward!

I think what we've got looks great, only thing I think we should work on (though it could perhaps be a followup), is what Bojhan mentioned on #28:

However how do we represent this on the place blocks page, and we should expose it in the contextual sidebar?

Some thoughts on this:

  1. It would make sense to show the published status of blocks on this page. At least seeing which blocks are unpublished should be clear to the user.
  2. Allowing users to place unpublished blocks makes sense in case you want to see the block before publishing it, so I would not restrict that.
  3. Adding the publish/unpublish to the operations dropdown might be useful.

Options I see:

  • Add a published column to that table (might be too much?)
  • Show (unpublished) next to the block name, so it looks like Site branding (unpublished) (might be too little?).
larowlan’s picture

Title: [PP-1] UI for publishing/unpublishing block_content blocks » UI for publishing/unpublishing block_content blocks

Blocker is in

Manuel Garcia’s picture

Awesome thanks @larowlan!
Queued a test for #34 let's see where we stand =)

Wim Leers’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
amateescu’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll

It doesn't need a reroll, there's a patch in #34 that applies to 8.5.x :) That's why I'm posting two patches every time, with and without the dependent issue.

jibran’s picture

+++ b/core/modules/block_content/src/Plugin/Action/PublishBlockContent.php
@@ -0,0 +1,40 @@
+class PublishBlockContent extends ActionBase {

+++ b/core/modules/block_content/src/Plugin/Action/UnpublishBlockContent.php
@@ -0,0 +1,40 @@
+class UnpublishBlockContent extends ActionBase {

Let's use \Drupal\Core\Field\FieldUpdateActionBase just like \Drupal\node\Plugin\Action\PublishNode and \Drupal\node\Plugin\Action\UnpublishNode

Wim Leers’s picture

@amateescu++
@Wim Leers--

Sorry!

Wim Leers’s picture

+++ b/core/modules/block_content/src/Plugin/Action/UnpublishBlockContent.php
@@ -0,0 +1,40 @@
+ * Unpublishes a node.

s/node/block content/

This is the only thing I'm able to find, and it's a silly nit!

Manuel Garcia’s picture

Yeah latest patch is ok and already passing (was up to date with #2820848: Make BlockContent entities publishable) =)

Addressing #40 and #42.

timmillwood’s picture

Status: Needs review » Reviewed & tested by the community

Looks like we're good to go.

jibran’s picture

--- /dev/null
+++ b/core/modules/block_content/config/install/system.action.block_content_publish_action.yml

--- /dev/null
+++ b/core/modules/block_content/config/install/system.action.block_content_unpublish_action.yml

--- a/core/modules/block_content/config/optional/views.view.block_content.yml
+++ b/core/modules/block_content/config/optional/views.view.block_content.yml

We are adding two actions and updating an existing view. Do we need an update path to add the actions and update the existing view?

Wim Leers’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs update path, +Needs update path tests

Well spotted, @jibran!

amateescu’s picture

As far as I know, we still don't have a way to update configuration provided by a module (#2684081: Modules need a way to keep their configuration up to date) so I'm not sure there's anything we can do about the existing view.

jibran’s picture

Issue tags: +VDC

I think #2898344: Add filters to the comments administration pages is relevant here, see comments #7.2, #9 #10, #11 and #13 in that issue for further details.

TL;DR we didn't add an upgrade path for that view.

But let me quote #10

Let's assume this won't make it to 8.4.x, but rather just in 8.5. IN that case we could use the config hash stored in _core to determine whether things got changed.

and #11

Just for the reference core default_config_hash is:

_core:
  default_config_hash: CTRys5yrLceyvD5kd4rr-XLUceQHt-9x9C3Hnn8K5Rg

#2560049: Incorrect capitalisation of translatable strings, #2600576: MIME, not Mime / mime and #2712647: Update Symfony components to ~3.2 all made changes to the file admin default view without updating the existing view in storage. We can totally drop upgrade path for it if it won't make it to 8.4.x.

This is not going to be in 8.4.x this is just going to be in 8.5.x so by the same logic we don't need an upgrade path for the view.

I asked the upgrade path question in #45 because we are adding two new actions to the existing view if we would have been importing the new view like comment_post_update_enable_comment_admin_view then we would have to import the actions as well but is it true here.
Let's discuss the two cases:

  • On a fresh 8.5.0 install, this won't be a problem because when block_content is installed everything from config/install would be installed and when the views module is installed we'll install the new updated view from config/optional.
  • After the upgrade from 8.4.x to 8.5.0, the view in storage will be updated (I think, not sure about this. We have to find out.) but action instances will not be created and we'll end up with broken view if the view will be updated so we need an upgrade path to import the actions maybe?
  1. +++ b/core/modules/block_content/src/BlockContentViewsData.php
    @@ -30,6 +30,15 @@ public function getViewsData() {
    +    $data['block_content']['block_content_bulk_form'] = [
    +      'title' => $this->t('Block content operations bulk form'),
    +      'help' => $this->t('Add a form element that lets you run operations on multiple block content.'),
    +      'field' => [
    +        'id' => 'block_content_bulk_form',
    +      ],
    +    ];
    

    FYI, we need a cache clear post-update hook for this change only.

  2. +++ b/core/modules/block_content/src/Entity/BlockContent.php
    @@ -165,6 +165,16 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    +    $fields['status']
    +      ->setDisplayOptions('form', [
    +        'type' => 'boolean_checkbox',
    +        'settings' => [
    +          'display_label' => TRUE,
    +        ],
    +        'weight' => 120,
    +      ])
    +      ->setDisplayConfigurable('form', TRUE);
    

    This change will add an update to EUDM but we only added the status field in #2820848: Make BlockContent entities publishable so we don't need update hook for this.

PS: I think we shouldn't do views and action changes here because this is about updating the UI. We can update the admin view in followup and add actions there because the above discussion seems out of scope here.

Manuel Garcia’s picture

I took a look to see where we stand when it comes to the block_content view moving from 8.4 to 8.5.

Steps taken:

  1. git checkout 8.4.x
  2. drush si -y
  3. git checkout 8.5.x
  4. git apply --index 2834546-43.patch
  5. drush updb -y

Result:
The block_content view does not show the published column nor the bulk actions to publish/unpublish custom blocks.

So clearly the view changes require an upgrade path. I vote for splitting those changes into a follow up, unless someone is willing to do this here...

Manuel Garcia’s picture

Status: Needs work » Needs review
FileSize
14.67 KB
2.04 KB

Here is a patch with just the UI changes related to the block content form (no actions or view changes).

I will create the follow up with the view and actions patch shortly.

Manuel Garcia’s picture

Well, before I run and create a follow up, let's hear what others have to say about it, because we could/should also be making changes to the block layout screen.. (see #35), so we may want to split that into another followup perhaps.

In any case, here is the starting point adding what I removed on #50.

dawehner’s picture

Issue summary: View changes

I think its the right idea to provide an update path:

  • It does not change visitor's behaviour
  • It provides a new feature for editors, without impacting existing functionality

The update path should update individual bits of the view, aka. set the additional field and add the filters instead of replacing the entire view.
The update path test should then test some basic behaviour of the view.

+++ b/core/modules/block_content/src/BlockContentViewsData.php
@@ -30,6 +30,15 @@ public function getViewsData() {
+
+    $data['block_content']['block_content_bulk_form'] = [
+      'title' => $this->t('Block content operations bulk form'),
+      'help' => $this->t('Add a form element that lets you run operations on multiple block content.'),
+      'field' => [
+        'id' => 'block_content_bulk_form',
+      ],
+    ];

+++ b/core/modules/block_content/src/Plugin/views/field/BlockContentBulkForm.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace Drupal\block_content\Plugin\views\field;
+
+use Drupal\system\Plugin\views\field\BulkForm;
+
+/**
+ * Defines a block content operations bulk form element.
+ *
+ * @ViewsField("block_content_bulk_form")
+ */
+class BlockContentBulkForm extends BulkForm {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function emptySelectedMessage() {
+    return $this->t('No block content selected.');
+  }
+
+}

I just added a follow up issue which would have avoided all this additional code: #2909423: Get rid of BulkForm subclasses when they just override emptySelectedMessage

jibran’s picture

I think its the right idea to provide an update path:

  • It does not change visitor's behaviour
  • It provides a new feature for editors, without impacting existing functionality

The update path should update individual bits of the view, aka. set the additional field and add the filters instead of replacing the entire view.
The update path test should then test some basic behaviour of the view.

Let's create a follow-up with whole views related changes then so that we don't block this feature.

Manuel Garcia’s picture

Alright then, I've opened up the follow up for the view / actions part:
#2909435: Update block library page to adapt publishable block content implementation

Not 100% sure of the issue description there, please review =)

Manuel Garcia’s picture

Now the patch #50 is simple enough, since we've split off the changes to views.

vijaycs85’s picture

Here is test to check for the new field (and test-only patch is the diff file).

The last submitted patch, 56: 2834546-test-only-56.patch, failed testing. View results

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Manuel Garcia’s picture

Thanks @vijaycs85 for the test!
Just cleaning up unrelated changes to the test file on this patch. Anything else we should be doing here?

The last submitted patch, 59: 2834546-test-only-59.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 59: 2834546-59.patch, failed testing. View results

Manuel Garcia’s picture

Status: Needs work » Needs review
FileSize
1.41 KB
4.37 KB

Fixing failing tests...

Status: Needs review » Needs work

The last submitted patch, 62: 2834546-62.patch, failed testing. View results

Manuel Garcia’s picture

Status: Needs work » Needs review
timmillwood’s picture

Should we postpone this on #2909435: Update block library page to adapt publishable block content implementation?
And maybe on #2809177: Introduce entity permission providers? Do we need any tweaks to \Drupal\block_content\BlockContentAccessControlHandler? Should users with the "administer blocks" permission be able to view unpublished blocks?

Manuel Garcia’s picture

Re #65:

As far as postponing on #2909435: Update block library page to adapt publishable block content implementation - We purposely split that into its own issue so as to not to block this one (see #53, #54).

As far as postponing on #2809177: Introduce entity permission providers - If I understand correctly, that adds a view own unpublished $entity_type, but nothing related to publishing/unpublishing entities, so I'm not sure how it relates to this issue?

Users with 'administer blocks' permission are already able to view unpublished blocks, and I think this is to be expected. So no need to change BlockContentAccessControlHandler in my opinion.

timmillwood’s picture

Status: Needs review » Needs work

One small item, otherwise looks good:

+++ b/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php
@@ -51,6 +51,14 @@ public function testBlockContentCreation() {
+    $this->assertSession()->statusCodeEquals(200);
...
+    $this->assertSession()->fieldExists('edit-status-value');
+    $this->assertSession()->checkboxChecked('edit-status-value');

We don't need to load WebAssert three times, we can use load it once into a variable and use it again.

Manuel Garcia’s picture

Status: Needs work » Needs review
FileSize
1.22 KB
4.55 KB

Good point, addressing #67 here.

timmillwood’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, looks good

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 68: 2834546-68.patch, failed testing. View results

Manuel Garcia’s picture

Status: Needs work » Needs review
FileSize
1.48 KB
6.03 KB

Fixing failing test.

timmillwood’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC then.

catch’s picture

Status: Reviewed & tested by the community » Needs review

Does this need an update for the entity form display, or has that been avoided intentionally? I see discussion about whether or not to update the view here, but not the form display.

amateescu’s picture

I don't think there's any reason not to update the form display, good point :) We just need to copy and adapt the code we used for updating form displays for nodes: node_post_update_configure_status_field_widget().

Manuel Garcia’s picture

Thanks both, I think that makes sense, hopefully I got it right, adding the update and accompanying test.

Status: Needs review » Needs work

The last submitted patch, 75: 2834546-75.patch, failed testing. View results

Manuel Garcia’s picture

Status: Needs work » Needs review
FileSize
613 bytes
8.83 KB

Oops.

timmillwood’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @Manuel Garcia

catch’s picture

Status: Reviewed & tested by the community » Needs work

While in practice form displays should be quite finite, in general we should be batching config updates, since we've had problems with some going out of memory. I think we should do that here even though it's unlikely to be a problem, since it also helps if someone copies and pastes the update to implement their own in a situation that would be a problem.

I've just committed #2949351: Add a helper class to make updating configuration simple which makes that a lot easier to implement.

Manuel Garcia’s picture

Status: Needs work » Needs review
FileSize
1.76 KB
8.66 KB

Good idea @catch

Let's see if I got it right :)

Manuel Garcia’s picture

Actually the field placement is simpler nowadays, so adjusting this to be like how we're doing it on other editorial content entities.

Manuel Garcia’s picture

Issue summary: View changes

Updated issue summary with what we are actually proposing in the patch.

Manuel Garcia’s picture

Issue summary: View changes
amateescu’s picture

+++ b/core/modules/block_content/src/BlockContentForm.php
@@ -36,8 +36,6 @@ public function form(array $form, FormStateInterface $form_state) {
-    $form['status']['#group'] = 'footer';

Are you sure about this? NodeForm still does it..

Manuel Garcia’s picture

You're right, its been a while since i looked at this issue... re-uploading #80 for clarity.

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Great!

Berdir’s picture

+++ b/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php
@@ -44,12 +44,21 @@ protected function setUp() {
     $edit['info[0][value]'] = 'Test Block';
     $edit['body[0][value]'] = $this->randomMachineName(16);
+
+    $this->drupalGet('block/add/basic');
+    $assert->statusCodeEquals(200);
+
+    // Make sure status field exist.
+    $assert->fieldExists('edit-status-value');
+    $assert->checkboxChecked('edit-status-value');
+

That's not that much test coverage on the implications of this. While that technically doesn't change by making it visible, we AFAIK pushed back quite a few questions on this issue when adding the status originally, like:

* No way to see if a block is published or not in the overview nor being able to filter on it
* Weren't 100% sure on whether an admin should see a block with an unpublished block_content entity (right now they can)
* If they can (I guess that makes sense, even though a bit confusing), there is no class nor any resulting visual indication that this element is visible only for users with the administer blocks permission. Nodes have the node--unpublished and the very pretty background color (which I just researched to use a name, but turns out it's not an exact match for anything but close to "Snow"...)
* Translations is also interesting, did we check that the status is then not duplicated? \Drupal\content_translation\ContentTranslationHandler::entityFormAlter() defines a translation status field, which for example \Drupal\node\NodeTranslationHandler::entityFormAlter() hides again. (with one wrong key, see #2971390: Make exposure of translation meta fields conditional, considering to generalize that logic because we actually can do that now)

Are we really sure that we want to expose this functionality to users without having that resolved?

I guess one big advantage would be that users where block_content_8400() failed would have a way to fix their content in the UI, but it will only by in 8.6 anyway ;)

amateescu’s picture

No way to see if a block is published or not in the overview nor being able to filter on it

We have an issue for this already: #2909435: Update block library page to adapt publishable block content implementation

So we will need two more issues to handle the visual indication for unpublished blocks throughout the site and another one for the content translation form alter :)

larowlan’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/modules/block_content/tests/src/Functional/Update/BlockContentUpdateTest.php
@@ -66,4 +67,26 @@ public function testStatusFieldAddition() {
+    // Run updates.
+    $this->runUpdates();
+
+    $query = \Drupal::entityQuery('entity_form_display')
+      ->condition('targetEntityType', 'block_content');
+    $ids = $query->execute();

Can we test the state before the update too?

Just in case someone updates the dump file, which would render this test invalid.

We typically do that

Manuel Garcia’s picture

Good idea @larowlan, so... something like this would do I suppose?

Status: Needs review » Needs work

The last submitted patch, 90: 2834546-90.patch, failed testing. View results

Manuel Garcia’s picture

OK now I'm confused... how can it be that the status form component is there before the updates are run? 0_o

Berdir’s picture

Because base field default form/view display configuration is merged in from the field definitions if nothing is specified yet.

Second, you are anyway not allowed to use the config entity API before running updates, you must use config API directly. Doing that will also fix the first problem as that config-entity level logic will not run.

Manuel Garcia’s picture

Status: Needs work » Needs review
FileSize
1.56 KB
9.1 KB

Thanks @Berdir!

Status: Needs review » Needs work

The last submitted patch, 94: 2834546-94.patch, failed testing. View results

Manuel Garcia’s picture

Status: Needs work » Needs review

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Manuel Garcia’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
Manuel Garcia’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
1.98 KB
9.34 KB
amateescu’s picture

Status: Needs review » Needs work
+++ b/core/modules/block_content/block_content.post_update.php
@@ -88,3 +89,22 @@ function block_content_post_update_add_views_reusable_filter(&$sandbox = NULL) {
+    $entity_form_display->setComponent('status', [

We need to bring this in line with what we're doing in #2899923: UI for publishing/unpublishing taxonomy terms and don't update the 'status' component if it already exists on the form display.

Manuel Garcia’s picture

Addressing #100 :)

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Nice! We still need to work on the followups from #87 / #88, but this is a good small step.

larowlan’s picture

Issue tags: +Needs change record

This looks ready to go in my book, however I think we need a change record *and* I think @Berdir's concerns in #87/#88 would be semi-addressed if we timed this to go in at the same time as #2909435: Update block library page to adapt publishable block content implementation, which still needs work to address committer feedback on the update path.

Let's get the change record ready to go, and then see how we go on the other one. It would be good to coordinate a commit of this with a subsequent commit of #2909435: Update block library page to adapt publishable block content implementation

Thanks for your work here, this is a big feature.

Manuel Garcia’s picture

Issue tags: -Needs change record

Thanks @larowlan - I have created a draft change record, combing the two issues into it, let me know what you think :)
https://www.drupal.org/node/3001390

vijaycs85’s picture

Tested manually on both scenarios (install with patch & install, apply patch & drush updb) and can see the publish checkbox on both cases. +1 to RTBC.

alexpott’s picture

The change record seems to have a screenshot of admin/content and not of the new block content library with publishing status included. I have to agree with @Berdir / #87 - I'm struggling to see how we can be doing this and #2909435: Update block library page to adapt publishable block content implementation in separate issues. Leaving at RTBC for other committers to decide but the CR does look like it needs attention. And if we are going to do them separately then I think we need #2909435: Update block library page to adapt publishable block content implementation close to rtbc to get this in.

catch’s picture

Status: Reviewed & tested by the community » Needs work

Yes I agree with alexpott, we should combine this issue with #2909435: Update block library page to adapt publishable block content implementation and commit the change together to keep the block UI as a whole consistent.

szeidler’s picture

Thanks for the great work here. I just encountered, that enabling content translation on a block type and making the "Published" field translatable causes the "Published" field to not save changes anymore, not in the host language, not in the translated ones.

I'm not sure if that is part of the UI issue here, or a bug in the underlying non-ui implementation.

szeidler’s picture

Referring to #108, here is a short screencast. Actually the "Published" checkbox is completely effectless on the translated block_content form and the "This translation is published" is the only one working. It seems both have the seem meaning and have side effects on each other.

Only local images are allowed.

szeidler’s picture

Actually I found, that we have the same issue as reported in #108 and #109 also with #2899923-76: UI for publishing/unpublishing taxonomy terms.

I fixed it by using the same approach as in the other issue (thanks for @ManuelGarcia). There might be a better solution, because we're doing the exact same thing then for terms and block content.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Manuel Garcia’s picture

Status: Needs work » Needs review
FileSize
865 bytes
15 KB

Rerolled, manually fixed conflicts on:

  • core/profiles/demo_umami/config/install/core.entity_form_display.block_content.banner_block.default.yml
  • core/profiles/demo_umami/config/install/core.entity_form_display.block_content.basic.default.yml
  • core/profiles/demo_umami/config/install/core.entity_form_display.block_content.disclaimer_block.default.yml
  • core/profiles/demo_umami/config/install/core.entity_form_display.block_content.footer_promo_block.default.yml

Also trying to fix the tests, interdiff is after the reroll.

Still needs work because it's been requested that we merge #2909435: Update block library page to adapt publishable block content implementation into this one. FWIW, we had previously split that into its own issue so as to not to block this one (see #53, #54).

Status: Needs review » Needs work

The last submitted patch, 112: 2834546-112.patch, failed testing. View results

Manuel Garcia’s picture

Status: Needs work » Needs review
FileSize
1.34 KB
16.19 KB

Looks like the interdiff on #110 was incomplete, reverting the changes to changes to core.entity_form_display.block_content.basic.default.yml added in that patch, and adding the fixture yml file back in, hopefully getting this back to green.

A heads up on the patch, not sure why git diff thinks I'm doing this:

copy from core/profiles/demo_umami/config/install/core.entity_form_display.block_content.basic.default.yml
copy to core/modules/block_content/tests/fixtures/update/core.entity_form_display.block_content.basic.default_2834546.yml

I copied core/profiles/standard/config/install/core.entity_form_display.block_content.basic.default.yml over and modified it to create the new file for the fixture...

Status: Needs review » Needs work

The last submitted patch, 114: 2834546-114.patch, failed testing. View results

Manuel Garcia’s picture

Status: Needs work » Needs review
FileSize
635 bytes
16.19 KB

I can't figure out why this test is failing:

There was 1 error:

1) Drupal\Tests\demo_umami\Functional\DemoUmamiProfileTest::testConfig
Exception: core.entity_form_display.block_content.banner_block.default: Drupal\Component\Diff\Engine\DiffOpDelete::__set_state(array(
   'type' => 'delete',
   'orig' => 
  array (
    0 => '  translation:',
    1 => '    weight: 10',
    2 => '    settings: {  }',
    3 => '    third_party_settings: {  }',
    4 => '    region: content',
  ),
   'closing' => false,
))

/var/www/html/core/tests/Drupal/KernelTests/AssertConfigTrait.php:38
/var/www/html/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php:77
/var/www/html/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php:54

Anyone has an idea why?

For now just reverting another unwanted change introduced in #110.

Status: Needs review » Needs work

The last submitted patch, 116: 2834546-116.patch, failed testing. View results

Manuel Garcia’s picture

OK so I think I finally figured it out... the installed configuration is actually the same as the default, but the order of the items in the file is different, which results in test failure.

I found out by installing demo_umami profile, exporting the configuration, and doing a diff between the default file and the exported file.

amateescu’s picture

The latest feedback from #107 was that we should combine this issue with #2909435: Update block library page to adapt publishable block content implementation. That's not going to be easy since both of them have 100 comments already, but I guess it can be done :)

@Manuel Garcia, what do you think?

Manuel Garcia’s picture

Guess we should merge these two back into one, let's focus on getting a green patch again on #2909435: Update block library page to adapt publishable block content implementation and merge it into here then.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

capysara’s picture

Is there any interest in resurrecting this? If so, I can test the last patch (and the patch in https://www.drupal.org/project/drupal/issues/2909435).

amateescu’s picture

Rerolled the patch from #118 for 9.3.x.

hardikpandya’s picture

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

FileSize
0 bytes
14.92 KB

Starting at #126

rerolled for 9.5 with a few phpcs fixes.

Status: Needs review » Needs work

The last submitted patch, 130: 2834546-130.patch, failed testing. View results

smustgrave’s picture

Status: Needs work » Needs review
FileSize
0 bytes
16.05 KB

This is going to need a heavy code review.

I removed translation and language fields from the core.entity_form in the fixtures folder but kept them in the demo_umami folder because it didn't seem to make sense to remove them for the status field.

Updated one of the failing tests and fixed a deprecation call.

With regards to combining with https://www.drupal.org/project/drupal/issues/2909435 I would vote to keep them separate. That other ticket is far from ready and this one seems closer at least. Easier to get things in smaller chunks then a huge one. Hate to see this feature delayed while we try to fix the other.

larowlan’s picture

Looking great, a couple of observations

  1. +++ b/core/modules/block_content/src/BlockContentForm.php
    @@ -36,6 +36,8 @@ public function form(array $form, FormStateInterface $form_state) {
    +    $form['status']['#group'] = 'footer';
    +
    

    for super-safety we should probably check $form['status'] exists first here.

    there will be the odd site that didn't run the update hook properly, or export their config properly and this will cause some oddities in their form/possibly raise warnings

  2. +++ b/core/modules/block_content/src/BlockContentTranslationHandler.php
    @@ -19,4 +20,23 @@ protected function entityFormTitle(EntityInterface $entity) {
    +  public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity) {
    +    parent::entityFormAlter($form, $form_state, $entity);
    +    $form['content_translation']['status']['#access'] = !isset($form['content_translation']);
    +  }
    +
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state) {
    +    if ($form_state->hasValue('content_translation')) {
    +      $translation = &$form_state->getValue('content_translation');
    +      $translation['status'] = $entity->isPublished();
    +    }
    +    parent::entityFormEntityBuild($entity_type, $entity, $form, $form_state);
    

    I have no idea about this, so will need to do some research into what this does

  3. +++ b/core/modules/block_content/tests/fixtures/update/core.entity_form_display.block_content.basic.default_2834546.yml
    --- /dev/null
    +++ b/core/modules/block_content/tests/fixtures/update/drupal-8.entity_form_display_block_content-2834546.php
    
    +++ b/core/modules/block_content/tests/fixtures/update/drupal-8.entity_form_display_block_content-2834546.php
    @@ -0,0 +1,22 @@
    + * Contains database additions to drupal-8.bare.standard.php.gz for testing the
    

    is the 8 in the name accurate here now?

  4. +++ b/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php
    @@ -150,4 +150,41 @@ protected function doTestTranslationEdit() {
    +      // (Un)publish the block content translations and check that the translation
    ...
    +        // The block content is created as unpublished thus we switch to the published
    

    nit, > 80 chars in this comment

  5. +++ b/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php
    @@ -150,4 +150,41 @@ protected function doTestTranslationEdit() {
    +      $storage->resetCache([$this->entityId]);
    +      $entity = $storage->load($this->entityId);
    

    we can use ->loadUnchanged here and avoid the resetCache call, one less line

  6. +++ b/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php
    @@ -150,4 +150,41 @@ protected function doTestTranslationEdit() {
    +        $status = !$index;
    

    not sure about this magic

  7. +++ b/core/modules/block_content/tests/src/Functional/Update/BlockContentUpdateTest.php
    @@ -0,0 +1,68 @@
    +      __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-9.0.0.bare.standard.php.gz',
    +      __DIR__ . '/../../../fixtures/update/drupal-8.entity_form_display_block_content-2834546.php',
    

    yeah the 9.0.0 here makes me think we should rename the fixture to be 9 instead of 8 and update the comment

  8. +++ b/core/profiles/demo_umami/config/install/core.entity_form_display.block_content.basic.default.yml
    @@ -36,10 +36,16 @@ content:
    -hidden:
    -  moderation_state: true
    +hidden: {  }
    

    is this a regression?

  9. +++ b/core/profiles/demo_umami/config/install/core.entity_form_display.block_content.disclaimer_block.default.yml
    @@ -43,6 +43,13 @@ content:
    +    weight: 120
    
    +++ b/core/profiles/demo_umami/config/install/core.entity_form_display.block_content.footer_promo_block.default.yml
    @@ -61,6 +61,13 @@ content:
    +    weight: 120
    
    +++ b/core/profiles/standard/config/install/core.entity_form_display.block_content.basic.default.yml
    @@ -29,4 +29,11 @@ content:
    +    weight: 120
    

    120 feels high, are these shown below or above the submit button.

    I know there's a bug in core that puts all new fields on taxonomy form displays under the button 🤦

smustgrave’s picture

Issue summary: View changes
FileSize
6.1 KB
15.94 KB

#133
1. Added an if statement to check
2. Not too sure either. From the original patch
3. Updated to 9
4. Fixed
5. Fixed in 2 spots for that function
6. Wasn't sure either. Is it checking that the status is FALSE? we could just remove and use assertFalse
7. Fixed
8. Possibly? Not sure why it would need to be removed. So added back
9. It appears above the save button

smustgrave’s picture

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

bumping

larowlan’s picture

Issue summary: View changes
Status: Needs review » Needs work

I re-read all the comments here, and in #106 and #107 we have two committers asking for this to be combined with #2909435: Update block library page to adapt publishable block content implementation

In addition in #87 Berdir had a number of questions about test coverage and the implication for translations which I don't think have been addressed yet.

It also looks like #13 is unresolved

I've updated the issue summary with all those items

smustgrave’s picture

smustgrave’s picture

Issue summary: View changes
FileSize
25.55 KB
42.24 KB

Combined the changes from #2909435: Update block library page to adapt publishable block content implementation

Still need work for the additional tests and translation coverage.

@berdir would you mind taking a relook about what could be needed please? Know things have changed in 5 years

I do think we will need a view unpublished permission we may be able to get this ready but ultimately may be blocked by #2809177: Introduce entity permission providers

smustgrave’s picture

frankdesign’s picture

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?

larowlan’s picture

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.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

smustgrave’s picture

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.

smustgrave’s picture

Issue summary: View changes
Status: Needs work » Needs review

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.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
90 bytes

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.

smustgrave’s picture

Status: Needs work » Needs review

Moved logic to blockAccess ready for review again.

savkaviktor16@gmail.com’s picture

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

Status: Needs review » Needs work

The last submitted patch, 153: 2834546-153.patch, failed testing. View results

smustgrave’s picture

Status: Needs work » Needs review

Hiding patch

larowlan’s picture

Status: Needs review » Needs work

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

smustgrave’s picture

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

smustgrave’s picture

Status: Needs work » Needs review

All threads I believe have been resolved.

borisson_’s picture

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

BramDriesen’s picture

Status: Needs review » Needs work

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

smustgrave’s picture

Status: Needs work » Needs review

Addressed feedback and cleanup CR.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

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

lauriii’s picture

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. 😊

frankdesign’s picture

@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

mrshowerman’s picture

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.

lauriii’s picture

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.

smustgrave’s picture

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.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
FileSize
90 bytes

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.

smustgrave’s picture

Status: Needs work » Needs review

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.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
12.16 KB

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.

smustgrave’s picture

Status: Needs work » Needs review

Rebased

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
90 bytes

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.

smustgrave’s picture

Status: Needs work » Needs review

Rebased

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
90 bytes

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.

smustgrave’s picture

Status: Needs work » Needs review

Rebased

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
90 bytes

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.

sakthi_dev made their first commit to this issue’s fork.

sakthi_dev’s picture

Rebased with 11.x and resolved conflicts.

smustgrave’s picture

Status: Needs work » Needs review

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

larowlan’s picture

Status: Needs review » Needs work

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