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:
Jakub Zych
2026-11-13 20:39:45 +01:00
parent 52c9c7eb18
commit 67f7164302
14 changed files with 460 additions and 118 deletions

View File

@@ -564,8 +564,10 @@ func rowName(title, full string) string {
// ResetOverride returns one file-backed row to its file version: the content
// columns mirror the file again and is_custom, base_hash and customized_at
// are cleared. kind is KindTemplate, KindLayout or KindPartial and code the
// row's code. A database-only layout has no file version: it is refused, and
// so is a code cat does not hold.
// row's code. The file version of a fallback-locale template row (a
// <template>-<locale> code whose locale ships no file) is the base
// template's file (Catalog.TemplateFor). A database-only layout has no file
// version: it is refused, and so is a code cat does not hold.
func ResetOverride(ctx context.Context, db *gorm.DB, cat *Catalog, kind Kind, code string) error {
if db == nil {
return fmt.Errorf("postcard: reset %s: database is nil", code)
@@ -577,7 +579,8 @@ func ResetOverride(ctx context.Context, db *gorm.DB, cat *Catalog, kind Kind, co
var res *gorm.DB
switch kind {
case KindTemplate:
f, ok := cat.Template(code)
// A fallback-locale row returns to the base template's file.
f, ok := cat.TemplateFor(code)
if !ok {
return fmt.Errorf("postcard: reset %s: no file version", code)
}