@raketa-cloud/admin 0.0.68 → 0.0.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/package.json +1 -1
  2. package/src/handlers/_shared/SettingsHandler.js +1 -1
  3. package/src/handlers/articles/TranslationsHandler.js +129 -44
  4. package/src/handlers/events/TranslationsHandler.js +132 -49
  5. package/src/tests/handlers/_shared/SettingsHandler.test/update.test.js +1 -1
  6. package/src/tests/handlers/articles/TranslationHandler.test/create.test.js +291 -0
  7. package/src/tests/handlers/articles/TranslationHandler.test/create_form.test.js +71 -0
  8. package/src/tests/handlers/articles/TranslationHandler.test/index.test.js +91 -0
  9. package/src/tests/handlers/events/TranslationHandler.test/create.test.js +297 -0
  10. package/src/tests/handlers/events/TranslationHandler.test/create_form.test.js +71 -0
  11. package/src/tests/handlers/events/TranslationHandler.test/index.test.js +91 -0
  12. package/src/tests/handlers/pages/TranslationHandler.test/create.test.js +1 -1
  13. package/src/views/articles/_shared/_history_toolbar.ejs +2 -2
  14. package/src/views/articles/show.ejs +15 -4
  15. package/src/views/articles/translations/_translation_toolbar.ejs +18 -0
  16. package/src/views/articles/translations/create_form.ejs +68 -4
  17. package/src/views/articles/translations/index.ejs +39 -0
  18. package/src/views/events/_shared/_history_toolbar.ejs +2 -2
  19. package/src/views/events/show.ejs +15 -4
  20. package/src/views/events/translations/_translation_toolbar.ejs +18 -0
  21. package/src/views/events/translations/create_form.ejs +68 -4
  22. package/src/views/events/translations/index.ejs +39 -0
  23. package/src/views/pages/_shared/_history_toolbar.ejs +2 -2
  24. package/src/views/pages/show.ejs +2 -4
  25. package/src/views/pages/translations/_translation_toolbar.ejs +18 -0
  26. package/src/views/pages/translations/index.ejs +2 -19
  27. package/src/views/articles/translations/_form.ejs +0 -31
  28. package/src/views/events/translations/_form.ejs +0 -33
@@ -5,6 +5,13 @@
5
5
  </div>
6
6
 
7
7
  <div class="flex flex-wrap items-center gap-1 mb-6 -mt-4">
8
+ <%
9
+ const availableLocales = Object.keys(_context.locales);
10
+ const totalPossibleTranslations = availableLocales.length - 1;
11
+ const existingTranslationsCount = Object.keys(resource.translations).length;
12
+ const canBeTranslated = existingTranslationsCount < totalPossibleTranslations;
13
+ %>
14
+
8
15
  <% Object.keys(_context.locales).forEach(key => { %>
9
16
  <% const { name, _code, flag} = _context.locales[key] %>
10
17
  <% if (key === _context.locale) { %>
@@ -19,6 +26,12 @@
19
26
  </a>
20
27
  <% } %>
21
28
  <% }); %>
29
+
30
+ <% if (canBeTranslated) { %>
31
+ <a href="<%= `/${_context.locale}/${_context.resourceConfig.eventTypePlural}/${resource.id}/translations/new` %>" class="btn-text ml-2">
32
+ Translate
33
+ </a>
34
+ <% } %>
22
35
  </div>
23
36
 
24
37
  <% if (revisions.length) { %>
@@ -55,9 +68,7 @@
55
68
  </div>
56
69
  <% } %>
57
70
 
58
- <a href="/remote-login?redirect_to=/admin/<%= _context.resourceConfig.eventType %>-revisions/<%= revision.id %>/builder" target="_blank" class="btn-text has-icon <%= revision.meta && revision.meta.locked ? 'cursor-not-allowed text-gray-400 pointer-events-none' : '' %>">
59
- <%= revision.title %>
60
- </a>
71
+ <%= revision.title %>
61
72
  </div>
62
73
  </td>
63
74
 
@@ -155,4 +166,4 @@
155
166
  </tbody>
156
167
  </table>
157
168
  </div>
158
- </div>
169
+ </div>
@@ -0,0 +1,18 @@
1
+ <div class="actions-toolbar justify-end">
2
+ <a href="/remote-login?redirect_to=/<%= translation.translationLocale %>/admin/<%= _context.resourceConfig.eventType %>-revisions/<%= translation.revisionId %>/builder" target="_blank" class="btn-text has-icon">
3
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
4
+ <path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125" />
5
+ </svg>
6
+
7
+ Update Content
8
+ </a>
9
+
10
+ <a href="<%= `/${translation.translationLocale}/event_revisions/${translation.revisionId}/general/edit` %>" class="btn-text has-icon">
11
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
12
+ <path stroke-linecap="round" stroke-linejoin="round" d="M10.343 3.94c.09-.542.56-.94 1.11-.94h1.093c.55 0 1.02.398 1.11.94l.149.894c.07.424.384.764.78.93.398.164.855.142 1.205-.108l.737-.527a1.125 1.125 0 0 1 1.45.12l.773.774c.39.389.44 1.002.12 1.45l-.527.737c-.25.35-.272.806-.107 1.204.165.397.505.71.93.78l.893.15c.543.09.94.559.94 1.109v1.094c0 .55-.397 1.02-.94 1.11l-.894.149c-.424.07-.764.383-.929.78-.165.398-.143.854.107 1.204l.527.738c.32.447.269 1.06-.12 1.45l-.774.773a1.125 1.125 0 0 1-1.449.12l-.738-.527c-.35-.25-.806-.272-1.203-.107-.398.165-.71.505-.781.929l-.149.894c-.09.542-.56.94-1.11.94h-1.094c-.55 0-1.019-.398-1.11-.94l-.148-.894c-.071-.424-.384-.764-.781-.93-.398-.164-.854-.142-1.204.108l-.738.527c-.447.32-1.06.269-1.45-.12l-.773-.774a1.125 1.125 0 0 1-.12-1.45l.527-.737c.25-.35.272-.806.108-1.204-.165-.397-.506-.71-.93-.78l-.894-.15c-.542-.09-.94-.56-.94-1.109v-1.094c0-.55.398-1.02.94-1.11l.894-.149c.424-.07.765-.383.93-.78.165-.398.143-.854-.108-1.204l-.526-.738a1.125 1.125 0 0 1 .12-1.45l.773-.773a1.125 1.125 0 0 1 1.45-.12l.737.527c.35.25.807.272 1.204.107.397-.165.71-.505.78-.929l.15-.894Z" />
13
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
14
+ </svg>
15
+
16
+ Update Settings
17
+ </a>
18
+ </div>
@@ -1,9 +1,73 @@
1
1
  <div class="page-wrapper">
2
- <div class="page-title">
3
- <h1 class="heading-1">Create <%= Inflector.humanize(Inflector.downcase(_context.resourceConfig.eventType)) %> translation</h1>
2
+ <div class="page-title flex flex-col items-start">
3
+ <h1 class="heading-1">
4
+ <span class="opacity-50">Translate from <%= _context.locales[_context.locale].name %> / </span>
5
+ <%= blueprint.title %>
6
+ </h1>
4
7
  </div>
5
8
 
6
9
  <div class="grid gap-4 md:grid-cols-3">
7
- <%- render_partial('_form.ejs') %>
10
+ <% form_for({ resource }, errors, (f) => { %>
11
+ <form action="<%= `/${_context.locale}/${_context.resourceConfig.eventTypePlural}/${blueprint.id}/translations` %>" method="post" class="form">
12
+ <h6>Available languages:</h6>
13
+ <% if (targetLocale) { %>
14
+ <input type="hidden" name="resource[languages][]" value="<%= targetLocale %>">
15
+ <% } %>
16
+ <div class="checkbox-group !max-h-fit mb-3">
17
+ <% Object.entries(_context.locales).forEach(([key, locale]) => {
18
+ const isExistingTranslation = resource.translations[key];
19
+ const isCurrentLocale = key === _context.locale;
20
+ const wasSelected = Array.isArray(resource.languages) && resource.languages.includes(key);
21
+ const isChecked = isExistingTranslation || isCurrentLocale || key === targetLocale || wasSelected;
22
+ const isDisabled = isExistingTranslation || isCurrentLocale || key === targetLocale;
23
+ %>
24
+ <% if(!isCurrentLocale) { %>
25
+ <label class="<%= isDisabled && key !== targetLocale ? 'opacity-50' : '' %>">
26
+ <input type="<%= isCurrentLocale ? 'hidden' : 'checkbox' %>" name="resource[languages][]" value="<%= key %>" <%= isChecked ? 'checked' : '' %> <%= isDisabled ? 'disabled' : '' %>>
27
+ <%= locale.name %>
28
+ </label>
29
+ <% } %>
30
+ <% }) %>
31
+ </div>
32
+
33
+ <% if (errors?.resource && targetLocale) { %>
34
+ <div>
35
+ <p class="text-sm text-red-600 font-medium mb-1">
36
+ Failed to create <%= _context.locales[targetLocale].name %> translation.
37
+ </p>
38
+ <% Object.entries(errors.resource).forEach(([errorKey, error]) => { %>
39
+ <p class="text-sm text-red-600 font-medium mb-3"> Reason is <%= errorKey %>: <%= error %></p>
40
+ <% }) %>
41
+ </div>
42
+ <% } %>
43
+
44
+ <div class="form-actions">
45
+ <div class="btn-toolbar">
46
+ <%- f.submit('Initiate translations', { class: 'btn-primary' }) %>
47
+ <a href="<%= `/${_context.locale}/${_context.resourceConfig.eventTypePlural}/${blueprint.id}` %>" class="btn-secondary">Cancel</a>
48
+ </div>
49
+ </div>
50
+ </form>
51
+ <% }) %>
52
+
53
+ <div>
54
+ <div class="help">
55
+ <div class="flex items-center gap-1 mb-2">
56
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
57
+ <path stroke-linecap="round" stroke-linejoin="round" d="m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z" />
58
+ </svg>
59
+
60
+ <h3 class="heading-3">Translating events</h3>
61
+ </div>
62
+
63
+ <div class="markdown">
64
+ <ol>
65
+ <li>Select multiple locales to initiate bulk translations.</li>
66
+ <li>A private copy of the event will be automatically created for each selected language, with a new revision opened to facilitate the translation process.</li>
67
+ <li>On the next screen you'll see a list with quick links to transalte settings and widgets</li>
68
+ </ol>
69
+ </div>
70
+ </div>
71
+ </div>
8
72
  </div>
9
- </div>
73
+ </div>
@@ -0,0 +1,39 @@
1
+ <div class="page-wrapper">
2
+ <div class="page-title">
3
+ <div>
4
+ <h1 class="heading-1">Translations initiated</h1>
5
+ <span class="body-2 opacity-50"><%= eventTitle %></span>
6
+ </div>
7
+ </div>
8
+
9
+ <% if (translations && translations.length > 0) { %>
10
+ <table class="data-grid alt">
11
+ <thead>
12
+ <tr>
13
+ <th>Locale</th>
14
+ <th>&nbsp;</th>
15
+ </tr>
16
+ </thead>
17
+ <tbody>
18
+ <% translations.forEach(translation => { %>
19
+ <tr class="border-b border-mono-25">
20
+ <td class="py-4 pl-2 w-full">
21
+ <div class="flex gap-1 items-center">
22
+ <a href="<%= `/${translation.translationLocale}/${_context.resourceConfig.eventTypePlural}/${translation.id}` %>" class="btn-text">
23
+ <%= _context.locales[translation.translationLocale].name %>
24
+ </a>
25
+ </div>
26
+ </td>
27
+
28
+ <td class="whitespace-nowrap">
29
+ <%- render_partial('./_translation_toolbar.ejs', { translation }) %>
30
+ </td>
31
+ </tr>
32
+ <% }) %>
33
+ </tbody>
34
+ </table>
35
+ <% } %>
36
+ <a href="<%= `/${_context.locale}/${_context.resourceConfig.eventTypePlural}/${parent_id}` %>" class="btn-primary mt-8">
37
+ Go to original
38
+ </a>
39
+ </div>
@@ -12,7 +12,7 @@
12
12
  </form>
13
13
  <% } %>
14
14
 
15
- <a href="#" class="btn-text has-icon">
15
+ <a href="#" class="btn-text hidden">
16
16
  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
17
17
  <path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z" />
18
18
  <path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
@@ -20,4 +20,4 @@
20
20
 
21
21
  Preview
22
22
  </a>
23
- </div>
23
+ </div>
@@ -69,9 +69,7 @@
69
69
  </div>
70
70
  <% } %>
71
71
 
72
- <a href="/remote-login?redirect_to=/admin/<%= _context.resourceConfig.pageType %>-revisions/<%= revision.id %>/builder" target="_blank" class="btn-text has-icon <%= revision.meta && revision.meta.locked ? 'cursor-not-allowed text-gray-400 pointer-events-none' : '' %>">
73
- <%= revision.title %>
74
- </a>
72
+ <%= revision.title %>
75
73
  </div>
76
74
  </td>
77
75
 
@@ -169,4 +167,4 @@
169
167
  </tbody>
170
168
  </table>
171
169
  </div>
172
- </div>
170
+ </div>
@@ -0,0 +1,18 @@
1
+ <div class="actions-toolbar justify-end">
2
+ <a href="/remote-login?redirect_to=/<%= translation.translationLocale %>/admin/<%= _context.resourceConfig.pageType %>-revisions/<%= translation.revisionId %>/builder" target="_blank" class="btn-text has-icon">
3
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
4
+ <path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125" />
5
+ </svg>
6
+
7
+ Update Content
8
+ </a>
9
+
10
+ <a href="<%= `/${translation.translationLocale}/page_revisions/${translation.revisionId}/general/edit` %>" class="btn-text has-icon">
11
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
12
+ <path stroke-linecap="round" stroke-linejoin="round" d="M10.343 3.94c.09-.542.56-.94 1.11-.94h1.093c.55 0 1.02.398 1.11.94l.149.894c.07.424.384.764.78.93.398.164.855.142 1.205-.108l.737-.527a1.125 1.125 0 0 1 1.45.12l.773.774c.39.389.44 1.002.12 1.45l-.527.737c-.25.35-.272.806-.107 1.204.165.397.505.71.93.78l.893.15c.543.09.94.559.94 1.109v1.094c0 .55-.397 1.02-.94 1.11l-.894.149c-.424.07-.764.383-.929.78-.165.398-.143.854.107 1.204l.527.738c.32.447.269 1.06-.12 1.45l-.774.773a1.125 1.125 0 0 1-1.449.12l-.738-.527c-.35-.25-.806-.272-1.203-.107-.398.165-.71.505-.781.929l-.149.894c-.09.542-.56.94-1.11.94h-1.094c-.55 0-1.019-.398-1.11-.94l-.148-.894c-.071-.424-.384-.764-.781-.93-.398-.164-.854-.142-1.204.108l-.738.527c-.447.32-1.06.269-1.45-.12l-.773-.774a1.125 1.125 0 0 1-.12-1.45l.527-.737c.25-.35.272-.806.108-1.204-.165-.397-.506-.71-.93-.78l-.894-.15c-.542-.09-.94-.56-.94-1.109v-1.094c0-.55.398-1.02.94-1.11l.894-.149c.424-.07.765-.383.93-.78.165-.398.143-.854-.108-1.204l-.526-.738a1.125 1.125 0 0 1 .12-1.45l.773-.773a1.125 1.125 0 0 1 1.45-.12l.737.527c.35.25.807.272 1.204.107.397-.165.71-.505.78-.929l.15-.894Z" />
13
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
14
+ </svg>
15
+
16
+ Update Settings
17
+ </a>
18
+ </div>
@@ -12,7 +12,6 @@
12
12
  <tr>
13
13
  <th>Locale</th>
14
14
  <th>&nbsp;</th>
15
- <th>&nbsp;</th>
16
15
  </tr>
17
16
  </thead>
18
17
  <tbody>
@@ -27,23 +26,7 @@
27
26
  </td>
28
27
 
29
28
  <td class="whitespace-nowrap">
30
- <div class="body-3 text-raketa-foreground/50">
31
- <div class="flex items-center gap-1">
32
- <a href="<%= `/${translation.translationLocale}/page_revisions/${translation.revisionId}/general/edit` %>" class="btn-text">
33
- Update Settings
34
- </a>
35
- </div>
36
- </div>
37
- </td>
38
-
39
- <td class="whitespace-nowrap">
40
- <div class="body-3 text-raketa-foreground/50">
41
- <div class="flex items-center gap-1">
42
- <a href="/remote-login?redirect_to=/<%= translation.translationLocale %>/admin/<%= _context.resourceConfig.pageType %>-revisions/<%= translation.revisionId %>/builder" target="_blank" class="btn-text">
43
- Update Content
44
- </a>
45
- </div>
46
- </div>
29
+ <%- render_partial('./_translation_toolbar.ejs', { translation }) %>
47
30
  </td>
48
31
  </tr>
49
32
  <% }) %>
@@ -53,4 +36,4 @@
53
36
  <a href="<%= `/${_context.locale}/${_context.resourceConfig.pageTypePlural}/${parent_id}` %>" class="btn-primary mt-8">
54
37
  Go to original
55
38
  </a>
56
- </div>
39
+ </div>
@@ -1,31 +0,0 @@
1
- <% form_for({ resource }, errors, (f) => { %>
2
- <form action="<%= `/${_context.locale}/${_context.resourceConfig.articleTypePlural}/${blueprint.id}/translations` %>" method="post" class="form">
3
- <input type="hidden" name="target_locale" value="<%= targetLocale %>" />
4
-
5
- <%- f.field('resource.title', { required: true }) %>
6
- <%- f.field('resource.slug', { label: "URL", required: true }) %>
7
- <%- f.field('resource.publishAt', { required: true, type: 'datetime-local' }) %>
8
- <%- f.field('resource.visibility', { as: 'select', required: true, options: visibilityOptions }) %>
9
-
10
- <%- include('../../_shared/_credentials_input.ejs', { f, visibilityFieldId: "f_resource_visibility"}) %>
11
- <%- include('../../_shared/_layout_input.ejs', { f }) %>
12
-
13
- <%- f.field('resource.settings.meta.title', { required: true, label: "Meta title" }) %>
14
- <%- f.field('resource.settings.meta.description', { as: "textarea", required: true, label: "Meta description" }) %>
15
-
16
- <raketa-image-picker name="resource[settings][meta][image]" value="<%= JSON.stringify(resource.settings?.meta?.image || {}) %>" label="Meta image"></raketa-image-picker>
17
-
18
- <h6>Original tags:</h6>
19
- <div><%= blueprint.tags.map((tag) => tag.name).join(", ")%></div>
20
-
21
- <%- f.field('resource.tags', { as: 'checkbox_group', options: tags.map(tag => [tag.id, tag.name])}) %>
22
-
23
- <div class="form-actions">
24
- <div class="btn-toolbar">
25
- <%- f.submit('Save record', { class: 'btn-primary' }) %>
26
-
27
- <a href="<%= `/${_context.locale}/${_context.resourceConfig.articleTypePlural}/${blueprint.id}` %>" class="btn-secondary">Cancel</a>
28
- </div>
29
- </div>
30
- </form>
31
- <% }) %>
@@ -1,33 +0,0 @@
1
- <% form_for({ resource }, errors, (f) => { %>
2
- <form action="<%= `/${_context.locale}/${_context.resourceConfig.eventTypePlural}/${blueprint.id}/translations` %>" method="post" class="form">
3
- <input type="hidden" name="target_locale" value="<%= targetLocale %>" />
4
-
5
- <%- f.field('resource.title', { required: true }) %>
6
- <%- f.field('resource.slug', { label: "URL", required: true }) %>
7
- <%- f.field('resource.publishAt', { required: true, type: 'datetime-local' }) %>
8
- <%- f.field('resource.startsAt', { required: true, type: 'datetime-local' }) %>
9
- <%- f.field('resource.endsAt', { required: true, type: 'datetime-local' }) %>
10
- <%- f.field('resource.visibility', { as: 'select', required: true, options: visibilityOptions }) %>
11
-
12
- <%- include('../../_shared/_credentials_input.ejs', { f, visibilityFieldId: "f_resource_visibility"}) %>
13
- <%- include('../../_shared/_layout_input.ejs', { f }) %>
14
-
15
- <%- f.field('resource.settings.meta.title', { required: true, label: "Meta title" }) %>
16
- <%- f.field('resource.settings.meta.description', { as: "textarea", required: true, label: "Meta description" }) %>
17
-
18
- <raketa-image-picker name="resource[settings][meta][image]" value="<%= JSON.stringify(resource.settings?.meta?.image || {}) %>" label="Meta image"></raketa-image-picker>
19
-
20
- <h6>Original tags:</h6>
21
- <div><%= blueprint.tags.map((tag) => tag.name).join(", ")%></div>
22
-
23
- <%- f.field('resource.tags', { as: 'checkbox_group', options: tags.map(tag => [tag.id, tag.name])}) %>
24
-
25
- <div class="form-actions">
26
- <div class="btn-toolbar">
27
- <%- f.submit('Save record', { class: 'btn-primary' }) %>
28
-
29
- <a href="<%= `/${_context.locale}/${_context.resourceConfig.eventTypePlural}/${blueprint.id}` %>" class="btn-secondary">Cancel</a>
30
- </div>
31
- </div>
32
- </form>
33
- <% }) %>