@translationstudio/translationstudio-strapi-extension 2.1.0 → 4.0.0
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/README.md +1 -1
- package/dist/Types.d.ts +36 -0
- package/dist/_chunks/App-BR-y9Q87.js +331 -0
- package/dist/_chunks/App-Cc3EklWX.mjs +331 -0
- package/dist/_chunks/HistoryPage-BG_RchOk.js +1057 -0
- package/dist/_chunks/HistoryPage-CSMW8AED.mjs +1057 -0
- package/dist/_chunks/index-B9kFLfY3.js +834 -0
- package/dist/_chunks/index-ChM8Lw4L.mjs +835 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +2 -2
- package/dist/admin/src/components/BulkTranslationMenu.d.ts +3 -0
- package/dist/admin/src/components/BulkTranslationPanel.d.ts +3 -0
- package/dist/admin/src/components/EntryHistory.d.ts +3 -0
- package/dist/admin/src/components/HistoryIcon.d.ts +2 -0
- package/dist/admin/src/components/HistoryMenu.d.ts +2 -0
- package/dist/admin/src/components/LoadingSpinner.d.ts +4 -0
- package/dist/admin/src/components/SettingsIcon.d.ts +2 -0
- package/dist/admin/src/components/TranslationstudioLogo.d.ts +2 -0
- package/dist/admin/src/components/utils/alertUtils.d.ts +13 -0
- package/dist/admin/src/components/utils/dateUtils.d.ts +1 -0
- package/dist/admin/src/components/utils/emailUtils.d.ts +2 -0
- package/dist/admin/src/components/utils/entryUtils.d.ts +2 -0
- package/dist/admin/src/components/utils/filterAndTransformContentTypes.d.ts +2 -0
- package/dist/admin/src/components/utils/formatDate.d.ts +1 -0
- package/dist/admin/src/components/utils/getEntryHelper.d.ts +3 -0
- package/dist/admin/src/components/utils/handleHistoryResponse.d.ts +5 -0
- package/dist/admin/src/components/utils/historyDataUtils.d.ts +13 -0
- package/dist/admin/src/components/utils/historyStatusUtils.d.ts +7 -0
- package/dist/admin/src/components/utils/searchUtils.d.ts +2 -0
- package/dist/admin/src/components/utils/sortUtils.d.ts +9 -0
- package/dist/admin/src/components/utils/statusHelper.d.ts +6 -0
- package/dist/admin/src/components/utils/theme.d.ts +15 -0
- package/dist/admin/src/components/utils/translationUtils.d.ts +5 -0
- package/dist/admin/src/components/utils/useDebounce.d.ts +1 -0
- package/dist/admin/src/pages/HistoryPage.d.ts +2 -0
- package/dist/server/index.js +50 -29
- package/dist/server/index.mjs +50 -29
- package/dist/server/src/controllers/controller.d.ts +1 -1
- package/dist/server/src/controllers/index.d.ts +1 -1
- package/dist/server/src/index.d.ts +2 -4
- package/dist/server/src/services/functions/importData/transformFieldsToData.d.ts +1 -1
- package/dist/server/src/services/index.d.ts +1 -3
- package/dist/server/src/services/service.d.ts +1 -3
- package/package.json +23 -21
- package/dist/_chunks/App-Hb9oaG2M.mjs +0 -337
- package/dist/_chunks/App-v67y1hUs.js +0 -337
- package/dist/_chunks/index-BgsAgrFL.mjs +0 -345
- package/dist/_chunks/index-ehPijnQ-.js +0 -344
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { getFetchClient, Page } from "@strapi/strapi/admin";
|
|
3
|
-
import { Routes, Route } from "react-router-dom";
|
|
4
|
-
import { Main, Box, Alert, Grid, Typography, TextInput, Button, Switch } from "@strapi/design-system";
|
|
5
|
-
import { useState, useEffect } from "react";
|
|
6
|
-
import { ArrowClockwise, Play } from "@strapi/icons";
|
|
7
|
-
import { T as TSlogoFarbig, a as TSlogoWhite } from "./index-BgsAgrFL.mjs";
|
|
8
|
-
async function loadLicense(fnGet) {
|
|
9
|
-
try {
|
|
10
|
-
const response = await fnGet("/translationstudio/getLicense");
|
|
11
|
-
if (typeof response.data?.license === "string")
|
|
12
|
-
return response.data.license;
|
|
13
|
-
} catch (err) {
|
|
14
|
-
console.error(err);
|
|
15
|
-
}
|
|
16
|
-
return "";
|
|
17
|
-
}
|
|
18
|
-
async function loadDevUrl(fnGet) {
|
|
19
|
-
try {
|
|
20
|
-
const response = await fnGet("/translationstudio/devurl");
|
|
21
|
-
if (typeof response.data?.url === "string")
|
|
22
|
-
return response.data.url;
|
|
23
|
-
} catch (err) {
|
|
24
|
-
console.error(err);
|
|
25
|
-
}
|
|
26
|
-
return "";
|
|
27
|
-
}
|
|
28
|
-
async function updateDevlUrl(fnPost, url) {
|
|
29
|
-
try {
|
|
30
|
-
const response = await fnPost("/translationstudio/devurl", { url });
|
|
31
|
-
if (typeof response.data?.success === "boolean")
|
|
32
|
-
return response.data.success;
|
|
33
|
-
} catch (err) {
|
|
34
|
-
console.error(err);
|
|
35
|
-
}
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
const TextareaStyle = {
|
|
39
|
-
color: "grey",
|
|
40
|
-
width: "100%",
|
|
41
|
-
display: "block",
|
|
42
|
-
backgroundColor: "#f6f6f6",
|
|
43
|
-
cursor: "default"
|
|
44
|
-
};
|
|
45
|
-
const BUttonStyle = { backgroundColor: "#e94642", border: "none", paddingTop: "0.6em", paddingBottom: "0.6em" };
|
|
46
|
-
const SettingsPage = () => {
|
|
47
|
-
const [licenseValue, setLicenseValue] = useState("");
|
|
48
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
49
|
-
const [tokenValue, setTokenValue] = useState("");
|
|
50
|
-
const [isLoadingToken, setIsLoadingToken] = useState(false);
|
|
51
|
-
const [showDevOptions, setShowDevOptions] = useState(false);
|
|
52
|
-
const [showAlert, setShowAlert] = useState(false);
|
|
53
|
-
const [alertType, setAlertType] = useState("success");
|
|
54
|
-
const [alertMessage, setAlertMessage] = useState("");
|
|
55
|
-
const [devUrl, setDevUrl] = useState("");
|
|
56
|
-
const { get, post } = getFetchClient();
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
const getLicense = async () => {
|
|
59
|
-
setIsLoading(true);
|
|
60
|
-
const license = await loadLicense(get);
|
|
61
|
-
if (license)
|
|
62
|
-
setLicenseValue(license);
|
|
63
|
-
const dUrl = await loadDevUrl(get);
|
|
64
|
-
if (dUrl) {
|
|
65
|
-
console.log(dUrl);
|
|
66
|
-
setDevUrl(dUrl);
|
|
67
|
-
setShowDevOptions(true);
|
|
68
|
-
}
|
|
69
|
-
setIsLoading(false);
|
|
70
|
-
};
|
|
71
|
-
getLicense();
|
|
72
|
-
}, [setLicenseValue, setDevUrl, setIsLoading, setShowDevOptions]);
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
const fetchToken = async () => {
|
|
75
|
-
setIsLoadingToken(true);
|
|
76
|
-
try {
|
|
77
|
-
const response = await get("/translationstudio/getToken");
|
|
78
|
-
if (response.data.token) {
|
|
79
|
-
setTokenValue(response.data.token);
|
|
80
|
-
} else {
|
|
81
|
-
setTokenValue("");
|
|
82
|
-
}
|
|
83
|
-
} catch (err) {
|
|
84
|
-
console.error(err);
|
|
85
|
-
} finally {
|
|
86
|
-
setIsLoadingToken(false);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
fetchToken();
|
|
90
|
-
}, []);
|
|
91
|
-
const handleLicenseChange = (e) => {
|
|
92
|
-
setLicenseValue(e.target.value.trim());
|
|
93
|
-
};
|
|
94
|
-
const handleUpdateUrl = async function() {
|
|
95
|
-
setIsLoading(true);
|
|
96
|
-
updateDevlUrl(post, devUrl).then(() => {
|
|
97
|
-
if (devUrl === "")
|
|
98
|
-
setShowDevOptions(false);
|
|
99
|
-
}).finally(() => setIsLoading(false));
|
|
100
|
-
};
|
|
101
|
-
const handleSaveLicense = async () => {
|
|
102
|
-
try {
|
|
103
|
-
const response = await post("/translationstudio/setLicense", { license: licenseValue });
|
|
104
|
-
if (response) {
|
|
105
|
-
displayAlert("success");
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
} catch (err) {
|
|
109
|
-
console.error(err);
|
|
110
|
-
}
|
|
111
|
-
displayAlert("danger");
|
|
112
|
-
};
|
|
113
|
-
const displayAlert = (variant) => {
|
|
114
|
-
let message = variant === "success" ? "License saved" : "Error saving license";
|
|
115
|
-
setAlertType(variant);
|
|
116
|
-
setAlertMessage(message);
|
|
117
|
-
setShowAlert(true);
|
|
118
|
-
setTimeout(() => {
|
|
119
|
-
setShowAlert(false);
|
|
120
|
-
}, 5e3);
|
|
121
|
-
};
|
|
122
|
-
const handleGenerateToken = async () => {
|
|
123
|
-
setIsLoadingToken(true);
|
|
124
|
-
try {
|
|
125
|
-
const response = await post("/translationstudio/generateToken");
|
|
126
|
-
if (response.data?.token) {
|
|
127
|
-
setTokenValue(response.data.token);
|
|
128
|
-
}
|
|
129
|
-
} catch (err) {
|
|
130
|
-
console.error(err);
|
|
131
|
-
} finally {
|
|
132
|
-
setIsLoadingToken(false);
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
const onChangeDevOptions = function(val) {
|
|
136
|
-
if (val)
|
|
137
|
-
setShowDevOptions(val);
|
|
138
|
-
else
|
|
139
|
-
updateDevlUrl(post, "").finally(() => setShowDevOptions(val));
|
|
140
|
-
};
|
|
141
|
-
return /* @__PURE__ */ jsxs(Main, { children: [
|
|
142
|
-
showAlert && /* @__PURE__ */ jsx(
|
|
143
|
-
Box,
|
|
144
|
-
{
|
|
145
|
-
style: {
|
|
146
|
-
position: "fixed",
|
|
147
|
-
top: "10%",
|
|
148
|
-
left: "50%",
|
|
149
|
-
transform: "translate(-50%, -50%)",
|
|
150
|
-
zIndex: 10,
|
|
151
|
-
minWidth: "400px",
|
|
152
|
-
maxWidth: "90%"
|
|
153
|
-
},
|
|
154
|
-
children: /* @__PURE__ */ jsx(Alert, { closeLabel: "Close", variant: alertType, onClose: () => setShowAlert(false), children: alertMessage })
|
|
155
|
-
}
|
|
156
|
-
),
|
|
157
|
-
/* @__PURE__ */ jsx(
|
|
158
|
-
Box,
|
|
159
|
-
{
|
|
160
|
-
padding: 10,
|
|
161
|
-
style: {
|
|
162
|
-
minHeight: "90vh",
|
|
163
|
-
marginTop: "5vh"
|
|
164
|
-
},
|
|
165
|
-
children: /* @__PURE__ */ jsxs(Grid.Root, { children: [
|
|
166
|
-
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, children: /* @__PURE__ */ jsx(Box, { style: { textAlign: "right", width: "100%" }, children: /* @__PURE__ */ jsxs("picture", { style: {
|
|
167
|
-
width: "300px",
|
|
168
|
-
height: "auto",
|
|
169
|
-
display: "inline-block"
|
|
170
|
-
}, children: [
|
|
171
|
-
/* @__PURE__ */ jsx("source", { srcSet: TSlogoFarbig, media: "(prefers-color-scheme: light)" }),
|
|
172
|
-
/* @__PURE__ */ jsx("source", { srcSet: TSlogoWhite, media: "(prefers-color-scheme: dark)" }),
|
|
173
|
-
/* @__PURE__ */ jsx("img", { src: TSlogoFarbig })
|
|
174
|
-
] }) }) }),
|
|
175
|
-
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, style: { paddingTop: "2em" }, children: /* @__PURE__ */ jsx(Typography, { variant: "beta", style: { width: "100%" }, children: "translationstudio License" }) }),
|
|
176
|
-
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, style: { paddingBottom: "1em" }, children: /* @__PURE__ */ jsxs(Typography, { variant: "charlie", style: { width: "100%" }, children: [
|
|
177
|
-
"You can create or revoke a license at",
|
|
178
|
-
" ",
|
|
179
|
-
/* @__PURE__ */ jsx(
|
|
180
|
-
"a",
|
|
181
|
-
{
|
|
182
|
-
href: "https://account.translationstudio.tech/",
|
|
183
|
-
target: "_blank",
|
|
184
|
-
rel: "noopener noreferrer",
|
|
185
|
-
style: { textDecoration: "none", color: "#e94642" },
|
|
186
|
-
children: "account.translationstudio.tech"
|
|
187
|
-
}
|
|
188
|
-
)
|
|
189
|
-
] }) }),
|
|
190
|
-
/* @__PURE__ */ jsx(Grid.Item, { xs: 10, children: /* @__PURE__ */ jsx(Box, { style: { width: "100%" }, children: /* @__PURE__ */ jsx(
|
|
191
|
-
TextInput,
|
|
192
|
-
{
|
|
193
|
-
name: "jwt-token",
|
|
194
|
-
label: "JWT Token",
|
|
195
|
-
placeholder: "Paste your Strapi translationstudio license into this field and click save to apply it to this project",
|
|
196
|
-
"aria-label": "Strapi license Input",
|
|
197
|
-
value: licenseValue,
|
|
198
|
-
onChange: handleLicenseChange,
|
|
199
|
-
disabled: isLoading,
|
|
200
|
-
style: TextareaStyle
|
|
201
|
-
}
|
|
202
|
-
) }) }),
|
|
203
|
-
/* @__PURE__ */ jsx(Grid.Item, { xs: 2, children: /* @__PURE__ */ jsx(
|
|
204
|
-
Button,
|
|
205
|
-
{
|
|
206
|
-
onClick: handleSaveLicense,
|
|
207
|
-
disabled: isLoading,
|
|
208
|
-
style: BUttonStyle,
|
|
209
|
-
size: "L",
|
|
210
|
-
startIcon: /* @__PURE__ */ jsx(
|
|
211
|
-
"svg",
|
|
212
|
-
{
|
|
213
|
-
width: "20",
|
|
214
|
-
height: "20",
|
|
215
|
-
viewBox: "0 0 24 24",
|
|
216
|
-
fill: "none",
|
|
217
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
218
|
-
children: /* @__PURE__ */ jsx(
|
|
219
|
-
"path",
|
|
220
|
-
{
|
|
221
|
-
d: "M21,20V8.414a1,1,0,0,0-.293-.707L16.293,3.293A1,1,0,0,0,15.586,3H4A1,1,0,0,0,3,4V20a1,1,0,0,0,1,1H20A1,1,0,0,0,21,20ZM9,8h6V6h1v3H8V6H9ZM8,18V14h8v4Z",
|
|
222
|
-
fill: "currentColor"
|
|
223
|
-
}
|
|
224
|
-
)
|
|
225
|
-
}
|
|
226
|
-
),
|
|
227
|
-
children: "Save license"
|
|
228
|
-
}
|
|
229
|
-
) }),
|
|
230
|
-
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, style: { paddingTop: "3em" }, children: /* @__PURE__ */ jsx(Typography, { variant: "beta", children: "Authorize translationstudio requests" }) }),
|
|
231
|
-
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, style: { paddingBottom: "1em" }, children: /* @__PURE__ */ jsx(Typography, { variant: "charlie", style: { width: "100%" }, children: "When translationstudio connects with this plugin it will use the following access key to authorize itself." }) }),
|
|
232
|
-
/* @__PURE__ */ jsx(Grid.Item, { xs: 10, children: /* @__PURE__ */ jsx(Box, { style: { width: "100%" }, children: /* @__PURE__ */ jsx(
|
|
233
|
-
TextInput,
|
|
234
|
-
{
|
|
235
|
-
name: "access-token",
|
|
236
|
-
label: "Access Key",
|
|
237
|
-
placeholder: "Generate an access key to validate incoming requests",
|
|
238
|
-
"aria-label": "Access Key Input",
|
|
239
|
-
value: tokenValue,
|
|
240
|
-
onChange: () => {
|
|
241
|
-
},
|
|
242
|
-
disabled: true,
|
|
243
|
-
style: TextareaStyle
|
|
244
|
-
}
|
|
245
|
-
) }) }),
|
|
246
|
-
/* @__PURE__ */ jsx(Grid.Item, { xs: 2, children: /* @__PURE__ */ jsx(
|
|
247
|
-
Button,
|
|
248
|
-
{
|
|
249
|
-
onClick: handleGenerateToken,
|
|
250
|
-
style: BUttonStyle,
|
|
251
|
-
disabled: isLoadingToken,
|
|
252
|
-
loading: isLoadingToken,
|
|
253
|
-
size: "L",
|
|
254
|
-
startIcon: /* @__PURE__ */ jsx(ArrowClockwise, {}),
|
|
255
|
-
children: isLoadingToken ? "Generating..." : tokenValue ? "New access key" : "Create access key"
|
|
256
|
-
}
|
|
257
|
-
) }),
|
|
258
|
-
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, style: { paddingTop: "5em" }, children: /* @__PURE__ */ jsx(Typography, { variant: "beta", children: "Customization" }) }),
|
|
259
|
-
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, style: { paddingBottom: "1em" }, children: /* @__PURE__ */ jsx(Typography, { variant: "charlie", style: { width: "100%" }, children: "You will not need these settings, but you might want to customize your translationstudio instance." }) }),
|
|
260
|
-
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, children: /* @__PURE__ */ jsx(
|
|
261
|
-
Switch,
|
|
262
|
-
{
|
|
263
|
-
checked: showDevOptions,
|
|
264
|
-
onCheckedChange: () => onChangeDevOptions(!showDevOptions),
|
|
265
|
-
onLabel: "Use custom translationstudio URL",
|
|
266
|
-
offLabel: "Custom translationstudio URL is currently disabled (default)",
|
|
267
|
-
visibleLabels: true
|
|
268
|
-
}
|
|
269
|
-
) }),
|
|
270
|
-
showDevOptions && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
271
|
-
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, style: { paddingTop: "2em" }, children: /* @__PURE__ */ jsx(Typography, { variant: "beta", children: "Use custom translationstudio URL." }) }),
|
|
272
|
-
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, style: { paddingBottom: "1em" }, children: /* @__PURE__ */ jsx(Typography, { variant: "delta", children: "This is usually only necessary for development purposes." }) }),
|
|
273
|
-
/* @__PURE__ */ jsx(Grid.Item, { xs: 10, children: /* @__PURE__ */ jsx(Box, { style: { width: "100%" }, children: /* @__PURE__ */ jsx(
|
|
274
|
-
TextInput,
|
|
275
|
-
{
|
|
276
|
-
onChange: (e) => setDevUrl(e.target.value.trim()),
|
|
277
|
-
name: "devurl",
|
|
278
|
-
label: "Custom translationstudio url",
|
|
279
|
-
placeholder: "Paste your custom translationstudio url here",
|
|
280
|
-
"aria-label": "translationstudio custom url",
|
|
281
|
-
value: devUrl,
|
|
282
|
-
style: TextareaStyle
|
|
283
|
-
}
|
|
284
|
-
) }) }),
|
|
285
|
-
/* @__PURE__ */ jsx(Grid.Item, { xs: 2, children: /* @__PURE__ */ jsx(
|
|
286
|
-
Button,
|
|
287
|
-
{
|
|
288
|
-
onClick: handleUpdateUrl,
|
|
289
|
-
style: BUttonStyle,
|
|
290
|
-
disabled: isLoadingToken,
|
|
291
|
-
loading: isLoadingToken,
|
|
292
|
-
startIcon: /* @__PURE__ */ jsx(Play, {}),
|
|
293
|
-
size: "L",
|
|
294
|
-
children: "Update URL"
|
|
295
|
-
}
|
|
296
|
-
) })
|
|
297
|
-
] }),
|
|
298
|
-
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, style: { paddingTop: "4em" }, children: /* @__PURE__ */ jsxs(Typography, { variant: "sigma", style: { width: "100%", textAlign: "right" }, children: [
|
|
299
|
-
"If you do not have a translationstudio account, please create one at",
|
|
300
|
-
" ",
|
|
301
|
-
/* @__PURE__ */ jsx(
|
|
302
|
-
"a",
|
|
303
|
-
{
|
|
304
|
-
href: "https://account.translationstudio.tech/",
|
|
305
|
-
target: "_blank",
|
|
306
|
-
rel: "noopener noreferrer",
|
|
307
|
-
style: { textDecoration: "none", color: "#e94642" },
|
|
308
|
-
children: "account.translationstudio.tech"
|
|
309
|
-
}
|
|
310
|
-
),
|
|
311
|
-
". You can find further information at ",
|
|
312
|
-
/* @__PURE__ */ jsx(
|
|
313
|
-
"a",
|
|
314
|
-
{
|
|
315
|
-
href: "https://www.translationstudio.tech/",
|
|
316
|
-
target: "_blank",
|
|
317
|
-
rel: "noopener noreferrer",
|
|
318
|
-
style: { textDecoration: "none", color: "#e94642" },
|
|
319
|
-
children: "translationstudio.tech"
|
|
320
|
-
}
|
|
321
|
-
),
|
|
322
|
-
" "
|
|
323
|
-
] }) })
|
|
324
|
-
] })
|
|
325
|
-
}
|
|
326
|
-
)
|
|
327
|
-
] });
|
|
328
|
-
};
|
|
329
|
-
const App = () => {
|
|
330
|
-
return /* @__PURE__ */ jsxs(Routes, { children: [
|
|
331
|
-
/* @__PURE__ */ jsx(Route, { index: true, element: /* @__PURE__ */ jsx(SettingsPage, {}) }),
|
|
332
|
-
/* @__PURE__ */ jsx(Route, { path: "*", element: /* @__PURE__ */ jsx(Page.Error, {}) })
|
|
333
|
-
] });
|
|
334
|
-
};
|
|
335
|
-
export {
|
|
336
|
-
App
|
|
337
|
-
};
|
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const admin = require("@strapi/strapi/admin");
|
|
5
|
-
const reactRouterDom = require("react-router-dom");
|
|
6
|
-
const designSystem = require("@strapi/design-system");
|
|
7
|
-
const react = require("react");
|
|
8
|
-
const icons = require("@strapi/icons");
|
|
9
|
-
const index = require("./index-ehPijnQ-.js");
|
|
10
|
-
async function loadLicense(fnGet) {
|
|
11
|
-
try {
|
|
12
|
-
const response = await fnGet("/translationstudio/getLicense");
|
|
13
|
-
if (typeof response.data?.license === "string")
|
|
14
|
-
return response.data.license;
|
|
15
|
-
} catch (err) {
|
|
16
|
-
console.error(err);
|
|
17
|
-
}
|
|
18
|
-
return "";
|
|
19
|
-
}
|
|
20
|
-
async function loadDevUrl(fnGet) {
|
|
21
|
-
try {
|
|
22
|
-
const response = await fnGet("/translationstudio/devurl");
|
|
23
|
-
if (typeof response.data?.url === "string")
|
|
24
|
-
return response.data.url;
|
|
25
|
-
} catch (err) {
|
|
26
|
-
console.error(err);
|
|
27
|
-
}
|
|
28
|
-
return "";
|
|
29
|
-
}
|
|
30
|
-
async function updateDevlUrl(fnPost, url) {
|
|
31
|
-
try {
|
|
32
|
-
const response = await fnPost("/translationstudio/devurl", { url });
|
|
33
|
-
if (typeof response.data?.success === "boolean")
|
|
34
|
-
return response.data.success;
|
|
35
|
-
} catch (err) {
|
|
36
|
-
console.error(err);
|
|
37
|
-
}
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
const TextareaStyle = {
|
|
41
|
-
color: "grey",
|
|
42
|
-
width: "100%",
|
|
43
|
-
display: "block",
|
|
44
|
-
backgroundColor: "#f6f6f6",
|
|
45
|
-
cursor: "default"
|
|
46
|
-
};
|
|
47
|
-
const BUttonStyle = { backgroundColor: "#e94642", border: "none", paddingTop: "0.6em", paddingBottom: "0.6em" };
|
|
48
|
-
const SettingsPage = () => {
|
|
49
|
-
const [licenseValue, setLicenseValue] = react.useState("");
|
|
50
|
-
const [isLoading, setIsLoading] = react.useState(true);
|
|
51
|
-
const [tokenValue, setTokenValue] = react.useState("");
|
|
52
|
-
const [isLoadingToken, setIsLoadingToken] = react.useState(false);
|
|
53
|
-
const [showDevOptions, setShowDevOptions] = react.useState(false);
|
|
54
|
-
const [showAlert, setShowAlert] = react.useState(false);
|
|
55
|
-
const [alertType, setAlertType] = react.useState("success");
|
|
56
|
-
const [alertMessage, setAlertMessage] = react.useState("");
|
|
57
|
-
const [devUrl, setDevUrl] = react.useState("");
|
|
58
|
-
const { get, post } = admin.getFetchClient();
|
|
59
|
-
react.useEffect(() => {
|
|
60
|
-
const getLicense = async () => {
|
|
61
|
-
setIsLoading(true);
|
|
62
|
-
const license = await loadLicense(get);
|
|
63
|
-
if (license)
|
|
64
|
-
setLicenseValue(license);
|
|
65
|
-
const dUrl = await loadDevUrl(get);
|
|
66
|
-
if (dUrl) {
|
|
67
|
-
console.log(dUrl);
|
|
68
|
-
setDevUrl(dUrl);
|
|
69
|
-
setShowDevOptions(true);
|
|
70
|
-
}
|
|
71
|
-
setIsLoading(false);
|
|
72
|
-
};
|
|
73
|
-
getLicense();
|
|
74
|
-
}, [setLicenseValue, setDevUrl, setIsLoading, setShowDevOptions]);
|
|
75
|
-
react.useEffect(() => {
|
|
76
|
-
const fetchToken = async () => {
|
|
77
|
-
setIsLoadingToken(true);
|
|
78
|
-
try {
|
|
79
|
-
const response = await get("/translationstudio/getToken");
|
|
80
|
-
if (response.data.token) {
|
|
81
|
-
setTokenValue(response.data.token);
|
|
82
|
-
} else {
|
|
83
|
-
setTokenValue("");
|
|
84
|
-
}
|
|
85
|
-
} catch (err) {
|
|
86
|
-
console.error(err);
|
|
87
|
-
} finally {
|
|
88
|
-
setIsLoadingToken(false);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
fetchToken();
|
|
92
|
-
}, []);
|
|
93
|
-
const handleLicenseChange = (e) => {
|
|
94
|
-
setLicenseValue(e.target.value.trim());
|
|
95
|
-
};
|
|
96
|
-
const handleUpdateUrl = async function() {
|
|
97
|
-
setIsLoading(true);
|
|
98
|
-
updateDevlUrl(post, devUrl).then(() => {
|
|
99
|
-
if (devUrl === "")
|
|
100
|
-
setShowDevOptions(false);
|
|
101
|
-
}).finally(() => setIsLoading(false));
|
|
102
|
-
};
|
|
103
|
-
const handleSaveLicense = async () => {
|
|
104
|
-
try {
|
|
105
|
-
const response = await post("/translationstudio/setLicense", { license: licenseValue });
|
|
106
|
-
if (response) {
|
|
107
|
-
displayAlert("success");
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
} catch (err) {
|
|
111
|
-
console.error(err);
|
|
112
|
-
}
|
|
113
|
-
displayAlert("danger");
|
|
114
|
-
};
|
|
115
|
-
const displayAlert = (variant) => {
|
|
116
|
-
let message = variant === "success" ? "License saved" : "Error saving license";
|
|
117
|
-
setAlertType(variant);
|
|
118
|
-
setAlertMessage(message);
|
|
119
|
-
setShowAlert(true);
|
|
120
|
-
setTimeout(() => {
|
|
121
|
-
setShowAlert(false);
|
|
122
|
-
}, 5e3);
|
|
123
|
-
};
|
|
124
|
-
const handleGenerateToken = async () => {
|
|
125
|
-
setIsLoadingToken(true);
|
|
126
|
-
try {
|
|
127
|
-
const response = await post("/translationstudio/generateToken");
|
|
128
|
-
if (response.data?.token) {
|
|
129
|
-
setTokenValue(response.data.token);
|
|
130
|
-
}
|
|
131
|
-
} catch (err) {
|
|
132
|
-
console.error(err);
|
|
133
|
-
} finally {
|
|
134
|
-
setIsLoadingToken(false);
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
const onChangeDevOptions = function(val) {
|
|
138
|
-
if (val)
|
|
139
|
-
setShowDevOptions(val);
|
|
140
|
-
else
|
|
141
|
-
updateDevlUrl(post, "").finally(() => setShowDevOptions(val));
|
|
142
|
-
};
|
|
143
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Main, { children: [
|
|
144
|
-
showAlert && /* @__PURE__ */ jsxRuntime.jsx(
|
|
145
|
-
designSystem.Box,
|
|
146
|
-
{
|
|
147
|
-
style: {
|
|
148
|
-
position: "fixed",
|
|
149
|
-
top: "10%",
|
|
150
|
-
left: "50%",
|
|
151
|
-
transform: "translate(-50%, -50%)",
|
|
152
|
-
zIndex: 10,
|
|
153
|
-
minWidth: "400px",
|
|
154
|
-
maxWidth: "90%"
|
|
155
|
-
},
|
|
156
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Alert, { closeLabel: "Close", variant: alertType, onClose: () => setShowAlert(false), children: alertMessage })
|
|
157
|
-
}
|
|
158
|
-
),
|
|
159
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
160
|
-
designSystem.Box,
|
|
161
|
-
{
|
|
162
|
-
padding: 10,
|
|
163
|
-
style: {
|
|
164
|
-
minHeight: "90vh",
|
|
165
|
-
marginTop: "5vh"
|
|
166
|
-
},
|
|
167
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { children: [
|
|
168
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { textAlign: "right", width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsxs("picture", { style: {
|
|
169
|
-
width: "300px",
|
|
170
|
-
height: "auto",
|
|
171
|
-
display: "inline-block"
|
|
172
|
-
}, children: [
|
|
173
|
-
/* @__PURE__ */ jsxRuntime.jsx("source", { srcSet: index.TSlogoFarbig, media: "(prefers-color-scheme: light)" }),
|
|
174
|
-
/* @__PURE__ */ jsxRuntime.jsx("source", { srcSet: index.TSlogoWhite, media: "(prefers-color-scheme: dark)" }),
|
|
175
|
-
/* @__PURE__ */ jsxRuntime.jsx("img", { src: index.TSlogoFarbig })
|
|
176
|
-
] }) }) }),
|
|
177
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, style: { paddingTop: "2em" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", style: { width: "100%" }, children: "translationstudio License" }) }),
|
|
178
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, style: { paddingBottom: "1em" }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "charlie", style: { width: "100%" }, children: [
|
|
179
|
-
"You can create or revoke a license at",
|
|
180
|
-
" ",
|
|
181
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
182
|
-
"a",
|
|
183
|
-
{
|
|
184
|
-
href: "https://account.translationstudio.tech/",
|
|
185
|
-
target: "_blank",
|
|
186
|
-
rel: "noopener noreferrer",
|
|
187
|
-
style: { textDecoration: "none", color: "#e94642" },
|
|
188
|
-
children: "account.translationstudio.tech"
|
|
189
|
-
}
|
|
190
|
-
)
|
|
191
|
-
] }) }),
|
|
192
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 10, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
193
|
-
designSystem.TextInput,
|
|
194
|
-
{
|
|
195
|
-
name: "jwt-token",
|
|
196
|
-
label: "JWT Token",
|
|
197
|
-
placeholder: "Paste your Strapi translationstudio license into this field and click save to apply it to this project",
|
|
198
|
-
"aria-label": "Strapi license Input",
|
|
199
|
-
value: licenseValue,
|
|
200
|
-
onChange: handleLicenseChange,
|
|
201
|
-
disabled: isLoading,
|
|
202
|
-
style: TextareaStyle
|
|
203
|
-
}
|
|
204
|
-
) }) }),
|
|
205
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
206
|
-
designSystem.Button,
|
|
207
|
-
{
|
|
208
|
-
onClick: handleSaveLicense,
|
|
209
|
-
disabled: isLoading,
|
|
210
|
-
style: BUttonStyle,
|
|
211
|
-
size: "L",
|
|
212
|
-
startIcon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
213
|
-
"svg",
|
|
214
|
-
{
|
|
215
|
-
width: "20",
|
|
216
|
-
height: "20",
|
|
217
|
-
viewBox: "0 0 24 24",
|
|
218
|
-
fill: "none",
|
|
219
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
220
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
221
|
-
"path",
|
|
222
|
-
{
|
|
223
|
-
d: "M21,20V8.414a1,1,0,0,0-.293-.707L16.293,3.293A1,1,0,0,0,15.586,3H4A1,1,0,0,0,3,4V20a1,1,0,0,0,1,1H20A1,1,0,0,0,21,20ZM9,8h6V6h1v3H8V6H9ZM8,18V14h8v4Z",
|
|
224
|
-
fill: "currentColor"
|
|
225
|
-
}
|
|
226
|
-
)
|
|
227
|
-
}
|
|
228
|
-
),
|
|
229
|
-
children: "Save license"
|
|
230
|
-
}
|
|
231
|
-
) }),
|
|
232
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, style: { paddingTop: "3em" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", children: "Authorize translationstudio requests" }) }),
|
|
233
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, style: { paddingBottom: "1em" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "charlie", style: { width: "100%" }, children: "When translationstudio connects with this plugin it will use the following access key to authorize itself." }) }),
|
|
234
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 10, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
235
|
-
designSystem.TextInput,
|
|
236
|
-
{
|
|
237
|
-
name: "access-token",
|
|
238
|
-
label: "Access Key",
|
|
239
|
-
placeholder: "Generate an access key to validate incoming requests",
|
|
240
|
-
"aria-label": "Access Key Input",
|
|
241
|
-
value: tokenValue,
|
|
242
|
-
onChange: () => {
|
|
243
|
-
},
|
|
244
|
-
disabled: true,
|
|
245
|
-
style: TextareaStyle
|
|
246
|
-
}
|
|
247
|
-
) }) }),
|
|
248
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
249
|
-
designSystem.Button,
|
|
250
|
-
{
|
|
251
|
-
onClick: handleGenerateToken,
|
|
252
|
-
style: BUttonStyle,
|
|
253
|
-
disabled: isLoadingToken,
|
|
254
|
-
loading: isLoadingToken,
|
|
255
|
-
size: "L",
|
|
256
|
-
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowClockwise, {}),
|
|
257
|
-
children: isLoadingToken ? "Generating..." : tokenValue ? "New access key" : "Create access key"
|
|
258
|
-
}
|
|
259
|
-
) }),
|
|
260
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, style: { paddingTop: "5em" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", children: "Customization" }) }),
|
|
261
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, style: { paddingBottom: "1em" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "charlie", style: { width: "100%" }, children: "You will not need these settings, but you might want to customize your translationstudio instance." }) }),
|
|
262
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
263
|
-
designSystem.Switch,
|
|
264
|
-
{
|
|
265
|
-
checked: showDevOptions,
|
|
266
|
-
onCheckedChange: () => onChangeDevOptions(!showDevOptions),
|
|
267
|
-
onLabel: "Use custom translationstudio URL",
|
|
268
|
-
offLabel: "Custom translationstudio URL is currently disabled (default)",
|
|
269
|
-
visibleLabels: true
|
|
270
|
-
}
|
|
271
|
-
) }),
|
|
272
|
-
showDevOptions && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
273
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, style: { paddingTop: "2em" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", children: "Use custom translationstudio URL." }) }),
|
|
274
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, style: { paddingBottom: "1em" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", children: "This is usually only necessary for development purposes." }) }),
|
|
275
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 10, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
276
|
-
designSystem.TextInput,
|
|
277
|
-
{
|
|
278
|
-
onChange: (e) => setDevUrl(e.target.value.trim()),
|
|
279
|
-
name: "devurl",
|
|
280
|
-
label: "Custom translationstudio url",
|
|
281
|
-
placeholder: "Paste your custom translationstudio url here",
|
|
282
|
-
"aria-label": "translationstudio custom url",
|
|
283
|
-
value: devUrl,
|
|
284
|
-
style: TextareaStyle
|
|
285
|
-
}
|
|
286
|
-
) }) }),
|
|
287
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
288
|
-
designSystem.Button,
|
|
289
|
-
{
|
|
290
|
-
onClick: handleUpdateUrl,
|
|
291
|
-
style: BUttonStyle,
|
|
292
|
-
disabled: isLoadingToken,
|
|
293
|
-
loading: isLoadingToken,
|
|
294
|
-
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Play, {}),
|
|
295
|
-
size: "L",
|
|
296
|
-
children: "Update URL"
|
|
297
|
-
}
|
|
298
|
-
) })
|
|
299
|
-
] }),
|
|
300
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, style: { paddingTop: "4em" }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "sigma", style: { width: "100%", textAlign: "right" }, children: [
|
|
301
|
-
"If you do not have a translationstudio account, please create one at",
|
|
302
|
-
" ",
|
|
303
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
304
|
-
"a",
|
|
305
|
-
{
|
|
306
|
-
href: "https://account.translationstudio.tech/",
|
|
307
|
-
target: "_blank",
|
|
308
|
-
rel: "noopener noreferrer",
|
|
309
|
-
style: { textDecoration: "none", color: "#e94642" },
|
|
310
|
-
children: "account.translationstudio.tech"
|
|
311
|
-
}
|
|
312
|
-
),
|
|
313
|
-
". You can find further information at ",
|
|
314
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
315
|
-
"a",
|
|
316
|
-
{
|
|
317
|
-
href: "https://www.translationstudio.tech/",
|
|
318
|
-
target: "_blank",
|
|
319
|
-
rel: "noopener noreferrer",
|
|
320
|
-
style: { textDecoration: "none", color: "#e94642" },
|
|
321
|
-
children: "translationstudio.tech"
|
|
322
|
-
}
|
|
323
|
-
),
|
|
324
|
-
" "
|
|
325
|
-
] }) })
|
|
326
|
-
] })
|
|
327
|
-
}
|
|
328
|
-
)
|
|
329
|
-
] });
|
|
330
|
-
};
|
|
331
|
-
const App = () => {
|
|
332
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
|
|
333
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { index: true, element: /* @__PURE__ */ jsxRuntime.jsx(SettingsPage, {}) }),
|
|
334
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "*", element: /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Error, {}) })
|
|
335
|
-
] });
|
|
336
|
-
};
|
|
337
|
-
exports.App = App;
|