@raketa-cloud/admin 1.8.21 → 1.8.23

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.
@@ -2359,10 +2359,6 @@ select {
2359
2359
  padding-top: 0.25rem;
2360
2360
  }
2361
2361
 
2362
- .pt-2 {
2363
- padding-top: 0.5rem;
2364
- }
2365
-
2366
2362
  .pt-6 {
2367
2363
  padding-top: 1.5rem;
2368
2364
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raketa-cloud/admin",
3
- "version": "1.8.21",
3
+ "version": "1.8.23",
4
4
  "main": "src/index.js",
5
5
  "files": [
6
6
  "src/",
@@ -107,6 +107,7 @@ const create = async (ctx) => {
107
107
  resource: {
108
108
  translations: blueprint.translations || {},
109
109
  languages: [],
110
+ workflow: ctx.resourceParams?.resource?.workflow,
110
111
  },
111
112
  blueprint,
112
113
  targetLocale: originalLocale,
@@ -167,6 +168,7 @@ const create = async (ctx) => {
167
168
  ...resource,
168
169
  translations: blueprint.translations || {},
169
170
  languages: formLanguages,
171
+ workflow: workflow,
170
172
  },
171
173
  blueprint,
172
174
  targetLocale: originalLocale,
@@ -211,6 +213,7 @@ const create = async (ctx) => {
211
213
  ...resource,
212
214
  translations: blueprint.translations || {},
213
215
  languages: formLanguages,
216
+ workflow: workflow,
214
217
  },
215
218
  blueprint,
216
219
  targetLocale: locale,
@@ -1,18 +1,14 @@
1
- <div class="flex justify-between w-full pb-8">
2
- <div class="flex flex-col">
3
- <h1 class="flex items-center gap-2 heading-1">
4
- <%= resource.title %>
5
- </h1>
6
- <a href="<%= _context.remoteConfig.resourceUrl(resource, _context.resourceConfig.resourceType, _context.locale) %>" target="_blank" class="btn-text"><%= _context.remoteConfig.resourceUrl(resource, _context.resourceConfig.resourceType, _context.locale) %></a>
7
- </div>
1
+ <div class="flex flex-col pb-4">
2
+ <h1 class="heading-1 flex items-center gap-2">
3
+ <%= resource.title %>
8
4
 
9
- <%
10
- const withTranslations = locals.withTranslations && locals.render_partial;
11
- %>
12
-
13
- <% if (withTranslations) { %>
14
- <div class="pt-2">
15
- <%- render_partial('./_shared/_translations_strip.ejs') %>
16
- </div>
17
- <% } %>
5
+ <% if (resource.visibility !== "private") { %>
6
+ <a href="<%= _context.remoteConfig.resourceUrl(resource, _context.resourceConfig.resourceType, _context.locale) %>" target="_blank">
7
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6 text-raketa-primary">
8
+ <path stroke-linecap="round" stroke-linejoin="round" d="M13.5 6H5.25A2.25 2.25 0 0 0 3 8.25v10.5A2.25 2.25 0 0 0 5.25 21h10.5A2.25 2.25 0 0 0 18 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25" />
9
+ </svg>
10
+ </a>
11
+ <% } %>
12
+ </h1>
13
+ <a href="<%= _context.remoteConfig.resourceUrl(resource, _context.resourceConfig.resourceType, _context.locale) %>" target="_blank" class="btn-text"><%= _context.remoteConfig.resourceUrl(resource, _context.resourceConfig.resourceType, _context.locale) %></a>
18
14
  </div>
@@ -5,17 +5,21 @@
5
5
  !resource.activeContentTask.completedAt &&
6
6
  !resource.activeContentTask.failedAt;
7
7
  %>
8
- <% if (_context.query?.revisions_count_error) { %>
9
- <div class="text-red-600">Cannot open a new revision. Current limit is <%= _context.maxOpenRevisions %>. </div>
10
- <% } %>
11
-
12
- <% if (hasActiveContentTask) { %>
13
- <div class="mt-2 text-orange-700 dark:text-orange-300">Actions are disabled while a translation task is in progress.</div>
14
- <% } %>
15
-
16
8
  <div class="actions-toolbar">
9
+ <form method="POST" action="<%= `/${_context.locale}/${_context.resourceConfig.resourceTypePlural}/${resource.id}/${_context.resourceConfig.resourceType}_revisions` %>" class="inline-block">
10
+ <% if (resource.revisionsCount >= _context?.maxOpenRevisions || hasActiveContentTask) { %>
11
+ <button type="submit" class="btn-primary" disabled style="opacity: 50%;">
12
+ Start revision
13
+ </button>
14
+ <% } else {%>
15
+ <button type="submit" class="btn-primary">
16
+ Start revision
17
+ </button>
18
+ <% } %>
19
+ </form>
20
+
17
21
  <% if (hasActiveContentTask) { %>
18
- <button type="button" class="btn-secondary has-icon" disabled style="opacity: 50%; cursor: not-allowed;">
22
+ <button type="button" class="btn-text has-icon" disabled style="opacity: 50%; cursor: not-allowed;">
19
23
  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
20
24
  <path stroke-linecap="round" stroke-linejoin="round" d="M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244" />
21
25
  </svg>
@@ -23,7 +27,7 @@
23
27
  Change URL
24
28
  </button>
25
29
  <% } else { %>
26
- <a href="<%= `/${_context.locale}/${_context.resourceConfig.resourceTypePlural}/${resource.id}/urls/new` %>" class="btn-secondary has-icon">
30
+ <a href="<%= `/${_context.locale}/${_context.resourceConfig.resourceTypePlural}/${resource.id}/urls/new` %>" class="btn-text has-icon">
27
31
  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
28
32
  <path stroke-linecap="round" stroke-linejoin="round" d="M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244" />
29
33
  </svg>
@@ -33,7 +37,7 @@
33
37
  <% } %>
34
38
 
35
39
  <form action="<%= `/${_context.locale}/${_context.resourceConfig.resourceTypePlural}/${resource.id}/clones` %>" method="post" class="inline-block">
36
- <button type="submit" class="btn-secondary has-icon" <%= hasActiveContentTask ? 'disabled style="opacity: 50%;"' : '' %>>
40
+ <button type="submit" class="btn-text has-icon" <%= hasActiveContentTask ? 'disabled style="opacity: 50%;"' : '' %>>
37
41
  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
38
42
  <path stroke-linecap="round" stroke-linejoin="round" d="M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 0 1-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 0 1 1.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 0 0-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 0 1-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H9.75" />
39
43
  </svg>
@@ -61,5 +65,11 @@
61
65
  <% } %>
62
66
  </div>
63
67
 
68
+ <% if (_context.query?.revisions_count_error) { %>
69
+ <div class="text-red-600">Cannot open a new revision. Current limit is <%= _context.maxOpenRevisions %>. </div>
70
+ <% } %>
64
71
 
72
+ <% if (hasActiveContentTask) { %>
73
+ <div class="text-orange-700 mt-2 dark:text-orange-300">Actions are disabled while a translation task is in progress.</div>
74
+ <% } %>
65
75
  </div>
@@ -1,4 +1,4 @@
1
- <div class="flex flex-wrap items-center gap-1">
1
+ <div class="flex flex-wrap items-center gap-1 pb-8">
2
2
  <%
3
3
  const availableLocales = Object.keys(_context.locales);
4
4
  const totalPossibleTranslations = availableLocales.length - 1;
@@ -1,8 +1,11 @@
1
1
  <div class="page-wrapper">
2
2
  <div class="page-title">
3
- <%- render_partial('./_shared/_title.ejs', { withTranslations: true, render_partial }) %>
3
+ <%- render_partial('./_shared/_title.ejs') %>
4
+ <%- render_partial('./_shared/_toolbar.ejs') %>
4
5
  </div>
5
6
 
7
+ <%- render_partial('./_shared/_translations_strip.ejs') %>
8
+
6
9
  <%
7
10
  const openedRevisions = []
8
11
  const scheduledRevisions = []
@@ -40,23 +43,6 @@
40
43
  resource.revisionsCount >= _context?.maxOpenRevisions;
41
44
  const canStartRevision = !atRevisionLimit && !hasActiveContentTask;
42
45
  %>
43
-
44
- <div class="pb-4">
45
- <% if (_context.query?.revisions_count_error) { %>
46
- <div class="text-red-600">Cannot open a new revision. Current limit is <%= _context.maxOpenRevisions %>. </div>
47
- <% } %>
48
-
49
- <% if (hasActiveContentTask) { %>
50
- <div class="mb-2 text-orange-700 dark:text-orange-300">Actions are disabled while a translation task is in progress.</div>
51
- <% } %>
52
-
53
- <form method="POST" action="<%= `/${_context.locale}/${_context.resourceConfig.resourceTypePlural}/${resource.id}/${_context.resourceConfig.resourceType}_revisions` %>" class="inline-block">
54
- <button type="submit" class="btn-primary" <%- canStartRevision ? '' : 'disabled style="opacity: 50%;"' %> <% if (atRevisionLimit && !hasActiveContentTask) { %> title="Open revision limit reached (<%= _context.maxOpenRevisions %>)" <% } %>>
55
- Start revision
56
- </button>
57
- </form>
58
- </div>
59
-
60
46
  <% if (openedRevisions.length) { %>
61
47
  <table class="data-grid alt">
62
48
  <thead>
@@ -173,20 +159,6 @@
173
159
  Full page history
174
160
  </a>
175
161
  </div>
176
-
177
-
178
- <div class="pb-8">
179
-
180
- <h4 class="flex items-center gap-2 pb-4 heading-3">
181
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="size-5 text-raketa-primary">
182
- <path fill-rule="evenodd" clip-rule="evenodd" d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 0 1 1.37.49l1.296 2.247a1.125 1.125 0 0 1-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 0 1 0 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 0 1-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 0 1-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.94-1.11.94h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 0 1-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 0 1-1.369-.49l-1.297-2.247a1.125 1.125 0 0 1 .26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 0 1 0-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.125 1.125 0 0 1-.26-1.43l1.297-2.247a1.125 1.125 0 0 1 1.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28ZM15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
183
- </svg>
184
-
185
- Actions
186
- </h4>
187
-
188
- <%- render_partial('./_shared/_toolbar.ejs') %>
189
- </div>
190
162
  </div>
191
163
 
192
164
  <% if (reports.path) { %>
@@ -36,15 +36,15 @@
36
36
  <select name="resource[workflow][type]" id="workflow">
37
37
  <option value="">Default (no workflow)</option>
38
38
 
39
- <option value="LOKALISE_TO_AI_RT_HUM" <%= resource.workflow === 'LOKALISE_TO_AI_RT_HUM' ? 'selected' : '' %>>
39
+ <option value="LOKALISE_TO_AI_RT_HUM" <%= resource.workflow?.type === 'LOKALISE_TO_AI_RT_HUM' ? 'selected' : '' %>>
40
40
  <%= content_tasks.workflowsMap("LOKALISE_TO_AI_RT_HUM".toLowerCase()) %>
41
41
  </option>
42
42
 
43
- <option value="LOKALISE_TT_HUM" <%= resource.workflow === 'LOKALISE_TT_HUM' ? 'selected' : '' %>>
43
+ <option value="LOKALISE_TT_HUM" <%= resource.workflow?.type === 'LOKALISE_TT_HUM' ? 'selected' : '' %>>
44
44
  <%= content_tasks.workflowsMap("LOKALISE_TT_HUM".toLowerCase()) %>
45
45
  </option>
46
46
 
47
- <option value="LOKALISE_TT_AI" <%= resource.workflow === 'LOKALISE_TT_AI' ? 'selected' : '' %>>
47
+ <option value="LOKALISE_TT_AI" <%= resource.workflow?.type === 'LOKALISE_TT_AI' ? 'selected' : '' %>>
48
48
  <%= content_tasks.workflowsMap("LOKALISE_TT_AI".toLowerCase()) %>
49
49
  </option>
50
50
  </select>
@@ -55,49 +55,85 @@
55
55
 
56
56
  <div class="mb-4" id="due_date_wrapper">
57
57
  <label for="due_date" class="font-semibold hover:cursor-pointer body-3">Due date (UTC)</label>
58
- <input type="datetime-local" name="resource[workflow][due_date]" id="due_date" />
58
+ <input type="datetime-local" name="resource[workflow][due_date]" id="due_date" value="<%= resource.workflow?.due_date || "" %>" />
59
+
59
60
  <p class="text-sm text-raketa-foreground/50 mt-1">
60
- Select a workflow for the translation process. Lokalise workflow initiates a translation task for external translation.
61
+ Select a due date for the translation. Weekends are not a valid choice.
61
62
  </p>
62
63
  </div>
63
64
 
64
65
  <script>
65
- (function () {
66
- const workflowSelect = document.getElementById("workflow");
67
- const dueDateWrapper = document.getElementById("due_date_wrapper");
68
- const dueDateInput = document.getElementById("due_date");
69
-
70
- function getTwoDaysFromNowString() {
71
- const date = new Date();
72
- date.setDate(date.getDate() + 2);
73
- const year = date.getFullYear();
74
- const month = String(date.getMonth() + 1).padStart(2, "0");
75
- const day = String(date.getDate()).padStart(2, "0");
76
- const hours = String(date.getHours()).padStart(2, "0");
77
- const minutes = String(date.getMinutes()).padStart(2, "0");
78
- return `${year}-${month}-${day}T${hours}:${minutes}`;
79
- }
80
-
81
- function toggleDueDate() {
82
- if (!workflowSelect || !dueDateWrapper || !dueDateInput) return;
83
- const minDate = getTwoDaysFromNowString();
84
- dueDateInput.min = minDate;
85
-
86
- const isDefault = !workflowSelect.value;
87
- dueDateWrapper.style.display = isDefault ? "none" : "block";
88
-
89
- if (isDefault) {
90
- dueDateInput.value = "";
91
- } else if (!dueDateInput.value) {
92
- dueDateInput.value = minDate;
66
+ window.addEventListener("load", (_event) => {
67
+ (function () {
68
+ const workflowSelect = document.getElementById("workflow");
69
+ const dueDateWrapper = document.getElementById("due_date_wrapper");
70
+ const dueDateInput = document.getElementById("due_date");
71
+
72
+ function validateInputValue(dInput) {
73
+ if (dInput.value === "") {
74
+ dInput.setCustomValidity('');
75
+ return;
76
+ }
77
+
78
+ const selectedDate = new Date(dInput.value);
79
+ const day = selectedDate.getDay();
80
+
81
+ if (day === 0 || day === 6) {
82
+ dInput.setCustomValidity('Weekends are not allowed. Please select a weekday.')
83
+ selectedDate.value = '';
84
+ } else {
85
+ dInput.setCustomValidity('');
86
+ }
93
87
  }
94
- }
95
88
 
96
- if (workflowSelect) {
97
- workflowSelect.addEventListener("change", toggleDueDate);
98
- toggleDueDate();
99
- }
100
- })();
89
+ dueDateInput.addEventListener('change', function(e) {
90
+ validateInputValue(dueDateInput);
91
+ });
92
+
93
+ function getTwoDaysFromNowString() {
94
+ const date = new Date();
95
+
96
+
97
+ date.setDate(date.getDate() + 2);
98
+
99
+ // Skip weekends.
100
+ while(date.getDay() === 0 || date.getDay() === 6) {
101
+ date.setDate(date.getDate() + 1);
102
+ }
103
+
104
+ const year = date.getFullYear();
105
+ const month = String(date.getMonth() + 1).padStart(2, "0");
106
+ const day = String(date.getDate()).padStart(2, "0");
107
+ const hours = String(date.getHours()).padStart(2, "0");
108
+ const minutes = String(date.getMinutes()).padStart(2, "0");
109
+ return `${year}-${month}-${day}T${hours}:${minutes}`;
110
+ }
111
+
112
+ function toggleDueDate() {
113
+ if (!workflowSelect || !dueDateWrapper || !dueDateInput) return;
114
+ const minDate = getTwoDaysFromNowString();
115
+ dueDateInput.min = minDate;
116
+
117
+ const isDefault = !workflowSelect.value;
118
+ dueDateWrapper.style.display = isDefault ? "none" : "block";
119
+
120
+ if (isDefault) {
121
+ dueDateInput.value = "";
122
+ } else if (!dueDateInput.value) {
123
+ dueDateInput.value = minDate;
124
+ }
125
+
126
+ // Trigger the on change so hints are visible together with the validation.
127
+ const changeEvent = new Event('change', { bubbles: true });
128
+ dueDateInput.dispatchEvent(changeEvent);
129
+ }
130
+
131
+ if (workflowSelect) {
132
+ workflowSelect.addEventListener("change", toggleDueDate);
133
+ toggleDueDate();
134
+ }
135
+ })();
136
+ })
101
137
  </script>
102
138
  <% } %>
103
139