@raketa-cloud/admin 1.10.3 → 1.10.4
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.
package/package.json
CHANGED
|
@@ -24,26 +24,21 @@ export const buildResourceUrl = (resource, globalConfig) => {
|
|
|
24
24
|
return `/${locale}/${route}/${id}`;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
export const
|
|
28
|
-
|
|
27
|
+
export const unattachedKeys = (task) => {
|
|
28
|
+
const keys = task?.lokaliseWorkflow?.settings?.unattached_keys;
|
|
29
|
+
const values = keys?.names || keys?.ids;
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
const ids = unattachedKeys?.ids;
|
|
31
|
+
if (Array.isArray(values)) return values;
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
return ids.length > 0;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return Boolean(ids);
|
|
33
|
+
return values ? [values] : [];
|
|
38
34
|
};
|
|
39
35
|
|
|
40
|
-
export const
|
|
41
|
-
const unattachedKeys = task?.lokaliseWorkflow?.settings?.unattached_keys;
|
|
42
|
-
const ids = unattachedKeys?.ids;
|
|
36
|
+
export const hasUnattachedKeys = (task) => unattachedKeys(task).length > 0;
|
|
43
37
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
export const unattachedKeyUrl = (task, key) => {
|
|
39
|
+
const keys = task?.lokaliseWorkflow?.settings?.unattached_keys;
|
|
40
|
+
|
|
41
|
+
if (!keys?.names || !keys.url) return null;
|
|
47
42
|
|
|
48
|
-
return
|
|
43
|
+
return `${keys.url}${encodeURIComponent(key)}`;
|
|
49
44
|
};
|
|
@@ -2,7 +2,8 @@ import {
|
|
|
2
2
|
workflowsMap,
|
|
3
3
|
buildResourceUrl,
|
|
4
4
|
hasUnattachedKeys,
|
|
5
|
-
|
|
5
|
+
unattachedKeys,
|
|
6
|
+
unattachedKeyUrl,
|
|
6
7
|
} from "../../helpers/content_tasks_helper";
|
|
7
8
|
|
|
8
9
|
describe("content_tasks_helper", () => {
|
|
@@ -114,46 +115,89 @@ describe("content_tasks_helper", () => {
|
|
|
114
115
|
).toBe(false);
|
|
115
116
|
});
|
|
116
117
|
|
|
117
|
-
test("returns true when task
|
|
118
|
+
test("returns true when the task has unattached key ids or names", () => {
|
|
118
119
|
expect(
|
|
119
120
|
hasUnattachedKeys({
|
|
120
|
-
completedAt: null,
|
|
121
|
-
failedAt: null,
|
|
122
121
|
lokaliseWorkflow: {
|
|
123
122
|
settings: { unattached_keys: { ids: [101, 102] } },
|
|
124
123
|
},
|
|
125
124
|
}),
|
|
126
125
|
).toBe(true);
|
|
126
|
+
expect(
|
|
127
|
+
hasUnattachedKeys({
|
|
128
|
+
lokaliseWorkflow: {
|
|
129
|
+
settings: { unattached_keys: { names: ["key_a"] } },
|
|
130
|
+
},
|
|
131
|
+
}),
|
|
132
|
+
).toBe(true);
|
|
127
133
|
});
|
|
128
134
|
});
|
|
129
135
|
|
|
130
|
-
describe("
|
|
131
|
-
test("returns empty
|
|
132
|
-
expect(
|
|
133
|
-
expect(
|
|
134
|
-
expect(
|
|
135
|
-
unattachedKeyIds({
|
|
136
|
-
lokaliseWorkflow: { settings: { unattached_keys: {} } },
|
|
137
|
-
}),
|
|
138
|
-
).toBe("");
|
|
136
|
+
describe("unattachedKeys", () => {
|
|
137
|
+
test("returns an empty array when no unattached keys exist", () => {
|
|
138
|
+
expect(unattachedKeys(null)).toEqual([]);
|
|
139
|
+
expect(unattachedKeys({})).toEqual([]);
|
|
139
140
|
});
|
|
140
141
|
|
|
141
|
-
test("
|
|
142
|
+
test("prefers names and falls back to ids", () => {
|
|
142
143
|
expect(
|
|
143
|
-
|
|
144
|
+
unattachedKeys({
|
|
144
145
|
lokaliseWorkflow: {
|
|
145
|
-
settings: {
|
|
146
|
+
settings: {
|
|
147
|
+
unattached_keys: { names: ["key_a", "key_b"], ids: [101, 102] },
|
|
148
|
+
},
|
|
146
149
|
},
|
|
147
150
|
}),
|
|
148
|
-
).
|
|
149
|
-
|
|
151
|
+
).toEqual(["key_a", "key_b"]);
|
|
150
152
|
expect(
|
|
151
|
-
|
|
153
|
+
unattachedKeys({
|
|
152
154
|
lokaliseWorkflow: {
|
|
153
|
-
settings: { unattached_keys: { ids: [
|
|
155
|
+
settings: { unattached_keys: { ids: [101, 102] } },
|
|
154
156
|
},
|
|
155
157
|
}),
|
|
156
|
-
).
|
|
158
|
+
).toEqual([101, 102]);
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
describe("unattachedKeyUrl", () => {
|
|
163
|
+
const task = {
|
|
164
|
+
lokaliseWorkflow: {
|
|
165
|
+
settings: {
|
|
166
|
+
unattached_keys: {
|
|
167
|
+
names: ["key one"],
|
|
168
|
+
url: "https://app.lokalise.com/project/123/?search=",
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
test("builds a Lokalise URL for a key name", () => {
|
|
175
|
+
expect(unattachedKeyUrl(task, "key one")).toBe(
|
|
176
|
+
"https://app.lokalise.com/project/123/?search=key%20one",
|
|
177
|
+
);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test("returns null for legacy ids or when the URL is missing", () => {
|
|
181
|
+
expect(
|
|
182
|
+
unattachedKeyUrl(
|
|
183
|
+
{
|
|
184
|
+
lokaliseWorkflow: {
|
|
185
|
+
settings: { unattached_keys: { ids: [101] } },
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
101,
|
|
189
|
+
),
|
|
190
|
+
).toBeNull();
|
|
191
|
+
expect(
|
|
192
|
+
unattachedKeyUrl(
|
|
193
|
+
{
|
|
194
|
+
lokaliseWorkflow: {
|
|
195
|
+
settings: { unattached_keys: { names: ["key_a"] } },
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
"key_a",
|
|
199
|
+
),
|
|
200
|
+
).toBeNull();
|
|
157
201
|
});
|
|
158
202
|
});
|
|
159
203
|
});
|
|
@@ -66,7 +66,15 @@
|
|
|
66
66
|
|
|
67
67
|
<% if (isMarked) { %>
|
|
68
68
|
<div class="body-3 text-raketa-foreground/50">
|
|
69
|
-
|
|
69
|
+
<% content_tasks.unattachedKeys(task).forEach((key, index) => { %>
|
|
70
|
+
<% if (index > 0) { %>, <% } %>
|
|
71
|
+
<% const keyUrl = content_tasks.unattachedKeyUrl(task, key) %>
|
|
72
|
+
<% if (keyUrl) { %>
|
|
73
|
+
<a href="<%= keyUrl %>" target="_blank" class="btn-text"><%= key %></a>
|
|
74
|
+
<% } else { %>
|
|
75
|
+
<%= key %>
|
|
76
|
+
<% } %>
|
|
77
|
+
<% }) %>
|
|
70
78
|
</div>
|
|
71
79
|
<% } %>
|
|
72
80
|
</td>
|