corpushub-design-system 0.1.0 → 0.1.2
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/localization/SentenceTexts.js +33 -33
- 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/functions/EditionTierUtils.js +11 -5
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import api, { lexiconApiBase, parserApiBase, platformApi } from '../../configs/api';
|
|
2
|
+
import authApi from '../../configs/auth/authApi';
|
|
2
3
|
import { convertPageable } from '../../common';
|
|
3
|
-
const AUTH_API = () => import.meta.env.VITE_APP_AUTH_API;
|
|
4
4
|
const APP_BY_MODE = {
|
|
5
5
|
corpus: 'CORPUS',
|
|
6
6
|
parser: 'PARSER',
|
|
@@ -10,20 +10,20 @@ function resourceKey(mode) {
|
|
|
10
10
|
return mode;
|
|
11
11
|
}
|
|
12
12
|
function updatePortal(user, corpus, request) {
|
|
13
|
-
return
|
|
13
|
+
return authApi.patch(`/portal/${user}`, {
|
|
14
14
|
corpus,
|
|
15
15
|
...request,
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
function update(mode, resourceUid, user, request) {
|
|
19
|
-
return
|
|
19
|
+
return authApi.patch(`/access/${resourceUid}`, {
|
|
20
20
|
user,
|
|
21
21
|
...request,
|
|
22
22
|
app: APP_BY_MODE[mode],
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
function revoke(mode, user, resourceUid) {
|
|
26
|
-
return
|
|
26
|
+
return authApi.delete(`/${resourceUid}/${user}/${mode}`);
|
|
27
27
|
}
|
|
28
28
|
function grant(mode, access, resourceUid) {
|
|
29
29
|
const flags = mode === 'corpus'
|
|
@@ -31,7 +31,7 @@ function grant(mode, access, resourceUid) {
|
|
|
31
31
|
: mode === 'parser'
|
|
32
32
|
? { corpus: false }
|
|
33
33
|
: { corpus: false, lexicon: true, parser: false };
|
|
34
|
-
return
|
|
34
|
+
return authApi.post(`/${resourceUid}`, {
|
|
35
35
|
...access,
|
|
36
36
|
...flags,
|
|
37
37
|
});
|
|
@@ -41,10 +41,10 @@ function page(mode, resourceUid, filter) {
|
|
|
41
41
|
[resourceKey(mode)]: resourceUid,
|
|
42
42
|
...convertPageable(filter),
|
|
43
43
|
};
|
|
44
|
-
return
|
|
44
|
+
return authApi.post('/access', data);
|
|
45
45
|
}
|
|
46
46
|
function search(mode, text, resourceUid) {
|
|
47
|
-
return
|
|
47
|
+
return authApi.get('/search', {
|
|
48
48
|
params: {
|
|
49
49
|
text,
|
|
50
50
|
[resourceKey(mode)]: resourceUid,
|
|
@@ -53,7 +53,7 @@ function search(mode, text, resourceUid) {
|
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
function searchAll(text) {
|
|
56
|
-
return
|
|
56
|
+
return authApi.get('/search', {
|
|
57
57
|
params: { text },
|
|
58
58
|
});
|
|
59
59
|
}
|
|
@@ -70,6 +70,17 @@ function findLexiconsByUser(uid) {
|
|
|
70
70
|
}
|
|
71
71
|
return api.get(`${base}/user/${uid}`);
|
|
72
72
|
}
|
|
73
|
+
function listGroups(corpus) {
|
|
74
|
+
return authApi.get(`/corpus/${corpus}/group`);
|
|
75
|
+
}
|
|
76
|
+
function addGroupMember(corpus, groupUid, userUid) {
|
|
77
|
+
return authApi.post(`/corpus/${corpus}/group/${groupUid}/member`, {
|
|
78
|
+
user: userUid,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function removeGroupMember(corpus, groupUid, userUid) {
|
|
82
|
+
return authApi.delete(`/corpus/${corpus}/group/${groupUid}/member/${userUid}`);
|
|
83
|
+
}
|
|
73
84
|
const AccessControlService = {
|
|
74
85
|
page,
|
|
75
86
|
revoke,
|
|
@@ -81,5 +92,8 @@ const AccessControlService = {
|
|
|
81
92
|
findCorporaByUser,
|
|
82
93
|
findParsersByUser,
|
|
83
94
|
findLexiconsByUser,
|
|
95
|
+
listGroups,
|
|
96
|
+
addGroupMember,
|
|
97
|
+
removeGroupMember,
|
|
84
98
|
};
|
|
85
99
|
export default AccessControlService;
|
|
@@ -2,11 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { useForm } from 'react-hook-form';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import { AsyncSelectField } from '../../../primitives';
|
|
6
5
|
import { AppForm, AppModal } from '../../../common';
|
|
7
6
|
import { AccessRoleName, AccessStatusName, EMPTY_ACCESS, } from '../../../configs/types/Access';
|
|
8
7
|
import { useMessageUtils } from '../../../configs/useMessageUtils';
|
|
9
8
|
import FormUtils from '../../../functions/FormUtils';
|
|
9
|
+
import { AsyncSelectField } from '../../../primitives';
|
|
10
10
|
import AccessControlService from '../AccessControlService';
|
|
11
11
|
import './style.scss';
|
|
12
12
|
export default function AccessGrant({ mode, resourceUid, onClose, reload, }) {
|
|
@@ -64,6 +64,7 @@ const getAccessGrantFields = (t) => [
|
|
|
64
64
|
type: 'select',
|
|
65
65
|
options: FormUtils.convertEnum(AccessRoleName, t, 'common'),
|
|
66
66
|
required: true,
|
|
67
|
+
allowEmpty: false,
|
|
67
68
|
},
|
|
68
69
|
{
|
|
69
70
|
attr: 'status',
|
|
@@ -71,5 +72,6 @@ const getAccessGrantFields = (t) => [
|
|
|
71
72
|
type: 'select',
|
|
72
73
|
options: FormUtils.convertEnum(AccessStatusName, t, 'common'),
|
|
73
74
|
required: true,
|
|
75
|
+
allowEmpty: false,
|
|
74
76
|
},
|
|
75
77
|
];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AccessMode } from
|
|
2
|
-
import { UserAccessRequest, UserAccessResponse } from
|
|
1
|
+
import { AccessMode } from '../../../configs/types/Access';
|
|
2
|
+
import { UserAccessRequest, UserAccessResponse } from '../types/UserAccessResponse';
|
|
3
3
|
type Props = {
|
|
4
4
|
mode: AccessMode;
|
|
5
5
|
resourceUid: string;
|
|
@@ -1,50 +1,50 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { yupResolver } from
|
|
3
|
-
import { useForm } from
|
|
4
|
-
import { useTranslation } from
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import AccessControlService from
|
|
2
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
3
|
+
import { useForm } from 'react-hook-form';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import * as yup from 'yup';
|
|
6
|
+
import { AccessRoleName, AccessStatusName, } from '../../../configs/types/Access';
|
|
7
|
+
import { useMessageUtils } from '../../../configs/useMessageUtils';
|
|
8
|
+
import FormUtils from '../../../functions/FormUtils';
|
|
9
|
+
import { Button, SelectField } from '../../../primitives';
|
|
10
|
+
import AccessControlService from '../AccessControlService';
|
|
11
11
|
/** Flat keys (no suffix under another key) — i18next `.` keySeparator nests otherwise. */
|
|
12
12
|
const TITLE_KEY = {
|
|
13
|
-
corpus:
|
|
14
|
-
parser:
|
|
15
|
-
lexicon:
|
|
13
|
+
corpus: 'access.title.corpus',
|
|
14
|
+
parser: 'access.title.parser',
|
|
15
|
+
lexicon: 'access.title.lexicon',
|
|
16
16
|
};
|
|
17
17
|
const DESC_KEY = {
|
|
18
|
-
corpus:
|
|
19
|
-
parser:
|
|
20
|
-
lexicon:
|
|
18
|
+
corpus: 'access.desc.corpus',
|
|
19
|
+
parser: 'access.desc.parser',
|
|
20
|
+
lexicon: 'access.desc.lexicon',
|
|
21
21
|
};
|
|
22
22
|
export default function AccessData({ mode, resourceUid, user, onChange, }) {
|
|
23
|
-
const { t } = useTranslation(
|
|
23
|
+
const { t } = useTranslation('access');
|
|
24
24
|
const { dispatchMessage } = useMessageUtils();
|
|
25
25
|
const createdForm = useForm({
|
|
26
26
|
resolver: yupResolver(getFormSchema(t)),
|
|
27
27
|
defaultValues: { role: user.role, status: user.status },
|
|
28
|
-
mode:
|
|
28
|
+
mode: 'onChange',
|
|
29
29
|
});
|
|
30
30
|
const handleSave = () => {
|
|
31
31
|
if (!resourceUid)
|
|
32
32
|
return;
|
|
33
33
|
const request = createdForm.getValues();
|
|
34
34
|
AccessControlService.update(mode, resourceUid, user.uid, request).then(() => {
|
|
35
|
-
dispatchMessage({ key:
|
|
35
|
+
dispatchMessage({ key: 'update.success', t });
|
|
36
36
|
onChange(request);
|
|
37
37
|
});
|
|
38
38
|
};
|
|
39
|
-
return (_jsxs("div", { className: "access-container", children: [_jsxs("div", { className: "header", children: [_jsx("span", { className: "title", children: t(TITLE_KEY[mode]) }), _jsx("span", { className: "desc", children: t(DESC_KEY[mode]) })] }), _jsxs("div", { className: "body", children: [_jsx(SelectField, { label: t(
|
|
39
|
+
return (_jsxs("div", { className: "access-container", children: [_jsxs("div", { className: "header", children: [_jsx("span", { className: "title", children: t(TITLE_KEY[mode]) }), _jsx("span", { className: "desc", children: t(DESC_KEY[mode]) })] }), _jsxs("div", { className: "body", children: [_jsx(SelectField, { label: t('table.label.role'), attr: "role", createdForm: createdForm, options: FormUtils.convertEnum(AccessRoleName, t, 'common'), showEndAdornment: false, allowEmpty: false }), _jsx(SelectField, { label: t('table.label.status'), attr: "status", createdForm: createdForm, options: FormUtils.convertEnum(AccessStatusName, t, 'common'), showEndAdornment: false, allowEmpty: false }), _jsx(Button, { text: t('common:button.save'), disabled: !createdForm.formState.isValid, onClick: handleSave, size: "x-small" })] })] }));
|
|
40
40
|
}
|
|
41
41
|
const getFormSchema = (t) => yup.object().shape({
|
|
42
42
|
status: yup
|
|
43
43
|
.string()
|
|
44
44
|
.oneOf(Object.keys(AccessStatusName))
|
|
45
|
-
.required(t(
|
|
45
|
+
.required(t('message:validation.required')),
|
|
46
46
|
role: yup
|
|
47
47
|
.string()
|
|
48
48
|
.oneOf(Object.keys(AccessRoleName))
|
|
49
|
-
.required(t(
|
|
49
|
+
.required(t('message:validation.required')),
|
|
50
50
|
});
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation } from "react-i18next";
|
|
3
|
-
import { AppModal } from "../../../common";
|
|
3
|
+
import { AppModal, AppPicture } from "../../../common";
|
|
4
4
|
import { useCorpusUtils } from "../../../configs/useCorpusUtils";
|
|
5
5
|
import AccessData from "./AccessData";
|
|
6
6
|
import AccessPortal from "./AccessPortal";
|
|
7
|
+
import AccessUserGroups from "./AccessUserGroups";
|
|
7
8
|
import AccessUserResources from "./AccessUserResources";
|
|
8
9
|
import "./style.scss";
|
|
9
10
|
export default function AccessUser({ mode, resourceUid, user, onClose, onReload, setItems, }) {
|
|
10
11
|
const { t } = useTranslation("access");
|
|
11
12
|
const { getCorpus, hasCorpus } = useCorpusUtils();
|
|
12
|
-
const
|
|
13
|
+
const hasDirectAccess = user.direct !== false;
|
|
14
|
+
const showPortal = mode === "corpus" &&
|
|
15
|
+
hasDirectAccess &&
|
|
16
|
+
hasCorpus() &&
|
|
17
|
+
getCorpus().opened;
|
|
13
18
|
const handleChangeAccess = (r) => {
|
|
14
19
|
setItems((prevState) => {
|
|
15
20
|
if (!prevState)
|
|
@@ -39,5 +44,17 @@ export default function AccessUser({ mode, resourceUid, user, onClose, onReload,
|
|
|
39
44
|
return { ...prevState, content: updatedContent };
|
|
40
45
|
});
|
|
41
46
|
};
|
|
42
|
-
|
|
47
|
+
const handleChangeGroups = (groups) => {
|
|
48
|
+
if (!hasDirectAccess && groups.length === 0) {
|
|
49
|
+
onReload();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
setItems((prevState) => {
|
|
53
|
+
if (!prevState)
|
|
54
|
+
return prevState;
|
|
55
|
+
const updatedContent = prevState.content.map((item) => item.uid === user.uid ? { ...item, groups } : item);
|
|
56
|
+
return { ...prevState, content: updatedContent };
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
return (_jsxs(AppModal, { title: user.name, className: "modal-access-user", close: onClose, disableCancel: true, hideFooter: true, children: [_jsxs("div", { className: "row-info", children: [_jsxs("div", { className: "col-profile", children: [_jsxs("div", { className: "info", children: [_jsx(AppPicture, { className: "avatar", src: user.picture, person: true }), _jsxs("div", { className: "texts", children: [_jsxs("span", { children: [_jsx("b", { children: t("access.label.name") }), " ", user.name] }), _jsxs("span", { children: [_jsx("b", { children: t("access.label.email") }), " ", user.email] })] })] }), hasDirectAccess && (_jsx(AccessData, { mode: mode, resourceUid: resourceUid, user: user, onChange: handleChangeAccess })), mode === "corpus" && (_jsx(AccessUserGroups, { resourceUid: resourceUid, user: user, onChange: handleChangeGroups }))] }), showPortal && (_jsx(AccessPortal, { resourceUid: resourceUid, user: user, onChange: handleChangePortal })), hasDirectAccess && (_jsx(AccessUserResources, { mode: mode, user: user, onReload: onReload }))] }), _jsx("div", { className: "uid", children: user.uid })] }));
|
|
43
60
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { UserAccessResponse } from '../types/UserAccessResponse';
|
|
2
|
+
type Props = {
|
|
3
|
+
resourceUid: string;
|
|
4
|
+
user: UserAccessResponse;
|
|
5
|
+
onChange: (groups: string[]) => void;
|
|
6
|
+
};
|
|
7
|
+
export default function AccessUserGroups({ resourceUid, user, onChange, }: Props): import("react").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import { useForm } from 'react-hook-form';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { useMessageUtils } from '../../../configs/useMessageUtils';
|
|
6
|
+
import { Button, SelectField, Tag } from '../../../primitives';
|
|
7
|
+
import AccessControlService from '../AccessControlService';
|
|
8
|
+
const ROLE_TAG_COLOR = {
|
|
9
|
+
EDITOR: 'blue',
|
|
10
|
+
READER: 'yellow',
|
|
11
|
+
};
|
|
12
|
+
function sortedNames(groups) {
|
|
13
|
+
return groups
|
|
14
|
+
.map((g) => g.name)
|
|
15
|
+
.filter(Boolean)
|
|
16
|
+
.sort((a, b) => a.localeCompare(b, undefined, { sensitivity: 'base' }));
|
|
17
|
+
}
|
|
18
|
+
export default function AccessUserGroups({ resourceUid, user, onChange, }) {
|
|
19
|
+
const { t } = useTranslation('access');
|
|
20
|
+
const { dispatchMessage } = useMessageUtils();
|
|
21
|
+
const [groups, setGroups] = useState([]);
|
|
22
|
+
const [loading, setLoading] = useState(true);
|
|
23
|
+
const [memberNames, setMemberNames] = useState(() => user.groups ?? []);
|
|
24
|
+
const createdForm = useForm({
|
|
25
|
+
defaultValues: { groupUid: '' },
|
|
26
|
+
});
|
|
27
|
+
const memberNameSet = useMemo(() => new Set(memberNames.filter(Boolean)), [memberNames]);
|
|
28
|
+
const memberships = useMemo(() => groups
|
|
29
|
+
.filter((g) => g.status === 'ACTIVE' && memberNameSet.has(g.name))
|
|
30
|
+
.sort((a, b) => a.name.localeCompare(b.name, undefined, { sensitivity: 'base' })), [groups, memberNameSet]);
|
|
31
|
+
const available = useMemo(() => groups
|
|
32
|
+
.filter((g) => g.status === 'ACTIVE' && !memberNameSet.has(g.name))
|
|
33
|
+
.sort((a, b) => a.name.localeCompare(b.name, undefined, { sensitivity: 'base' })), [groups, memberNameSet]);
|
|
34
|
+
const options = useMemo(() => available.map((g) => ({ value: g.uid, label: g.name })), [available]);
|
|
35
|
+
const load = () => {
|
|
36
|
+
if (!resourceUid)
|
|
37
|
+
return;
|
|
38
|
+
setLoading(true);
|
|
39
|
+
AccessControlService.listGroups(resourceUid)
|
|
40
|
+
.then((r) => setGroups(r.data ?? []))
|
|
41
|
+
.catch(() => setGroups([]))
|
|
42
|
+
.finally(() => setLoading(false));
|
|
43
|
+
};
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
setMemberNames(user.groups ?? []);
|
|
46
|
+
}, [user.uid, user.groups]);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
load();
|
|
49
|
+
}, [resourceUid]);
|
|
50
|
+
const applyMembership = (nextGroups) => {
|
|
51
|
+
const next = sortedNames(nextGroups);
|
|
52
|
+
setMemberNames(next);
|
|
53
|
+
onChange(next);
|
|
54
|
+
};
|
|
55
|
+
const handleAdd = () => {
|
|
56
|
+
const groupUid = createdForm.getValues('groupUid');
|
|
57
|
+
if (!resourceUid || !groupUid)
|
|
58
|
+
return;
|
|
59
|
+
const added = groups.find((g) => g.uid === groupUid);
|
|
60
|
+
if (!added)
|
|
61
|
+
return;
|
|
62
|
+
AccessControlService.addGroupMember(resourceUid, groupUid, user.uid).then(() => {
|
|
63
|
+
dispatchMessage({ key: 'update.success', t });
|
|
64
|
+
createdForm.reset({ groupUid: '' });
|
|
65
|
+
applyMembership([...memberships, added]);
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
const handleRemove = (group) => {
|
|
69
|
+
if (!resourceUid)
|
|
70
|
+
return;
|
|
71
|
+
AccessControlService.removeGroupMember(resourceUid, group.uid, user.uid).then(() => {
|
|
72
|
+
dispatchMessage({ key: 'update.success', t });
|
|
73
|
+
applyMembership(memberships.filter((g) => g.uid !== group.uid));
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
return (_jsxs("div", { className: "access-container access-groups-container", children: [_jsxs("div", { className: "header", children: [_jsx("span", { className: "title", children: t('group.title') }), _jsx("span", { className: "desc", children: t('group.desc') })] }), _jsxs("div", { className: "body", children: [!loading && groups.length === 0 && (_jsx("span", { className: "empty", children: t('group.empty') })), memberships.map((group) => (_jsxs("div", { className: "group-line", children: [_jsx("span", { className: "name", children: group.name }), _jsx(Tag, { text: t(`role.label.${group.role.toLowerCase()}`), color: ROLE_TAG_COLOR[group.role], size: "small" }), _jsx(Button, { text: t('common:button.remove'), onClick: () => handleRemove(group), size: "x-small", color: "danger" })] }, group.uid))), available.length > 0 && (_jsxs("div", { className: "add-row", children: [_jsx(SelectField, { label: t('table.label.groups'), attr: "groupUid", createdForm: createdForm, options: options, showEndAdornment: false, allowEmpty: true }), _jsx(Button, { text: t('common:button.add'), disabled: !createdForm.watch('groupUid'), onClick: handleAdd, size: "small" })] }))] })] }));
|
|
77
|
+
}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
max-width: 70vw !important;
|
|
4
4
|
top: 45% !important;
|
|
5
5
|
|
|
6
|
-
.body {
|
|
6
|
+
> .body {
|
|
7
7
|
display: flex;
|
|
8
8
|
flex-direction: column;
|
|
9
|
-
gap:
|
|
9
|
+
gap: 8px;
|
|
10
10
|
|
|
11
11
|
.uid {
|
|
12
12
|
margin-top: auto;
|
|
@@ -72,15 +72,53 @@
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
> .body {
|
|
75
|
+
padding-bottom: 8px;
|
|
75
76
|
display: flex;
|
|
76
77
|
flex-direction: column;
|
|
77
|
-
gap:
|
|
78
|
+
gap: 8px;
|
|
78
79
|
|
|
79
80
|
> .ds-button {
|
|
80
81
|
margin-left: auto;
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
}
|
|
85
|
+
|
|
86
|
+
.access-groups-container {
|
|
87
|
+
> .body {
|
|
88
|
+
> .empty {
|
|
89
|
+
@include body-medium-1;
|
|
90
|
+
color: var(--text-secondary);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
> .group-line {
|
|
94
|
+
display: flex;
|
|
95
|
+
align-items: center;
|
|
96
|
+
gap: 12px;
|
|
97
|
+
border-bottom: var(--border-default);
|
|
98
|
+
padding-bottom: 8px;
|
|
99
|
+
|
|
100
|
+
> .name {
|
|
101
|
+
@include body-xmedium-1;
|
|
102
|
+
flex: 1;
|
|
103
|
+
min-width: 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
> .ds-button {
|
|
107
|
+
margin-left: auto;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
> .add-row {
|
|
112
|
+
display: flex;
|
|
113
|
+
flex-direction: column;
|
|
114
|
+
gap: 12px;
|
|
115
|
+
|
|
116
|
+
> .ds-button {
|
|
117
|
+
margin-left: auto;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
84
122
|
}
|
|
85
123
|
|
|
86
124
|
.portal-container {
|
|
@@ -67,35 +67,50 @@ export default function AccessUsers({ mode, resourceUid }) {
|
|
|
67
67
|
const user = props.row.original;
|
|
68
68
|
return user.name || user.email;
|
|
69
69
|
};
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
70
|
+
const addGroupsToCell = (props) => {
|
|
71
|
+
const groups = props.row.original.groups;
|
|
72
|
+
return groups?.length ? groups.join(", ") : "—";
|
|
73
|
+
};
|
|
74
|
+
const columns = React.useMemo(() => {
|
|
75
|
+
const cols = [
|
|
76
|
+
{
|
|
77
|
+
id: "original",
|
|
78
|
+
header: "",
|
|
79
|
+
cell: addImageToCell,
|
|
80
|
+
size: 10,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: "name",
|
|
84
|
+
header: t("table.label.name"),
|
|
85
|
+
accessorFn: (row) => row.name || row.email,
|
|
86
|
+
cell: addNameToCell,
|
|
87
|
+
size: mode === "corpus" ? 28 : 35,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: "status",
|
|
91
|
+
header: t("table.label.status"),
|
|
92
|
+
accessorKey: "status",
|
|
93
|
+
cell: addStatusToCell,
|
|
94
|
+
size: 15,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
id: "role",
|
|
98
|
+
header: t("table.label.role"),
|
|
99
|
+
accessorKey: "role",
|
|
100
|
+
cell: addRoleToCell,
|
|
101
|
+
size: mode === "corpus" ? 20 : 35,
|
|
102
|
+
},
|
|
103
|
+
];
|
|
104
|
+
if (mode === "corpus") {
|
|
105
|
+
cols.push({
|
|
106
|
+
id: "groups",
|
|
107
|
+
header: t("table.label.groups"),
|
|
108
|
+
cell: addGroupsToCell,
|
|
109
|
+
size: 27,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return cols;
|
|
113
|
+
}, [resourceUid, data, t, mode]);
|
|
99
114
|
useEffect(() => {
|
|
100
115
|
paginate();
|
|
101
116
|
}, [filter, resourceUid, mode]);
|
|
@@ -5,6 +5,7 @@ export { default as AccessUser } from './AccessUser';
|
|
|
5
5
|
export { default as AccessGrant } from './AccessGrant';
|
|
6
6
|
export { default as AccessControlService } from './AccessControlService';
|
|
7
7
|
export type { AccessResponse, UserAccessRequest, UserAccessResponse, } from './types/UserAccessResponse';
|
|
8
|
+
export type { CorpusGroup, CorpusGroupRole, CorpusGroupStatus, } from './types/CorpusGroup';
|
|
8
9
|
export type { default as PortalInformation } from './types/PortalInformation';
|
|
9
10
|
export type { PortalInformationRequest, PortalRole, } from './types/PortalInformation';
|
|
10
11
|
export { EMPTY_PORTAL, PortalRoleName } from './types/PortalInformation';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type CorpusGroupRole = 'EDITOR' | 'READER';
|
|
2
|
+
export type CorpusGroupStatus = 'ACTIVE' | 'INACTIVE';
|
|
3
|
+
export type CorpusGroup = {
|
|
4
|
+
uid: string;
|
|
5
|
+
corpus: string;
|
|
6
|
+
name: string;
|
|
7
|
+
role: CorpusGroupRole;
|
|
8
|
+
status: CorpusGroupStatus;
|
|
9
|
+
members: number;
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -17,6 +17,10 @@ export type UserAccessResponse = {
|
|
|
17
17
|
role: AccessRole;
|
|
18
18
|
plan?: string | null;
|
|
19
19
|
lastLogin?: number | null;
|
|
20
|
+
/** Active corpus group names (corpus access page only). */
|
|
21
|
+
groups?: string[] | null;
|
|
22
|
+
/** False when the user only has access via groups (no direct grant). */
|
|
23
|
+
direct?: boolean;
|
|
20
24
|
corpora: AccessResponse[];
|
|
21
25
|
parsers: AccessResponse[];
|
|
22
26
|
lexicons: AccessResponse[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AccessMode } from '../../../configs/types/Access';
|
|
2
|
+
import Backup from '../types/Backup';
|
|
3
|
+
import './style.scss';
|
|
4
|
+
type Props = {
|
|
5
|
+
mode: AccessMode;
|
|
6
|
+
resourceUid: string;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
onConfirm: (b: Backup) => void;
|
|
9
|
+
};
|
|
10
|
+
export default function BackupCreate({ mode, resourceUid, onClose, onConfirm, }: Props): import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import AppLoading from '../../../common/AppLoading';
|
|
5
|
+
import AppModal from '../../../common/AppModal';
|
|
6
|
+
import { useMessageUtils } from '../../../configs/useMessageUtils';
|
|
7
|
+
import BackupService from '../BackupService';
|
|
8
|
+
import './style.scss';
|
|
9
|
+
const POLL_INTERVAL_MS = 2000;
|
|
10
|
+
export default function BackupCreate({ mode, resourceUid, onClose, onConfirm, }) {
|
|
11
|
+
const { t } = useTranslation('backup');
|
|
12
|
+
const { dispatchError, dispatchMessageDirect } = useMessageUtils();
|
|
13
|
+
const [loading, setLoading] = useState(false);
|
|
14
|
+
const mountedRef = useRef(true);
|
|
15
|
+
const pollRef = useRef(null);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
mountedRef.current = true;
|
|
18
|
+
return () => {
|
|
19
|
+
mountedRef.current = false;
|
|
20
|
+
if (pollRef.current != null) {
|
|
21
|
+
window.clearInterval(pollRef.current);
|
|
22
|
+
pollRef.current = null;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}, []);
|
|
26
|
+
const stopPolling = () => {
|
|
27
|
+
if (pollRef.current != null) {
|
|
28
|
+
window.clearInterval(pollRef.current);
|
|
29
|
+
pollRef.current = null;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const pollUntilDone = (backupId) => {
|
|
33
|
+
const tick = () => {
|
|
34
|
+
BackupService.status(backupId)
|
|
35
|
+
.then((r) => {
|
|
36
|
+
if (!mountedRef.current)
|
|
37
|
+
return;
|
|
38
|
+
const backup = r.data;
|
|
39
|
+
if (backup.status === 'PROCESSING')
|
|
40
|
+
return;
|
|
41
|
+
stopPolling();
|
|
42
|
+
setLoading(false);
|
|
43
|
+
if (backup.status === 'FINISHED') {
|
|
44
|
+
onConfirm(backup);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
dispatchMessageDirect(backup.log || t('backup.status.error'), 'error');
|
|
48
|
+
})
|
|
49
|
+
.catch((err) => {
|
|
50
|
+
if (!mountedRef.current)
|
|
51
|
+
return;
|
|
52
|
+
stopPolling();
|
|
53
|
+
setLoading(false);
|
|
54
|
+
dispatchError({ err, t });
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
tick();
|
|
58
|
+
pollRef.current = window.setInterval(tick, POLL_INTERVAL_MS);
|
|
59
|
+
};
|
|
60
|
+
const handleConfirm = () => {
|
|
61
|
+
if (loading || !resourceUid)
|
|
62
|
+
return;
|
|
63
|
+
setLoading(true);
|
|
64
|
+
BackupService.execute(mode, resourceUid)
|
|
65
|
+
.then((r) => {
|
|
66
|
+
if (!mountedRef.current)
|
|
67
|
+
return;
|
|
68
|
+
const backup = r.data;
|
|
69
|
+
if (backup.status === 'FINISHED') {
|
|
70
|
+
setLoading(false);
|
|
71
|
+
onConfirm(backup);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (backup.status === 'ERROR') {
|
|
75
|
+
setLoading(false);
|
|
76
|
+
dispatchMessageDirect(backup.log || t('backup.status.error'), 'error');
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
pollUntilDone(backup.id);
|
|
80
|
+
})
|
|
81
|
+
.catch((err) => {
|
|
82
|
+
if (!mountedRef.current)
|
|
83
|
+
return;
|
|
84
|
+
setLoading(false);
|
|
85
|
+
dispatchError({ err, t });
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
return (_jsxs(AppModal, { title: t('modal.title'), className: "backup-create-modal", confirm: handleConfirm, close: onClose, disableConfirm: loading, disableClose: loading, disableEscapeClose: loading, disableBackdropClose: loading, children: [_jsx("p", { children: t('modal.description') }), loading && _jsx(AppLoading, {})] }));
|
|
89
|
+
}
|