@crowdin/app-project-module 0.97.0 → 0.98.0-cf-1
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/out/index.js +25 -10
- package/out/middlewares/crowdin-client.d.ts +1 -1
- package/out/middlewares/integration-credentials.d.ts +1 -1
- package/out/middlewares/integration-credentials.js +4 -1
- package/out/middlewares/render-ui-module.d.ts +3 -3
- package/out/middlewares/render-ui-module.js +9 -13
- package/out/middlewares/ui-module.d.ts +1 -1
- package/out/middlewares/ui-module.js +4 -1
- package/out/modules/about.d.ts +1 -1
- package/out/modules/about.js +8 -2
- package/out/modules/ai-prompt-provider/handlers/compile.d.ts +1 -1
- package/out/modules/ai-prompt-provider/index.js +4 -2
- package/out/modules/ai-provider/handlers/chat-completions.d.ts +1 -1
- package/out/modules/ai-provider/handlers/get-model-list.d.ts +1 -1
- package/out/modules/ai-provider/index.js +4 -2
- package/out/modules/ai-request-processors/handler.d.ts +1 -1
- package/out/modules/ai-tools/handlers/tool-calls.d.ts +1 -1
- package/out/modules/ai-tools/index.js +1 -1
- package/out/modules/context-menu/index.js +2 -2
- package/out/modules/custom-mt/handlers/translate.d.ts +1 -1
- package/out/modules/custom-mt/index.js +3 -1
- package/out/modules/custom-spell-check/handlers/get-languages-list.d.ts +1 -1
- package/out/modules/custom-spell-check/handlers/spell-check.d.ts +1 -1
- package/out/modules/custom-spell-check/index.js +4 -4
- package/out/modules/editor-right-panel/index.js +1 -1
- package/out/modules/external-qa-check/handlers/validate.d.ts +1 -1
- package/out/modules/external-qa-check/index.js +2 -2
- package/out/modules/file-processing/handlers/custom-file-format.d.ts +1 -1
- package/out/modules/file-processing/handlers/file-download.d.ts +1 -1
- package/out/modules/file-processing/handlers/pre-post-process.d.ts +1 -1
- package/out/modules/form-data-display.d.ts +1 -1
- package/out/modules/form-data-save.d.ts +1 -1
- package/out/modules/install.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-file-progress.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-files.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-project.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-update.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-webhook.d.ts +1 -1
- package/out/modules/integration/handlers/integration-data.d.ts +1 -1
- package/out/modules/integration/handlers/integration-login.d.ts +1 -1
- package/out/modules/integration/handlers/integration-logout.d.ts +1 -1
- package/out/modules/integration/handlers/integration-update.d.ts +1 -1
- package/out/modules/integration/handlers/integration-webhook.d.ts +1 -1
- package/out/modules/integration/handlers/invite-users.d.ts +1 -1
- package/out/modules/integration/handlers/job-cancel.d.ts +1 -1
- package/out/modules/integration/handlers/job-info.d.ts +1 -1
- package/out/modules/integration/handlers/main.d.ts +1 -1
- package/out/modules/integration/handlers/main.js +13 -1
- package/out/modules/integration/handlers/oauth-login.d.ts +1 -1
- package/out/modules/integration/handlers/oauth-login.js +10 -2
- package/out/modules/integration/handlers/oauth-polling.d.ts +1 -1
- package/out/modules/integration/handlers/oauth-url.d.ts +1 -1
- package/out/modules/integration/handlers/settings-save.d.ts +1 -1
- package/out/modules/integration/handlers/settings.d.ts +1 -1
- package/out/modules/integration/handlers/sync-settings-save.d.ts +1 -1
- package/out/modules/integration/handlers/sync-settings.d.ts +1 -1
- package/out/modules/integration/handlers/user-errors.d.ts +1 -1
- package/out/modules/integration/handlers/users.d.ts +1 -1
- package/out/modules/integration/index.js +27 -21
- package/out/modules/modal/index.js +2 -2
- package/out/modules/organization-menu/index.js +6 -4
- package/out/modules/organization-settings-menu/index.js +6 -4
- package/out/modules/profile-resources-menu/index.js +6 -4
- package/out/modules/profile-settings-menu/index.js +6 -4
- package/out/modules/project-menu/index.js +1 -1
- package/out/modules/project-menu-crowdsource/index.js +1 -1
- package/out/modules/project-reports/index.js +4 -2
- package/out/modules/project-tools/index.js +4 -2
- package/out/modules/status.d.ts +1 -1
- package/out/modules/subscription-paid.d.ts +1 -1
- package/out/modules/uninstall.d.ts +1 -1
- package/out/modules/webhooks/handlers/webhook-handler.d.ts +1 -1
- package/out/modules/workflow-step-type/handlers/delete-step.d.ts +1 -1
- package/out/modules/workflow-step-type/handlers/step-settings-save.d.ts +1 -1
- package/out/modules/workflow-step-type/index.js +3 -2
- package/out/storage/d1.d.ts +99 -0
- package/out/storage/d1.js +769 -0
- package/out/storage/index.js +8 -1
- package/out/types.d.ts +11 -1
- package/out/util/credentials-masker.d.ts +1 -1
- package/out/util/index.d.ts +2 -0
- package/out/util/index.js +14 -2
- package/out/util/jsx-renderer.d.ts +6 -0
- package/out/util/jsx-renderer.js +13 -0
- package/out/util/static-files.d.ts +19 -0
- package/out/util/static-files.js +80 -0
- package/out/views/AboutPage.d.ts +9 -0
- package/out/views/AboutPage.js +79 -0
- package/out/views/ErrorPage.d.ts +18 -0
- package/out/views/ErrorPage.js +56 -0
- package/out/views/FormPage.d.ts +13 -0
- package/out/views/FormPage.js +27 -0
- package/out/views/InstallPage.d.ts +10 -0
- package/out/views/InstallPage.js +22 -0
- package/out/views/LoginPage.d.ts +33 -0
- package/out/views/LoginPage.js +199 -0
- package/out/views/MainPage.d.ts +79 -0
- package/out/views/MainPage.js +1613 -0
- package/out/views/OAuthPage.d.ts +7 -0
- package/out/views/OAuthPage.js +17 -0
- package/out/views/SubscriptionPage.d.ts +7 -0
- package/out/views/SubscriptionPage.js +26 -0
- package/out/views/index.d.ts +13 -0
- package/out/views/index.js +25 -0
- package/out/views/layout/Head.d.ts +9 -0
- package/out/views/layout/Head.js +54 -0
- package/package.json +12 -11
- package/out/util/handlebars.d.ts +0 -1
- package/out/util/handlebars.js +0 -46
- package/out/views/about.handlebars +0 -102
- package/out/views/error.handlebars +0 -54
- package/out/views/form.handlebars +0 -30
- package/out/views/install.handlebars +0 -16
- package/out/views/login.handlebars +0 -331
- package/out/views/main.handlebars +0 -1857
- package/out/views/oauth.handlebars +0 -11
- package/out/views/partials/head.handlebars +0 -53
- package/out/views/subscription.handlebars +0 -26
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LoginPage = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const Head_1 = require("./layout/Head");
|
|
9
|
+
const renderField = (field, name) => {
|
|
10
|
+
var _a;
|
|
11
|
+
if (!field.key) {
|
|
12
|
+
// Label-only field
|
|
13
|
+
return field.labelHtml ? (react_1.default.createElement("crowdin-p", Object.assign({}, (field.dependencySettings ? { 'data-dependency': field.dependencySettings } : {}), { dangerouslySetInnerHTML: { __html: field.labelHtml } }))) : (react_1.default.createElement("crowdin-p", Object.assign({}, (field.dependencySettings ? { 'data-dependency': field.dependencySettings } : {})), field.label));
|
|
14
|
+
}
|
|
15
|
+
const commonProps = Object.assign(Object.assign(Object.assign({ id: field.key, label: field.label }, (field.helpText ? { 'help-text': field.helpText } : {})), (field.helpTextHtml ? { 'help-text-html': field.helpTextHtml } : {})), (field.dependencySettings ? { 'data-dependency': field.dependencySettings } : {}));
|
|
16
|
+
// Special field types
|
|
17
|
+
if (['checkbox', 'select', 'textarea', 'file', 'notice'].includes(field.type || '')) {
|
|
18
|
+
switch (field.type) {
|
|
19
|
+
case 'checkbox':
|
|
20
|
+
return (react_1.default.createElement("crowdin-checkbox", Object.assign({}, commonProps, { value: "false", "use-switch": true }, (field.defaultValue === true ? { checked: String(field.defaultValue) } : {}))));
|
|
21
|
+
case 'select':
|
|
22
|
+
return (react_1.default.createElement("crowdin-select", Object.assign({}, commonProps, (field.isMulti ? { 'is-multi': true, 'close-on-select': 'false' } : {}), (field.isSearchable ? { 'is-searchable': true } : {})), (_a = field.options) === null || _a === void 0 ? void 0 : _a.map((option) => (react_1.default.createElement("option", Object.assign({ value: option.value }, (field.defaultValue === option.value ? { selected: true } : {})), option.label)))));
|
|
23
|
+
case 'textarea':
|
|
24
|
+
return (react_1.default.createElement("crowdin-textarea", Object.assign({}, commonProps, { value: field.defaultValue || '' })));
|
|
25
|
+
case 'notice':
|
|
26
|
+
return (react_1.default.createElement("crowdin-alert", Object.assign({}, (field.noticeType ? { type: field.noticeType } : {}), (field.label ? { title: field.label } : {}), (field.noIcon ? { 'no-icon': String(field.noIcon) } : {}), (field.dependencySettings ? { 'data-dependency': field.dependencySettings } : {}), { dangerouslySetInnerHTML: { __html: field.helpText || '' } })));
|
|
27
|
+
case 'file':
|
|
28
|
+
return (react_1.default.createElement("div", { className: "file-field" },
|
|
29
|
+
field.helpText && react_1.default.createElement("div", { className: "help-text" }, field.helpText),
|
|
30
|
+
field.helpTextHtml && react_1.default.createElement("div", { className: "help-text" }, field.helpTextHtml),
|
|
31
|
+
react_1.default.createElement("div", { className: "upload" },
|
|
32
|
+
react_1.default.createElement("crowdin-button", { outlined: true, onclick: `uploadFiles('${field.key}');` }, field.label),
|
|
33
|
+
react_1.default.createElement("textarea", { hidden: true, id: field.key }),
|
|
34
|
+
react_1.default.createElement("input", Object.assign({ id: `store_${field.key}`, "data-id": field.key }, (field.accept ? { accept: field.accept } : {}), { 'onchange': 'readFileData(event)' }, { hidden: true, type: field.type })),
|
|
35
|
+
react_1.default.createElement("div", { className: "uploaded-file" },
|
|
36
|
+
react_1.default.createElement("i", null, "No file")))));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Default input field
|
|
40
|
+
return (react_1.default.createElement("crowdin-input", Object.assign({}, commonProps, (field.type ? { type: field.type } : {}), { value: field.defaultValue || '' })));
|
|
41
|
+
};
|
|
42
|
+
const LoginPage = ({ name, loginFields, oauthLogin, oauthUrl, oauthMode, sentryData }) => (react_1.default.createElement("html", { lang: "en" },
|
|
43
|
+
react_1.default.createElement(Head_1.Head, { sentryData: sentryData }),
|
|
44
|
+
react_1.default.createElement("body", null,
|
|
45
|
+
react_1.default.createElement("div", { className: "i_w center" },
|
|
46
|
+
react_1.default.createElement("div", null,
|
|
47
|
+
react_1.default.createElement("crowdin-card", { "is-shadowed": true, "is-padding-lg": true, className: "login" },
|
|
48
|
+
react_1.default.createElement("img", { alt: `${name} logo`, src: "logo.png" }),
|
|
49
|
+
react_1.default.createElement("crowdin-h4", { id: "integration-name" }, name),
|
|
50
|
+
react_1.default.createElement("div", { className: "inputs" }, loginFields.map((field) => (react_1.default.createElement(react_1.default.Fragment, null,
|
|
51
|
+
renderField(field, name),
|
|
52
|
+
react_1.default.createElement("div", Object.assign({ style: { padding: '8px' } }, (field.dependencySettings ? { 'data-dependency': field.dependencySettings } : {}))))))),
|
|
53
|
+
react_1.default.createElement("crowdin-button", { id: "login-button", outlined: true, "icon-after": "arrow_forward", onclick: oauthLogin ? 'oauthLogin()' : 'integrationLogin()' },
|
|
54
|
+
"Log In With ",
|
|
55
|
+
name)))),
|
|
56
|
+
react_1.default.createElement("crowdin-toasts", null),
|
|
57
|
+
react_1.default.createElement("script", { type: "text/javascript", dangerouslySetInnerHTML: {
|
|
58
|
+
__html: `
|
|
59
|
+
const loginButton = document.querySelector('#login-button');
|
|
60
|
+
let refreshIntervalId;
|
|
61
|
+
|
|
62
|
+
function oauthLogin() {
|
|
63
|
+
const url = ${oauthUrl ? `'${oauthUrl}'` : 'undefined'};
|
|
64
|
+
if (url) {
|
|
65
|
+
openOAuthPopup(url);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
loginButton.setAttribute('disabled', true);
|
|
69
|
+
loginButton.setAttribute('is-loading', true);
|
|
70
|
+
checkOrigin()
|
|
71
|
+
.then(queryParams =>
|
|
72
|
+
fetch(\`api/oauth-url\${queryParams}\`, {
|
|
73
|
+
method: 'POST',
|
|
74
|
+
headers: { 'Content-Type': 'application/json' },
|
|
75
|
+
body: JSON.stringify({ loginForm: getLoginForm() })
|
|
76
|
+
})
|
|
77
|
+
)
|
|
78
|
+
.then(checkResponse)
|
|
79
|
+
.then(res => openOAuthPopup(res.url))
|
|
80
|
+
.catch(e => {
|
|
81
|
+
loginButton.setAttribute('disabled', false);
|
|
82
|
+
loginButton.setAttribute('is-loading', false);
|
|
83
|
+
catchRejection(e, 'Can\\'t get oauth token');
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function openOAuthPopup(url) {
|
|
88
|
+
const oauthMode = ${oauthMode ? `'${oauthMode}'` : 'undefined'};
|
|
89
|
+
const oauthWindow = window.open(url, '${name}', 'location=0,status=0,width=800,height=400');
|
|
90
|
+
|
|
91
|
+
if (oauthMode === 'polling') {
|
|
92
|
+
if (refreshIntervalId) {
|
|
93
|
+
clearInterval(refreshIntervalId);
|
|
94
|
+
}
|
|
95
|
+
refreshIntervalId = setInterval(() =>
|
|
96
|
+
checkOrigin()
|
|
97
|
+
.then(queryParams =>
|
|
98
|
+
fetch(\`api/oauth-polling\${queryParams}\`, { method: 'POST' })
|
|
99
|
+
)
|
|
100
|
+
.then(checkResponse)
|
|
101
|
+
.then(res => {
|
|
102
|
+
if (res.oauthCreds) {
|
|
103
|
+
integrationLogin({
|
|
104
|
+
refreshToken: res.oauthCreds.refreshToken,
|
|
105
|
+
accessToken: res.oauthCreds.accessToken,
|
|
106
|
+
expireIn: res.oauthCreds.expireIn,
|
|
107
|
+
timestamp: res.oauthCreds.timestamp
|
|
108
|
+
});
|
|
109
|
+
if (refreshIntervalId) {
|
|
110
|
+
clearInterval(refreshIntervalId);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}), 2000);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
postPromises['oauth_popup'] = {
|
|
118
|
+
resolve: (data) => {
|
|
119
|
+
if (data.error) {
|
|
120
|
+
showToast(data.error);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
integrationLogin({
|
|
124
|
+
refreshToken: data.refreshToken,
|
|
125
|
+
accessToken: data.accessToken,
|
|
126
|
+
expireIn: data.expireIn,
|
|
127
|
+
timestamp: data.timestamp
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function integrationLogin(oauthCredentials) {
|
|
134
|
+
const credentials = oauthCredentials || getLoginForm();
|
|
135
|
+
loginButton.setAttribute('disabled', true);
|
|
136
|
+
loginButton.setAttribute('is-loading', true);
|
|
137
|
+
checkOrigin()
|
|
138
|
+
.then(queryParams =>
|
|
139
|
+
fetch(\`api/login\${queryParams}\`, {
|
|
140
|
+
method: 'POST',
|
|
141
|
+
headers: { 'Content-Type': 'application/json' },
|
|
142
|
+
body: JSON.stringify({ credentials })
|
|
143
|
+
})
|
|
144
|
+
)
|
|
145
|
+
.then(checkResponse)
|
|
146
|
+
.then(localStorage.removeItem('revised_${name}'))
|
|
147
|
+
.then(reloadLocation)
|
|
148
|
+
.catch(e => {
|
|
149
|
+
loginButton.setAttribute('disabled', false);
|
|
150
|
+
loginButton.setAttribute('is-loading', false);
|
|
151
|
+
catchRejection(e, 'Credentials are not stored');
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function getLoginForm() {
|
|
156
|
+
return {
|
|
157
|
+
${loginFields
|
|
158
|
+
.filter((f) => f.key)
|
|
159
|
+
.map((f) => {
|
|
160
|
+
if (f.type === 'checkbox') {
|
|
161
|
+
return `'${f.key}': !!document.querySelector('#${f.key}').checked`;
|
|
162
|
+
}
|
|
163
|
+
return `'${f.key}': document.querySelector('#${f.key}').getAttribute('value') || document.querySelector('#${f.key}').value`;
|
|
164
|
+
})
|
|
165
|
+
.join(',\n ')}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function uploadFiles(id) {
|
|
170
|
+
const input = document.querySelector(\`#store_\${id}\`);
|
|
171
|
+
input.value = '';
|
|
172
|
+
input.click();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function readFileData(event) {
|
|
176
|
+
const reader = new FileReader();
|
|
177
|
+
const identifier = event.target.getAttribute('data-id');
|
|
178
|
+
const fileName = document.querySelector('.uploaded-file');
|
|
179
|
+
const input = document.querySelector(\`#\${identifier}\`);
|
|
180
|
+
const file = event.target.files[0];
|
|
181
|
+
fileName.innerText = file.name;
|
|
182
|
+
|
|
183
|
+
reader.onloadstart = function() {
|
|
184
|
+
loginButton.setAttribute('disabled', true);
|
|
185
|
+
loginButton.setAttribute('is-loading', true);
|
|
186
|
+
};
|
|
187
|
+
reader.onloadend = function() {
|
|
188
|
+
loginButton.setAttribute('disabled', false);
|
|
189
|
+
loginButton.setAttribute('is-loading', false);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
reader.onload = () => {
|
|
193
|
+
input.value = reader.result;
|
|
194
|
+
};
|
|
195
|
+
reader.readAsText(file);
|
|
196
|
+
}
|
|
197
|
+
`,
|
|
198
|
+
} }))));
|
|
199
|
+
exports.LoginPage = LoginPage;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
interface ConfigField {
|
|
3
|
+
key?: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
labelHtml?: string;
|
|
6
|
+
helpText?: string;
|
|
7
|
+
helpTextHtml?: string;
|
|
8
|
+
type?: string;
|
|
9
|
+
defaultValue?: any;
|
|
10
|
+
dependencySettings?: string;
|
|
11
|
+
isMulti?: boolean;
|
|
12
|
+
isSearchable?: boolean;
|
|
13
|
+
options?: Array<{
|
|
14
|
+
value: string;
|
|
15
|
+
label: string;
|
|
16
|
+
}>;
|
|
17
|
+
noticeType?: string;
|
|
18
|
+
noIcon?: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface ConfigurationTab {
|
|
21
|
+
name: string;
|
|
22
|
+
fields: ConfigField[];
|
|
23
|
+
}
|
|
24
|
+
interface Notice {
|
|
25
|
+
title: string;
|
|
26
|
+
content: string;
|
|
27
|
+
type?: string;
|
|
28
|
+
icon?: boolean;
|
|
29
|
+
close?: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface InfoModal {
|
|
32
|
+
title: string;
|
|
33
|
+
content: string;
|
|
34
|
+
}
|
|
35
|
+
interface MainPageProps {
|
|
36
|
+
name: string;
|
|
37
|
+
userId?: string;
|
|
38
|
+
notice?: Notice;
|
|
39
|
+
checkSubscription?: boolean;
|
|
40
|
+
isManager?: boolean;
|
|
41
|
+
isOwner?: boolean;
|
|
42
|
+
infoModal?: InfoModal;
|
|
43
|
+
configurationFields?: ConfigurationTab[];
|
|
44
|
+
config?: string;
|
|
45
|
+
syncNewElements?: {
|
|
46
|
+
crowdin?: boolean;
|
|
47
|
+
integration?: boolean;
|
|
48
|
+
};
|
|
49
|
+
withCronSync?: {
|
|
50
|
+
crowdin?: boolean;
|
|
51
|
+
integration?: boolean;
|
|
52
|
+
};
|
|
53
|
+
webhooks?: {
|
|
54
|
+
crowdin?: boolean;
|
|
55
|
+
integration?: boolean;
|
|
56
|
+
};
|
|
57
|
+
integrationOneLevelFetching?: boolean;
|
|
58
|
+
integrationSearchListener?: boolean;
|
|
59
|
+
integrationPagination?: boolean;
|
|
60
|
+
uploadTranslations?: boolean;
|
|
61
|
+
excludedTargetLanguages?: boolean;
|
|
62
|
+
forcePushTranslations?: boolean;
|
|
63
|
+
filtering?: {
|
|
64
|
+
crowdinLanguages?: boolean;
|
|
65
|
+
integrationFilterConfig?: string;
|
|
66
|
+
};
|
|
67
|
+
hasOrganization?: boolean;
|
|
68
|
+
zenModeUrl?: string;
|
|
69
|
+
asyncProgress?: {
|
|
70
|
+
checkInterval: number;
|
|
71
|
+
};
|
|
72
|
+
reloadOnConfigSave?: boolean;
|
|
73
|
+
sentryData?: {
|
|
74
|
+
dsn: string;
|
|
75
|
+
appIdentifier: string;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export declare const MainPage: FC<MainPageProps>;
|
|
79
|
+
export {};
|