corpushub-design-system 0.0.3 → 0.0.6

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.
Files changed (37) hide show
  1. package/dist/common/AppTable/styles.scss +6 -2
  2. package/dist/configs/Localization.js +2 -0
  3. package/dist/configs/localization/BackupTexts.d.ts +74 -0
  4. package/dist/configs/localization/BackupTexts.js +74 -0
  5. package/dist/configs/localization/CommentsTexts.d.ts +145 -145
  6. package/dist/configs/localization/CommentsTexts.js +145 -145
  7. package/dist/features/Backup/BackupCreate/BackupCreate.d.ts +11 -0
  8. package/dist/features/Backup/BackupCreate/BackupCreate.js +26 -0
  9. package/dist/features/Backup/BackupCreate/index.d.ts +2 -0
  10. package/dist/features/Backup/BackupCreate/index.js +2 -0
  11. package/dist/features/Backup/BackupCreate/style.scss +0 -0
  12. package/dist/features/Backup/BackupInfo/BackupInfo.d.ts +8 -0
  13. package/dist/features/Backup/BackupInfo/BackupInfo.js +36 -0
  14. package/dist/features/Backup/BackupInfo/index.d.ts +2 -0
  15. package/dist/features/Backup/BackupInfo/index.js +2 -0
  16. package/dist/features/Backup/BackupInfo/style.scss +23 -0
  17. package/dist/features/Backup/BackupRestore/BackupRestore.d.ts +7 -0
  18. package/dist/features/Backup/BackupRestore/BackupRestore.js +52 -0
  19. package/dist/features/Backup/BackupRestore/index.d.ts +3 -0
  20. package/dist/features/Backup/BackupRestore/index.js +2 -0
  21. package/dist/features/Backup/BackupRestore/style.scss +17 -0
  22. package/dist/features/Backup/BackupService.d.ts +18 -0
  23. package/dist/features/Backup/BackupService.js +39 -0
  24. package/dist/features/Backup/BackupTable/BackupSearchFilter.d.ts +5 -0
  25. package/dist/features/Backup/BackupTable/BackupSearchFilter.js +4 -0
  26. package/dist/features/Backup/BackupTable/BackupTable.d.ts +8 -0
  27. package/dist/features/Backup/BackupTable/BackupTable.js +121 -0
  28. package/dist/features/Backup/BackupTable/index.d.ts +4 -0
  29. package/dist/features/Backup/BackupTable/index.js +3 -0
  30. package/dist/features/Backup/BackupTable/style.scss +19 -0
  31. package/dist/features/Backup/index.d.ts +7 -0
  32. package/dist/features/Backup/index.js +4 -0
  33. package/dist/features/Backup/types/Backup.d.ts +14 -0
  34. package/dist/features/Backup/types/Backup.js +1 -0
  35. package/dist/features/index.d.ts +2 -0
  36. package/dist/features/index.js +1 -0
  37. package/package.json +1 -1
@@ -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,4 @@
1
+ import BackupTable from './BackupTable';
2
+ export default BackupTable;
3
+ export type { BackupTableProps } from './BackupTable';
4
+ export { EMPTY_BACKUP_SEARCH_FILTER, type BackupSearchFilter, } from './BackupSearchFilter';
@@ -0,0 +1,3 @@
1
+ import BackupTable from './BackupTable';
2
+ export default BackupTable;
3
+ export { EMPTY_BACKUP_SEARCH_FILTER, } from './BackupSearchFilter';
@@ -0,0 +1,19 @@
1
+ .backup-table-card {
2
+ overflow: hidden;
3
+
4
+ .body {
5
+ padding: 0;
6
+
7
+ .user {
8
+ display: flex;
9
+ align-items: center;
10
+
11
+ .avatar {
12
+ width: 28px;
13
+ height: 28px;
14
+ border-radius: 50%;
15
+ object-fit: cover;
16
+ }
17
+ }
18
+ }
19
+ }
@@ -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,4 @@
1
+ export { default as BackupTable } from './BackupTable';
2
+ export { EMPTY_BACKUP_SEARCH_FILTER, } from './BackupTable';
3
+ export { default as BackupRestore } from './BackupRestore';
4
+ export { default as BackupService } from './BackupService';
@@ -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 {};
@@ -2,6 +2,8 @@ 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
8
  export type { AccessUsersProps, AccessUsersFilter, AccessResponse, UserAccessRequest, UserAccessResponse, PortalInformation, PortalInformationRequest, PortalRole, } from "./AccessControl";
7
9
  export { CorpusOwner } from "./CorpusOwner";
@@ -1,6 +1,7 @@
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";
6
7
  export { default as SentenceView } from "./SentenceView";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corpushub-design-system",
3
3
  "private": false,
4
- "version": "0.0.3",
4
+ "version": "0.0.6",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {