Aggregator blocks can use contextual to get back to the settings page for their feed.

See #53 for screenshots of the effects of this patch.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Feature because this adds an extra contextual link to the aggregator block
Issue priority Normal
Prioritized changes The main goal of this issue is usability, it adds a fast way to go from an aggregator block to the feed's settings
Disruption There is no disruption, this is just an UI change
CommentFileSizeAuthor
#64 add_contextual_for-1020574-64.patch4.88 KBAjitS
#63 add_contextual_for-1020574-63.patch4.5 KBAjitS
#53 1020574-feed-block.png77.98 KBgeertvd
#53 1020574-feed-page.png197.81 KBgeertvd
#51 add_contextual_for-1020574-51.patch4.89 KBgeertvd
#51 interdiff-1020574-49-51.txt1.17 KBgeertvd
#49 add_contextual_for-1020574-49.patch5.51 KBgeertvd
#47 add_contextual_for-1020574-47.patch5.55 KBgeertvd
#47 interdiff-1020574-45-47.txt3.46 KBgeertvd
#45 add_contextual_for-1020574-45.patch4.98 KBgeertvd
#45 interdiff-1020574-43-45.txt968 bytesgeertvd
#43 add_contextual_for-1020574-43.patch4.99 KBgeertvd
#43 interdiff-1020574-41-43.txt1.64 KBgeertvd
#41 add_contextual_for-1020574-41.patch5.01 KBgeertvd
#39 interdiff-1020574-35-38.txt2.97 KBgeertvd
#38 add_contextual_for-1020574-38.patch6.58 KBgeertvd
#38 interdiff-1020574-35-38.txt4.54 KBgeertvd
#35 add_contextual_for-1020574-35.patch4.62 KBgeertvd
#35 interdiff-1020574-32-35.txt3.44 KBgeertvd
#32 add_contextual_for-1020574-32.patch4.8 KBAjitS
#32 interdiff.txt1.92 KBAjitS
#24 add_contextual_for-1020574-24-complete.patch3.95 KBgeertvd
#24 interdiff-1020574-20-24.txt1.03 KBgeertvd
#23 Screen Shot 2015-08-17 at 15.22.01.png149.47 KBpjbaert
#20 aggregator-contextual_links-1020574-20-complete.patch3.99 KBgeertvd
#20 aggregator-contextual_links-1020574-20-test.patch2.5 KBgeertvd
#20 interdiff-1020574-16-20.txt890 bytesgeertvd
#16 aggregator-contextual_links-1020574-16.patch4.08 KBgeertvd
#16 interdiff-1020574-13-16.txt2.59 KBgeertvd
#13 interdiff.txt736 bytesvbouchet
#13 aggregator-contextual_links-1020574-13.patch1.49 KBvbouchet
#9 interdiff.txt463 bytesvbouchet
#9 aggregator-contextual_links-1020574-9.patch1.52 KBvbouchet
#1 screenshot-aggregator_block-contextual_links.png10.47 KBvbouchet
#1 aggregator-contextual_links-1020574-1.patch1.29 KBvbouchet
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vbouchet’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
1.29 KB
10.47 KB

Please find a patch creating the aggregator.links.contextual.yml and implementing the hook_block_view_BASE_BLOCK_ID_alter() in aggregator.module.

Status: Needs review » Needs work

The last submitted patch, 1: aggregator-contextual_links-1020574-1.patch, failed testing.

The last submitted patch, 1: aggregator-contextual_links-1020574-1.patch, failed testing.

vbouchet’s picture

I don't know why SimpleTest failed here. It's working properly on my local and I can't see any test which should be updated to the new feature.

vbouchet’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: aggregator-contextual_links-1020574-1.patch, failed testing.

vbouchet’s picture

Update the patch to use the appropriate class.

AjitS’s picture

Shouldn't this be in 'needs review'?

vbouchet’s picture

Status: Needs work » Needs review

You are right...

Nick_vh’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/aggregator/aggregator.module
    @@ -177,3 +178,17 @@ function aggregator_preprocess_block(&$variables) {
    +/**
    + * Implements hook_block_view_BASE_BLOCK_ID_alter() for 'aggregator_feed_block'.
    + */
    

    Should document the arguments here.

  2. +++ b/core/modules/aggregator/aggregator.module
    @@ -177,3 +178,17 @@ function aggregator_preprocess_block(&$variables) {
    +  if (!empty($configuration['feed']) && isset($feeds[$configuration['feed']])) {
    

    Any reason why you want to do empty and isset? I'd do only empty if you really want a value or isset if you just want to know if the key was set. I'd do only isset here as you only pass it to the route_parameters and you don't care of the content.

vbouchet’s picture

Status: Needs work » Needs review
FileSize
1.49 KB
736 bytes

Please find an updated patch and interdiff. I kept only the isset() but didn't documented arguments of the function as it's a hook.

geertvd’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Looks good, we still need tests for this though.

geertvd’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
2.59 KB
4.08 KB

Added test

ParisLiakos’s picture

Status: Needs review » Needs work
+++ b/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php
@@ -27,6 +28,10 @@ class AggregatorRenderingTest extends AggregatorTestBase {
+    $this->container->get('module_installer')->install(['contextual']);

why not add it to the static $modules property?

can we also have a test only patch that fails?

geertvd’s picture

why not add it to the static $modules property?

I didn't think it was relevant for the other test, should I just added to the modules property?

Will add the test only patch tonight.

ParisLiakos’s picture

btw this also needs a beta evaluation, this might be 8.1.x material

geertvd’s picture

Removed the module install from the test and added it to the $modules property.
I also added the beta evaluation to the issue summary.

The last submitted patch, 20: aggregator-contextual_links-1020574-20-test.patch, failed testing.

ParisLiakos’s picture

Issue summary: View changes

yes, we can file this under prioritized changes due to the usabilty impact

pjbaert’s picture

Status: Needs review » Needs work
FileSize
149.47 KB

I tested this. The link is available after I clicked the contextual link. See screenshot.

+++ b/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php
@@ -65,6 +67,19 @@ public function testBlockLinks() {
+    $this->assertRaw('<div data-contextual-id="'. $id . '"></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $id)));

We shouldn't use format_string() here, it pollutes the safe string list. See #2549805: Remove all usage of FormattableMarkup in tests apart from explicit tests of that API

geertvd’s picture

pjbaert’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!
This looks fine to me now.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 24: add_contextual_for-1020574-24-complete.patch, failed testing.

Status: Needs work » Needs review
geertvd’s picture

Setting back to RTBC as per #25

geertvd’s picture

Status: Needs review » Reviewed & tested by the community
Wim Leers’s picture

Status: Reviewed & tested by the community » Needs work

Sorry guys, this is not quite ready yet!

  1. FeedViewBuilder should be updated too, similarly to NodeViewBuilder::alterBuild(), TermViewBuilder::alterBuild() etc.
  2. +++ b/core/modules/aggregator/aggregator.links.contextual.yml
    @@ -0,0 +1,4 @@
    +  title: 'Configure feed'
    

    s/Configure/Edit/

    AFAIK we use "Configure" for config entities only.

  3. +++ b/core/modules/aggregator/aggregator.module
    @@ -177,3 +178,17 @@ function aggregator_preprocess_block(&$variables) {
    +function aggregator_block_view_aggregator_feed_block_alter(array &$build, BlockPluginInterface $block) {
    

    This doesn't do the same additional check that menu_ui_block_view_system_menu_block_alter() does. Why not?

  4. +++ b/core/modules/aggregator/aggregator.module
    @@ -177,3 +178,17 @@ function aggregator_preprocess_block(&$variables) {
    +  $feeds = \Drupal::entityManager()->getStorage('aggregator_feed')->loadMultiple();
    ...
    +  if (isset($feeds[$configuration['feed']])) {
    

    So we load all feeds just to check if it's an actual feed? Is this really necessary? This is very bad for performance. Let's at least only load the one we actually need.

    Also, this means that the edge case of the feed not existing is not tested.

  5. +++ b/core/modules/aggregator/aggregator.module
    @@ -177,3 +178,17 @@ function aggregator_preprocess_block(&$variables) {
    +    $build['#contextual_links']['aggregator'] = array(
    +      'route_parameters' => array('aggregator_feed' => $configuration['feed']),
    +    );
    

    array() -> []

AjitS’s picture

Assigned: Unassigned » AjitS

Working on it now.

AjitS’s picture

Status: Needs work » Needs review
FileSize
1.92 KB
4.8 KB
  1. Added the function alterBuild() to the FeedViewBuilder class.
  2. Done.
  3. This might be due to the implementation of hook_block_view_BASE_BLOCK_ID_alter. IMO
    if ($block->getBaseId() == 'system_menu_block') {
    

    should be removed from menu_ui_block_view_system_menu_block_alter (in a separate issue). Checking for BLOCK ID in a hook which has it in the function name does not make sense to me.

  4. I was not able to find a way to load only one feed to check the validity. Can you please give me a pointer and I will accommodate it.
  5. Done.

Status: Needs review » Needs work

The last submitted patch, 32: add_contextual_for-1020574-32.patch, failed testing.

geertvd’s picture

  1. +++ b/core/modules/aggregator/aggregator.module
    @@ -177,3 +178,17 @@ function aggregator_preprocess_block(&$variables) {
    +  $feeds = \Drupal::entityManager()->getStorage('aggregator_feed')->loadMultiple();
    +
    +  $configuration = $block->getConfiguration();
    +  if (isset($feeds[$configuration['feed']])) {
    +    $build['#contextual_links']['aggregator'] = array(
    +      'route_parameters' => ['aggregator_feed' => $configuration['feed']],
    +    );
    +  }
    

    Can't we just change this to

    $build['#contextual_links']['aggregator'] = array(
      'route_parameters' => ['aggregator_feed' => $configuration['feed']],
    );
    

    Since the feed id should always be an existing feed anyway. A block will only be build if it is a valid feed id anyway.

  2. +++ b/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php
    @@ -65,6 +67,19 @@ public function testBlockLinks() {
    +    $this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $block->id() . '">Configure block</a></li><li class="aggregator-feed-edit"><a href="' . base_path() . 'aggregator/sources/' . $feed->id() . '/configure">Configure feed</a></li></ul>');
    

    We stil need to change this to 'Edit feed' also.

For the test fails, i cant't check right now but i think you still have to add this to AggregatorFeedBlock.php

use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
geertvd’s picture

Status: Needs work » Needs review
FileSize
3.44 KB
4.62 KB

I think this should be green.

geertvd’s picture

Assigned: AjitS » Unassigned

Status: Needs review » Needs work

The last submitted patch, 35: add_contextual_for-1020574-35.patch, failed testing.

geertvd’s picture

Status: Needs work » Needs review
FileSize
4.54 KB
6.58 KB

That last patch was not complete.

geertvd’s picture

FileSize
2.97 KB

Getting late, ignore that last interdiff also :)

Status: Needs review » Needs work

The last submitted patch, 38: add_contextual_for-1020574-38.patch, failed testing.

geertvd’s picture

Status: Needs work » Needs review
FileSize
5.01 KB

Status: Needs review » Needs work

The last submitted patch, 41: add_contextual_for-1020574-41.patch, failed testing.

geertvd’s picture

Status: Needs work » Needs review
FileSize
1.64 KB
4.99 KB

Status: Needs review » Needs work

The last submitted patch, 43: add_contextual_for-1020574-43.patch, failed testing.

geertvd’s picture

Status: Needs work » Needs review
FileSize
968 bytes
4.98 KB
Wim Leers’s picture

Status: Needs review » Needs work

Almost there now! :)

  1. +++ b/core/modules/aggregator/aggregator.links.contextual.yml
    @@ -0,0 +1,4 @@
    +entity.aggregator_feed.edit:
    

    I see this now has an entity prefix. Node also does this, so yay for consistency!

  2. +++ b/core/modules/aggregator/aggregator.links.contextual.yml
    @@ -0,0 +1,4 @@
    +  group: aggregator
    

    This should be aggregator_feed, because aggregator provides two entity types: Feed & Item. In theory, we may add contextual links to Item entities in the future, so we should be sufficiently specific here.

    (Yes, this "group" concept for contextual links is totally WTF. But that's out of scope here.)

  3. +++ b/core/modules/aggregator/aggregator.module
    @@ -177,3 +178,13 @@ function aggregator_preprocess_block(&$variables) {
    +function aggregator_block_view_aggregator_feed_block_alter(array &$build, BlockPluginInterface $block) {
    

    So much better!

  4. +++ b/core/modules/aggregator/aggregator.module
    @@ -177,3 +178,13 @@ function aggregator_preprocess_block(&$variables) {
    +  $build['#contextual_links']['aggregator'] = array(
    

    Still array().

  5. +++ b/core/modules/aggregator/src/FeedViewBuilder.php
    @@ -132,8 +134,19 @@ public function buildComponents(array &$build, array $entities, array $displays,
    +    $build['#contextual_links']['aggregator'] = array(
    

    Also array().

  6. +++ b/core/modules/aggregator/src/FeedViewBuilder.php
    @@ -132,8 +134,19 @@ public function buildComponents(array &$build, array $entities, array $displays,
    +      'metadata' => ['changed' => $entity->getLastModified()],
    

    Ugh, this is called getLastModified() instead of getChangedTime() because FeedInterface does not extend EntityChangedInterface. Could you file an issue for that and add a @todo?

geertvd’s picture

Status: Needs work » Needs review
FileSize
3.46 KB
5.55 KB
  1. Was thinking the same thing :)
  2. Done
  3. Yes, that would have been a bit expensive
  4. Oops missed those yesterday
  5. same
  6. Done #2554079: FeedInterface should extend EntityChangedInterface

Status: Needs review » Needs work

The last submitted patch, 47: add_contextual_for-1020574-47.patch, failed testing.

geertvd’s picture

Status: Needs work » Needs review
FileSize
5.51 KB

reroll

Wim Leers’s picture

Status: Needs review » Needs work

@ParisLiakos remarked in #2554079-3: FeedInterface should extend EntityChangedInterface that Feed::getLastModifiedTime() is about the external feed's last modification timestamp.

The patch in #46 that has

'metadata' => ['changed' => $entity->getLastModified()],

tricked me into thinking it was the feed entity's own last modification time!

  1. +++ b/core/modules/aggregator/src/FeedInterface.php
    @@ -200,6 +200,9 @@ public function setEtag($etag);
    +   * @todo Remove this function and extend from EntityChangedInterface instead
    +   *   https://www.drupal.org/node/2554079.
    

    Therefor this…

  2. +++ b/core/modules/aggregator/src/FeedViewBuilder.php
    @@ -133,8 +135,19 @@ public function buildComponents(array &$build, array $entities, array $displays,
    +      'metadata' => ['changed' => $entity->getLastModified()],
    

    … and this should simply be deleted.

Sorry for having missed that!

geertvd’s picture

Status: Needs work » Needs review
FileSize
1.17 KB
4.89 KB

Yup, that makes sense.

Wim Leers’s picture

Issue tags: +Usability, +Needs screenshots

What'd be helpful for a committer is if this also had a screenshot showing the contextual link on both a feed block and a feed page.

Once we have that, this is RTBC :)

geertvd’s picture

Issue summary: View changes
FileSize
197.81 KB
77.98 KB

Here you go.

Feed block:

Feed page:

geertvd’s picture

And thanks for reviewing, that was quite helpful.

Wim Leers’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs screenshots

#54: You're welcome :) Thanks for helping make D8 better!

Note that this may end up being postponed to 8.1 because it's a feature request. The only reason I've not moved it to 8.1 is because it's so tiny.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 51: add_contextual_for-1020574-51.patch, failed testing.

geertvd’s picture

Status: Needs work » Reviewed & tested by the community

#56 was probably a random fail so setting this back to RTBC

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 51: add_contextual_for-1020574-51.patch, failed testing.

geertvd’s picture

Status: Needs work » Reviewed & tested by the community

random fail, back to RTBC

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 51: add_contextual_for-1020574-51.patch, failed testing.

AjitS’s picture

Status: Needs work » Needs review
FileSize
4.5 KB

Rerolling.

$ sudo git rebase 8.0.x
First, rewinding head to replay your work on top of it...
Applying: Patch applied.
Using index info to reconstruct a base tree...
M	core/modules/aggregator/aggregator.module
M	core/modules/aggregator/src/FeedViewBuilder.php
M	core/modules/aggregator/src/Tests/AggregatorRenderingTest.php
Falling back to patching base and 3-way merge...
Auto-merging core/modules/aggregator/src/Tests/AggregatorRenderingTest.php
Auto-merging core/modules/aggregator/src/FeedViewBuilder.php
Auto-merging core/modules/aggregator/aggregator.module
AjitS’s picture

Missed out a file from the patch above. Added it back.

The last submitted patch, 63: add_contextual_for-1020574-63.patch, failed testing.

AjitS’s picture

Status: Needs review » Reviewed & tested by the community

Was a plain reroll. Setting back to RTBC.

The last submitted patch, 63: add_contextual_for-1020574-63.patch, failed testing.

alexpott’s picture

Version: 8.0.x-dev » 8.1.x-dev
Status: Reviewed & tested by the community » Postponed
Issue tags: +minor version target

Thanks for working on this everyone. Unfortunately this is not eligible for the Drupal 8.0 release as it adds risks of breaking something. This is a feature and is not required to be part of Drupal 8 for release - we should target this for release in a minor version.

Wim Leers’s picture

#68++

I already said something similar in #55:

Note that this may end up being postponed to 8.1 because it's a feature request. The only reason I've not moved it to 8.1 is because it's so tiny.

Good to have this ready though :)

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

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

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

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.

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.

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.

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.

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.

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.

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.

quietone’s picture

Project: Drupal core » Aggregator
Version: 9.4.x-dev » 1.x-dev
Component: aggregator.module » Code

The aggregator module has been removed from Core in 10.0.x-dev and now lives on as a contrib module. Issues in the Core queue about the aggregator module, like this one, have been moved to the contrib module queue.

larowlan’s picture

Title: Add contextual for aggregator blocks » Add contextual link to edit feed to aggregator blocks
Category: Task » Feature request
Status: Postponed » Active
Issue tags: -Usability, -minor version target +Aggregator 2.x
larowlan’s picture

Priority: Normal » Minor
larowlan’s picture

Version: 1.x-dev » 2.x-dev
Issue tags: -Aggregator 2.x