Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: email template editor #9

Merged
merged 1 commit into from
Mar 3, 2024

Conversation

thoward27
Copy link

Here is my v1 implementation of email template editing!

Let me know what your thoughts are on the approach, if you like the way this is heading then I can take another pass at it and do a bit more refactoring / documenting before we merge this into your mainline.

At this point, the full flow should work. You should be able to create email templates, connect them to events, move them to the trash, and restore them back or permanently delete them. Database guards prevent duplicate aliases from existing, ensure that only one template fires from one event at a time (excluding unset), and does on-the-fly computation of the alias field such that it is compatible with postmark.

I know this is a big change, some diffs were caused by a slight change to the publish step, which now uses dist, and others are related to fixes that oxlint could perform automatically on the codebase.

* feat: allow dynamic events

* ci: enable dev publishing to gh pr

* ci: rename

* ci: branch names

* ci: set registry

* ci: fix registry

* ci: try passing registry-url

* docs: add docs about dynamic events

* build: bump version to 4.7.0

* feat: v1 implementation of editor flow

* chore: editing subject

* chore: stylize the template editor

* chore: add migration to create object

* chore: get list of events and templates dynamically:

* chore: start implementing merge tags

* chore: add soft-delete attribute to model

* chore: remove view

* chore: unset notification event before soft remove

* chore: add ability to delete email templates

* feat: full create, delete, restore | permanent delete

* style: oxlint --fix

* chore: finish styling trash

* ci: tweak publish

* build: bump version
@Fullstak-nl
Copy link
Owner

Sorry totally missed this PR. Will look into it tomorrow.
I really want to thank you for your time and all this effort!

@thoward27
Copy link
Author

Sorry totally missed this PR. Will look into it tomorrow. I really want to thank you for your time and all this effort!

@Fullstak-nl have you had a chance to play with this? I'm going to start refactoring things and cleaning them up in the hopes I can get this merged in. Let me know if you run into any sharp edges with any of what I've written

@Fullstak-nl Fullstak-nl changed the base branch from main to template-editor March 3, 2024 00:04
@Fullstak-nl Fullstak-nl merged commit 975a035 into Fullstak-nl:template-editor Mar 3, 2024
@Fullstak-nl
Copy link
Owner

Just had time to test and verify. Thanks for all the hard work. Looks like it works right away.
I've merged it into a new branch so we can work on it a bit more.

If you have the time/energy to document it a bit more that would be awesome. But I don't mind to do it myself.
I will also look into some tests etc.. and better linting. oxlint is a good solution for the linting 👍

@Fullstak-nl Fullstak-nl linked an issue Mar 3, 2024 that may be closed by this pull request
@thoward27
Copy link
Author

thoward27 commented Mar 4, 2024

@Fullstak-nl thanks for merging and releasing! I can confirm that I've migrated one of my projects to use the v5 alpha and am very happy with how things are working. I still have a few things I think could be improved. Let me know if you'd like me to make GH issues around these items or if you're happy to just leave them documented here until I have time to get to them:


Merge Tags

image

Unlayer supports the idea of "merge tags" in the template editor. These should include all the variables that Medusa supplies to a template, and I do have some of those variables already mapped out, but the full mapping is far from complete. I found it hard to pinpoint exactly what variables would be provided to a given event template.

Template Creation Name Validation

Right now, when you create a new template, the UI will show an error if you use a name that is already defined. It does not take into account names of templates in the trash, but it should. The templates in the trash are still in the DB (to preserve templates, which can be really complex), so trying to save one with the same name results in a DB error that is not currently surfaced.

Test Email Sending

I'm not sure about the best way to approach this, Unlayer provides a plugin to do it, but that requires users to pass in a project ID and user ID with hashes to get it working. IMO it may be simpler to add another button to the top-bar to send a test email.

Layout Creation

Postmark supports the idea of template layouts, building that into this plugin would make it significantly easier for creators to manage multiple templates that should all look alike.

Surfacing Uploaded Images

When users upload images of products to Medusa, those images should be available in the template editor UI. Unfortunately, I think this is the most complicated thing on this list. Unlayer supports adding another tab to the UI, but that is marked as a "premium feature"

https://docs.unlayer.com/docs/tabs#create-a-custom-tab

Display Saving State

Like most realtime editors, the template editing page should show something like "saving..." somewhere when the page is saving.


Best,
Tom

@Fullstak-nl
Copy link
Owner

Fullstak-nl commented Apr 10, 2024

Sorry for the ULTRA late reply!
We've been busy with some projects.

I'm also looking into merging Medusa-documents maybe even hook into their template item somehow to combine the features.
Next release we will also launch your feature, with a fallback if not used/enabled. Furthermore we experienced some issues with the TRIGGER creation of update_updated_at_column.. Not sure why tho..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dynamic Configuration, Template Editing
2 participants