@translationstudio/translationstudio-strapi-extension 1.1.1 → 1.1.3
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/_chunks/{App-jiozoQyG.mjs → App-Cq1SRR-L.mjs} +148 -82
- package/dist/_chunks/{App-rdXR_woe.js → App-DkdbSZwI.js} +146 -80
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +75 -14
- package/dist/server/index.mjs +75 -14
- package/dist/server/src/controllers/controller.d.ts +2 -0
- package/dist/server/src/controllers/index.d.ts +2 -0
- package/dist/server/src/index.d.ts +5 -0
- package/dist/server/src/services/index.d.ts +3 -0
- package/dist/server/src/services/service.d.ts +3 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ Follow these steps:
|
|
|
22
22
|
|
|
23
23
|
1. run `npm install -g yalc` in this folder
|
|
24
24
|
2. run `npm install` (if there are errors, add `--legacy-peer-deps`)
|
|
25
|
-
3. run `npm run:
|
|
25
|
+
3. run `npm run watch:link` in this folder
|
|
26
26
|
4. Create a new strapi project and enter the folder
|
|
27
27
|
5. run `npx yalc add --link _translationstudio-strapi-extension_`
|
|
28
28
|
6. start strapi in development mode
|
|
@@ -1,36 +1,76 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { getFetchClient, Page } from "@strapi/strapi/admin";
|
|
3
3
|
import { Routes, Route } from "react-router-dom";
|
|
4
|
-
import { Main, Box, Alert,
|
|
4
|
+
import { Main, Box, Alert, Grid, Typography, TextInput, Button, Switch } from "@strapi/design-system";
|
|
5
5
|
import { useState, useEffect } from "react";
|
|
6
|
+
import { ArrowClockwise, Play } from "@strapi/icons";
|
|
6
7
|
const TSlogoFarbig = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='Ebene_1'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201444.47%20635.72'%3e%3cdefs%3e%3cstyle%3e.cls-1{fill:%23e94642;}.cls-2{fill:%23231f20;}.cls-3{fill:%23a51d78;}%3c/style%3e%3c/defs%3e%3cpath%20class='cls-2'%20d='M1151.68,294.37c34.28,0,50.11,19.74,50.11,59.01v56.4c0,6.94-3.91,10.85-10.85,10.85h-2.6c-6.94,0-10.84-3.9-10.84-10.85v-54.45c0-27.12-10.41-39.91-33.41-39.91s-32.97,15.4-32.97,42.74v51.63c0,6.94-3.91,10.85-10.85,10.85h-2.6c-6.94,0-10.85-3.9-10.85-10.85v-102.39c0-6.94,3.91-10.85,10.85-10.85h2.6c6.94,0,10.85,3.91,10.85,10.85v12.34c5.64-14.39,19.73-25.36,40.56-25.36h0Z'/%3e%3cpath%20class='cls-2'%20d='M0,313.78v55.76c0,37.96,14.53,51.2,46.42,51.2h0c1.96,0,4.12-.03,6.29-.22,6.9-.65,9.8-4.45,9.11-11.07-.61-5.88-4.99-8.24-11.71-8.24-18.88,0-25.6-8.9-25.6-34.49v-52.94h25.81c6.94,0,10.85-3.47,10.85-9.54s-3.9-9.33-10.85-9.33H24.51v-15.83c0-7.59-4.34-11.28-11.93-9.55l-3.04,.65c-6.29,1.3-9.54,5.21-9.54,11.71v31.89Z'/%3e%3cpath%20class='cls-2'%20d='M139.49,295.02c7.38,0,11.06,4.77,10.2,11.71l-.22,1.74c-.65,6.94-4.77,9.54-11.93,9.54-20.39,.43-30.16,15.19-30.16,41.22v50.55c0,6.94-3.9,10.85-10.85,10.85h-2.6c-6.94,0-10.85-3.9-10.85-10.85v-102.39c0-6.94,3.9-10.85,10.85-10.85h2.6c6.94,0,10.85,3.69,10.85,10.41v10.41c3.91-11.07,13.89-22.34,32.1-22.34h0Z'/%3e%3cpath%20class='cls-2'%20d='M259.67,358.59c0-27.12-15.84-43.82-38.83-43.82s-38.4,16.49-38.4,43.82,15.62,44.04,38.83,44.04,38.4-16.7,38.4-44.04m-101.53,0c0-42.74,26.03-64.43,56.84-64.43,19.52,0,36.88,9.54,44.04,26.69v-13.45c0-6.94,3.9-10.85,10.85-10.85h2.6c6.94,0,10.85,3.9,10.85,10.85v102.18c0,6.94-3.9,10.85-10.85,10.85h-2.6c-6.94,0-10.85-3.9-10.85-10.85v-12.58c-6.94,16.7-24.51,26.47-43.82,26.47-30.81,0-57.06-21.91-57.06-64.87'/%3e%3cpath%20class='cls-2'%20d='M380.06,294.37c34.28,0,50.11,19.74,50.11,59.01v56.4c0,6.94-3.91,10.85-10.85,10.85h-2.6c-6.94,0-10.85-3.9-10.85-10.85v-54.45c0-27.12-10.41-39.91-33.41-39.91s-32.98,15.4-32.98,42.74v51.63c0,6.94-3.9,10.85-10.85,10.85h-2.6c-6.94,0-10.85-3.9-10.85-10.85v-102.39c0-6.94,3.91-10.85,10.85-10.85h2.6c6.94,0,10.85,3.91,10.85,10.85v12.34c5.64-14.39,19.73-25.36,40.57-25.36h0Z'/%3e%3cpath%20class='cls-2'%20d='M508.94,422.81c-20.8,0-42.78-8.33-53.19-21.48-4.44-5.61-2.26-11.49,4.99-13.67l2.17-.65c4.75-1.43,8.02-1.28,14.32,4.36,8.65,7.74,20.41,10.61,31.71,10.61,18.05,0,28.81-6.44,28.81-17.36,0-28.63-80.45-5.9-80.45-54.24,0-22.87,23.1-36.01,49.75-36.01,16.09,0,36.22,6.5,47,17.79,5.1,5.33,3.34,11.34-3.68,13.45l-2.17,.65c-5.86,1.76-8.85-.39-14.53-3.84-8.11-4.92-16.87-8.09-26.22-8.09-15.64,0-26.27,5.18-26.27,14.91,0,27.74,81.1,4.51,81.1,54.72,0,23.06-22.28,38.83-53.32,38.83h0Z'/%3e%3cpath%20class='cls-2'%20d='M585.05,409.79v-142.75c0-6.94,3.9-10.85,10.85-10.85h2.82c6.94,0,10.85,3.9,10.85,10.85v142.75c0,6.94-3.91,10.85-10.85,10.85h-2.82c-6.94,0-10.85-3.91-10.85-10.85'/%3e%3cpath%20class='cls-2'%20d='M737.56,358.59c0-27.12-15.84-43.82-38.84-43.82s-38.4,16.49-38.4,43.82,15.62,44.04,38.83,44.04,38.4-16.7,38.4-44.04m-101.53,0c0-42.74,26.03-64.43,56.84-64.43,19.52,0,36.88,9.54,44.04,26.69v-13.45c0-6.94,3.9-10.85,10.85-10.85h2.6c6.94,0,10.85,3.9,10.85,10.85v102.18c0,6.94-3.9,10.85-10.85,10.85h-2.6c-6.94,0-10.85-3.9-10.85-10.85v-12.58c-6.94,16.7-24.51,26.47-43.82,26.47-30.81,0-57.06-21.91-57.06-64.87'/%3e%3cpath%20class='cls-2'%20d='M800.25,315.42v55.76c0,37.96,14.53,51.2,46.42,51.2h0c1.95,0,4.12-.03,6.29-.22,6.89-.65,9.8-4.45,9.11-11.07-.61-5.88-4.99-8.24-11.71-8.24-18.87,0-25.6-8.9-25.6-34.49v-52.94h25.81c6.94,0,10.85-3.47,10.85-9.55s-3.91-9.33-10.85-9.33h-25.81v-15.83c0-7.59-4.34-11.28-11.93-9.54l-3.04,.65c-6.29,1.3-9.55,5.21-9.55,11.71v31.89Z'/%3e%3cpath%20class='cls-2'%20d='M883.72,409.79v-102.4c0-6.94,3.83-10.85,10.65-10.85h2.77c6.82,0,10.65,3.9,10.65,10.85v102.4c0,6.94-3.83,10.85-10.65,10.85h-2.77c-6.81,0-10.65-3.91-10.65-10.85m-2.05-142.96c0-8.24,6.08-13.02,14.32-13.02,7.59,0,14.32,4.77,14.32,13.02s-6.72,13.02-14.32,13.02c-8.24,0-14.32-4.77-14.32-13.02'/%3e%3cpath%20class='cls-2'%20d='M1036.06,358.59c0-27.12-15.62-43.82-38.62-43.82s-38.4,16.49-38.4,43.82,15.4,44.04,38.61,44.04,38.4-16.7,38.4-44.04m-101.31,0c0-44.69,31.02-64.43,62.69-64.43s62.91,19.74,62.91,64.43-31.02,64.87-62.7,64.87-62.91-19.74-62.91-64.87'/%3e%3cpath%20class='cls-2'%20d='M555.77,635.72c-20.98,0-43.14-8.4-53.65-21.66-4.48-5.66-2.27-11.59,5.03-13.78l2.19-.66c4.79-1.44,8.09-1.29,14.43,4.4,8.73,7.81,20.59,10.69,31.98,10.69,18.2,0,29.05-6.49,29.05-17.5,0-28.88-81.14-5.95-81.14-54.7,0-23.07,23.3-36.31,50.17-36.31,16.23,0,36.53,6.55,47.41,17.94,5.14,5.38,3.37,11.43-3.72,13.56l-2.19,.66c-5.91,1.77-8.92-.39-14.66-3.87-8.18-4.96-17.02-8.16-26.45-8.16-15.78,0-26.5,5.22-26.5,15.04,0,27.98,81.79,4.55,81.79,55.18,0,23.26-22.47,39.16-53.78,39.16h0Z'/%3e%3cpath%20class='cls-2'%20d='M639.98,526.42v56.23c0,38.29,14.66,51.63,46.82,51.63h0c1.97,0,4.16-.03,6.34-.22,6.96-.66,9.89-4.49,9.19-11.16-.61-5.93-5.03-8.31-11.81-8.31-19.03,0-25.82-8.97-25.82-34.79v-53.38h26.03c7,0,10.94-3.5,10.94-9.63s-3.94-9.41-10.94-9.41h-26.03v-15.97c0-7.66-4.38-11.38-12.03-9.63l-3.06,.66c-6.34,1.31-9.63,5.25-9.63,11.81v32.16Z'/%3e%3cpath%20class='cls-2'%20d='M826.59,508.39c7,0,10.94,3.94,10.94,10.94v103.27c0,7-3.94,10.94-10.94,10.94h-2.62c-7,0-10.94-3.94-10.94-10.94v-12.45c-5.69,14.51-19.9,25.57-40.91,25.57-34.57,0-50.54-19.91-50.54-59.51v-56.89c0-7,3.94-10.93,10.94-10.93h2.63c7,0,10.94,3.93,10.94,10.93v54.92c0,27.35,10.5,40.26,33.69,40.26s33.26-15.53,33.26-43.1v-52.07c0-7,3.94-10.93,10.94-10.93h2.62Z'/%3e%3cpath%20class='cls-2'%20d='M967.71,570.31c0-27.35-15.75-44.19-39.16-44.19s-38.72,16.63-38.72,44.19,15.75,44.41,39.16,44.41,38.72-16.85,38.72-44.41m-102.39,0c0-43.1,26.25-64.98,57.32-64.98,19.69,0,37.41,9.63,44.41,26.91v-54.26c0-7,3.94-10.94,10.94-10.94h2.62c7,0,10.94,3.94,10.94,10.94v143.74c0,7-3.94,10.94-10.94,10.94h-2.62c-7,0-10.94-3.94-10.94-10.94v-12.69c-7,16.85-24.72,26.69-44.19,26.69-31.07,0-57.54-22.09-57.54-65.41'/%3e%3cpath%20class='cls-2'%20d='M1023.66,623.38v-103.27c0-7,3.87-10.94,10.74-10.94h2.79c6.87,0,10.74,3.94,10.74,10.94v103.27c0,7-3.87,10.94-10.74,10.94h-2.79c-6.87,0-10.74-3.94-10.74-10.94m-2.07-144.18c0-8.31,6.13-13.13,14.44-13.13,7.66,0,14.44,4.81,14.44,13.13s-6.78,13.13-14.44,13.13c-8.31,0-14.44-4.81-14.44-13.13'/%3e%3cpath%20class='cls-2'%20d='M1177.29,570.31c0-27.35-15.75-44.19-38.94-44.19s-38.72,16.63-38.72,44.19,15.53,44.41,38.94,44.41,38.72-16.85,38.72-44.41m-102.17,0c0-45.07,31.29-64.98,63.23-64.98s63.45,19.91,63.45,64.98-31.29,65.41-63.23,65.41-63.45-19.91-63.45-65.41'/%3e%3cpath%20class='cls-3'%20d='M1366.99,177.21c7.75,6.65,16.32,15.32,24.3,26.23,19.82,27.08,29.56,59.09,28.94,95.13-.29,16.74-3.42,30.61-9.31,41.23-.55,1-1.14,1.99-1.74,2.94-1.17,1.86-2.46,3.67-3.82,5.37-3.28,4.11-7.15,7.78-11.48,10.91-.85,.61-1.73,1.21-2.61,1.79-1.77,1.14-3.63,2.22-5.54,3.2-2.85,1.46-5.89,2.76-9.03,3.84-2.08,.72-4.25,1.36-6.44,1.91-6.58,1.65-13.54,2.48-20.67,2.48-19.29,0-36.82-6.22-49.35-17.5-14.34-12.91-21.61-31.67-21.61-55.75,0-30.01,11.74-53.91,31.41-63.94,15.09-7.69,29.61-15.71,41.22-29.17,7.24-8.39,12.46-17.89,15.72-28.67m-14.08-37.87c-3.24,0-6.11,2.04-6.11,5.55h0c.97,42.1-22.01,55.46-47.74,68.58-26.46,13.49-44.63,43.79-44.63,85.51,0,66.7,47.26,97.47,95.17,97.47,8.98,0,17.93-1.05,26.54-3.2,2.87-.72,5.7-1.56,8.49-2.52,4.18-1.45,8.24-3.17,12.16-5.18,2.61-1.34,5.16-2.81,7.63-4.41,1.24-.8,2.45-1.63,3.65-2.49,5.98-4.32,11.44-9.45,16.21-15.43,1.91-2.39,3.71-4.92,5.39-7.58,.84-1.33,1.65-2.7,2.42-4.1,7.76-14,11.99-31.44,12.35-52.56,1.63-95.85-61.94-144.16-87.99-158.76-.99-.56-2.19-.88-3.54-.88h0Z'/%3e%3cpath%20class='cls-1'%20d='M1234.82,24.21c19.29,0,36.82,6.22,49.35,17.5,14.34,12.91,21.61,31.67,21.61,55.75,0,30.01-11.74,53.91-31.41,63.94-15.09,7.69-29.61,15.71-41.22,29.17-7.24,8.39-12.46,17.89-15.72,28.67-7.75-6.65-16.32-15.32-24.3-26.23-19.82-27.08-29.56-59.09-28.94-95.13,.29-16.74,3.42-30.61,9.31-41.23,.55-1,1.14-1.98,1.74-2.93,1.17-1.86,2.46-3.67,3.82-5.37,3.28-4.11,7.15-7.78,11.48-10.91,.85-.61,1.73-1.21,2.61-1.79,1.77-1.14,3.63-2.22,5.54-3.2,2.85-1.46,5.89-2.76,9.03-3.84,2.08-.72,4.25-1.36,6.44-1.91,6.58-1.65,13.54-2.48,20.67-2.48m0-24.21c-8.98,0-17.93,1.05-26.54,3.2-2.87,.72-5.7,1.56-8.49,2.52-4.18,1.45-8.24,3.17-12.16,5.18-2.61,1.34-5.16,2.81-7.63,4.41-1.24,.8-2.45,1.63-3.65,2.49-5.98,4.32-11.44,9.45-16.21,15.43-1.91,2.39-3.71,4.92-5.39,7.58-.84,1.33-1.65,2.7-2.42,4.1-7.76,14-11.99,31.44-12.35,52.56-1.63,95.85,61.94,144.16,87.99,158.76,.99,.56,2.19,.88,3.54,.88,3.24,0,6.11-2.04,6.11-5.55h0c-.97-42.1,22.01-55.46,47.74-68.58,26.46-13.49,44.63-43.79,44.63-85.51,0-66.7-47.26-97.47-95.17-97.47h0Z'/%3e%3c/svg%3e";
|
|
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
|
+
console.log(response.status);
|
|
32
|
+
if (typeof response.data?.success === "boolean")
|
|
33
|
+
return response.data.success;
|
|
34
|
+
} catch (err) {
|
|
35
|
+
console.error(err);
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const TextareaStyle = {
|
|
40
|
+
color: "grey",
|
|
41
|
+
width: "100%",
|
|
42
|
+
display: "block",
|
|
43
|
+
backgroundColor: "#f6f6f6",
|
|
44
|
+
cursor: "default"
|
|
45
|
+
};
|
|
46
|
+
const BUttonStyle = { backgroundColor: "#e94642", border: "none", paddingTop: "0.6em", paddingBottom: "0.6em" };
|
|
7
47
|
const SettingsPage = () => {
|
|
8
48
|
const [licenseValue, setLicenseValue] = useState("");
|
|
9
49
|
const [isLoading, setIsLoading] = useState(true);
|
|
10
50
|
const [tokenValue, setTokenValue] = useState("");
|
|
11
51
|
const [isLoadingToken, setIsLoadingToken] = useState(false);
|
|
52
|
+
const [showDevOptions, setShowDevOptions] = useState(false);
|
|
12
53
|
const [showAlert, setShowAlert] = useState(false);
|
|
13
54
|
const [alertType, setAlertType] = useState("success");
|
|
14
55
|
const [alertMessage, setAlertMessage] = useState("");
|
|
56
|
+
const [devUrl, setDevUrl] = useState("");
|
|
15
57
|
const { get, post } = getFetchClient();
|
|
16
58
|
useEffect(() => {
|
|
17
59
|
const getLicense = async () => {
|
|
18
60
|
setIsLoading(true);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
console.error(err);
|
|
28
|
-
} finally {
|
|
29
|
-
setIsLoading(false);
|
|
61
|
+
const license = await loadLicense(get);
|
|
62
|
+
if (license)
|
|
63
|
+
setLicenseValue(license);
|
|
64
|
+
const dUrl = await loadDevUrl(get);
|
|
65
|
+
if (dUrl) {
|
|
66
|
+
console.log(dUrl);
|
|
67
|
+
setDevUrl(dUrl);
|
|
68
|
+
setShowDevOptions(true);
|
|
30
69
|
}
|
|
70
|
+
setIsLoading(false);
|
|
31
71
|
};
|
|
32
72
|
getLicense();
|
|
33
|
-
}, []);
|
|
73
|
+
}, [setLicenseValue, setDevUrl, setIsLoading, setShowDevOptions]);
|
|
34
74
|
useEffect(() => {
|
|
35
75
|
const fetchToken = async () => {
|
|
36
76
|
setIsLoadingToken(true);
|
|
@@ -50,7 +90,14 @@ const SettingsPage = () => {
|
|
|
50
90
|
fetchToken();
|
|
51
91
|
}, []);
|
|
52
92
|
const handleLicenseChange = (e) => {
|
|
53
|
-
setLicenseValue(e.target.value);
|
|
93
|
+
setLicenseValue(e.target.value.trim());
|
|
94
|
+
};
|
|
95
|
+
const handleUpdateUrl = async function() {
|
|
96
|
+
setIsLoading(true);
|
|
97
|
+
updateDevlUrl(post, devUrl).then(() => {
|
|
98
|
+
if (devUrl === "")
|
|
99
|
+
setShowDevOptions(false);
|
|
100
|
+
}).finally(() => setIsLoading(false));
|
|
54
101
|
};
|
|
55
102
|
const handleSaveLicense = async () => {
|
|
56
103
|
try {
|
|
@@ -86,6 +133,12 @@ const SettingsPage = () => {
|
|
|
86
133
|
setIsLoadingToken(false);
|
|
87
134
|
}
|
|
88
135
|
};
|
|
136
|
+
const onChangeDevOptions = function(val) {
|
|
137
|
+
if (val)
|
|
138
|
+
setShowDevOptions(val);
|
|
139
|
+
else
|
|
140
|
+
updateDevlUrl(post, "").finally(() => setShowDevOptions(val));
|
|
141
|
+
};
|
|
89
142
|
return /* @__PURE__ */ jsxs(Main, { children: [
|
|
90
143
|
showAlert && /* @__PURE__ */ jsx(
|
|
91
144
|
Box,
|
|
@@ -106,27 +159,27 @@ const SettingsPage = () => {
|
|
|
106
159
|
Box,
|
|
107
160
|
{
|
|
108
161
|
padding: 10,
|
|
109
|
-
paddingBottom: 0,
|
|
110
162
|
style: {
|
|
111
|
-
|
|
163
|
+
minHeight: "90vh",
|
|
112
164
|
marginTop: "5vh",
|
|
113
165
|
backgroundColor: "white",
|
|
114
166
|
color: "grey"
|
|
115
167
|
},
|
|
116
|
-
children: /* @__PURE__ */ jsxs(
|
|
117
|
-
/* @__PURE__ */ jsx(
|
|
168
|
+
children: /* @__PURE__ */ jsxs(Grid.Root, { children: [
|
|
169
|
+
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, children: /* @__PURE__ */ jsx(Box, { style: { textAlign: "right", width: "100%" }, children: /* @__PURE__ */ jsx(
|
|
118
170
|
"img",
|
|
119
171
|
{
|
|
120
172
|
src: TSlogoFarbig,
|
|
121
173
|
alt: "Translation Studio Logo",
|
|
122
174
|
style: {
|
|
123
|
-
|
|
124
|
-
height: "auto"
|
|
175
|
+
width: "300px",
|
|
176
|
+
height: "auto",
|
|
177
|
+
display: "inline-block"
|
|
125
178
|
}
|
|
126
179
|
}
|
|
127
|
-
),
|
|
128
|
-
/* @__PURE__ */ jsx(Typography, { variant: "beta", style: {
|
|
129
|
-
/* @__PURE__ */ jsxs(Typography, { variant: "charlie", children: [
|
|
180
|
+
) }) }),
|
|
181
|
+
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, style: { paddingTop: "2em" }, children: /* @__PURE__ */ jsx(Typography, { variant: "beta", style: { width: "100%" }, children: "translationstudio License" }) }),
|
|
182
|
+
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, style: { paddingBottom: "1em" }, children: /* @__PURE__ */ jsxs(Typography, { variant: "charlie", style: { width: "100%" }, children: [
|
|
130
183
|
"You can create or revoke a license at",
|
|
131
184
|
" ",
|
|
132
185
|
/* @__PURE__ */ jsx(
|
|
@@ -135,14 +188,13 @@ const SettingsPage = () => {
|
|
|
135
188
|
href: "https://account.translationstudio.tech/",
|
|
136
189
|
target: "_blank",
|
|
137
190
|
rel: "noopener noreferrer",
|
|
138
|
-
style: { textDecoration: "none", color: "#e94642"
|
|
191
|
+
style: { textDecoration: "none", color: "#e94642" },
|
|
139
192
|
children: "account.translationstudio.tech"
|
|
140
193
|
}
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
Textarea,
|
|
194
|
+
)
|
|
195
|
+
] }) }),
|
|
196
|
+
/* @__PURE__ */ jsx(Grid.Item, { xs: 10, children: /* @__PURE__ */ jsx(Box, { style: { width: "100%" }, children: /* @__PURE__ */ jsx(
|
|
197
|
+
TextInput,
|
|
146
198
|
{
|
|
147
199
|
name: "jwt-token",
|
|
148
200
|
label: "JWT Token",
|
|
@@ -151,20 +203,16 @@ const SettingsPage = () => {
|
|
|
151
203
|
value: licenseValue,
|
|
152
204
|
onChange: handleLicenseChange,
|
|
153
205
|
disabled: isLoading,
|
|
154
|
-
style:
|
|
155
|
-
color: "grey",
|
|
156
|
-
width: "25vw",
|
|
157
|
-
textAlign: "left",
|
|
158
|
-
backgroundColor: "#f6f6f6",
|
|
159
|
-
cursor: "text"
|
|
160
|
-
}
|
|
206
|
+
style: TextareaStyle
|
|
161
207
|
}
|
|
162
|
-
) }),
|
|
163
|
-
/* @__PURE__ */ jsx(
|
|
208
|
+
) }) }),
|
|
209
|
+
/* @__PURE__ */ jsx(Grid.Item, { xs: 2, children: /* @__PURE__ */ jsx(
|
|
164
210
|
Button,
|
|
165
211
|
{
|
|
166
212
|
onClick: handleSaveLicense,
|
|
167
|
-
|
|
213
|
+
disabled: isLoading,
|
|
214
|
+
style: BUttonStyle,
|
|
215
|
+
size: "L",
|
|
168
216
|
startIcon: /* @__PURE__ */ jsx(
|
|
169
217
|
"svg",
|
|
170
218
|
{
|
|
@@ -184,10 +232,11 @@ const SettingsPage = () => {
|
|
|
184
232
|
),
|
|
185
233
|
children: "Save license"
|
|
186
234
|
}
|
|
187
|
-
) })
|
|
188
|
-
/* @__PURE__ */ jsx(Typography, { variant: "beta", children: "Authorize
|
|
189
|
-
/* @__PURE__ */ jsx(
|
|
190
|
-
|
|
235
|
+
) }),
|
|
236
|
+
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, style: { paddingTop: "3em" }, children: /* @__PURE__ */ jsx(Typography, { variant: "beta", children: "Authorize translationstudio requests" }) }),
|
|
237
|
+
/* @__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." }) }),
|
|
238
|
+
/* @__PURE__ */ jsx(Grid.Item, { xs: 10, children: /* @__PURE__ */ jsx(Box, { style: { width: "100%" }, children: /* @__PURE__ */ jsx(
|
|
239
|
+
TextInput,
|
|
191
240
|
{
|
|
192
241
|
name: "access-token",
|
|
193
242
|
label: "Access Key",
|
|
@@ -197,69 +246,86 @@ const SettingsPage = () => {
|
|
|
197
246
|
onChange: () => {
|
|
198
247
|
},
|
|
199
248
|
disabled: true,
|
|
200
|
-
style:
|
|
201
|
-
color: "grey",
|
|
202
|
-
width: "25vw",
|
|
203
|
-
textAlign: "left",
|
|
204
|
-
backgroundColor: "#f6f6f6",
|
|
205
|
-
cursor: "default"
|
|
206
|
-
}
|
|
249
|
+
style: TextareaStyle
|
|
207
250
|
}
|
|
208
|
-
) }),
|
|
209
|
-
/* @__PURE__ */ jsx(
|
|
251
|
+
) }) }),
|
|
252
|
+
/* @__PURE__ */ jsx(Grid.Item, { xs: 2, children: /* @__PURE__ */ jsx(
|
|
210
253
|
Button,
|
|
211
254
|
{
|
|
212
255
|
onClick: handleGenerateToken,
|
|
213
|
-
style:
|
|
256
|
+
style: BUttonStyle,
|
|
214
257
|
disabled: isLoadingToken,
|
|
215
258
|
loading: isLoadingToken,
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
),
|
|
233
|
-
children: isLoadingToken ? "Generating..." : tokenValue ? "Generate new access key" : "Generate access key"
|
|
259
|
+
size: "L",
|
|
260
|
+
startIcon: /* @__PURE__ */ jsx(ArrowClockwise, {}),
|
|
261
|
+
children: isLoadingToken ? "Generating..." : tokenValue ? "New access key" : "Create access key"
|
|
262
|
+
}
|
|
263
|
+
) }),
|
|
264
|
+
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, style: { paddingTop: "5em" }, children: /* @__PURE__ */ jsx(Typography, { variant: "beta", children: "Customization" }) }),
|
|
265
|
+
/* @__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." }) }),
|
|
266
|
+
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, children: /* @__PURE__ */ jsx(
|
|
267
|
+
Switch,
|
|
268
|
+
{
|
|
269
|
+
checked: showDevOptions,
|
|
270
|
+
onCheckedChange: () => onChangeDevOptions(!showDevOptions),
|
|
271
|
+
onLabel: "Use custom translationstudio URL",
|
|
272
|
+
offLabel: "Custom translationstudio URL is currently disabled (default)",
|
|
273
|
+
visibleLabels: true
|
|
234
274
|
}
|
|
235
275
|
) }),
|
|
236
|
-
|
|
237
|
-
"
|
|
276
|
+
showDevOptions && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
277
|
+
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, style: { paddingTop: "2em" }, children: /* @__PURE__ */ jsx(Typography, { variant: "beta", children: "Use custom translationstudio URL." }) }),
|
|
278
|
+
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, style: { paddingBottom: "1em" }, children: /* @__PURE__ */ jsx(Typography, { variant: "delta", children: "This is usually only necessary for development purposes." }) }),
|
|
279
|
+
/* @__PURE__ */ jsx(Grid.Item, { xs: 10, children: /* @__PURE__ */ jsx(Box, { style: { width: "100%" }, children: /* @__PURE__ */ jsx(
|
|
280
|
+
TextInput,
|
|
281
|
+
{
|
|
282
|
+
onChange: (e) => setDevUrl(e.target.value.trim()),
|
|
283
|
+
name: "devurl",
|
|
284
|
+
label: "Custom translationstudio url",
|
|
285
|
+
placeholder: "Paste your custom translationstudio url here",
|
|
286
|
+
"aria-label": "translationstudio custom url",
|
|
287
|
+
value: devUrl,
|
|
288
|
+
style: TextareaStyle
|
|
289
|
+
}
|
|
290
|
+
) }) }),
|
|
291
|
+
/* @__PURE__ */ jsx(Grid.Item, { xs: 2, children: /* @__PURE__ */ jsx(
|
|
292
|
+
Button,
|
|
293
|
+
{
|
|
294
|
+
onClick: handleUpdateUrl,
|
|
295
|
+
style: BUttonStyle,
|
|
296
|
+
disabled: isLoadingToken,
|
|
297
|
+
loading: isLoadingToken,
|
|
298
|
+
startIcon: /* @__PURE__ */ jsx(Play, {}),
|
|
299
|
+
size: "L",
|
|
300
|
+
children: "Update URL"
|
|
301
|
+
}
|
|
302
|
+
) })
|
|
303
|
+
] }),
|
|
304
|
+
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, style: { paddingTop: "4em" }, children: /* @__PURE__ */ jsxs(Typography, { variant: "sigma", style: { width: "100%", textAlign: "right" }, children: [
|
|
305
|
+
"If you do not have a translationstudio account, please create one at",
|
|
238
306
|
" ",
|
|
239
307
|
/* @__PURE__ */ jsx(
|
|
240
308
|
"a",
|
|
241
309
|
{
|
|
242
|
-
href: "https://
|
|
310
|
+
href: "https://account.translationstudio.tech/",
|
|
243
311
|
target: "_blank",
|
|
244
312
|
rel: "noopener noreferrer",
|
|
245
313
|
style: { textDecoration: "none", color: "#e94642" },
|
|
246
|
-
children: "translationstudio"
|
|
314
|
+
children: "account.translationstudio.tech"
|
|
247
315
|
}
|
|
248
316
|
),
|
|
249
|
-
" ",
|
|
250
|
-
"account, please create one at",
|
|
251
|
-
" ",
|
|
317
|
+
". You can find further information at ",
|
|
252
318
|
/* @__PURE__ */ jsx(
|
|
253
319
|
"a",
|
|
254
320
|
{
|
|
255
|
-
href: "https://
|
|
321
|
+
href: "https://www.translationstudio.tech/",
|
|
256
322
|
target: "_blank",
|
|
257
323
|
rel: "noopener noreferrer",
|
|
258
324
|
style: { textDecoration: "none", color: "#e94642" },
|
|
259
|
-
children: "
|
|
325
|
+
children: "translationstudio.tech"
|
|
260
326
|
}
|
|
261
327
|
),
|
|
262
|
-
"
|
|
328
|
+
" "
|
|
263
329
|
] }) })
|
|
264
330
|
] })
|
|
265
331
|
}
|
|
@@ -5,34 +5,74 @@ const admin = require("@strapi/strapi/admin");
|
|
|
5
5
|
const reactRouterDom = require("react-router-dom");
|
|
6
6
|
const designSystem = require("@strapi/design-system");
|
|
7
7
|
const react = require("react");
|
|
8
|
+
const icons = require("@strapi/icons");
|
|
8
9
|
const TSlogoFarbig = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='Ebene_1'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201444.47%20635.72'%3e%3cdefs%3e%3cstyle%3e.cls-1{fill:%23e94642;}.cls-2{fill:%23231f20;}.cls-3{fill:%23a51d78;}%3c/style%3e%3c/defs%3e%3cpath%20class='cls-2'%20d='M1151.68,294.37c34.28,0,50.11,19.74,50.11,59.01v56.4c0,6.94-3.91,10.85-10.85,10.85h-2.6c-6.94,0-10.84-3.9-10.84-10.85v-54.45c0-27.12-10.41-39.91-33.41-39.91s-32.97,15.4-32.97,42.74v51.63c0,6.94-3.91,10.85-10.85,10.85h-2.6c-6.94,0-10.85-3.9-10.85-10.85v-102.39c0-6.94,3.91-10.85,10.85-10.85h2.6c6.94,0,10.85,3.91,10.85,10.85v12.34c5.64-14.39,19.73-25.36,40.56-25.36h0Z'/%3e%3cpath%20class='cls-2'%20d='M0,313.78v55.76c0,37.96,14.53,51.2,46.42,51.2h0c1.96,0,4.12-.03,6.29-.22,6.9-.65,9.8-4.45,9.11-11.07-.61-5.88-4.99-8.24-11.71-8.24-18.88,0-25.6-8.9-25.6-34.49v-52.94h25.81c6.94,0,10.85-3.47,10.85-9.54s-3.9-9.33-10.85-9.33H24.51v-15.83c0-7.59-4.34-11.28-11.93-9.55l-3.04,.65c-6.29,1.3-9.54,5.21-9.54,11.71v31.89Z'/%3e%3cpath%20class='cls-2'%20d='M139.49,295.02c7.38,0,11.06,4.77,10.2,11.71l-.22,1.74c-.65,6.94-4.77,9.54-11.93,9.54-20.39,.43-30.16,15.19-30.16,41.22v50.55c0,6.94-3.9,10.85-10.85,10.85h-2.6c-6.94,0-10.85-3.9-10.85-10.85v-102.39c0-6.94,3.9-10.85,10.85-10.85h2.6c6.94,0,10.85,3.69,10.85,10.41v10.41c3.91-11.07,13.89-22.34,32.1-22.34h0Z'/%3e%3cpath%20class='cls-2'%20d='M259.67,358.59c0-27.12-15.84-43.82-38.83-43.82s-38.4,16.49-38.4,43.82,15.62,44.04,38.83,44.04,38.4-16.7,38.4-44.04m-101.53,0c0-42.74,26.03-64.43,56.84-64.43,19.52,0,36.88,9.54,44.04,26.69v-13.45c0-6.94,3.9-10.85,10.85-10.85h2.6c6.94,0,10.85,3.9,10.85,10.85v102.18c0,6.94-3.9,10.85-10.85,10.85h-2.6c-6.94,0-10.85-3.9-10.85-10.85v-12.58c-6.94,16.7-24.51,26.47-43.82,26.47-30.81,0-57.06-21.91-57.06-64.87'/%3e%3cpath%20class='cls-2'%20d='M380.06,294.37c34.28,0,50.11,19.74,50.11,59.01v56.4c0,6.94-3.91,10.85-10.85,10.85h-2.6c-6.94,0-10.85-3.9-10.85-10.85v-54.45c0-27.12-10.41-39.91-33.41-39.91s-32.98,15.4-32.98,42.74v51.63c0,6.94-3.9,10.85-10.85,10.85h-2.6c-6.94,0-10.85-3.9-10.85-10.85v-102.39c0-6.94,3.91-10.85,10.85-10.85h2.6c6.94,0,10.85,3.91,10.85,10.85v12.34c5.64-14.39,19.73-25.36,40.57-25.36h0Z'/%3e%3cpath%20class='cls-2'%20d='M508.94,422.81c-20.8,0-42.78-8.33-53.19-21.48-4.44-5.61-2.26-11.49,4.99-13.67l2.17-.65c4.75-1.43,8.02-1.28,14.32,4.36,8.65,7.74,20.41,10.61,31.71,10.61,18.05,0,28.81-6.44,28.81-17.36,0-28.63-80.45-5.9-80.45-54.24,0-22.87,23.1-36.01,49.75-36.01,16.09,0,36.22,6.5,47,17.79,5.1,5.33,3.34,11.34-3.68,13.45l-2.17,.65c-5.86,1.76-8.85-.39-14.53-3.84-8.11-4.92-16.87-8.09-26.22-8.09-15.64,0-26.27,5.18-26.27,14.91,0,27.74,81.1,4.51,81.1,54.72,0,23.06-22.28,38.83-53.32,38.83h0Z'/%3e%3cpath%20class='cls-2'%20d='M585.05,409.79v-142.75c0-6.94,3.9-10.85,10.85-10.85h2.82c6.94,0,10.85,3.9,10.85,10.85v142.75c0,6.94-3.91,10.85-10.85,10.85h-2.82c-6.94,0-10.85-3.91-10.85-10.85'/%3e%3cpath%20class='cls-2'%20d='M737.56,358.59c0-27.12-15.84-43.82-38.84-43.82s-38.4,16.49-38.4,43.82,15.62,44.04,38.83,44.04,38.4-16.7,38.4-44.04m-101.53,0c0-42.74,26.03-64.43,56.84-64.43,19.52,0,36.88,9.54,44.04,26.69v-13.45c0-6.94,3.9-10.85,10.85-10.85h2.6c6.94,0,10.85,3.9,10.85,10.85v102.18c0,6.94-3.9,10.85-10.85,10.85h-2.6c-6.94,0-10.85-3.9-10.85-10.85v-12.58c-6.94,16.7-24.51,26.47-43.82,26.47-30.81,0-57.06-21.91-57.06-64.87'/%3e%3cpath%20class='cls-2'%20d='M800.25,315.42v55.76c0,37.96,14.53,51.2,46.42,51.2h0c1.95,0,4.12-.03,6.29-.22,6.89-.65,9.8-4.45,9.11-11.07-.61-5.88-4.99-8.24-11.71-8.24-18.87,0-25.6-8.9-25.6-34.49v-52.94h25.81c6.94,0,10.85-3.47,10.85-9.55s-3.91-9.33-10.85-9.33h-25.81v-15.83c0-7.59-4.34-11.28-11.93-9.54l-3.04,.65c-6.29,1.3-9.55,5.21-9.55,11.71v31.89Z'/%3e%3cpath%20class='cls-2'%20d='M883.72,409.79v-102.4c0-6.94,3.83-10.85,10.65-10.85h2.77c6.82,0,10.65,3.9,10.65,10.85v102.4c0,6.94-3.83,10.85-10.65,10.85h-2.77c-6.81,0-10.65-3.91-10.65-10.85m-2.05-142.96c0-8.24,6.08-13.02,14.32-13.02,7.59,0,14.32,4.77,14.32,13.02s-6.72,13.02-14.32,13.02c-8.24,0-14.32-4.77-14.32-13.02'/%3e%3cpath%20class='cls-2'%20d='M1036.06,358.59c0-27.12-15.62-43.82-38.62-43.82s-38.4,16.49-38.4,43.82,15.4,44.04,38.61,44.04,38.4-16.7,38.4-44.04m-101.31,0c0-44.69,31.02-64.43,62.69-64.43s62.91,19.74,62.91,64.43-31.02,64.87-62.7,64.87-62.91-19.74-62.91-64.87'/%3e%3cpath%20class='cls-2'%20d='M555.77,635.72c-20.98,0-43.14-8.4-53.65-21.66-4.48-5.66-2.27-11.59,5.03-13.78l2.19-.66c4.79-1.44,8.09-1.29,14.43,4.4,8.73,7.81,20.59,10.69,31.98,10.69,18.2,0,29.05-6.49,29.05-17.5,0-28.88-81.14-5.95-81.14-54.7,0-23.07,23.3-36.31,50.17-36.31,16.23,0,36.53,6.55,47.41,17.94,5.14,5.38,3.37,11.43-3.72,13.56l-2.19,.66c-5.91,1.77-8.92-.39-14.66-3.87-8.18-4.96-17.02-8.16-26.45-8.16-15.78,0-26.5,5.22-26.5,15.04,0,27.98,81.79,4.55,81.79,55.18,0,23.26-22.47,39.16-53.78,39.16h0Z'/%3e%3cpath%20class='cls-2'%20d='M639.98,526.42v56.23c0,38.29,14.66,51.63,46.82,51.63h0c1.97,0,4.16-.03,6.34-.22,6.96-.66,9.89-4.49,9.19-11.16-.61-5.93-5.03-8.31-11.81-8.31-19.03,0-25.82-8.97-25.82-34.79v-53.38h26.03c7,0,10.94-3.5,10.94-9.63s-3.94-9.41-10.94-9.41h-26.03v-15.97c0-7.66-4.38-11.38-12.03-9.63l-3.06,.66c-6.34,1.31-9.63,5.25-9.63,11.81v32.16Z'/%3e%3cpath%20class='cls-2'%20d='M826.59,508.39c7,0,10.94,3.94,10.94,10.94v103.27c0,7-3.94,10.94-10.94,10.94h-2.62c-7,0-10.94-3.94-10.94-10.94v-12.45c-5.69,14.51-19.9,25.57-40.91,25.57-34.57,0-50.54-19.91-50.54-59.51v-56.89c0-7,3.94-10.93,10.94-10.93h2.63c7,0,10.94,3.93,10.94,10.93v54.92c0,27.35,10.5,40.26,33.69,40.26s33.26-15.53,33.26-43.1v-52.07c0-7,3.94-10.93,10.94-10.93h2.62Z'/%3e%3cpath%20class='cls-2'%20d='M967.71,570.31c0-27.35-15.75-44.19-39.16-44.19s-38.72,16.63-38.72,44.19,15.75,44.41,39.16,44.41,38.72-16.85,38.72-44.41m-102.39,0c0-43.1,26.25-64.98,57.32-64.98,19.69,0,37.41,9.63,44.41,26.91v-54.26c0-7,3.94-10.94,10.94-10.94h2.62c7,0,10.94,3.94,10.94,10.94v143.74c0,7-3.94,10.94-10.94,10.94h-2.62c-7,0-10.94-3.94-10.94-10.94v-12.69c-7,16.85-24.72,26.69-44.19,26.69-31.07,0-57.54-22.09-57.54-65.41'/%3e%3cpath%20class='cls-2'%20d='M1023.66,623.38v-103.27c0-7,3.87-10.94,10.74-10.94h2.79c6.87,0,10.74,3.94,10.74,10.94v103.27c0,7-3.87,10.94-10.74,10.94h-2.79c-6.87,0-10.74-3.94-10.74-10.94m-2.07-144.18c0-8.31,6.13-13.13,14.44-13.13,7.66,0,14.44,4.81,14.44,13.13s-6.78,13.13-14.44,13.13c-8.31,0-14.44-4.81-14.44-13.13'/%3e%3cpath%20class='cls-2'%20d='M1177.29,570.31c0-27.35-15.75-44.19-38.94-44.19s-38.72,16.63-38.72,44.19,15.53,44.41,38.94,44.41,38.72-16.85,38.72-44.41m-102.17,0c0-45.07,31.29-64.98,63.23-64.98s63.45,19.91,63.45,64.98-31.29,65.41-63.23,65.41-63.45-19.91-63.45-65.41'/%3e%3cpath%20class='cls-3'%20d='M1366.99,177.21c7.75,6.65,16.32,15.32,24.3,26.23,19.82,27.08,29.56,59.09,28.94,95.13-.29,16.74-3.42,30.61-9.31,41.23-.55,1-1.14,1.99-1.74,2.94-1.17,1.86-2.46,3.67-3.82,5.37-3.28,4.11-7.15,7.78-11.48,10.91-.85,.61-1.73,1.21-2.61,1.79-1.77,1.14-3.63,2.22-5.54,3.2-2.85,1.46-5.89,2.76-9.03,3.84-2.08,.72-4.25,1.36-6.44,1.91-6.58,1.65-13.54,2.48-20.67,2.48-19.29,0-36.82-6.22-49.35-17.5-14.34-12.91-21.61-31.67-21.61-55.75,0-30.01,11.74-53.91,31.41-63.94,15.09-7.69,29.61-15.71,41.22-29.17,7.24-8.39,12.46-17.89,15.72-28.67m-14.08-37.87c-3.24,0-6.11,2.04-6.11,5.55h0c.97,42.1-22.01,55.46-47.74,68.58-26.46,13.49-44.63,43.79-44.63,85.51,0,66.7,47.26,97.47,95.17,97.47,8.98,0,17.93-1.05,26.54-3.2,2.87-.72,5.7-1.56,8.49-2.52,4.18-1.45,8.24-3.17,12.16-5.18,2.61-1.34,5.16-2.81,7.63-4.41,1.24-.8,2.45-1.63,3.65-2.49,5.98-4.32,11.44-9.45,16.21-15.43,1.91-2.39,3.71-4.92,5.39-7.58,.84-1.33,1.65-2.7,2.42-4.1,7.76-14,11.99-31.44,12.35-52.56,1.63-95.85-61.94-144.16-87.99-158.76-.99-.56-2.19-.88-3.54-.88h0Z'/%3e%3cpath%20class='cls-1'%20d='M1234.82,24.21c19.29,0,36.82,6.22,49.35,17.5,14.34,12.91,21.61,31.67,21.61,55.75,0,30.01-11.74,53.91-31.41,63.94-15.09,7.69-29.61,15.71-41.22,29.17-7.24,8.39-12.46,17.89-15.72,28.67-7.75-6.65-16.32-15.32-24.3-26.23-19.82-27.08-29.56-59.09-28.94-95.13,.29-16.74,3.42-30.61,9.31-41.23,.55-1,1.14-1.98,1.74-2.93,1.17-1.86,2.46-3.67,3.82-5.37,3.28-4.11,7.15-7.78,11.48-10.91,.85-.61,1.73-1.21,2.61-1.79,1.77-1.14,3.63-2.22,5.54-3.2,2.85-1.46,5.89-2.76,9.03-3.84,2.08-.72,4.25-1.36,6.44-1.91,6.58-1.65,13.54-2.48,20.67-2.48m0-24.21c-8.98,0-17.93,1.05-26.54,3.2-2.87,.72-5.7,1.56-8.49,2.52-4.18,1.45-8.24,3.17-12.16,5.18-2.61,1.34-5.16,2.81-7.63,4.41-1.24,.8-2.45,1.63-3.65,2.49-5.98,4.32-11.44,9.45-16.21,15.43-1.91,2.39-3.71,4.92-5.39,7.58-.84,1.33-1.65,2.7-2.42,4.1-7.76,14-11.99,31.44-12.35,52.56-1.63,95.85,61.94,144.16,87.99,158.76,.99,.56,2.19,.88,3.54,.88,3.24,0,6.11-2.04,6.11-5.55h0c-.97-42.1,22.01-55.46,47.74-68.58,26.46-13.49,44.63-43.79,44.63-85.51,0-66.7-47.26-97.47-95.17-97.47h0Z'/%3e%3c/svg%3e";
|
|
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
|
+
console.log(response.status);
|
|
34
|
+
if (typeof response.data?.success === "boolean")
|
|
35
|
+
return response.data.success;
|
|
36
|
+
} catch (err) {
|
|
37
|
+
console.error(err);
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
const TextareaStyle = {
|
|
42
|
+
color: "grey",
|
|
43
|
+
width: "100%",
|
|
44
|
+
display: "block",
|
|
45
|
+
backgroundColor: "#f6f6f6",
|
|
46
|
+
cursor: "default"
|
|
47
|
+
};
|
|
48
|
+
const BUttonStyle = { backgroundColor: "#e94642", border: "none", paddingTop: "0.6em", paddingBottom: "0.6em" };
|
|
9
49
|
const SettingsPage = () => {
|
|
10
50
|
const [licenseValue, setLicenseValue] = react.useState("");
|
|
11
51
|
const [isLoading, setIsLoading] = react.useState(true);
|
|
12
52
|
const [tokenValue, setTokenValue] = react.useState("");
|
|
13
53
|
const [isLoadingToken, setIsLoadingToken] = react.useState(false);
|
|
54
|
+
const [showDevOptions, setShowDevOptions] = react.useState(false);
|
|
14
55
|
const [showAlert, setShowAlert] = react.useState(false);
|
|
15
56
|
const [alertType, setAlertType] = react.useState("success");
|
|
16
57
|
const [alertMessage, setAlertMessage] = react.useState("");
|
|
58
|
+
const [devUrl, setDevUrl] = react.useState("");
|
|
17
59
|
const { get, post } = admin.getFetchClient();
|
|
18
60
|
react.useEffect(() => {
|
|
19
61
|
const getLicense = async () => {
|
|
20
62
|
setIsLoading(true);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
console.error(err);
|
|
30
|
-
} finally {
|
|
31
|
-
setIsLoading(false);
|
|
63
|
+
const license = await loadLicense(get);
|
|
64
|
+
if (license)
|
|
65
|
+
setLicenseValue(license);
|
|
66
|
+
const dUrl = await loadDevUrl(get);
|
|
67
|
+
if (dUrl) {
|
|
68
|
+
console.log(dUrl);
|
|
69
|
+
setDevUrl(dUrl);
|
|
70
|
+
setShowDevOptions(true);
|
|
32
71
|
}
|
|
72
|
+
setIsLoading(false);
|
|
33
73
|
};
|
|
34
74
|
getLicense();
|
|
35
|
-
}, []);
|
|
75
|
+
}, [setLicenseValue, setDevUrl, setIsLoading, setShowDevOptions]);
|
|
36
76
|
react.useEffect(() => {
|
|
37
77
|
const fetchToken = async () => {
|
|
38
78
|
setIsLoadingToken(true);
|
|
@@ -52,7 +92,14 @@ const SettingsPage = () => {
|
|
|
52
92
|
fetchToken();
|
|
53
93
|
}, []);
|
|
54
94
|
const handleLicenseChange = (e) => {
|
|
55
|
-
setLicenseValue(e.target.value);
|
|
95
|
+
setLicenseValue(e.target.value.trim());
|
|
96
|
+
};
|
|
97
|
+
const handleUpdateUrl = async function() {
|
|
98
|
+
setIsLoading(true);
|
|
99
|
+
updateDevlUrl(post, devUrl).then(() => {
|
|
100
|
+
if (devUrl === "")
|
|
101
|
+
setShowDevOptions(false);
|
|
102
|
+
}).finally(() => setIsLoading(false));
|
|
56
103
|
};
|
|
57
104
|
const handleSaveLicense = async () => {
|
|
58
105
|
try {
|
|
@@ -88,6 +135,12 @@ const SettingsPage = () => {
|
|
|
88
135
|
setIsLoadingToken(false);
|
|
89
136
|
}
|
|
90
137
|
};
|
|
138
|
+
const onChangeDevOptions = function(val) {
|
|
139
|
+
if (val)
|
|
140
|
+
setShowDevOptions(val);
|
|
141
|
+
else
|
|
142
|
+
updateDevlUrl(post, "").finally(() => setShowDevOptions(val));
|
|
143
|
+
};
|
|
91
144
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Main, { children: [
|
|
92
145
|
showAlert && /* @__PURE__ */ jsxRuntime.jsx(
|
|
93
146
|
designSystem.Box,
|
|
@@ -108,27 +161,27 @@ const SettingsPage = () => {
|
|
|
108
161
|
designSystem.Box,
|
|
109
162
|
{
|
|
110
163
|
padding: 10,
|
|
111
|
-
paddingBottom: 0,
|
|
112
164
|
style: {
|
|
113
|
-
|
|
165
|
+
minHeight: "90vh",
|
|
114
166
|
marginTop: "5vh",
|
|
115
167
|
backgroundColor: "white",
|
|
116
168
|
color: "grey"
|
|
117
169
|
},
|
|
118
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.
|
|
119
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
170
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { children: [
|
|
171
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { textAlign: "right", width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
120
172
|
"img",
|
|
121
173
|
{
|
|
122
174
|
src: TSlogoFarbig,
|
|
123
175
|
alt: "Translation Studio Logo",
|
|
124
176
|
style: {
|
|
125
|
-
|
|
126
|
-
height: "auto"
|
|
177
|
+
width: "300px",
|
|
178
|
+
height: "auto",
|
|
179
|
+
display: "inline-block"
|
|
127
180
|
}
|
|
128
181
|
}
|
|
129
|
-
),
|
|
130
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", style: {
|
|
131
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "charlie", children: [
|
|
182
|
+
) }) }),
|
|
183
|
+
/* @__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" }) }),
|
|
184
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, style: { paddingBottom: "1em" }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "charlie", style: { width: "100%" }, children: [
|
|
132
185
|
"You can create or revoke a license at",
|
|
133
186
|
" ",
|
|
134
187
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -137,14 +190,13 @@ const SettingsPage = () => {
|
|
|
137
190
|
href: "https://account.translationstudio.tech/",
|
|
138
191
|
target: "_blank",
|
|
139
192
|
rel: "noopener noreferrer",
|
|
140
|
-
style: { textDecoration: "none", color: "#e94642"
|
|
193
|
+
style: { textDecoration: "none", color: "#e94642" },
|
|
141
194
|
children: "account.translationstudio.tech"
|
|
142
195
|
}
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
designSystem.Textarea,
|
|
196
|
+
)
|
|
197
|
+
] }) }),
|
|
198
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 10, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
199
|
+
designSystem.TextInput,
|
|
148
200
|
{
|
|
149
201
|
name: "jwt-token",
|
|
150
202
|
label: "JWT Token",
|
|
@@ -153,20 +205,16 @@ const SettingsPage = () => {
|
|
|
153
205
|
value: licenseValue,
|
|
154
206
|
onChange: handleLicenseChange,
|
|
155
207
|
disabled: isLoading,
|
|
156
|
-
style:
|
|
157
|
-
color: "grey",
|
|
158
|
-
width: "25vw",
|
|
159
|
-
textAlign: "left",
|
|
160
|
-
backgroundColor: "#f6f6f6",
|
|
161
|
-
cursor: "text"
|
|
162
|
-
}
|
|
208
|
+
style: TextareaStyle
|
|
163
209
|
}
|
|
164
|
-
) }),
|
|
165
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
|
210
|
+
) }) }),
|
|
211
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
166
212
|
designSystem.Button,
|
|
167
213
|
{
|
|
168
214
|
onClick: handleSaveLicense,
|
|
169
|
-
|
|
215
|
+
disabled: isLoading,
|
|
216
|
+
style: BUttonStyle,
|
|
217
|
+
size: "L",
|
|
170
218
|
startIcon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
171
219
|
"svg",
|
|
172
220
|
{
|
|
@@ -186,10 +234,11 @@ const SettingsPage = () => {
|
|
|
186
234
|
),
|
|
187
235
|
children: "Save license"
|
|
188
236
|
}
|
|
189
|
-
) })
|
|
190
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", children: "Authorize
|
|
191
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
|
192
|
-
|
|
237
|
+
) }),
|
|
238
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, style: { paddingTop: "3em" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", children: "Authorize translationstudio requests" }) }),
|
|
239
|
+
/* @__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." }) }),
|
|
240
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 10, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
241
|
+
designSystem.TextInput,
|
|
193
242
|
{
|
|
194
243
|
name: "access-token",
|
|
195
244
|
label: "Access Key",
|
|
@@ -199,69 +248,86 @@ const SettingsPage = () => {
|
|
|
199
248
|
onChange: () => {
|
|
200
249
|
},
|
|
201
250
|
disabled: true,
|
|
202
|
-
style:
|
|
203
|
-
color: "grey",
|
|
204
|
-
width: "25vw",
|
|
205
|
-
textAlign: "left",
|
|
206
|
-
backgroundColor: "#f6f6f6",
|
|
207
|
-
cursor: "default"
|
|
208
|
-
}
|
|
251
|
+
style: TextareaStyle
|
|
209
252
|
}
|
|
210
|
-
) }),
|
|
211
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
|
253
|
+
) }) }),
|
|
254
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
212
255
|
designSystem.Button,
|
|
213
256
|
{
|
|
214
257
|
onClick: handleGenerateToken,
|
|
215
|
-
style:
|
|
258
|
+
style: BUttonStyle,
|
|
216
259
|
disabled: isLoadingToken,
|
|
217
260
|
loading: isLoadingToken,
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
),
|
|
235
|
-
children: isLoadingToken ? "Generating..." : tokenValue ? "Generate new access key" : "Generate access key"
|
|
261
|
+
size: "L",
|
|
262
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowClockwise, {}),
|
|
263
|
+
children: isLoadingToken ? "Generating..." : tokenValue ? "New access key" : "Create access key"
|
|
264
|
+
}
|
|
265
|
+
) }),
|
|
266
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, style: { paddingTop: "5em" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", children: "Customization" }) }),
|
|
267
|
+
/* @__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." }) }),
|
|
268
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
269
|
+
designSystem.Switch,
|
|
270
|
+
{
|
|
271
|
+
checked: showDevOptions,
|
|
272
|
+
onCheckedChange: () => onChangeDevOptions(!showDevOptions),
|
|
273
|
+
onLabel: "Use custom translationstudio URL",
|
|
274
|
+
offLabel: "Custom translationstudio URL is currently disabled (default)",
|
|
275
|
+
visibleLabels: true
|
|
236
276
|
}
|
|
237
277
|
) }),
|
|
238
|
-
|
|
239
|
-
"
|
|
278
|
+
showDevOptions && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
279
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, style: { paddingTop: "2em" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", children: "Use custom translationstudio URL." }) }),
|
|
280
|
+
/* @__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." }) }),
|
|
281
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 10, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
282
|
+
designSystem.TextInput,
|
|
283
|
+
{
|
|
284
|
+
onChange: (e) => setDevUrl(e.target.value.trim()),
|
|
285
|
+
name: "devurl",
|
|
286
|
+
label: "Custom translationstudio url",
|
|
287
|
+
placeholder: "Paste your custom translationstudio url here",
|
|
288
|
+
"aria-label": "translationstudio custom url",
|
|
289
|
+
value: devUrl,
|
|
290
|
+
style: TextareaStyle
|
|
291
|
+
}
|
|
292
|
+
) }) }),
|
|
293
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
294
|
+
designSystem.Button,
|
|
295
|
+
{
|
|
296
|
+
onClick: handleUpdateUrl,
|
|
297
|
+
style: BUttonStyle,
|
|
298
|
+
disabled: isLoadingToken,
|
|
299
|
+
loading: isLoadingToken,
|
|
300
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Play, {}),
|
|
301
|
+
size: "L",
|
|
302
|
+
children: "Update URL"
|
|
303
|
+
}
|
|
304
|
+
) })
|
|
305
|
+
] }),
|
|
306
|
+
/* @__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: [
|
|
307
|
+
"If you do not have a translationstudio account, please create one at",
|
|
240
308
|
" ",
|
|
241
309
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
242
310
|
"a",
|
|
243
311
|
{
|
|
244
|
-
href: "https://
|
|
312
|
+
href: "https://account.translationstudio.tech/",
|
|
245
313
|
target: "_blank",
|
|
246
314
|
rel: "noopener noreferrer",
|
|
247
315
|
style: { textDecoration: "none", color: "#e94642" },
|
|
248
|
-
children: "translationstudio"
|
|
316
|
+
children: "account.translationstudio.tech"
|
|
249
317
|
}
|
|
250
318
|
),
|
|
251
|
-
" ",
|
|
252
|
-
"account, please create one at",
|
|
253
|
-
" ",
|
|
319
|
+
". You can find further information at ",
|
|
254
320
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
255
321
|
"a",
|
|
256
322
|
{
|
|
257
|
-
href: "https://
|
|
323
|
+
href: "https://www.translationstudio.tech/",
|
|
258
324
|
target: "_blank",
|
|
259
325
|
rel: "noopener noreferrer",
|
|
260
326
|
style: { textDecoration: "none", color: "#e94642" },
|
|
261
|
-
children: "
|
|
327
|
+
children: "translationstudio.tech"
|
|
262
328
|
}
|
|
263
329
|
),
|
|
264
|
-
"
|
|
330
|
+
" "
|
|
265
331
|
] }) })
|
|
266
332
|
] })
|
|
267
333
|
}
|
package/dist/admin/index.js
CHANGED
|
@@ -307,7 +307,7 @@ const index = {
|
|
|
307
307
|
defaultMessage: PLUGIN_ID
|
|
308
308
|
},
|
|
309
309
|
Component: async () => {
|
|
310
|
-
const { App } = await Promise.resolve().then(() => require("../_chunks/App-
|
|
310
|
+
const { App } = await Promise.resolve().then(() => require("../_chunks/App-DkdbSZwI.js"));
|
|
311
311
|
return App;
|
|
312
312
|
}
|
|
313
313
|
});
|
package/dist/admin/index.mjs
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -81,6 +81,27 @@ const controller = ({ strapi: strapi2 }) => ({
|
|
|
81
81
|
ctx.status = 200;
|
|
82
82
|
ctx.body = [{ fields: result }];
|
|
83
83
|
},
|
|
84
|
+
async setDevelopmentUrl(ctx) {
|
|
85
|
+
const url = ctx.request.body.url;
|
|
86
|
+
const result = await strapi2.plugin(APP_NAME$1).service("service").setDevelopmentUrl(url);
|
|
87
|
+
if (result) {
|
|
88
|
+
ctx.status = 200;
|
|
89
|
+
ctx.body = { success: true };
|
|
90
|
+
} else {
|
|
91
|
+
ctx.status = 500;
|
|
92
|
+
ctx.body = { success: false };
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
async getDevelopmentUrl(ctx) {
|
|
96
|
+
const url = await strapi2.plugin(APP_NAME$1).service("service").getDevelopmentUrl();
|
|
97
|
+
if (url) {
|
|
98
|
+
ctx.status = 200;
|
|
99
|
+
ctx.body = { url };
|
|
100
|
+
} else {
|
|
101
|
+
ctx.status = 404;
|
|
102
|
+
ctx.body = { url: "" };
|
|
103
|
+
}
|
|
104
|
+
},
|
|
84
105
|
async importData(ctx) {
|
|
85
106
|
if (!await this.validateToken(ctx)) {
|
|
86
107
|
ctx.status = 400;
|
|
@@ -144,6 +165,22 @@ const routes = [
|
|
|
144
165
|
policies: []
|
|
145
166
|
}
|
|
146
167
|
},
|
|
168
|
+
{
|
|
169
|
+
method: "GET",
|
|
170
|
+
path: "/devurl",
|
|
171
|
+
handler: "controller.getDevelopmentUrl",
|
|
172
|
+
config: {
|
|
173
|
+
policies: []
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
method: "POST",
|
|
178
|
+
path: "/devurl",
|
|
179
|
+
handler: "controller.setDevelopmentUrl",
|
|
180
|
+
config: {
|
|
181
|
+
policies: []
|
|
182
|
+
}
|
|
183
|
+
},
|
|
147
184
|
{
|
|
148
185
|
method: "GET",
|
|
149
186
|
path: "/getToken",
|
|
@@ -943,9 +980,9 @@ function prepareImportData(translatables, existingEntry, targetSchema) {
|
|
|
943
980
|
return withDynamicZones;
|
|
944
981
|
}, {});
|
|
945
982
|
}
|
|
946
|
-
|
|
983
|
+
require("jsonwebtoken");
|
|
947
984
|
const crypto = require("crypto");
|
|
948
|
-
const TRANSLATIONTUDIO_URL = "https://
|
|
985
|
+
const TRANSLATIONTUDIO_URL = "https://strapi.translationstudio.tech";
|
|
949
986
|
const APP_NAME = "translationstudio";
|
|
950
987
|
const service = ({ strapi: strapi2 }) => {
|
|
951
988
|
const pluginStore = strapi2.store({
|
|
@@ -958,6 +995,16 @@ const service = ({ strapi: strapi2 }) => {
|
|
|
958
995
|
const result = await pluginStore.get({ key: "license" });
|
|
959
996
|
return { license: result };
|
|
960
997
|
},
|
|
998
|
+
async getTranslationstudioUrl() {
|
|
999
|
+
try {
|
|
1000
|
+
const result = await pluginStore.get({ key: "developurl" });
|
|
1001
|
+
if (typeof result === "string" && result !== "")
|
|
1002
|
+
return result;
|
|
1003
|
+
} catch (err) {
|
|
1004
|
+
console.warn(err);
|
|
1005
|
+
}
|
|
1006
|
+
return TRANSLATIONTUDIO_URL;
|
|
1007
|
+
},
|
|
961
1008
|
async setLicense(license) {
|
|
962
1009
|
try {
|
|
963
1010
|
await pluginStore.set({
|
|
@@ -969,6 +1016,26 @@ const service = ({ strapi: strapi2 }) => {
|
|
|
969
1016
|
return { success: false };
|
|
970
1017
|
}
|
|
971
1018
|
},
|
|
1019
|
+
async setDevelopmentUrl(url) {
|
|
1020
|
+
try {
|
|
1021
|
+
await pluginStore.set({
|
|
1022
|
+
key: "developurl",
|
|
1023
|
+
value: url
|
|
1024
|
+
});
|
|
1025
|
+
return true;
|
|
1026
|
+
} catch (error) {
|
|
1027
|
+
return false;
|
|
1028
|
+
}
|
|
1029
|
+
},
|
|
1030
|
+
async getDevelopmentUrl() {
|
|
1031
|
+
try {
|
|
1032
|
+
const result = await pluginStore.get({ key: "developurl" });
|
|
1033
|
+
if (typeof result === "string")
|
|
1034
|
+
return result;
|
|
1035
|
+
} catch (error) {
|
|
1036
|
+
}
|
|
1037
|
+
return "";
|
|
1038
|
+
},
|
|
972
1039
|
// Access Token
|
|
973
1040
|
async getToken() {
|
|
974
1041
|
try {
|
|
@@ -980,23 +1047,16 @@ const service = ({ strapi: strapi2 }) => {
|
|
|
980
1047
|
},
|
|
981
1048
|
async generateToken() {
|
|
982
1049
|
const secretKey = crypto.randomBytes(64).toString("hex");
|
|
983
|
-
const token = jwt.sign(
|
|
984
|
-
{
|
|
985
|
-
app: APP_NAME,
|
|
986
|
-
iat: Math.floor(Date.now() / 1e3)
|
|
987
|
-
},
|
|
988
|
-
secretKey,
|
|
989
|
-
{ expiresIn: "10y" }
|
|
990
|
-
);
|
|
991
1050
|
await pluginStore.set({
|
|
992
1051
|
key: "token",
|
|
993
|
-
value:
|
|
1052
|
+
value: secretKey
|
|
994
1053
|
});
|
|
995
|
-
return { token };
|
|
1054
|
+
return { token: secretKey };
|
|
996
1055
|
},
|
|
997
1056
|
async getLanguageOptions() {
|
|
998
1057
|
const { license } = await this.getLicense();
|
|
999
|
-
const
|
|
1058
|
+
const url = await this.getTranslationstudioUrl();
|
|
1059
|
+
const response = await fetch(url + "/mappings", {
|
|
1000
1060
|
headers: { Authorization: `${license}` }
|
|
1001
1061
|
});
|
|
1002
1062
|
const responseData = await response.json();
|
|
@@ -1034,7 +1094,8 @@ const service = ({ strapi: strapi2 }) => {
|
|
|
1034
1094
|
},
|
|
1035
1095
|
async requestTranslation(payload) {
|
|
1036
1096
|
const { license } = await this.getLicense();
|
|
1037
|
-
const
|
|
1097
|
+
const url = await this.getTranslationstudioUrl();
|
|
1098
|
+
const response = await fetch(url + "/translate", {
|
|
1038
1099
|
method: "POST",
|
|
1039
1100
|
headers: {
|
|
1040
1101
|
Authorization: `${license}`,
|
package/dist/server/index.mjs
CHANGED
|
@@ -80,6 +80,27 @@ const controller = ({ strapi: strapi2 }) => ({
|
|
|
80
80
|
ctx.status = 200;
|
|
81
81
|
ctx.body = [{ fields: result }];
|
|
82
82
|
},
|
|
83
|
+
async setDevelopmentUrl(ctx) {
|
|
84
|
+
const url = ctx.request.body.url;
|
|
85
|
+
const result = await strapi2.plugin(APP_NAME$1).service("service").setDevelopmentUrl(url);
|
|
86
|
+
if (result) {
|
|
87
|
+
ctx.status = 200;
|
|
88
|
+
ctx.body = { success: true };
|
|
89
|
+
} else {
|
|
90
|
+
ctx.status = 500;
|
|
91
|
+
ctx.body = { success: false };
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
async getDevelopmentUrl(ctx) {
|
|
95
|
+
const url = await strapi2.plugin(APP_NAME$1).service("service").getDevelopmentUrl();
|
|
96
|
+
if (url) {
|
|
97
|
+
ctx.status = 200;
|
|
98
|
+
ctx.body = { url };
|
|
99
|
+
} else {
|
|
100
|
+
ctx.status = 404;
|
|
101
|
+
ctx.body = { url: "" };
|
|
102
|
+
}
|
|
103
|
+
},
|
|
83
104
|
async importData(ctx) {
|
|
84
105
|
if (!await this.validateToken(ctx)) {
|
|
85
106
|
ctx.status = 400;
|
|
@@ -143,6 +164,22 @@ const routes = [
|
|
|
143
164
|
policies: []
|
|
144
165
|
}
|
|
145
166
|
},
|
|
167
|
+
{
|
|
168
|
+
method: "GET",
|
|
169
|
+
path: "/devurl",
|
|
170
|
+
handler: "controller.getDevelopmentUrl",
|
|
171
|
+
config: {
|
|
172
|
+
policies: []
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
method: "POST",
|
|
177
|
+
path: "/devurl",
|
|
178
|
+
handler: "controller.setDevelopmentUrl",
|
|
179
|
+
config: {
|
|
180
|
+
policies: []
|
|
181
|
+
}
|
|
182
|
+
},
|
|
146
183
|
{
|
|
147
184
|
method: "GET",
|
|
148
185
|
path: "/getToken",
|
|
@@ -942,9 +979,9 @@ function prepareImportData(translatables, existingEntry, targetSchema) {
|
|
|
942
979
|
return withDynamicZones;
|
|
943
980
|
}, {});
|
|
944
981
|
}
|
|
945
|
-
|
|
982
|
+
require("jsonwebtoken");
|
|
946
983
|
const crypto = require("crypto");
|
|
947
|
-
const TRANSLATIONTUDIO_URL = "https://
|
|
984
|
+
const TRANSLATIONTUDIO_URL = "https://strapi.translationstudio.tech";
|
|
948
985
|
const APP_NAME = "translationstudio";
|
|
949
986
|
const service = ({ strapi: strapi2 }) => {
|
|
950
987
|
const pluginStore = strapi2.store({
|
|
@@ -957,6 +994,16 @@ const service = ({ strapi: strapi2 }) => {
|
|
|
957
994
|
const result = await pluginStore.get({ key: "license" });
|
|
958
995
|
return { license: result };
|
|
959
996
|
},
|
|
997
|
+
async getTranslationstudioUrl() {
|
|
998
|
+
try {
|
|
999
|
+
const result = await pluginStore.get({ key: "developurl" });
|
|
1000
|
+
if (typeof result === "string" && result !== "")
|
|
1001
|
+
return result;
|
|
1002
|
+
} catch (err) {
|
|
1003
|
+
console.warn(err);
|
|
1004
|
+
}
|
|
1005
|
+
return TRANSLATIONTUDIO_URL;
|
|
1006
|
+
},
|
|
960
1007
|
async setLicense(license) {
|
|
961
1008
|
try {
|
|
962
1009
|
await pluginStore.set({
|
|
@@ -968,6 +1015,26 @@ const service = ({ strapi: strapi2 }) => {
|
|
|
968
1015
|
return { success: false };
|
|
969
1016
|
}
|
|
970
1017
|
},
|
|
1018
|
+
async setDevelopmentUrl(url) {
|
|
1019
|
+
try {
|
|
1020
|
+
await pluginStore.set({
|
|
1021
|
+
key: "developurl",
|
|
1022
|
+
value: url
|
|
1023
|
+
});
|
|
1024
|
+
return true;
|
|
1025
|
+
} catch (error) {
|
|
1026
|
+
return false;
|
|
1027
|
+
}
|
|
1028
|
+
},
|
|
1029
|
+
async getDevelopmentUrl() {
|
|
1030
|
+
try {
|
|
1031
|
+
const result = await pluginStore.get({ key: "developurl" });
|
|
1032
|
+
if (typeof result === "string")
|
|
1033
|
+
return result;
|
|
1034
|
+
} catch (error) {
|
|
1035
|
+
}
|
|
1036
|
+
return "";
|
|
1037
|
+
},
|
|
971
1038
|
// Access Token
|
|
972
1039
|
async getToken() {
|
|
973
1040
|
try {
|
|
@@ -979,23 +1046,16 @@ const service = ({ strapi: strapi2 }) => {
|
|
|
979
1046
|
},
|
|
980
1047
|
async generateToken() {
|
|
981
1048
|
const secretKey = crypto.randomBytes(64).toString("hex");
|
|
982
|
-
const token = jwt.sign(
|
|
983
|
-
{
|
|
984
|
-
app: APP_NAME,
|
|
985
|
-
iat: Math.floor(Date.now() / 1e3)
|
|
986
|
-
},
|
|
987
|
-
secretKey,
|
|
988
|
-
{ expiresIn: "10y" }
|
|
989
|
-
);
|
|
990
1049
|
await pluginStore.set({
|
|
991
1050
|
key: "token",
|
|
992
|
-
value:
|
|
1051
|
+
value: secretKey
|
|
993
1052
|
});
|
|
994
|
-
return { token };
|
|
1053
|
+
return { token: secretKey };
|
|
995
1054
|
},
|
|
996
1055
|
async getLanguageOptions() {
|
|
997
1056
|
const { license } = await this.getLicense();
|
|
998
|
-
const
|
|
1057
|
+
const url = await this.getTranslationstudioUrl();
|
|
1058
|
+
const response = await fetch(url + "/mappings", {
|
|
999
1059
|
headers: { Authorization: `${license}` }
|
|
1000
1060
|
});
|
|
1001
1061
|
const responseData = await response.json();
|
|
@@ -1033,7 +1093,8 @@ const service = ({ strapi: strapi2 }) => {
|
|
|
1033
1093
|
},
|
|
1034
1094
|
async requestTranslation(payload) {
|
|
1035
1095
|
const { license } = await this.getLicense();
|
|
1036
|
-
const
|
|
1096
|
+
const url = await this.getTranslationstudioUrl();
|
|
1097
|
+
const response = await fetch(url + "/translate", {
|
|
1037
1098
|
method: "POST",
|
|
1038
1099
|
headers: {
|
|
1039
1100
|
Authorization: `${license}`,
|
|
@@ -10,6 +10,8 @@ declare const controller: ({ strapi }: {
|
|
|
10
10
|
getLanguageOptions(ctx: any): Promise<void>;
|
|
11
11
|
requestTranslation(ctx: any): Promise<void>;
|
|
12
12
|
exportData(ctx: any): Promise<void>;
|
|
13
|
+
setDevelopmentUrl(ctx: any): Promise<void>;
|
|
14
|
+
getDevelopmentUrl(ctx: any): Promise<void>;
|
|
13
15
|
importData(ctx: any): Promise<void>;
|
|
14
16
|
ping(ctx: any): Promise<void>;
|
|
15
17
|
getLanguages(ctx: any): Promise<void>;
|
|
@@ -10,6 +10,8 @@ declare const _default: {
|
|
|
10
10
|
getLanguageOptions(ctx: any): Promise<void>;
|
|
11
11
|
requestTranslation(ctx: any): Promise<void>;
|
|
12
12
|
exportData(ctx: any): Promise<void>;
|
|
13
|
+
setDevelopmentUrl(ctx: any): Promise<void>;
|
|
14
|
+
getDevelopmentUrl(ctx: any): Promise<void>;
|
|
13
15
|
importData(ctx: any): Promise<void>;
|
|
14
16
|
ping(ctx: any): Promise<void>;
|
|
15
17
|
getLanguages(ctx: any): Promise<void>;
|
|
@@ -24,6 +24,8 @@ declare const _default: {
|
|
|
24
24
|
getLanguageOptions(ctx: any): Promise<void>;
|
|
25
25
|
requestTranslation(ctx: any): Promise<void>;
|
|
26
26
|
exportData(ctx: any): Promise<void>;
|
|
27
|
+
setDevelopmentUrl(ctx: any): Promise<void>;
|
|
28
|
+
getDevelopmentUrl(ctx: any): Promise<void>;
|
|
27
29
|
importData(ctx: any): Promise<void>;
|
|
28
30
|
ping(ctx: any): Promise<void>;
|
|
29
31
|
getLanguages(ctx: any): Promise<void>;
|
|
@@ -55,9 +57,12 @@ declare const _default: {
|
|
|
55
57
|
getLicense(): Promise<{
|
|
56
58
|
license: unknown;
|
|
57
59
|
}>;
|
|
60
|
+
getTranslationstudioUrl(): Promise<string>;
|
|
58
61
|
setLicense(license: string): Promise<{
|
|
59
62
|
success: boolean;
|
|
60
63
|
}>;
|
|
64
|
+
setDevelopmentUrl(url: string): Promise<boolean>;
|
|
65
|
+
getDevelopmentUrl(): Promise<string>;
|
|
61
66
|
getToken(): Promise<{
|
|
62
67
|
token: unknown;
|
|
63
68
|
}>;
|
|
@@ -5,9 +5,12 @@ declare const _default: {
|
|
|
5
5
|
getLicense(): Promise<{
|
|
6
6
|
license: unknown;
|
|
7
7
|
}>;
|
|
8
|
+
getTranslationstudioUrl(): Promise<string>;
|
|
8
9
|
setLicense(license: string): Promise<{
|
|
9
10
|
success: boolean;
|
|
10
11
|
}>;
|
|
12
|
+
setDevelopmentUrl(url: string): Promise<boolean>;
|
|
13
|
+
getDevelopmentUrl(): Promise<string>;
|
|
11
14
|
getToken(): Promise<{
|
|
12
15
|
token: unknown;
|
|
13
16
|
}>;
|
|
@@ -6,9 +6,12 @@ declare const service: ({ strapi }: {
|
|
|
6
6
|
getLicense(): Promise<{
|
|
7
7
|
license: unknown;
|
|
8
8
|
}>;
|
|
9
|
+
getTranslationstudioUrl(): Promise<string>;
|
|
9
10
|
setLicense(license: string): Promise<{
|
|
10
11
|
success: boolean;
|
|
11
12
|
}>;
|
|
13
|
+
setDevelopmentUrl(url: string): Promise<boolean>;
|
|
14
|
+
getDevelopmentUrl(): Promise<string>;
|
|
12
15
|
getToken(): Promise<{
|
|
13
16
|
token: unknown;
|
|
14
17
|
}>;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"license": "GPL-2.0-only",
|
|
5
5
|
"author": "Duncan Leininger <duncan.leininger@idmedia.com>",
|
|
6
6
|
"homepage": "https://translationstudio.tech",
|
|
7
|
-
"version": "1.1.
|
|
7
|
+
"version": "1.1.3",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"translationstudio",
|
|
10
10
|
"strapi",
|
|
@@ -49,17 +49,17 @@
|
|
|
49
49
|
"react-intl": "^7.1.10"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@strapi/strapi": "^5.12.4",
|
|
53
52
|
"@strapi/sdk-plugin": "^5.3.2",
|
|
54
|
-
"
|
|
53
|
+
"@strapi/strapi": "^5.12.4",
|
|
54
|
+
"@strapi/typescript-utils": "^5.5.0",
|
|
55
55
|
"@types/react": "^18.3.1",
|
|
56
56
|
"@types/react-dom": "^18.3.1",
|
|
57
|
-
"
|
|
57
|
+
"prettier": "^3.4.2",
|
|
58
58
|
"typescript": "^5.7.2"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@strapi/strapi": "^5.5.0",
|
|
62
61
|
"@strapi/sdk-plugin": "^5.2.7",
|
|
62
|
+
"@strapi/strapi": "^5.5.0",
|
|
63
63
|
"react": "^18.3.1",
|
|
64
64
|
"react-dom": "^18.3.1",
|
|
65
65
|
"react-router-dom": "^6.28.0",
|