corpushub-design-system 0.1.0 → 0.1.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/dist/common/AppDropzone/AppDropzoneBody.js +2 -1
- package/dist/common/AppDropzone/UploadedFile.d.ts +2 -0
- package/dist/common/AppDropzone/index.d.ts +2 -0
- package/dist/common/AppDropzone/index.js +1 -0
- package/dist/common/AppDropzone/toMediaDisplayUrl.d.ts +10 -0
- package/dist/common/AppDropzone/toMediaDisplayUrl.js +27 -0
- package/dist/common/AppPicture/AppPicture.js +1 -1
- package/dist/common/AppTable/styles.scss +6 -2
- package/dist/common/index.d.ts +1 -1
- package/dist/common/index.js +1 -1
- package/dist/configs/Localization.js +4 -0
- package/dist/configs/api/applyAuthErrorHandling.js +5 -0
- package/dist/configs/api/index.js +2 -0
- package/dist/configs/auth/authApi.js +6 -0
- package/dist/configs/auth/installAuthRefreshInterceptor.js +5 -0
- package/dist/configs/auth/isPublicAuthRequest.d.ts +6 -0
- package/dist/configs/auth/isPublicAuthRequest.js +28 -0
- package/dist/configs/auth/session.js +8 -6
- package/dist/configs/brand.d.ts +6 -0
- package/dist/configs/brand.js +10 -3
- package/dist/configs/index.d.ts +3 -2
- package/dist/configs/index.js +2 -1
- package/dist/configs/localization/BackupTexts.d.ts +74 -0
- package/dist/configs/localization/BackupTexts.js +74 -0
- package/dist/configs/localization/CommentsTexts.d.ts +145 -145
- package/dist/configs/localization/CommentsTexts.js +145 -145
- package/dist/configs/localization/CommonTexts.d.ts +15 -0
- package/dist/configs/localization/CommonTexts.js +18 -3
- package/dist/configs/localization/HeaderTexts.js +3 -3
- package/dist/configs/localization/HelpTexts.d.ts +44 -2
- package/dist/configs/localization/HelpTexts.js +53 -11
- package/dist/configs/localization/HistoryTexts.d.ts +6 -0
- package/dist/configs/localization/HistoryTexts.js +6 -0
- package/dist/configs/localization/ParserRuleGroupsTexts.d.ts +53 -0
- package/dist/configs/localization/ParserRuleGroupsTexts.js +53 -0
- package/dist/configs/services/ProfileService.js +3 -3
- package/dist/configs/tour/index.d.ts +1 -1
- package/dist/configs/types/CorpusImage.d.ts +3 -0
- package/dist/features/AccessControl/AccessControlService.d.ts +9 -0
- package/dist/features/AccessControl/AccessControlService.js +22 -8
- package/dist/features/AccessControl/AccessGrant/AccessGrant.js +3 -1
- package/dist/features/AccessControl/AccessUser/AccessData.d.ts +2 -2
- package/dist/features/AccessControl/AccessUser/AccessData.js +21 -21
- package/dist/features/AccessControl/AccessUser/AccessUser.js +20 -3
- package/dist/features/AccessControl/AccessUser/AccessUserGroups.d.ts +8 -0
- package/dist/features/AccessControl/AccessUser/AccessUserGroups.js +77 -0
- package/dist/features/AccessControl/AccessUser/style.scss +41 -3
- package/dist/features/AccessControl/AccessUsers/AccessUsers.js +44 -29
- package/dist/features/AccessControl/AccessUsers/styles.scss +5 -0
- package/dist/features/AccessControl/index.d.ts +1 -0
- package/dist/features/AccessControl/types/CorpusGroup.d.ts +10 -0
- package/dist/features/AccessControl/types/CorpusGroup.js +1 -0
- package/dist/features/AccessControl/types/UserAccessResponse.d.ts +4 -0
- package/dist/features/Backup/BackupCreate/BackupCreate.d.ts +11 -0
- package/dist/features/Backup/BackupCreate/BackupCreate.js +89 -0
- package/dist/features/Backup/BackupCreate/index.d.ts +2 -0
- package/dist/features/Backup/BackupCreate/index.js +2 -0
- package/dist/features/Backup/BackupCreate/style.scss +5 -0
- package/dist/features/Backup/BackupInfo/BackupInfo.d.ts +8 -0
- package/dist/features/Backup/BackupInfo/BackupInfo.js +36 -0
- package/dist/features/Backup/BackupInfo/index.d.ts +2 -0
- package/dist/features/Backup/BackupInfo/index.js +2 -0
- package/dist/features/Backup/BackupInfo/style.scss +23 -0
- package/dist/features/Backup/BackupRestore/BackupRestore.d.ts +7 -0
- package/dist/features/Backup/BackupRestore/BackupRestore.js +52 -0
- package/dist/features/Backup/BackupRestore/index.d.ts +3 -0
- package/dist/features/Backup/BackupRestore/index.js +2 -0
- package/dist/features/Backup/BackupRestore/style.scss +17 -0
- package/dist/features/Backup/BackupService.d.ts +20 -0
- package/dist/features/Backup/BackupService.js +43 -0
- package/dist/features/Backup/BackupTable/BackupSearchFilter.d.ts +5 -0
- package/dist/features/Backup/BackupTable/BackupSearchFilter.js +4 -0
- package/dist/features/Backup/BackupTable/BackupTable.d.ts +8 -0
- package/dist/features/Backup/BackupTable/BackupTable.js +121 -0
- package/dist/features/Backup/BackupTable/index.d.ts +4 -0
- package/dist/features/Backup/BackupTable/index.js +3 -0
- package/dist/features/Backup/BackupTable/style.scss +19 -0
- package/dist/features/Backup/index.d.ts +7 -0
- package/dist/features/Backup/index.js +4 -0
- package/dist/features/Backup/types/Backup.d.ts +14 -0
- package/dist/features/Backup/types/Backup.js +1 -0
- package/dist/features/Comments/CommentService.js +2 -1
- package/dist/features/PageRender/PageRenderView.d.ts +1 -1
- package/dist/features/PageRender/PageRenderView.js +67 -9
- package/dist/features/PageRender/style.scss +27 -5
- package/dist/features/PageRender/types.d.ts +5 -1
- package/dist/features/ParserRuleGroups/ParserRuleGroupItem.d.ts +9 -0
- package/dist/features/ParserRuleGroups/ParserRuleGroupItem.js +18 -0
- package/dist/features/ParserRuleGroups/ParserRuleGroupsEditor.d.ts +17 -0
- package/dist/features/ParserRuleGroups/ParserRuleGroupsEditor.js +129 -0
- package/dist/features/ParserRuleGroups/index.d.ts +2 -0
- package/dist/features/ParserRuleGroups/index.js +2 -0
- package/dist/features/ParserRuleGroups/style.scss +81 -0
- package/dist/features/ServerErrorReport/ServerErrorReport.js +9 -48
- package/dist/features/ServerErrorReport/ServerErrorReportForm.d.ts +22 -0
- package/dist/features/ServerErrorReport/ServerErrorReportForm.js +85 -0
- package/dist/features/ServerErrorReport/captureTabScreenshot.d.ts +1 -1
- package/dist/features/ServerErrorReport/captureTabScreenshot.js +5 -20
- package/dist/features/ServerErrorReport/index.d.ts +2 -0
- package/dist/features/ServerErrorReport/index.js +1 -0
- package/dist/features/ServerErrorReport/styles.scss +22 -9
- package/dist/features/index.d.ts +5 -1
- package/dist/features/index.js +2 -0
- package/dist/primitives/AsyncSelectField/AsyncSelectField.js +2 -2
- package/dist/primitives/AsyncSelectField/styles.scss +31 -31
- package/dist/primitives/Button/Button.d.ts +5 -4
- package/dist/primitives/Button/Button.js +19 -19
- package/dist/primitives/DropdownButton/DropdownButton.d.ts +2 -1
- package/dist/primitives/DropdownButton/DropdownButton.js +2 -2
- package/dist/primitives/DropdownMenu/DropdownMenu.js +7 -1
- package/dist/primitives/Icon/Icon.d.ts +2 -1
- package/dist/primitives/Icon/Icon.js +2 -2
- package/dist/primitives/IconButton/IconButton.d.ts +2 -1
- package/dist/primitives/IconButton/IconButton.js +2 -2
- package/dist/primitives/Tag/Tag.d.ts +2 -1
- package/dist/primitives/Tag/Tag.js +3 -3
- package/dist/primitives/index.js +1 -1
- package/dist/shell/Header/HelpButton/HelpModal.js +3 -69
- package/dist/shell/Header/HelpButton/HelpModalMainColumn.d.ts +5 -0
- package/dist/shell/Header/HelpButton/HelpModalMainColumn.js +76 -0
- package/dist/shell/Header/HelpButton/HelpModalSideColumn.d.ts +7 -0
- package/dist/shell/Header/HelpButton/HelpModalSideColumn.js +18 -0
- package/dist/shell/Header/HelpButton/live-tour.png +0 -0
- package/dist/shell/Header/HelpButton/style.scss +330 -47
- package/dist/styles/base/_typographs.scss +376 -1
- package/dist/styles/main.scss +112 -1
- package/package.json +1 -1
- package/dist/primitives/styles/base/_typographs.scss +0 -376
- package/dist/primitives/styles/font-googleapis.scss +0 -222
- package/dist/primitives/styles/main.scss +0 -112
- /package/dist/{primitives/fonts → fonts}/material-symbols-outlined.woff2 +0 -0
- /package/dist/{primitives/fonts → fonts}/work-sans-latin-ext.woff2 +0 -0
- /package/dist/{primitives/fonts → fonts}/work-sans-latin.woff2 +0 -0
- /package/dist/{primitives/fonts → fonts}/work-sans-vietnamese.woff2 +0 -0
- /package/dist/{primitives/fonts.d.ts → fonts.d.ts} +0 -0
- /package/dist/{primitives/fonts.js → fonts.js} +0 -0
- /package/dist/{primitives/styles → styles}/base/_borders.scss +0 -0
- /package/dist/{primitives/styles → styles}/base/_colors.scss +0 -0
- /package/dist/{primitives/styles → styles}/base/_displays.scss +0 -0
- /package/dist/{primitives/styles → styles}/base/_margins.css +0 -0
- /package/dist/{primitives/styles → styles}/base/_spacing.scss +0 -0
- /package/dist/{primitives/styles → styles}/base/_tokens.scss +0 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import { saveAs } from 'file-saver';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import AppCard from '../../common/AppCard/AppCard';
|
|
7
|
+
import AppDropzoneLocal from '../../common/AppDropzoneLocal';
|
|
8
|
+
import { Button, IconButton } from '../../primitives';
|
|
9
|
+
import { applyParserRuleGroupsMap, toParserRuleGroupsMap, } from './ParserRuleGroupItem';
|
|
10
|
+
import './style.scss';
|
|
11
|
+
const JSON_ACCEPT = {
|
|
12
|
+
'application/json': ['.json'],
|
|
13
|
+
'text/plain': ['.json'],
|
|
14
|
+
};
|
|
15
|
+
export default function ParserRuleGroupsEditor({ items, onChange, onSave, title, className, exportFileName = 'parser-rule-groups.json', extraOptions = [], onClose, }) {
|
|
16
|
+
const { t } = useTranslation('parser-rule-groups');
|
|
17
|
+
const [drafts, setDrafts] = useState({});
|
|
18
|
+
const [openImport, setOpenImport] = useState(false);
|
|
19
|
+
const isEditing = (line) => Object.prototype.hasOwnProperty.call(drafts, line.id);
|
|
20
|
+
const commit = (next) => {
|
|
21
|
+
onChange(next);
|
|
22
|
+
onSave(next);
|
|
23
|
+
};
|
|
24
|
+
const handleChange = (item, value) => {
|
|
25
|
+
const idx = items.findIndex((s) => s.id === item.id);
|
|
26
|
+
if (idx < 0)
|
|
27
|
+
return;
|
|
28
|
+
commit([
|
|
29
|
+
...items.slice(0, idx),
|
|
30
|
+
{ ...item, group: value || undefined },
|
|
31
|
+
...items.slice(idx + 1),
|
|
32
|
+
]);
|
|
33
|
+
};
|
|
34
|
+
const getDraft = (line) => drafts[line.id] !== undefined ? drafts[line.id] : line.group || '';
|
|
35
|
+
const startEdit = (line, initial) => {
|
|
36
|
+
setDrafts((prev) => ({ ...prev, [line.id]: initial }));
|
|
37
|
+
};
|
|
38
|
+
const clearDraft = (line) => {
|
|
39
|
+
setDrafts((prev) => {
|
|
40
|
+
const next = { ...prev };
|
|
41
|
+
delete next[line.id];
|
|
42
|
+
return next;
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
const handleGroupSave = (line) => {
|
|
46
|
+
const value = getDraft(line).trim();
|
|
47
|
+
handleChange(line, value || undefined);
|
|
48
|
+
clearDraft(line);
|
|
49
|
+
};
|
|
50
|
+
const handleGroupCancel = (line) => {
|
|
51
|
+
clearDraft(line);
|
|
52
|
+
};
|
|
53
|
+
const handleAdd = (line) => {
|
|
54
|
+
startEdit(line, t('default.group.name'));
|
|
55
|
+
};
|
|
56
|
+
const handleEdit = (line) => {
|
|
57
|
+
startEdit(line, line.group || '');
|
|
58
|
+
};
|
|
59
|
+
const handleDelete = (line) => {
|
|
60
|
+
handleChange(line);
|
|
61
|
+
clearDraft(line);
|
|
62
|
+
};
|
|
63
|
+
const handleExport = () => {
|
|
64
|
+
const blob = new Blob([JSON.stringify(toParserRuleGroupsMap(items))], {
|
|
65
|
+
type: 'application/json;charset=utf-8',
|
|
66
|
+
});
|
|
67
|
+
saveAs(blob, exportFileName);
|
|
68
|
+
};
|
|
69
|
+
const handleImportSuccess = (files) => {
|
|
70
|
+
const content = files[0]?.content;
|
|
71
|
+
if (!content) {
|
|
72
|
+
setOpenImport(false);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
let groups;
|
|
76
|
+
try {
|
|
77
|
+
groups = JSON.parse(content);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
console.error('Failed to parse imported groups:', error);
|
|
81
|
+
setOpenImport(false);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
commit(applyParserRuleGroupsMap(items, groups));
|
|
85
|
+
setDrafts({});
|
|
86
|
+
setOpenImport(false);
|
|
87
|
+
};
|
|
88
|
+
const menuOptions = [
|
|
89
|
+
{
|
|
90
|
+
icon: 'upload',
|
|
91
|
+
label: t('menu.import'),
|
|
92
|
+
onClick: () => setOpenImport(true),
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
icon: 'download',
|
|
96
|
+
label: t('menu.export'),
|
|
97
|
+
onClick: handleExport,
|
|
98
|
+
},
|
|
99
|
+
...extraOptions,
|
|
100
|
+
...(onClose
|
|
101
|
+
? [
|
|
102
|
+
{
|
|
103
|
+
icon: 'close',
|
|
104
|
+
label: t('menu.close'),
|
|
105
|
+
onClick: onClose,
|
|
106
|
+
},
|
|
107
|
+
]
|
|
108
|
+
: []),
|
|
109
|
+
];
|
|
110
|
+
const renderGroupCell = (line) => {
|
|
111
|
+
if (isEditing(line)) {
|
|
112
|
+
return (_jsxs("div", { className: "group-edit", children: [_jsx("input", { type: "text", className: "group-name-input", value: getDraft(line), onChange: (e) => setDrafts((prev) => ({ ...prev, [line.id]: e.target.value })), placeholder: t('placeholder.input'), "aria-label": t('placeholder.input'), autoFocus: true }), _jsx(Button, { text: t('button.save.row'), size: "x-small", onClick: () => handleGroupSave(line) })] }));
|
|
113
|
+
}
|
|
114
|
+
if (line.group) {
|
|
115
|
+
return _jsx("span", { className: "group-name", children: line.group });
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
};
|
|
119
|
+
const renderActions = (line) => {
|
|
120
|
+
if (isEditing(line)) {
|
|
121
|
+
return (_jsx(IconButton, { name: "close", size: "small", title: t('button.cancel.row'), onClick: () => handleGroupCancel(line) }));
|
|
122
|
+
}
|
|
123
|
+
if (line.group) {
|
|
124
|
+
return (_jsxs("div", { className: "group-actions", children: [_jsx(IconButton, { name: "edit", size: "small", title: t('button.edit.row'), onClick: () => handleEdit(line) }), _jsx(IconButton, { name: "delete", size: "small", color: "danger", title: t('button.delete.row'), onClick: () => handleDelete(line) })] }));
|
|
125
|
+
}
|
|
126
|
+
return (_jsx(IconButton, { name: "add", size: "small", title: t('button.add.row'), onClick: () => handleAdd(line) }));
|
|
127
|
+
};
|
|
128
|
+
return (_jsxs(_Fragment, { children: [_jsx(AppCard, { title: title ?? t('label.title'), className: cx('ds-parser-rule-groups', className), options: menuOptions, children: _jsxs("table", { className: "table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("td", { width: "55%", children: t('table.column.rule') }), _jsx("td", { width: "45%", children: t('table.column.group') }), _jsx("td", { children: "\u00A0" })] }) }), _jsx("tbody", { children: items.map((line) => (_jsxs("tr", { children: [_jsx("td", { children: line.label }), _jsx("td", { children: renderGroupCell(line) }), _jsx("td", { children: renderActions(line) })] }, line.id))) })] }) }), openImport && (_jsx(AppDropzoneLocal, { accept: JSON_ACCEPT, title: t('modal.import.title'), onClose: () => setOpenImport(false), onSuccess: handleImportSuccess }))] }));
|
|
129
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
.ds-parser-rule-groups {
|
|
2
|
+
.ds-app-card-body,
|
|
3
|
+
.body {
|
|
4
|
+
overflow: auto;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.table {
|
|
8
|
+
width: 100%;
|
|
9
|
+
border-collapse: collapse;
|
|
10
|
+
|
|
11
|
+
> thead {
|
|
12
|
+
> tr {
|
|
13
|
+
> td {
|
|
14
|
+
border-bottom: 1px solid var(--border-accent-2);
|
|
15
|
+
padding: 8px;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
> tbody {
|
|
21
|
+
> tr {
|
|
22
|
+
> td {
|
|
23
|
+
border-bottom: 1px solid var(--border-subtle-2);
|
|
24
|
+
padding: 8px;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.group-name {
|
|
31
|
+
display: inline-block;
|
|
32
|
+
max-width: 100%;
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
text-overflow: ellipsis;
|
|
35
|
+
white-space: nowrap;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.group-edit {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
gap: var(--spacing-100);
|
|
42
|
+
min-width: 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.group-actions {
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
gap: var(--spacing-50, 4px);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.group-name-input {
|
|
52
|
+
flex: 1;
|
|
53
|
+
min-width: 0;
|
|
54
|
+
max-width: 220px;
|
|
55
|
+
height: 32px;
|
|
56
|
+
padding: 0 12px;
|
|
57
|
+
border: 1px solid var(--border-accent-2, #eaeaeb);
|
|
58
|
+
border-radius: 4px;
|
|
59
|
+
background: var(--surface-primary, #fff);
|
|
60
|
+
color: var(--text-primary);
|
|
61
|
+
font: inherit;
|
|
62
|
+
font-size: 14px;
|
|
63
|
+
line-height: 1.2;
|
|
64
|
+
outline: none;
|
|
65
|
+
transition: border-color 120ms ease-out, box-shadow 120ms ease-out;
|
|
66
|
+
|
|
67
|
+
&::placeholder {
|
|
68
|
+
color: var(--text-placeholder);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&:hover {
|
|
72
|
+
border-color: var(--border-accent-1, #c8c8cb);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&:focus {
|
|
76
|
+
border-color: var(--border-focus, var(--color-accent, #3d5a80));
|
|
77
|
+
box-shadow: 0 0 0 2px
|
|
78
|
+
color-mix(in srgb, var(--color-accent, #3d5a80) 25%, transparent);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -1,54 +1,15 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import
|
|
3
|
-
import { useState } from 'react';
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState } from 'react';
|
|
4
3
|
import { useTranslation } from 'react-i18next';
|
|
5
4
|
import AppModal from '../../common/AppModal/AppModal';
|
|
6
|
-
import
|
|
7
|
-
import ErrorReportService from '../../configs/services/ErrorReportService';
|
|
8
|
-
import { captureTabScreenshot } from './captureTabScreenshot';
|
|
9
|
-
import { getConsoleLogs } from './consoleCapture';
|
|
5
|
+
import ServerErrorReportForm from './ServerErrorReportForm';
|
|
10
6
|
import './styles.scss';
|
|
11
7
|
export default function ServerErrorReport({ errorContext, corpus, onClose, onSent, }) {
|
|
12
|
-
const { t
|
|
13
|
-
const
|
|
8
|
+
const { t } = useTranslation('common');
|
|
9
|
+
const formRef = useRef(null);
|
|
14
10
|
const [sending, setSending] = useState(false);
|
|
15
|
-
const [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
setSending(true);
|
|
22
|
-
setSendError(null);
|
|
23
|
-
try {
|
|
24
|
-
const screenshot = await captureTabScreenshot();
|
|
25
|
-
await ErrorReportService.send({
|
|
26
|
-
userMessage,
|
|
27
|
-
errorContext,
|
|
28
|
-
sendContext: {
|
|
29
|
-
locale: i18n.resolvedLanguage || i18n.language,
|
|
30
|
-
corpusUid: corpus?.uid,
|
|
31
|
-
corpusName: corpus?.name,
|
|
32
|
-
},
|
|
33
|
-
consoleLogs: getConsoleLogs(),
|
|
34
|
-
screenshot,
|
|
35
|
-
});
|
|
36
|
-
onSent();
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
console.error('Failed to send server error report:', axios.isAxiosError(error)
|
|
40
|
-
? {
|
|
41
|
-
message: error.message,
|
|
42
|
-
status: error.response?.status,
|
|
43
|
-
data: error.response?.data,
|
|
44
|
-
url: error.config?.url,
|
|
45
|
-
}
|
|
46
|
-
: error);
|
|
47
|
-
setSendError(t('server.error.report.send.failed'));
|
|
48
|
-
}
|
|
49
|
-
finally {
|
|
50
|
-
setSending(false);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
return (_jsx(AppModal, { title: t('server.error.report.modal.title'), subtitle: t('server.error.report.modal.subtitle'), close: onClose, confirm: handleSend, disableConfirm: sending || !userMessage.trim(), confirmLabel: t('server.error.report.modal.send'), className: "server-error-report-modal", children: _jsxs("div", { className: "server-error-report-modal__body", children: [_jsx(AppTextArea, { value: userMessage, onChange: (e) => setUserMessage(e.target.value), placeholder: t('server.error.report.modal.placeholder'), rows: 6, disabled: sending, "aria-label": t('server.error.report.modal.placeholder') }), sendError && (_jsx("p", { className: "server-error-report-modal__error", role: "alert", children: sendError }))] }) }));
|
|
11
|
+
const [canSend, setCanSend] = useState(true);
|
|
12
|
+
return (_jsx(AppModal, { title: t('server.error.report.modal.title'), subtitle: t('server.error.report.modal.subtitle'), close: onClose, confirm: () => {
|
|
13
|
+
void formRef.current?.send();
|
|
14
|
+
}, disableConfirm: sending || !canSend, confirmLabel: t('server.error.report.modal.send'), className: "server-error-report-modal", children: _jsx(ServerErrorReportForm, { ref: formRef, errorContext: errorContext, corpus: corpus, intent: "error", onSent: onSent, onSendingChange: setSending, onCanSendChange: setCanSend }) }));
|
|
54
15
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ServerErrorContext } from '../../common/AppToast/ToastMessage';
|
|
2
|
+
import type { Corpus } from '../../configs/types/Corpus';
|
|
3
|
+
import './styles.scss';
|
|
4
|
+
export type ServerErrorReportIntent = 'error' | 'feedback';
|
|
5
|
+
export type ServerErrorReportFormHandle = {
|
|
6
|
+
send: () => Promise<void>;
|
|
7
|
+
canSend: boolean;
|
|
8
|
+
sending: boolean;
|
|
9
|
+
};
|
|
10
|
+
type Props = {
|
|
11
|
+
errorContext?: ServerErrorContext;
|
|
12
|
+
corpus?: Corpus;
|
|
13
|
+
intent?: ServerErrorReportIntent;
|
|
14
|
+
/** When true, renders a Send button inside the form (Help Center embed). */
|
|
15
|
+
showSendButton?: boolean;
|
|
16
|
+
onSent: () => void;
|
|
17
|
+
onSendingChange?: (sending: boolean) => void;
|
|
18
|
+
onCanSendChange?: (canSend: boolean) => void;
|
|
19
|
+
className?: string;
|
|
20
|
+
};
|
|
21
|
+
declare const ServerErrorReportForm: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<ServerErrorReportFormHandle>>;
|
|
22
|
+
export default ServerErrorReportForm;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import AppTextArea from '../../common/AppTextArea/AppTextArea';
|
|
6
|
+
import ErrorReportService from '../../configs/services/ErrorReportService';
|
|
7
|
+
import { Button } from '../../primitives';
|
|
8
|
+
import { captureTabScreenshot } from './captureTabScreenshot';
|
|
9
|
+
import { getConsoleLogs } from './consoleCapture';
|
|
10
|
+
import './styles.scss';
|
|
11
|
+
const DEFAULT_USER_MESSAGE = 'No extra information given by the user';
|
|
12
|
+
const ServerErrorReportForm = forwardRef(function ServerErrorReportForm({ errorContext, corpus, intent = 'error', showSendButton = false, onSent, onSendingChange, onCanSendChange, className, }, ref) {
|
|
13
|
+
const { t, i18n } = useTranslation('common');
|
|
14
|
+
const [userMessage, setUserMessage] = useState('');
|
|
15
|
+
const [sending, setSending] = useState(false);
|
|
16
|
+
const [sendError, setSendError] = useState(null);
|
|
17
|
+
const canSend = !sending;
|
|
18
|
+
const placeholderKey = intent === 'feedback'
|
|
19
|
+
? 'server.error.report.feedback.placeholder'
|
|
20
|
+
: 'server.error.report.modal.placeholder';
|
|
21
|
+
const sendLabelKey = intent === 'feedback'
|
|
22
|
+
? 'server.error.report.feedback.send'
|
|
23
|
+
: 'server.error.report.modal.send';
|
|
24
|
+
const handleSend = async () => {
|
|
25
|
+
setSending(true);
|
|
26
|
+
onSendingChange?.(true);
|
|
27
|
+
setSendError(null);
|
|
28
|
+
try {
|
|
29
|
+
const screenshot = await captureTabScreenshot();
|
|
30
|
+
await ErrorReportService.send({
|
|
31
|
+
userMessage: userMessage.trim() || DEFAULT_USER_MESSAGE,
|
|
32
|
+
errorContext,
|
|
33
|
+
sendContext: {
|
|
34
|
+
locale: i18n.resolvedLanguage || i18n.language,
|
|
35
|
+
corpusUid: corpus?.uid,
|
|
36
|
+
corpusName: corpus?.name,
|
|
37
|
+
},
|
|
38
|
+
consoleLogs: getConsoleLogs(),
|
|
39
|
+
screenshot,
|
|
40
|
+
});
|
|
41
|
+
setUserMessage('');
|
|
42
|
+
onSent();
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.error('Failed to send server error report:', axios.isAxiosError(error)
|
|
46
|
+
? {
|
|
47
|
+
message: error.message,
|
|
48
|
+
status: error.response?.status,
|
|
49
|
+
data: error.response?.data,
|
|
50
|
+
url: error.config?.url,
|
|
51
|
+
}
|
|
52
|
+
: error);
|
|
53
|
+
setSendError(t('server.error.report.send.failed'));
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
setSending(false);
|
|
57
|
+
onSendingChange?.(false);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
useImperativeHandle(ref, () => ({
|
|
61
|
+
send: handleSend,
|
|
62
|
+
canSend,
|
|
63
|
+
sending,
|
|
64
|
+
}),
|
|
65
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- handleSend closes over latest state
|
|
66
|
+
[canSend, sending, userMessage, errorContext, corpus, intent]);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
onCanSendChange?.(canSend);
|
|
69
|
+
}, [canSend, onCanSendChange]);
|
|
70
|
+
const rootClass = [
|
|
71
|
+
'server-error-report-form',
|
|
72
|
+
intent === 'feedback' && 'server-error-report-form--feedback',
|
|
73
|
+
className,
|
|
74
|
+
]
|
|
75
|
+
.filter(Boolean)
|
|
76
|
+
.join(' ');
|
|
77
|
+
return (_jsxs("div", { className: rootClass, children: [_jsx(AppTextArea, { value: userMessage, onChange: (e) => {
|
|
78
|
+
setUserMessage(e.target.value);
|
|
79
|
+
if (sendError)
|
|
80
|
+
setSendError(null);
|
|
81
|
+
}, placeholder: t(placeholderKey), rows: intent === 'feedback' ? 5 : 6, disabled: sending, "aria-label": t(placeholderKey) }), sendError && (_jsx("p", { className: "server-error-report-form__error", role: "alert", children: sendError })), showSendButton && (_jsx(Button, { text: t(sendLabelKey), size: "small", icon: "send", onClick: () => {
|
|
82
|
+
void handleSend();
|
|
83
|
+
}, disabled: !canSend }))] }));
|
|
84
|
+
});
|
|
85
|
+
export default ServerErrorReportForm;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Best-effort tab screenshot for error reports.
|
|
3
|
-
*
|
|
3
|
+
* Skips open MUI modals (incl. Help Center) and toasts so the page underneath is captured.
|
|
4
4
|
*/
|
|
5
5
|
export declare function captureTabScreenshot(): Promise<string | null>;
|
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
import html2canvas from 'html2canvas';
|
|
2
2
|
const MAX_WIDTH = 1600;
|
|
3
3
|
const JPEG_QUALITY = 0.85;
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const root = modal?.closest('.MuiModal-root') ||
|
|
8
|
-
modal;
|
|
9
|
-
if (root) {
|
|
10
|
-
hidden.push({ el: root, display: root.style.display });
|
|
11
|
-
root.style.display = 'none';
|
|
12
|
-
}
|
|
13
|
-
return hidden;
|
|
14
|
-
}
|
|
15
|
-
function restoreHidden(hidden) {
|
|
16
|
-
hidden.forEach(({ el, display }) => {
|
|
17
|
-
el.style.display = display;
|
|
18
|
-
});
|
|
4
|
+
function shouldIgnoreElement(el) {
|
|
5
|
+
return (el.classList.contains('MuiModal-root') ||
|
|
6
|
+
el.classList.contains('Toastify'));
|
|
19
7
|
}
|
|
20
8
|
function toJpegDataUrl(canvas) {
|
|
21
9
|
let out = canvas;
|
|
@@ -33,24 +21,21 @@ function toJpegDataUrl(canvas) {
|
|
|
33
21
|
}
|
|
34
22
|
/**
|
|
35
23
|
* Best-effort tab screenshot for error reports.
|
|
36
|
-
*
|
|
24
|
+
* Skips open MUI modals (incl. Help Center) and toasts so the page underneath is captured.
|
|
37
25
|
*/
|
|
38
26
|
export async function captureTabScreenshot() {
|
|
39
27
|
if (typeof document === 'undefined' || !document.body) {
|
|
40
28
|
return null;
|
|
41
29
|
}
|
|
42
|
-
const hidden = hideReportUi();
|
|
43
30
|
try {
|
|
44
31
|
const canvas = await html2canvas(document.body, {
|
|
45
32
|
logging: false,
|
|
46
33
|
useCORS: true,
|
|
34
|
+
ignoreElements: shouldIgnoreElement,
|
|
47
35
|
});
|
|
48
36
|
return toJpegDataUrl(canvas);
|
|
49
37
|
}
|
|
50
38
|
catch {
|
|
51
39
|
return null;
|
|
52
40
|
}
|
|
53
|
-
finally {
|
|
54
|
-
restoreHidden(hidden);
|
|
55
|
-
}
|
|
56
41
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
.server-error-report-modal {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
flex-direction: column;
|
|
5
|
-
gap: var(--spacing-200);
|
|
2
|
+
.app-text-area {
|
|
3
|
+
min-height: 160px;
|
|
6
4
|
}
|
|
5
|
+
}
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
7
|
+
.server-error-report-form {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
gap: var(--spacing-200);
|
|
13
11
|
|
|
14
12
|
.app-text-area {
|
|
15
13
|
min-height: 160px;
|
|
@@ -17,4 +15,19 @@
|
|
|
17
15
|
border-radius: var(--radius-100);
|
|
18
16
|
background-color: var(--background-default);
|
|
19
17
|
}
|
|
18
|
+
|
|
19
|
+
&--feedback .app-text-area {
|
|
20
|
+
min-height: 120px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&__error {
|
|
24
|
+
margin: 0;
|
|
25
|
+
color: var(--text-danger);
|
|
26
|
+
@include body-small-1;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
> .ds-button {
|
|
30
|
+
align-self: flex-start;
|
|
31
|
+
margin-top: var(--spacing-050);
|
|
32
|
+
}
|
|
20
33
|
}
|
package/dist/features/index.d.ts
CHANGED
|
@@ -2,10 +2,14 @@ export { default as CommentComponent } from "./Comments";
|
|
|
2
2
|
export { default as HeaderNotifications } from "./Comments/HeaderNotifications";
|
|
3
3
|
export type { Comment, CommentRequest } from "./Comments/types/Comment";
|
|
4
4
|
export { default as CommentService } from "./Comments/CommentService";
|
|
5
|
+
export { BackupTable, BackupRestore, BackupService, EMPTY_BACKUP_SEARCH_FILTER, } from "./Backup";
|
|
6
|
+
export type { Backup, BackupStatus, BackupTableProps, BackupRestoreProps, BackupSearchFilter, } from "./Backup";
|
|
5
7
|
export { AccessUsers, AccessUser, AccessGrant, AccessControlService, EMPTY_ACCESS_SEARCH_FILTER, EMPTY_PORTAL, PortalRoleName, } from "./AccessControl";
|
|
6
|
-
export type { AccessUsersProps, AccessUsersFilter, AccessResponse, UserAccessRequest, UserAccessResponse, PortalInformation, PortalInformationRequest, PortalRole, } from "./AccessControl";
|
|
8
|
+
export type { AccessUsersProps, AccessUsersFilter, AccessResponse, UserAccessRequest, UserAccessResponse, CorpusGroup, CorpusGroupRole, CorpusGroupStatus, PortalInformation, PortalInformationRequest, PortalRole, } from "./AccessControl";
|
|
7
9
|
export { CorpusOwner } from "./CorpusOwner";
|
|
8
10
|
export type { CorpusOwnerProps, CorpusOwnerUser } from "./CorpusOwner";
|
|
11
|
+
export { ParserRuleGroupsEditor, applyParserRuleGroupsMap, toParserRuleGroupsMap, } from "./ParserRuleGroups";
|
|
12
|
+
export type { ParserRuleGroupsEditorProps, ParserRuleGroupItem, } from "./ParserRuleGroups";
|
|
9
13
|
export { default as SentenceView } from "./SentenceView";
|
|
10
14
|
export { default as TreeView } from "./TreeView";
|
|
11
15
|
export { default as ConlluGraphViewer } from "./ConlluGraphViewer";
|
package/dist/features/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export { default as CommentComponent } from "./Comments";
|
|
2
2
|
export { default as HeaderNotifications } from "./Comments/HeaderNotifications";
|
|
3
3
|
export { default as CommentService } from "./Comments/CommentService";
|
|
4
|
+
export { BackupTable, BackupRestore, BackupService, EMPTY_BACKUP_SEARCH_FILTER, } from "./Backup";
|
|
4
5
|
export { AccessUsers, AccessUser, AccessGrant, AccessControlService, EMPTY_ACCESS_SEARCH_FILTER, EMPTY_PORTAL, PortalRoleName, } from "./AccessControl";
|
|
5
6
|
export { CorpusOwner } from "./CorpusOwner";
|
|
7
|
+
export { ParserRuleGroupsEditor, applyParserRuleGroupsMap, toParserRuleGroupsMap, } from "./ParserRuleGroups";
|
|
6
8
|
export { default as SentenceView } from "./SentenceView";
|
|
7
9
|
export { default as TreeView } from "./TreeView";
|
|
8
10
|
export { default as ConlluGraphViewer } from "./ConlluGraphViewer";
|
|
@@ -42,7 +42,7 @@ export default function AsyncSelectField({ className, attr, label, createdForm,
|
|
|
42
42
|
}
|
|
43
43
|
}, []);
|
|
44
44
|
const hasError = () => !!createdForm.formState.errors[attr];
|
|
45
|
-
const getClassNames = cx('ds-select-text', className, {
|
|
45
|
+
const getClassNames = cx('ds-async-select-text', className, {
|
|
46
46
|
disabled: disabled,
|
|
47
47
|
});
|
|
48
48
|
useEffect(() => {
|
|
@@ -95,7 +95,7 @@ export default function AsyncSelectField({ className, attr, label, createdForm,
|
|
|
95
95
|
field.onChange(trimmed);
|
|
96
96
|
onChange?.(attr, trimmed);
|
|
97
97
|
};
|
|
98
|
-
return (_jsxs("div", { className: getClassNames, children: [_jsxs("div", { className: "ds-select-text__autofill-trap", "aria-hidden": "true", children: [_jsx("input", { type: "text", tabIndex: -1, autoComplete: "username", name: `${autoCompleteToken}-username`, defaultValue: "" }), _jsx("input", { type: "password", tabIndex: -1, autoComplete: "new-password", name: `${autoCompleteToken}-password`, defaultValue: "" })] }), _jsx(Controller, { name: fieldName, control: createdForm.control, render: ({ field }) => (_jsxs(ThemeProvider, { theme: selectAutocompleteTheme(outerTheme, {
|
|
98
|
+
return (_jsxs("div", { className: getClassNames, children: [_jsxs("div", { className: "ds-async-select-text__autofill-trap", "aria-hidden": "true", children: [_jsx("input", { type: "text", tabIndex: -1, autoComplete: "username", name: `${autoCompleteToken}-username`, defaultValue: "" }), _jsx("input", { type: "password", tabIndex: -1, autoComplete: "new-password", name: `${autoCompleteToken}-password`, defaultValue: "" })] }), _jsx(Controller, { name: fieldName, control: createdForm.control, render: ({ field }) => (_jsxs(ThemeProvider, { theme: selectAutocompleteTheme(outerTheme, {
|
|
99
99
|
hasLabel: !!label,
|
|
100
100
|
}), children: [_jsx(FormControl, { fullWidth: true, variant: "filled", disabled: disabled, children: _jsx(Autocomplete, { multiple: multiple, freeSolo: freeSolo, disableCloseOnSelect: multiple, value: field.value ?? (multiple ? [] : null), onChange: (_event, newValue) => {
|
|
101
101
|
field.onChange(newValue);
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
.ds-select-text {
|
|
2
|
-
width: 100%;
|
|
3
|
-
position: relative;
|
|
4
|
-
|
|
5
|
-
&.disabled {
|
|
6
|
-
color: var(--text-on-disabled);
|
|
7
|
-
cursor: not-allowed;
|
|
8
|
-
|
|
9
|
-
input {
|
|
10
|
-
cursor: not-allowed;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
&__autofill-trap {
|
|
15
|
-
position: absolute;
|
|
16
|
-
width: 0;
|
|
17
|
-
height: 0;
|
|
18
|
-
overflow: hidden;
|
|
19
|
-
opacity: 0;
|
|
20
|
-
pointer-events: none;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.validation-message {
|
|
25
|
-
@include helper-small-1;
|
|
26
|
-
margin-top: 4px;
|
|
27
|
-
|
|
28
|
-
&.error {
|
|
29
|
-
color: var(--text-error);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
.ds-async-select-text {
|
|
2
|
+
width: 100%;
|
|
3
|
+
position: relative;
|
|
4
|
+
|
|
5
|
+
&.disabled {
|
|
6
|
+
color: var(--text-on-disabled);
|
|
7
|
+
cursor: not-allowed;
|
|
8
|
+
|
|
9
|
+
input {
|
|
10
|
+
cursor: not-allowed;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&__autofill-trap {
|
|
15
|
+
position: absolute;
|
|
16
|
+
width: 0;
|
|
17
|
+
height: 0;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
opacity: 0;
|
|
20
|
+
pointer-events: none;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.validation-message {
|
|
25
|
+
@include helper-small-1;
|
|
26
|
+
margin-top: 4px;
|
|
27
|
+
|
|
28
|
+
&.error {
|
|
29
|
+
color: var(--text-error);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
32
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { IconSizes } from '../Icon/Icon';
|
|
2
|
+
import './styles.scss';
|
|
3
3
|
export declare const ButtonModes: readonly ["filled", "tonal", "outlined", "ghost"];
|
|
4
4
|
export type ButtonDSModes = (typeof ButtonModes)[number];
|
|
5
5
|
export declare const ButtonSizes: readonly ["large", "medium", "small", "x-small"];
|
|
@@ -8,7 +8,7 @@ export declare const ButtonColors: readonly ["accent", "danger", "white"];
|
|
|
8
8
|
export type ButtonDSColors = (typeof ButtonColors)[number];
|
|
9
9
|
export declare const ButtonIconPositions: readonly ["left", "right"];
|
|
10
10
|
export type ButtonDSPositions = (typeof ButtonIconPositions)[number];
|
|
11
|
-
export type Props = JSX.IntrinsicElements[
|
|
11
|
+
export type Props = JSX.IntrinsicElements['button'] & {
|
|
12
12
|
text: string;
|
|
13
13
|
color?: ButtonDSColors;
|
|
14
14
|
size?: ButtonDSSizes;
|
|
@@ -21,5 +21,6 @@ export type Props = JSX.IntrinsicElements["button"] & {
|
|
|
21
21
|
iconSize?: IconSizes;
|
|
22
22
|
iconFilled?: boolean;
|
|
23
23
|
spin?: boolean;
|
|
24
|
+
dataTour?: string;
|
|
24
25
|
};
|
|
25
|
-
export default function Button({ text, className, disabled, active, color, size, mode, icon, iconImage, iconPosition, iconSize, iconFilled, spin, onClick, ...buttonProps }: Props): import("react").JSX.Element;
|
|
26
|
+
export default function Button({ text, className, disabled, active, color, size, mode, icon, iconImage, iconPosition, iconSize, iconFilled, spin, onClick, dataTour, ...buttonProps }: Props): import("react").JSX.Element;
|