feat(cabana): mail templates list grouped by template with per-locale status
Gap G-35-1 (supersedes D-05; D-06 reset and D-07 drift per locale): - the templates list keeps one row per template (the base row, or the lowest variant when only variants ship) with a Customized locales column (Default, then locale codes, at most three then +N); - row states and the status filter aggregate over the template's locale versions; the locale filter is removed; - a not-customized locale without a file shows the base row's current subject, body and layout; its info partial says so, its file version compares with the base file, and Reset returns it to the base file (postcard.ResetOverride accepts a fallback-locale code); - copy: mail.template.customized_locales, mail.info_locale_default, mail.info_locale_fallback (en/pl); - tests: TestMailScreensSmoke/locales_list, templates and drift updated, TestMailDrift on the grouped row, TestMailTemplateFilterScopes.
This commit is contained in:
@@ -169,11 +169,11 @@ The log lines carry the component `postcard`. In a test, pass any `postcard.Over
|
||||
|
||||
Every application with an admin gets the mail screens in Settings → Mail, with no setup in the application or its plugins. They are served by the admin itself (cabana) over postcard's tables:
|
||||
|
||||
- **Mail templates** lists every template the application's plugins register, one row per file, so `acme.blog::mail.welcome` and `acme.blog::mail.welcome-en` are separate rows. The list shows the code, the subject, the file's description, the locale (the suffix after the last dash when it is one of the application's locales, otherwise Default) and the layout. The form edits the subject, the Markdown message and the layout, chosen from every file layout and every layout created in the admin. The description stays the file's.
|
||||
- **Mail templates** lists every template the application's plugins register, one row per template however many locales the application has: `acme.blog::mail.welcome` and its `acme.blog::mail.welcome-en` variant are one row. The list shows the code, the subject, the file's description, the customized locales (Default and the locale codes whose version was customized, at most three and then +N) and the layout. The Customized and File changed badges and the status filter (customized, not customized, file changed) are about the whole template: any of its locale versions. The form edits the subject, the Markdown message and the layout, chosen from every file layout and every layout created in the admin. The description stays the file's. A **Language** select under the title switches between the template's versions: Default (the template's own file), every locale with its own file, and every other locale of the application. A locale with neither a file nor a customization shows the default version, which is what it sends; saving it creates that locale's own version, and Reset to file version returns it to the default version. The application's locales are the admin's translation locales plus the content locales of a translate plugin, when one is installed.
|
||||
|
||||
The screen needs `system.manage_mail_templates` (see [Users and permissions](../backend/users-and-permissions.md#permissions)). Templates come from files, so the list has no create and no delete.
|
||||
|
||||
The rows exist before anyone edits a template: when the admin starts, it writes an index row for every file template, layout and partial (`postcard.SyncIndex`), and keeps a row that is not customized equal to its file. A row whose plugin is no longer installed stays in the table but is not listed. If the tables are not there yet when the admin starts, the first open of a mail list writes the rows.
|
||||
The rows exist before anyone edits a template: when the admin starts, it writes an index row for every file template, layout and partial (`postcard.SyncIndex`) and for every locale a template ships no file for (`postcard.EnsureLocaleRows`), and keeps a row that is not customized equal to its file. A row whose plugin is no longer installed stays in the table but is not listed. If the tables are not there yet when the admin starts, the first open of a mail list writes the rows.
|
||||
|
||||
Saving a template stores your subject, message and layout in its row and marks it customized, together with the hash of the file the change was based on. From then on your version is sent instead of the file, until the template is reset to the file version. A save is checked the way a send would render it (`postcard.Editor.Validate`): a message that does not parse, does not render with the sample values or fails the safety checks is refused with a line under the field, and nothing is stored.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user