Comments

Miguel.kode’s picture

Assigned: Unassigned » Miguel.kode

I am working on it.

This is the repository:

https://github.com/MiguelCarogar/mail_edit_d8

salvis’s picture

Thanks for jumping in, Miguel.kode!

Please be aware of Mail Editor's "special relationship" with Subscriptions. ME is useful in its own right, but it's also open for extensive customization by modules like Subscriptions, and this capability needs to be carried over into D8.

Miguel.kode’s picture

Ok salvis. I will work on it. Thanks

salvis’s picture

Have you been able to make any progress, Miguel.kode?

damienmckenna’s picture

Title: Mail Editor for D8 » Port Mail Editor to Drupal 8
Priority: Major » Normal
damienmckenna’s picture

There's an 8.x-1.x branch, but it only includes a copy of 7.x-1.x's codebase.

Given D8's mail system is almost identical to D7's, this should be a pretty straightforward port.

salvis’s picture

Assigned: Miguel.kode » Unassigned
Priority: Normal » Major
Status: Active » Needs work
damienmckenna’s picture

fyi I'm actively working on this, hope to have a prototype on Thursday.

salvis’s picture

Assigned: Unassigned » damienmckenna

Fantastic, welcome!

damienmckenna’s picture

Priority: Major » Normal
Status: Needs work » Needs review
StatusFileSize
new64.54 KB
new6.47 KB

This is v0.1 - it can edit system emails but nothing else. Tomorrow I'll be working on making it able to edit custom emails.

damienmckenna’s picture

Issue tags: +Needs tests

Also, no tests yet.

damienmckenna’s picture

FYI I didn't go into any language handling at all because I think we should push to support core's config translation system and just leave this module as a unified system for modifying all emails. That said, I could be completely wrong on this assumption as I haven't dug into how core's config translation system works.

damienmckenna’s picture

StatusFileSize
new7.21 KB
new71.79 KB

Some serious refactoring, and addition of some hooks to allow this to be extendable.

My next step is to test out adding hooks to my own module to confirm it all works as intended.

damienmckenna’s picture

StatusFileSize
new7.58 KB
new73 KB

This fixes some problems with the previous version, and now allows emails to be dynamically generated, i.e. the config objects don't have to exist before someone edits them, so long as they're defined in the appropriate hooks it'll be possible to save something.

damienmckenna’s picture

The patch in #14 is working for me, would love to hear what could be done to improve upon it.

damienmckenna’s picture

StatusFileSize
new7.79 KB
new73.8 KB

This includes improvements to the comments.

damienmckenna’s picture

StatusFileSize
new73.68 KB
new7.71 KB

Some more minor coding format tweaks.

damienmckenna’s picture

StatusFileSize
new73.7 KB
new7.71 KB

There was a typo in MailEditTemplateForm.php, sorry.

salvis’s picture

I'm sorry, I'm on the road with little connectivity until the end of next week. I'll try to take a look ASAP before that, but I can't promise.

Thank you very much for working on it!

damienmckenna’s picture

@salvis: No problem :)

FYI I was short on time so built the APIs in D7-style hooks, this may be enough for a quick 1.0 release, but it probably would be worth putting the time into building a proper annotation-based API.

salvis’s picture

I found out that I've already branched 8.x-1.x from 7.x-1.x, but the latter got a few more commits, and I've committed #2735109: Some spaces disappear from long mail subjects (at least when using Mimemail). Now, I'm waiting for the testbot to complete. Then I'll tag 7.x-1.2, merge the missing commits to 8.x-1.x.

#18 doesn't apply to yesterday's 8.x-1.x—I assume you've diffed it against 7.x-1.x—but I'll just copy over the zip file and adjust the change log. There's nothing you need to do.

The testbot hasn't budged yet, I'll continue tomorrow.

Do you by any chance know whether the bug mentioned in #2735109: Some spaces disappear from long mail subjects (at least when using Mimemail) is also in your D8 port?

damienmckenna’s picture

Assigned: damienmckenna » Unassigned

The port I created was a from-scratch rewrite that does not use any custom data structures, instead it relies on hooks and existing config entities for the emails; one rationale for this is that it pushes the translation handling to core's config translation system rather than having to manually handle it, though I haven't tested it. That said, I did keep the same permission and menu path ;-)

salvis’s picture

Status: Needs review » Needs work
StatusFileSize
new71.19 KB
new6.02 KB

Thank you, that's a good start.

Here are some changes that I've made, and some comments:

  1. +++ b/CHANGELOG.txt
    @@ -1,91 +1,3 @@
    -CHANGELOG.txt for Mail Editor for Drupal 7
    

    I prefer to keep the change log across major versions.

  2. +++ b/mail_edit.module
    @@ -1,226 +1,39 @@
    +    case 'mail_edit.list':
    

    This needs to be 'help.page.mail_edit'.

  3. I've added a dummy test so that I can enable the testbot.

  4. Interestingly, admin/config/people/accounts is not working correctly in multi-language mode. I've done some experimenting by adding German. Core always displays and saves the English text, even when I switch to German. Your implementation OTOH initially displays the German text, but after editing and saving, you'll display the unchanged German original in German and the edited German version in English. Also, the subjects and text bodies are not exactly in sync.
  5. I think we will need to make the distinction between Add and Edit again (as well as provide a Purge action), because having to open each template to check whether they are all customized is a pain. Likewise, seeing all the languages on the same page, rather than having to switch the language, helps to keep things in order, and it would be what we can offer on top of Core for the user emails.
  6. What does the character count buy us?
  7. The admin/config/system/mail-edit/% page is missing a page title.

I'm still checking it in as a work-in-progress, so that we have a base to build on.

Do you have a contrib that uses Mail Editor?

  • salvis committed bcd0041 on 8.x-1.x authored by DamienMcKenna
    Issue #2526518 by DamienMcKenna: Port of some limited functionality.
    
salvis’s picture

Hmm, can I not make the snapshot release visible on the front page anymore?

damienmckenna’s picture

I fixed the problem on the release node, there was a checkbox you had to check for the dev snapshot to make it visible.

damienmckenna’s picture

Thanks for committing the patch.

I had specifically avoided adding an extra data storage layer because I felt the system should focus on editing the original emails. That way if someone edits the message in the original location there won't be any difference in what they see.

I also have not tested the config translations. It might be worth adding an indicator on the page as to which language is being accessed.

I didn't add support to any other contrib modules (yet), it was for custom code.

salvis’s picture

Thank you for publishing the snapshot!

I had specifically avoided adding an extra data storage layer because I felt the system should focus on editing the original emails. That way if someone edits the message in the original location there won't be any difference in what they see.

Yes, that makes sense for the user templates, there seems to be storage for each active language, but somehow neither Core nor Mail Editor manage to get the right slot (or even the same slot) for every operation...

However, for third party modules (like Subscriptions), that rely completely on Mail Editor, we'll need storage. Right now, Mail Editor doesn't offer much more than Core does.

Why the character count? I don't think I want to keep that...

damienmckenna’s picture

The idea for 3rd party modules was to leverage existing configuration objects and to just work out a (better?) API to handle them? Then we'd be defining an API for other modules to take advantage of.

The character count was just something to help tell how large the different emails were, it can be removed without any concern.

salvis’s picture

The idea for 3rd party modules was to leverage existing configuration objects and to just work out a (better?) API to handle them? Then we'd be defining an API for other modules to take advantage of.

Yes, exactly. Client modules just define mailkeys and default text, and Mail Editor does the rest. It provides conditions and loops for working with tokens, and the client module can provide additional tokens to be used in the templates.

The Subscriptions module added a second template field (for formatting comments to go with nodes) and a preview mode. Preview cannot be provided by Mail Editor alone, because the client module has to supply the data to go with the template, but Mail Editor could help.

alexdmccabe’s picture

Status: Needs work » Fixed

Marking as fixed because it has been committed.

Status: Fixed » Closed (fixed)

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