The link "Add Newsletter issues" in the admin/content/simplenews form apears as "Add @label", needs to appear again as "Add Newsletter issues".
And the tests fails for that issue: https://qa.drupal.org/pifr/test/1106023

Comments

edurenye’s picture

Issue summary: View changes
edurenye’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new893 bytes

Solved, now the link is shown properly.

berdir’s picture

Status: Needs review » Needs work

I don't think that's correct, unless we actually cache those per language now and afaik we don't?

Support for title arguments was removed from core, although I don't fully understand the reason, this was the perfect example that needs it :)

alexpott’s picture

title arguments support was removed from YamlDiscovery of plugins. This is a derived plugin afaik that is a totally different situation.

berdir’s picture

Apparently not, because the title argument is clearly no longer available here. It's using the same class as local actions defined in yaml, so it has the same features.

I guess we need a custom local task plugin class to support this :(

miro_dietiker’s picture

Well there is also the core guideline that proposes to only have one such item... Currently we create multiple in case there are multiple newsletter types...

So... Do we need an intermediate page in case there are multiple newsletter types?

Workaround proposal to deal with the situation:
In case we have only one type we could directly point the user to the node creation form.
In case we have multiple types, we should just point the user to the "Add content" overview...

edurenye’s picture

Status: Needs work » Needs review
StatusFileSize
new1.39 KB
new1.23 KB

Done, now it differs from only type and multiple types.

Status: Needs review » Needs work

The last submitted patch, 7: link_add_newsletter-2540586-7.patch, failed testing.

The last submitted patch, 7: link_add_newsletter-2540586-7.patch, failed testing.

The last submitted patch, 2: link_add_newsletter-2540586-2.patch, failed testing.

juanse254’s picture

Status: Needs work » Needs review

Its green now, everything is looking good.

berdir’s picture

Priority: Normal » Major
Status: Needs review » Needs work
  1. +++ b/src/Plugin/Derivative/AddSimplenewsIssueActionLinks.php
    @@ -20,17 +20,21 @@ class AddSimplenewsIssueActionLinks extends DeriverBase {
         $node_types = simplenews_get_content_types();
    -    foreach ($node_types as $node_type) {
    +    $node_type = $node_types['simplenews_issue'];
    +    if (count($node_types) == 1) {
    

    Hardcoding that type is wrong, instead, you need to use reset($node_types) if you just have one.

  2. +++ b/src/Plugin/Derivative/AddSimplenewsIssueActionLinks.php
    @@ -20,17 +20,21 @@ class AddSimplenewsIssueActionLinks extends DeriverBase {
           $this->derivatives[$node_type] = $base_plugin_definition;
    -      $this->derivatives[$node_type]['title'] = 'Add @label';
    -      $this->derivatives[$node_type]['title_arguments'] = array(
    -        '@label' => $label,
    -      );
    +      $this->derivatives[$node_type]['title'] = t('Add @label', array('@label' => $label));
    

    Calling t() here is wrong, it will not work correctly for transltable sites.

    Still not sure what the correct solution is, maybe using a TranslationWrapper().

  3. +++ b/src/Plugin/Derivative/AddSimplenewsIssueActionLinks.php
    @@ -20,17 +20,21 @@ class AddSimplenewsIssueActionLinks extends DeriverBase {
    +    elseif (count($node_types) > 1) {
    +      $base_plugin_definition['route_name'] = 'node.add_page';
    +      $base_plugin_definition['title'] = t('Add content');
    +      $this->derivatives[] = $base_plugin_definition;
    

    Same, t() is wrong.

    Also, add content is wrong and that list will then show all the types, not sure I like that pattern.

    I'd actually suggest to just do the minimal (correct) fix here to get the tests passing again and then think about the multiple local actions problem in a separate issue.

edurenye’s picture

Status: Needs work » Needs review
StatusFileSize
new1.35 KB
new1.33 KB

Done.

edurenye’s picture

I forgot the translatorwrapper.

berdir’s picture

Status: Needs review » Fixed

Ok, committed for now, not sure this is correct but we can change later and it works.

  • Berdir committed 8ddbb7b on 8.x-1.x authored by edurenye
    Issue #2540586 by edurenye: Link "Add newsletter" not rendered properly
    

The last submitted patch, 16: link_add_newsletter-2540586-16.patch, failed testing.

Status: Fixed » Closed (fixed)

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