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,52 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import AppDropzone from '../../../common/AppDropzone';
|
|
5
|
+
import AppLoading from '../../../common/AppLoading';
|
|
6
|
+
import AppModal from '../../../common/AppModal';
|
|
7
|
+
import { useMessageUtils } from '../../../configs/useMessageUtils';
|
|
8
|
+
import BackupService from '../BackupService';
|
|
9
|
+
import './style.scss';
|
|
10
|
+
export default function BackupRestore({ mode, onClose }) {
|
|
11
|
+
const { t } = useTranslation('backup');
|
|
12
|
+
const { dispatchError } = useMessageUtils();
|
|
13
|
+
const [openExists, setOpenExists] = useState(false);
|
|
14
|
+
const [backup, setBackup] = useState();
|
|
15
|
+
const [loading, setLoading] = useState(false);
|
|
16
|
+
const handleSuccess = (uploaded) => {
|
|
17
|
+
BackupService.restore(mode, uploaded)
|
|
18
|
+
.then((r) => {
|
|
19
|
+
setBackup(r.data);
|
|
20
|
+
if (r.data.message === 'corpus.exists') {
|
|
21
|
+
setOpenExists(true);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
handleExecute(r.data.id);
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
.catch((err) => {
|
|
28
|
+
dispatchError({ err, t });
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
const handleExecute = (id) => {
|
|
32
|
+
if (loading)
|
|
33
|
+
return;
|
|
34
|
+
setLoading(true);
|
|
35
|
+
BackupService.executeRestore(id)
|
|
36
|
+
.then(() => {
|
|
37
|
+
location.reload();
|
|
38
|
+
})
|
|
39
|
+
.catch((err) => {
|
|
40
|
+
dispatchError({ err, t });
|
|
41
|
+
setLoading(false);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const handleError = () => {
|
|
45
|
+
dispatchError({ err: 'message:upload.error', t });
|
|
46
|
+
};
|
|
47
|
+
return (_jsxs(_Fragment, { children: [_jsx(AppDropzone, { folder: "/restore", onSuccess: handleSuccess, onError: handleError, onClose: onClose, keepName: true, accept: {
|
|
48
|
+
'application/gzip': ['.gz'],
|
|
49
|
+
'application/x-tar': ['.tar'],
|
|
50
|
+
'application/x-compressed-tar': ['.tar.gz'],
|
|
51
|
+
} }), openExists && (_jsxs(AppModal, { title: t('modal.restore.title'), className: "modal-parameter", confirm: () => backup && handleExecute(backup.id), close: () => setOpenExists(false), disableConfirm: loading, disableClose: loading, disableEscapeClose: loading, disableBackdropClose: loading, children: [_jsx("div", { className: "alert alert-danger m-b-0", children: _jsxs("p", { children: [_jsx("span", { children: t(`modal.restore.message.${mode}`) }), _jsx("b", { className: "ms-1", children: t('modal.restore.confirm') })] }) }), loading && _jsx(AppLoading, {})] }))] }));
|
|
52
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AccessMode } from '../../configs/types/Access';
|
|
2
|
+
import { AppPage } from '../../common';
|
|
3
|
+
import { UploadedFile } from '../../common/AppDropzone/UploadedFile';
|
|
4
|
+
import { BackupSearchFilter } from './BackupTable/BackupSearchFilter';
|
|
5
|
+
import Backup from './types/Backup';
|
|
6
|
+
declare function page(mode: AccessMode, resourceUid: string, filter: BackupSearchFilter): Promise<import("axios").AxiosResponse<AppPage<Backup>, any, {}, any>>;
|
|
7
|
+
declare function execute(mode: AccessMode, resourceUid: string): Promise<import("axios").AxiosResponse<Backup, any, {}, any>>;
|
|
8
|
+
declare function status(id: string): Promise<import("axios").AxiosResponse<Backup, any, {}, any>>;
|
|
9
|
+
declare function restore(mode: AccessMode, uploaded: UploadedFile): Promise<import("axios").AxiosResponse<Backup, any, {}, any>>;
|
|
10
|
+
declare function executeRestore(id: string): Promise<import("axios").AxiosResponse<Backup, any, {}, any>>;
|
|
11
|
+
declare function download(id: string): Promise<import("axios").AxiosResponse<string, any, {}, any>>;
|
|
12
|
+
declare const BackupService: {
|
|
13
|
+
page: typeof page;
|
|
14
|
+
execute: typeof execute;
|
|
15
|
+
status: typeof status;
|
|
16
|
+
download: typeof download;
|
|
17
|
+
restore: typeof restore;
|
|
18
|
+
executeRestore: typeof executeRestore;
|
|
19
|
+
};
|
|
20
|
+
export default BackupService;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import api from '../../configs/api';
|
|
2
|
+
import { convertPageable } from '../../common';
|
|
3
|
+
const FUNCTIONS_API = () => import.meta.env.VITE_APP_FUNCTIONS_API;
|
|
4
|
+
const APP_BY_MODE = {
|
|
5
|
+
corpus: 'CORPUS',
|
|
6
|
+
parser: 'PARSER',
|
|
7
|
+
lexicon: 'LEXICON',
|
|
8
|
+
};
|
|
9
|
+
function page(mode, resourceUid, filter) {
|
|
10
|
+
const data = {
|
|
11
|
+
id: resourceUid,
|
|
12
|
+
app: APP_BY_MODE[mode],
|
|
13
|
+
...convertPageable(filter),
|
|
14
|
+
};
|
|
15
|
+
return api.post(`${FUNCTIONS_API()}/backup`, data);
|
|
16
|
+
}
|
|
17
|
+
function execute(mode, resourceUid) {
|
|
18
|
+
return api.get(`${FUNCTIONS_API()}/backup/${resourceUid}/${APP_BY_MODE[mode]}`);
|
|
19
|
+
}
|
|
20
|
+
function status(id) {
|
|
21
|
+
return api.get(`${FUNCTIONS_API()}/backup/status/${id}`);
|
|
22
|
+
}
|
|
23
|
+
function restore(mode, uploaded) {
|
|
24
|
+
return api.post(`${FUNCTIONS_API()}/backup/restore`, {
|
|
25
|
+
filename: uploaded.path,
|
|
26
|
+
app: APP_BY_MODE[mode],
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function executeRestore(id) {
|
|
30
|
+
return api.post(`${FUNCTIONS_API()}/backup/restore/${id}`);
|
|
31
|
+
}
|
|
32
|
+
function download(id) {
|
|
33
|
+
return api.get(`${FUNCTIONS_API()}/backup/download/${id}`);
|
|
34
|
+
}
|
|
35
|
+
const BackupService = {
|
|
36
|
+
page,
|
|
37
|
+
execute,
|
|
38
|
+
status,
|
|
39
|
+
download,
|
|
40
|
+
restore,
|
|
41
|
+
executeRestore,
|
|
42
|
+
};
|
|
43
|
+
export default BackupService;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AccessMode } from '../../../configs/types/Access';
|
|
3
|
+
import './style.scss';
|
|
4
|
+
export type BackupTableProps = {
|
|
5
|
+
mode: AccessMode;
|
|
6
|
+
resourceUid: string;
|
|
7
|
+
};
|
|
8
|
+
export default function BackupTable({ mode, resourceUid }: BackupTableProps): React.JSX.Element;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import AppCard from '../../../common/AppCard/AppCard';
|
|
5
|
+
import AppPicture from '../../../common/AppPicture';
|
|
6
|
+
import AppPlaceholder from '../../../common/AppPlaceholder';
|
|
7
|
+
import AppTable from '../../../common/AppTable';
|
|
8
|
+
import { EMPTY_PAGE } from '../../../common/AppTable/types/AppPage';
|
|
9
|
+
import DateUtils from '../../../functions/DateUtils';
|
|
10
|
+
import { Button } from '../../../primitives';
|
|
11
|
+
import BackupCreate from '../BackupCreate';
|
|
12
|
+
import BackupInfo from '../BackupInfo';
|
|
13
|
+
import BackupService from '../BackupService';
|
|
14
|
+
import { EMPTY_BACKUP_SEARCH_FILTER, } from './BackupSearchFilter';
|
|
15
|
+
import './style.scss';
|
|
16
|
+
export default function BackupTable({ mode, resourceUid }) {
|
|
17
|
+
const { t } = useTranslation('backup');
|
|
18
|
+
const [filter, setFilter] = useState(EMPTY_BACKUP_SEARCH_FILTER);
|
|
19
|
+
const [data, setData] = useState();
|
|
20
|
+
const [selected, setSelected] = useState();
|
|
21
|
+
const [openInfo, setOpenInfo] = useState(false);
|
|
22
|
+
const [openCreate, setOpenCreate] = useState(false);
|
|
23
|
+
const load = () => {
|
|
24
|
+
if (!resourceUid)
|
|
25
|
+
return;
|
|
26
|
+
BackupService.page(mode, resourceUid, filter).then((r) => {
|
|
27
|
+
setData(r.data);
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const onClickRow = (row) => {
|
|
31
|
+
setSelected(row);
|
|
32
|
+
setOpenInfo(true);
|
|
33
|
+
};
|
|
34
|
+
const handleCreate = () => {
|
|
35
|
+
setSelected(undefined);
|
|
36
|
+
setOpenCreate(true);
|
|
37
|
+
};
|
|
38
|
+
const onConfirm = (backup) => {
|
|
39
|
+
const updatedData = {
|
|
40
|
+
...(data || EMPTY_PAGE),
|
|
41
|
+
totalElements: (data?.totalElements ?? 0) + 1,
|
|
42
|
+
content: [backup, ...(data?.content ?? [])],
|
|
43
|
+
};
|
|
44
|
+
setData(updatedData);
|
|
45
|
+
setOpenCreate(false);
|
|
46
|
+
};
|
|
47
|
+
const handleDownload = (fileUrl) => {
|
|
48
|
+
if (!resourceUid)
|
|
49
|
+
return;
|
|
50
|
+
BackupService.download(resourceUid).then((r) => {
|
|
51
|
+
const filename = fileUrl.split('/').pop();
|
|
52
|
+
if (!filename) {
|
|
53
|
+
console.error('Invalid file URL');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const secureUrl = `${fileUrl}?token=${encodeURIComponent(r.data)}`;
|
|
57
|
+
window.open(secureUrl, '_blank');
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
const menuOptions = [
|
|
61
|
+
{
|
|
62
|
+
icon: 'add',
|
|
63
|
+
label: t('button.create'),
|
|
64
|
+
onClick: handleCreate,
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
const addDownloadButtonToCell = (props) => {
|
|
68
|
+
return (_jsx(Button, { text: t('backup.field.download'), size: "x-small", onClick: (e) => {
|
|
69
|
+
e.stopPropagation();
|
|
70
|
+
handleDownload(props.row.original.path);
|
|
71
|
+
} }));
|
|
72
|
+
};
|
|
73
|
+
const addDateToCell = (props) => {
|
|
74
|
+
return (_jsx("span", { children: DateUtils.extractDateFromMongoId(props.row.original.id, true) }));
|
|
75
|
+
};
|
|
76
|
+
const addUserToCell = (props) => {
|
|
77
|
+
const user = props.row.original.user;
|
|
78
|
+
return (_jsxs("div", { className: "user", children: [_jsx(AppPicture, { className: "avatar", src: user.picture, person: true }), _jsx("span", { className: "ms-2", children: user.name })] }));
|
|
79
|
+
};
|
|
80
|
+
const columns = React.useMemo(() => [
|
|
81
|
+
{
|
|
82
|
+
id: 'date',
|
|
83
|
+
header: t('backup.field.id'),
|
|
84
|
+
cell: addDateToCell,
|
|
85
|
+
size: 20,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: 'filename',
|
|
89
|
+
header: t('backup.field.filename'),
|
|
90
|
+
accessorKey: 'filename',
|
|
91
|
+
size: 45,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: 'user',
|
|
95
|
+
header: t('backup.field.user.name'),
|
|
96
|
+
cell: addUserToCell,
|
|
97
|
+
size: 25,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: 'status',
|
|
101
|
+
header: t('backup.field.status'),
|
|
102
|
+
accessorKey: 'status',
|
|
103
|
+
cell: (props) => t(`backup.status.${props.row.original.status.toLowerCase()}`),
|
|
104
|
+
size: 10,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: 'download',
|
|
108
|
+
header: t('backup.field.download'),
|
|
109
|
+
cell: addDownloadButtonToCell,
|
|
110
|
+
size: 10,
|
|
111
|
+
},
|
|
112
|
+
], [data, t]);
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
load();
|
|
115
|
+
}, [filter, resourceUid, mode]);
|
|
116
|
+
return (_jsxs(AppCard, { title: t('label.title'), className: "base-card backup-table-card", dataTour: "admin-info-backups-panel", options: menuOptions, children: [data && data.totalElements !== 0 && (_jsx(AppTable, { columns: columns, data: data, onClickRow: onClickRow, pagination: { pageIndex: filter.page, pageSize: filter.size }, setPagination: (p) => {
|
|
117
|
+
setFilter({ ...filter, page: p.pageIndex, size: p.pageSize });
|
|
118
|
+
}, sorting: filter.sort || [], setSorting: (s) => {
|
|
119
|
+
setFilter({ ...filter, sort: s });
|
|
120
|
+
} })), data && data.totalElements === 0 && (_jsx(AppPlaceholder, { text: t('placeholder.empty') })), openInfo && selected && (_jsx(BackupInfo, { backup: selected, onClose: () => setOpenInfo(false) })), openCreate && (_jsx(BackupCreate, { mode: mode, resourceUid: resourceUid, onClose: () => setOpenCreate(false), onConfirm: onConfirm }))] }));
|
|
121
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as BackupTable } from './BackupTable';
|
|
2
|
+
export type { BackupTableProps } from './BackupTable';
|
|
3
|
+
export { EMPTY_BACKUP_SEARCH_FILTER, type BackupSearchFilter, } from './BackupTable';
|
|
4
|
+
export { default as BackupRestore } from './BackupRestore';
|
|
5
|
+
export type { BackupRestoreProps } from './BackupRestore';
|
|
6
|
+
export { default as BackupService } from './BackupService';
|
|
7
|
+
export type { Backup, BackupStatus } from './types/Backup';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { User } from '../../../configs/types/User';
|
|
2
|
+
export type BackupStatus = 'ERROR' | 'PROCESSING' | 'FINISHED';
|
|
3
|
+
export type Backup = {
|
|
4
|
+
id: string;
|
|
5
|
+
log: string;
|
|
6
|
+
ref: string;
|
|
7
|
+
filename: string;
|
|
8
|
+
user: User;
|
|
9
|
+
status: BackupStatus;
|
|
10
|
+
app: string;
|
|
11
|
+
message: string;
|
|
12
|
+
path: string;
|
|
13
|
+
};
|
|
14
|
+
export default Backup;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import api from '../../configs/api';
|
|
2
|
+
import authApi from '../../configs/auth/authApi';
|
|
2
3
|
import StorybookUtils from '../../functions/StorybookUtils';
|
|
3
4
|
import { mockCommentUsers, mockComments } from './CommentService.mock';
|
|
4
5
|
let storybookComments = mockComments.map((c) => ({ ...c }));
|
|
@@ -109,7 +110,7 @@ function findAvailableUsers(uid, mode) {
|
|
|
109
110
|
if (StorybookUtils.isStorybook()) {
|
|
110
111
|
return mockResponse(mockCommentUsers);
|
|
111
112
|
}
|
|
112
|
-
return
|
|
113
|
+
return authApi.get(`/${mode}/${uid}`);
|
|
113
114
|
}
|
|
114
115
|
const CommentService = {
|
|
115
116
|
add,
|
|
@@ -2,5 +2,5 @@ import './style.scss';
|
|
|
2
2
|
import { CollapsedPageRenderElement, PageRenderElement, PageRenderViewProps } from './types';
|
|
3
3
|
/** Ensure PARTICIPANT elements carry a sentence uid (API or next-token look-ahead). */
|
|
4
4
|
export declare function withParticipantSentenceUids(elements: PageRenderElement[]): PageRenderElement[];
|
|
5
|
-
export default function PageRenderView({ elements, selectedTier, corpus, displayTags, showLineNumbers, highlightSentenceUid, activeTokenKey, selectedTokenKeys, tokenSelectionKey, getDisplayValue, getTokenStyle, getTokenClassName, isTokenEdited, getParticipantName, getParticipantColor, onTokenClick, onTokenHover, onParticipantHover, onParticipantClick, wrapToken, renderTokenSuffix, }: PageRenderViewProps): import("react").JSX.Element;
|
|
5
|
+
export default function PageRenderView({ elements, selectedTier, corpus, displayTags, showLineNumbers, showSectionLabels, highlightSentenceUid, activeTokenKey, selectedTokenKeys, tokenSelectionKey, getDisplayValue, getTokenStyle, getTokenClassName, isTokenEdited, getParticipantName, getParticipantColor, getSectionLabel, onTokenClick, onTokenHover, onParticipantHover, onParticipantClick, wrapToken, renderTokenSuffix, }: PageRenderViewProps): import("react").JSX.Element;
|
|
6
6
|
export declare function findPunctuationAfterCollapsedJunction(items: CollapsedPageRenderElement[], junctionIndex: number): number | undefined;
|
|
@@ -24,7 +24,7 @@ export function withParticipantSentenceUids(elements) {
|
|
|
24
24
|
return element;
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
export default function PageRenderView({ elements, selectedTier, corpus, displayTags = false, showLineNumbers = true, highlightSentenceUid, activeTokenKey, selectedTokenKeys, tokenSelectionKey, getDisplayValue, getTokenStyle, getTokenClassName, isTokenEdited, getParticipantName, getParticipantColor, onTokenClick, onTokenHover, onParticipantHover, onParticipantClick, wrapToken, renderTokenSuffix, }) {
|
|
27
|
+
export default function PageRenderView({ elements, selectedTier, corpus, displayTags = false, showLineNumbers = true, showSectionLabels = true, highlightSentenceUid, activeTokenKey, selectedTokenKeys, tokenSelectionKey, getDisplayValue, getTokenStyle, getTokenClassName, isTokenEdited, getParticipantName, getParticipantColor, getSectionLabel, onTokenClick, onTokenHover, onParticipantHover, onParticipantClick, wrapToken, renderTokenSuffix, }) {
|
|
28
28
|
const elementsWithUids = useMemo(() => withParticipantSentenceUids(elements), [elements]);
|
|
29
29
|
const collapsed = collapseElementsForTier(elementsWithUids, selectedTier, corpus);
|
|
30
30
|
const punctuationBeforeBreak = new Map();
|
|
@@ -36,8 +36,30 @@ export default function PageRenderView({ elements, selectedTier, corpus, display
|
|
|
36
36
|
punctuationBeforeBreak.set(index, punctuationIndex);
|
|
37
37
|
punctuationIndexes.add(punctuationIndex);
|
|
38
38
|
});
|
|
39
|
+
const sectionLabelByItemKey = useMemo(() => {
|
|
40
|
+
const labels = new Map();
|
|
41
|
+
if (!showSectionLabels || !getSectionLabel)
|
|
42
|
+
return labels;
|
|
43
|
+
const seenSentences = new Set();
|
|
44
|
+
for (const item of collapsed) {
|
|
45
|
+
if (!isTokenBearingItem(item))
|
|
46
|
+
continue;
|
|
47
|
+
const uid = sentenceUidForItem(item);
|
|
48
|
+
if (!uid || seenSentences.has(uid))
|
|
49
|
+
continue;
|
|
50
|
+
// Skip empty categories / hidden tokens so the chip floats over the
|
|
51
|
+
// first actually displayed word of the sentence.
|
|
52
|
+
if (!isVisibleSectionHost(item, displayTags))
|
|
53
|
+
continue;
|
|
54
|
+
seenSentences.add(uid);
|
|
55
|
+
const label = getSectionLabel(uid);
|
|
56
|
+
if (label)
|
|
57
|
+
labels.set(item.key, label);
|
|
58
|
+
}
|
|
59
|
+
return labels;
|
|
60
|
+
}, [collapsed, displayTags, getSectionLabel, showSectionLabels]);
|
|
39
61
|
const renderItem = (item) => (_jsx(PageRenderElementItem, { item: item, highlight: highlightSentenceUid != null &&
|
|
40
|
-
sentenceUidForItem(item) === highlightSentenceUid, showLineNumbers: showLineNumbers, displayTags: displayTags, activeTokenKey: activeTokenKey, selectedTokenKeys: selectedTokenKeys, tokenSelectionKey: tokenSelectionKey, getDisplayValue: getDisplayValue, getTokenStyle: getTokenStyle, getTokenClassName: getTokenClassName, isTokenEdited: isTokenEdited, getParticipantName: getParticipantName, getParticipantColor: getParticipantColor, onTokenClick: onTokenClick, onTokenHover: onTokenHover, onParticipantHover: onParticipantHover, onParticipantClick: onParticipantClick, wrapToken: wrapToken, renderTokenSuffix: renderTokenSuffix }, item.key));
|
|
62
|
+
sentenceUidForItem(item) === highlightSentenceUid, showLineNumbers: showLineNumbers, displayTags: displayTags, activeTokenKey: activeTokenKey, selectedTokenKeys: selectedTokenKeys, tokenSelectionKey: tokenSelectionKey, getDisplayValue: getDisplayValue, getTokenStyle: getTokenStyle, getTokenClassName: getTokenClassName, isTokenEdited: isTokenEdited, getParticipantName: getParticipantName, getParticipantColor: getParticipantColor, sectionLabel: sectionLabelByItemKey.get(item.key), onTokenClick: onTokenClick, onTokenHover: onTokenHover, onParticipantHover: onParticipantHover, onParticipantClick: onParticipantClick, wrapToken: wrapToken, renderTokenSuffix: renderTokenSuffix }, item.key));
|
|
41
63
|
return (_jsx("div", { className: "page-render-elements", children: collapsed.map((item, index) => {
|
|
42
64
|
if (punctuationIndexes.has(index))
|
|
43
65
|
return null;
|
|
@@ -82,9 +104,40 @@ function sentenceUidForItem(item) {
|
|
|
82
104
|
return item.element.uid;
|
|
83
105
|
return undefined;
|
|
84
106
|
}
|
|
85
|
-
function
|
|
107
|
+
function isTokenBearingItem(item) {
|
|
108
|
+
if (item.kind === 'collapsedJunction')
|
|
109
|
+
return true;
|
|
110
|
+
if (item.kind !== 'single' || !item.element.token)
|
|
111
|
+
return false;
|
|
112
|
+
return (item.element.type === PageRenderElementType.TOKEN ||
|
|
113
|
+
item.element.type === PageRenderElementType.JUNCTION_SPLIT ||
|
|
114
|
+
item.element.type === PageRenderElementType.MARK);
|
|
115
|
+
}
|
|
116
|
+
function tokenRefForItem(item) {
|
|
117
|
+
if (item.kind === 'collapsedJunction')
|
|
118
|
+
return item.token;
|
|
119
|
+
return item.element.token;
|
|
120
|
+
}
|
|
121
|
+
/** Matches TokenNode visibility: marks always show; empty categories do not. */
|
|
122
|
+
function isVisibleSectionHost(item, displayTags) {
|
|
123
|
+
const ref = tokenRefForItem(item);
|
|
124
|
+
if (!ref)
|
|
125
|
+
return false;
|
|
126
|
+
const isMark = item.kind === 'single' &&
|
|
127
|
+
item.element.type === PageRenderElementType.MARK;
|
|
128
|
+
if (isMark)
|
|
129
|
+
return true;
|
|
130
|
+
if (!isTokenRefVisible(ref))
|
|
131
|
+
return false;
|
|
132
|
+
// Same rule as TokenNode: split pieces of empty categories are hidden
|
|
133
|
+
// when POS tags are off.
|
|
134
|
+
if (ref.ec && ref.split && !displayTags)
|
|
135
|
+
return false;
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
function PageRenderElementItem({ item, highlight, showLineNumbers, displayTags, activeTokenKey, selectedTokenKeys, tokenSelectionKey, getDisplayValue, getTokenStyle, getTokenClassName, isTokenEdited, getParticipantName, getParticipantColor, sectionLabel, onTokenClick, onTokenHover, onParticipantHover, onParticipantClick, wrapToken, renderTokenSuffix, }) {
|
|
86
139
|
if (item.kind === 'collapsedJunction') {
|
|
87
|
-
return (_jsx(TokenNode, { refToken: item.token, splitIdx: item.splitIdx ?? 0, isSplit: true, isCollapsedJunction: true, highlight: highlight, displayTags: displayTags, activeTokenKey: activeTokenKey, selectedTokenKeys: selectedTokenKeys, tokenSelectionKey: tokenSelectionKey, getDisplayValue: getDisplayValue, getTokenStyle: getTokenStyle, getTokenClassName: getTokenClassName, isTokenEdited: isTokenEdited, onTokenClick: onTokenClick, onTokenHover: onTokenHover, wrapToken: wrapToken, renderTokenSuffix: renderTokenSuffix }));
|
|
140
|
+
return (_jsx(TokenNode, { refToken: item.token, splitIdx: item.splitIdx ?? 0, isSplit: true, isCollapsedJunction: true, highlight: highlight, displayTags: displayTags, activeTokenKey: activeTokenKey, selectedTokenKeys: selectedTokenKeys, tokenSelectionKey: tokenSelectionKey, getDisplayValue: getDisplayValue, getTokenStyle: getTokenStyle, getTokenClassName: getTokenClassName, isTokenEdited: isTokenEdited, sectionLabel: sectionLabel, onTokenClick: onTokenClick, onTokenHover: onTokenHover, wrapToken: wrapToken, renderTokenSuffix: renderTokenSuffix }));
|
|
88
141
|
}
|
|
89
142
|
const { element } = item;
|
|
90
143
|
switch (element.type) {
|
|
@@ -112,20 +165,20 @@ function PageRenderElementItem({ item, highlight, showLineNumbers, displayTags,
|
|
|
112
165
|
case PageRenderElementType.MARK:
|
|
113
166
|
if (!element.token)
|
|
114
167
|
return null;
|
|
115
|
-
return (_jsx(TokenNode, { refToken: element.token, splitIdx:
|
|
168
|
+
return (_jsx(TokenNode, { refToken: element.token, splitIdx: undefined, isMark: true, highlight: highlight, displayTags: displayTags, activeTokenKey: activeTokenKey, selectedTokenKeys: selectedTokenKeys, tokenSelectionKey: tokenSelectionKey, getDisplayValue: getDisplayValue, getTokenStyle: getTokenStyle, getTokenClassName: getTokenClassName, isTokenEdited: isTokenEdited, sectionLabel: sectionLabel, onTokenClick: onTokenClick, onTokenHover: onTokenHover, wrapToken: wrapToken, renderTokenSuffix: renderTokenSuffix }));
|
|
116
169
|
case PageRenderElementType.JUNCTION_SPLIT:
|
|
117
170
|
if (!element.token)
|
|
118
171
|
return null;
|
|
119
|
-
return (_jsx(TokenNode, { refToken: element.token, splitIdx: element.idx ?? 0, isSplit: true, highlight: highlight, displayTags: displayTags, activeTokenKey: activeTokenKey, selectedTokenKeys: selectedTokenKeys, tokenSelectionKey: tokenSelectionKey, getDisplayValue: getDisplayValue, getTokenStyle: getTokenStyle, getTokenClassName: getTokenClassName, isTokenEdited: isTokenEdited, onTokenClick: onTokenClick, onTokenHover: onTokenHover, wrapToken: wrapToken, renderTokenSuffix: renderTokenSuffix }));
|
|
172
|
+
return (_jsx(TokenNode, { refToken: element.token, splitIdx: element.idx ?? 0, isSplit: true, highlight: highlight, displayTags: displayTags, activeTokenKey: activeTokenKey, selectedTokenKeys: selectedTokenKeys, tokenSelectionKey: tokenSelectionKey, getDisplayValue: getDisplayValue, getTokenStyle: getTokenStyle, getTokenClassName: getTokenClassName, isTokenEdited: isTokenEdited, sectionLabel: sectionLabel, onTokenClick: onTokenClick, onTokenHover: onTokenHover, wrapToken: wrapToken, renderTokenSuffix: renderTokenSuffix }));
|
|
120
173
|
case PageRenderElementType.TOKEN:
|
|
121
174
|
if (!element.token)
|
|
122
175
|
return null;
|
|
123
|
-
return (_jsx(TokenNode, { refToken: element.token, splitIdx:
|
|
176
|
+
return (_jsx(TokenNode, { refToken: element.token, splitIdx: undefined, highlight: highlight, displayTags: displayTags, activeTokenKey: activeTokenKey, selectedTokenKeys: selectedTokenKeys, tokenSelectionKey: tokenSelectionKey, getDisplayValue: getDisplayValue, getTokenStyle: getTokenStyle, getTokenClassName: getTokenClassName, isTokenEdited: isTokenEdited, sectionLabel: sectionLabel, onTokenClick: onTokenClick, onTokenHover: onTokenHover, wrapToken: wrapToken, renderTokenSuffix: renderTokenSuffix }));
|
|
124
177
|
default:
|
|
125
178
|
return null;
|
|
126
179
|
}
|
|
127
180
|
}
|
|
128
|
-
function TokenNode({ refToken, splitIdx, isSplit = false, isMark = false, isCollapsedJunction = false, highlight, displayTags, activeTokenKey, selectedTokenKeys, tokenSelectionKey, getDisplayValue, getTokenStyle, getTokenClassName, isTokenEdited, onTokenClick, onTokenHover, wrapToken, renderTokenSuffix, }) {
|
|
181
|
+
function TokenNode({ refToken, splitIdx, isSplit = false, isMark = false, isCollapsedJunction = false, highlight, displayTags, activeTokenKey, selectedTokenKeys, tokenSelectionKey, getDisplayValue, getTokenStyle, getTokenClassName, isTokenEdited, sectionLabel, onTokenClick, onTokenHover, wrapToken, renderTokenSuffix, }) {
|
|
129
182
|
const token = tokenRefToToken(refToken);
|
|
130
183
|
const displaySplits = Boolean(token.ec && token.split && !displayTags);
|
|
131
184
|
const visible = isMark || isTokenRefVisible(refToken);
|
|
@@ -161,5 +214,10 @@ function TokenNode({ refToken, splitIdx, isSplit = false, isMark = false, isColl
|
|
|
161
214
|
onTokenClick(refToken, splitIdx, 'sentence', clickModifiers(event));
|
|
162
215
|
}
|
|
163
216
|
: undefined, onMouseEnter: () => onTokenHover?.(refToken.uid), onMouseLeave: () => onTokenHover?.(undefined), children: [getDisplayValue(token, splitIdx), displayTags && (_jsxs("b", { className: "tag", children: ["/", token.split ? token.split.t : token.t] })), renderTokenSuffix?.(refToken, token, ctx)] }));
|
|
164
|
-
|
|
217
|
+
const tokenNode = wrapToken
|
|
218
|
+
? wrapToken(refToken, token, content, ctx)
|
|
219
|
+
: content;
|
|
220
|
+
if (!sectionLabel)
|
|
221
|
+
return _jsx(_Fragment, { children: tokenNode });
|
|
222
|
+
return (_jsxs("span", { className: "section-anchor", children: [_jsx("span", { className: "section", children: sectionLabel }), tokenNode] }));
|
|
165
223
|
}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
.mark {
|
|
24
|
-
font-family:
|
|
24
|
+
font-family: 'Georgia', serif;
|
|
25
25
|
cursor: pointer;
|
|
26
26
|
@include body-xmedium-1;
|
|
27
27
|
display: inline-flex;
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
margin-bottom: var(--spacing-050);
|
|
31
31
|
width: auto;
|
|
32
32
|
background-color: var(--layer-semantic-info);
|
|
33
|
-
line-height: var(--spacing-300);
|
|
34
33
|
|
|
35
34
|
&.selected {
|
|
36
35
|
background-color: var(--layer-semantic-info);
|
|
@@ -39,13 +38,12 @@
|
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
.token {
|
|
42
|
-
font-family:
|
|
41
|
+
font-family: 'Georgia', serif;
|
|
43
42
|
cursor: pointer;
|
|
44
43
|
@include body-xmedium-1;
|
|
45
44
|
display: inline-flex;
|
|
46
45
|
align-items: center;
|
|
47
46
|
height: var(--spacing-300);
|
|
48
|
-
line-height: var(--spacing-300);
|
|
49
47
|
min-height: 0;
|
|
50
48
|
padding: 0 var(--spacing-050);
|
|
51
49
|
margin-bottom: var(--spacing-050);
|
|
@@ -63,7 +61,9 @@
|
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
&.edited {
|
|
66
|
-
border-bottom: 1px dashed var(--text-on-color-accent);
|
|
64
|
+
//border-bottom: 1px dashed var(--text-on-color-accent);
|
|
65
|
+
text-decoration: underline dashed var(--text-on-color-accent);
|
|
66
|
+
text-underline-offset: 4px;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
&.review {
|
|
@@ -106,4 +106,26 @@
|
|
|
106
106
|
cursor: pointer;
|
|
107
107
|
height: var(--spacing-300);
|
|
108
108
|
}
|
|
109
|
+
|
|
110
|
+
.section-anchor {
|
|
111
|
+
position: relative;
|
|
112
|
+
display: inline-flex;
|
|
113
|
+
align-items: center;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.section {
|
|
117
|
+
position: absolute;
|
|
118
|
+
left: 0;
|
|
119
|
+
bottom: calc(100% - var(--spacing-050));
|
|
120
|
+
z-index: 1;
|
|
121
|
+
pointer-events: none;
|
|
122
|
+
white-space: nowrap;
|
|
123
|
+
border-radius: var(--radius-100);
|
|
124
|
+
padding: 0 var(--spacing-050);
|
|
125
|
+
background-color: var(--layer-semantic-info);
|
|
126
|
+
border: 1px solid var(--semantic-info-70);
|
|
127
|
+
color: var(--text-primary);
|
|
128
|
+
line-height: 1.2;
|
|
129
|
+
@include helper-small-1;
|
|
130
|
+
}
|
|
109
131
|
}
|
|
@@ -57,7 +57,7 @@ export type PageRenderTokenContext = {
|
|
|
57
57
|
isSplit: boolean;
|
|
58
58
|
isMark: boolean;
|
|
59
59
|
isCollapsedJunction: boolean;
|
|
60
|
-
splitIdx: number;
|
|
60
|
+
splitIdx: number | undefined;
|
|
61
61
|
highlight: boolean;
|
|
62
62
|
selected: boolean;
|
|
63
63
|
};
|
|
@@ -68,6 +68,8 @@ export type PageRenderViewProps = {
|
|
|
68
68
|
document?: Document | null;
|
|
69
69
|
displayTags?: boolean;
|
|
70
70
|
showLineNumbers?: boolean;
|
|
71
|
+
/** When false, section/block labels are hidden. Defaults to true. */
|
|
72
|
+
showSectionLabels?: boolean;
|
|
71
73
|
highlightSentenceUid?: string;
|
|
72
74
|
activeTokenKey?: string;
|
|
73
75
|
selectedTokenKeys?: Set<string>;
|
|
@@ -78,6 +80,8 @@ export type PageRenderViewProps = {
|
|
|
78
80
|
isTokenEdited?: (token: Token) => boolean;
|
|
79
81
|
getParticipantName?: (code: string) => string;
|
|
80
82
|
getParticipantColor?: (code: string) => string | undefined;
|
|
83
|
+
/** Section/block label for a sentence uid; shown once before that sentence's first token. */
|
|
84
|
+
getSectionLabel?: (sentenceUid: string) => string | undefined;
|
|
81
85
|
onTokenClick?: (ref: TokenRef, splitIdx: number | undefined, source: TokenClickSource, modifiers: TokenClickModifiers) => void;
|
|
82
86
|
onTokenHover?: (sentenceUid: string | undefined) => void;
|
|
83
87
|
onParticipantHover?: (code: string | undefined) => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type ParserRuleGroupItem = {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
group?: string;
|
|
5
|
+
};
|
|
6
|
+
/** Build the persisted map (rule id → group name) from items that have a group. */
|
|
7
|
+
export declare function toParserRuleGroupsMap(items: ParserRuleGroupItem[]): Record<string, string>;
|
|
8
|
+
/** Apply a groups map onto items; missing keys clear the group. */
|
|
9
|
+
export declare function applyParserRuleGroupsMap(items: ParserRuleGroupItem[], groups: Record<string, string>): ParserRuleGroupItem[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Build the persisted map (rule id → group name) from items that have a group. */
|
|
2
|
+
export function toParserRuleGroupsMap(items) {
|
|
3
|
+
return items
|
|
4
|
+
.filter((item) => item.group)
|
|
5
|
+
.reduce((acc, item) => {
|
|
6
|
+
acc[item.id] = item.group || '';
|
|
7
|
+
return acc;
|
|
8
|
+
}, {});
|
|
9
|
+
}
|
|
10
|
+
/** Apply a groups map onto items; missing keys clear the group. */
|
|
11
|
+
export function applyParserRuleGroupsMap(items, groups) {
|
|
12
|
+
return items.map((item) => {
|
|
13
|
+
if (Object.prototype.hasOwnProperty.call(groups, item.id)) {
|
|
14
|
+
return { ...item, group: groups[item.id] };
|
|
15
|
+
}
|
|
16
|
+
return { ...item, group: undefined };
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DropdownMenuItem } from '../../primitives';
|
|
2
|
+
import { type ParserRuleGroupItem } from './ParserRuleGroupItem';
|
|
3
|
+
import './style.scss';
|
|
4
|
+
export type ParserRuleGroupsEditorProps = {
|
|
5
|
+
items: ParserRuleGroupItem[];
|
|
6
|
+
onChange: (items: ParserRuleGroupItem[]) => void;
|
|
7
|
+
/** Persist committed group changes (row save, delete, import). */
|
|
8
|
+
onSave: (items: ParserRuleGroupItem[]) => void;
|
|
9
|
+
title?: React.ReactNode;
|
|
10
|
+
className?: string;
|
|
11
|
+
exportFileName?: string;
|
|
12
|
+
/** Extra card menu actions (e.g. load defaults in revision). */
|
|
13
|
+
extraOptions?: DropdownMenuItem[];
|
|
14
|
+
/** When set (e.g. revision modal), adds a Close item to the card menu. */
|
|
15
|
+
onClose?: () => void;
|
|
16
|
+
};
|
|
17
|
+
export default function ParserRuleGroupsEditor({ items, onChange, onSave, title, className, exportFileName, extraOptions, onClose, }: ParserRuleGroupsEditorProps): import("react").JSX.Element;
|