Problem/Motivation

Extracted from todo.txt :
simplenews_help: work over

Proposed resolution

Update hook help arguments, it receives route now, not path. See other examples. Update the code, e.g. user_access() so it works. Enable the help module in the administration test, place the help block and make sure it shows up on the relevant pages.

Remaining tasks

User interface changes

API changes

Comments

miro_dietiker’s picture

Component: Code » Documentation
berdir’s picture

Issue summary: View changes
tduong’s picture

Status: Active » Needs review
StatusFileSize
new7.44 KB

Discussed/Working with @yongt9412 and @Arla, in this patch we've tried to edit what is in "Proposed solution", but we're not sure how to specify two path cases ('admin/config/services/simplenews/settings/newsletter' and 'admin/structure/types/manage/article/display'). Any suggestion?

Status: Needs review » Needs work

The last submitted patch, 3: update_hook_help-2410247-3.patch, failed testing.

berdir’s picture

  1. +++ b/simplenews.module
    @@ -814,55 +814,55 @@ function simplenews_newsletter_load_multiple($ids = NULL, $reset = FALSE) {
           return $help;
    -    case 'node/add/simplenews_issue':
    +    case 'node.add':
           $help = '<ul>';
    

    This is not the same. node.add is the page that lists the node types. This is an argument, so you need to combine it with $route_match, which has the arguments for it.

    I'm actually wondering if we shouldn't move this text here to the help property of the node type. That should also show up on that page. We can't have dynamic access checks and links in there, so we might need to simplify it a bit.

  2. +++ b/simplenews.module
    @@ -814,55 +814,55 @@ function simplenews_newsletter_load_multiple($ids = NULL, $reset = FALSE) {
           return $help;
    -    case 'admin/config/services/simplenews/newsletter':
    +    case 'simplenews.settings_newsletter'://settings?
           $help = '<ul>';
    

    this should be fine.

  3. +++ b/simplenews.module
    @@ -814,55 +814,55 @@ function simplenews_newsletter_load_multiple($ids = NULL, $reset = FALSE) {
           $help .= '<li>' . t('Install <a href=":mime_mail_url">Mime Mail</a> or <a href=":html_mail_url">HTML Mail</a> to send HTML emails or emails with attachments (both plain text and HTML).', array(':mime_mail_url' => 'http://drupal.org/project/mimemail', ':html_mail_url' => 'http://drupal.org/project/htmlmail')) . "</li>\n";
    

    We should update this to include Swiftmailer as well, which is what we use now in D8. Those other two afaik have no D8 port yet.

  4. +++ b/simplenews.module
    @@ -814,55 +814,55 @@ function simplenews_newsletter_load_multiple($ids = NULL, $reset = FALSE) {
    -    case 'admin/structure/types/manage/simplenews_issue/display':
    +    case 'entity.entity_view_display.node.default'://missing specified check for simplenews_issue
    

    Same here. This is a combination of route name (See RouteSubscriber in field_ui, should be "entity.entity_form_display.node.form_mode" + you have a form_mode_name argument in route match that is then simplenews_issue.

    Note that simplenews_issue is just a default type. Others could have it too. We might want to check that with simplenews_check_node_types()

  5. +++ b/src/Tests/SimplenewsTestBase.php
    @@ -41,6 +41,7 @@ abstract class SimplenewsTestBase extends WebTestBase {
         $this->drupalPlaceBlock('page_title_block');
    +    $this->drupalPlaceBlock('help_block');
    

    this doesn't match. you enable the module only in AdministrationTest (which is correct) but place the block here, for all tests. Move this to AdministrationTest as well.

    Additionally, go through hook_help() and try to find one case where that page is visited in the administration page. If so, add an assertText() for atleast part of the help message.

tduong’s picture

Status: Needs work » Needs review
StatusFileSize
new7.68 KB
new9.92 KB

Done #5.1-4.
As discussed with @Berdir, for #5.1 is fine enough

Test coming soon.

Status: Needs review » Needs work

The last submitted patch, 6: update_hook_help-2410247-6.patch, failed testing.

johnchque’s picture

Status: Needs work » Needs review
StatusFileSize
new8.52 KB
new14.14 KB

Added test cases. Patch attached. Added interdiff between last patch and current patch.

berdir’s picture

Status: Needs review » Needs work
  1. +++ b/src/Tests/SimplenewsAdministrationTest.php
    @@ -26,7 +26,16 @@ class SimplenewsAdministrationTest extends SimplenewsTestBase {
    +    $this->config = $this->config('simplenews.settings');
    

    what is this for?

  2. +++ b/src/Tests/SimplenewsAdministrationTest.php
    @@ -59,6 +68,8 @@ class SimplenewsAdministrationTest extends SimplenewsTestBase {
         $this->drupalGet('admin/config/services/simplenews');
    +    //Check if the help text is displayed
    +    $this->assertText('Newsletter allow you to send periodic e-mails to subscribers.');
    

    Check comment coding standards. Space after //, . at the end.

johnchque’s picture

Status: Needs work » Needs review
StatusFileSize
new3.05 KB
new14.03 KB

Added patch based on comment #9. Added interdiff.

berdir’s picture

Title: todo.txt: simplenews_help: work over » Port simplenews_help()
Category: Task » Bug report
Priority: Normal » Major
Status: Needs review » Fixed
Parent issue: #2410245: todo.txt: simplenews_recent_newsletters: Replace this list by a View »

Great. Changing to a major bug since this wasn't working at all. Core considers missing help critical :)

  • Berdir committed 73ea7bf on 8.x-1.x authored by yongt9412
    Issue #2410247 by yongt9412, tduong: Port simplenews_help()
    

Status: Fixed » Closed (fixed)

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