tycho-components 0.45.7 → 0.45.9
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/features/AccessControl/AccessGrant/style.scss +1 -0
- package/dist/features/CorpusOwner/CorpusOwner.d.ts +12 -0
- package/dist/features/CorpusOwner/CorpusOwner.js +42 -0
- package/dist/features/CorpusOwner/index.d.ts +2 -0
- package/dist/features/CorpusOwner/index.js +1 -0
- package/dist/features/CorpusOwner/style.scss +18 -0
- package/dist/features/index.d.ts +2 -0
- package/dist/features/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import './style.scss';
|
|
2
|
+
export type CorpusOwnerUser = {
|
|
3
|
+
uid: string;
|
|
4
|
+
name: string;
|
|
5
|
+
email?: string;
|
|
6
|
+
};
|
|
7
|
+
export type CorpusOwnerProps = {
|
|
8
|
+
ownerName?: string | null;
|
|
9
|
+
onUpdateOwner: (userUid: string) => Promise<CorpusOwnerUser>;
|
|
10
|
+
onOwnerUpdated: (owner: CorpusOwnerUser) => void;
|
|
11
|
+
};
|
|
12
|
+
export default function CorpusOwner({ ownerName, onUpdateOwner, onOwnerUpdated, }: CorpusOwnerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { useForm } from 'react-hook-form';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { AsyncSelectField, Button } from 'tycho-storybook';
|
|
6
|
+
import { useLoggedUtils } from '../../configs/useLoggedUtils';
|
|
7
|
+
import { useMessageUtils } from '../../configs/useMessageUtils';
|
|
8
|
+
import AccessControlService from '../AccessControl/AccessControlService';
|
|
9
|
+
import './style.scss';
|
|
10
|
+
export default function CorpusOwner({ ownerName, onUpdateOwner, onOwnerUpdated, }) {
|
|
11
|
+
const { t } = useTranslation(['information', 'configuration', 'message']);
|
|
12
|
+
const { dispatchMessage } = useMessageUtils();
|
|
13
|
+
const { isSuper } = useLoggedUtils();
|
|
14
|
+
const [change, setChange] = useState(false);
|
|
15
|
+
const createdForm = useForm({
|
|
16
|
+
defaultValues: { user: null },
|
|
17
|
+
});
|
|
18
|
+
const handleSelectUser = (_attr, value) => {
|
|
19
|
+
if (!value?.value)
|
|
20
|
+
return;
|
|
21
|
+
onUpdateOwner(value.value).then((owner) => {
|
|
22
|
+
dispatchMessage({ key: 'update.success', t });
|
|
23
|
+
onOwnerUpdated(owner);
|
|
24
|
+
setChange(false);
|
|
25
|
+
createdForm.reset({ user: null });
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
const filterUsers = async (value) => {
|
|
29
|
+
if (value.length < 2)
|
|
30
|
+
return [];
|
|
31
|
+
const r = await AccessControlService.searchAll(value);
|
|
32
|
+
const options = [];
|
|
33
|
+
for (const thisUser of r.data) {
|
|
34
|
+
options.push({
|
|
35
|
+
value: thisUser.uid,
|
|
36
|
+
label: `${thisUser.name} - ${thisUser.email}`,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return options;
|
|
40
|
+
};
|
|
41
|
+
return (_jsxs("div", { className: "owner-container", children: [_jsx("div", { className: "title", children: t('document.field.owner.name') }), isSuper() && change && (_jsx(AsyncSelectField, { attr: "user", createdForm: createdForm, loadOptions: filterUsers, onChange: handleSelectUser, noOptionsText: t('message:generic.option.notfound') })), _jsxs("div", { className: "group", children: [!change && _jsx("span", { children: ownerName }), isSuper() && !change && (_jsx(Button, { text: t('document.button.changeOwner'), size: "small", onClick: () => setChange(true) }))] })] }));
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CorpusOwner } from './CorpusOwner';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.owner-container {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: var(--spacing-100);
|
|
5
|
+
|
|
6
|
+
> .title {
|
|
7
|
+
@include body-medium-2;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
> .group {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
|
|
14
|
+
> .ds-button {
|
|
15
|
+
margin-left: auto;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
package/dist/features/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export type { Comment, CommentRequest } from "./Comments/types/Comment";
|
|
|
4
4
|
export { default as CommentService } from "./Comments/CommentService";
|
|
5
5
|
export { AccessUsers, AccessUser, AccessGrant, AccessControlService, EMPTY_ACCESS_SEARCH_FILTER, EMPTY_PORTAL, PortalRoleName, } from "./AccessControl";
|
|
6
6
|
export type { AccessUsersProps, AccessUsersFilter, AccessResponse, UserAccessRequest, UserAccessResponse, PortalInformation, PortalInformationRequest, PortalRole, } from "./AccessControl";
|
|
7
|
+
export { CorpusOwner } from "./CorpusOwner";
|
|
8
|
+
export type { CorpusOwnerProps, CorpusOwnerUser } from "./CorpusOwner";
|
|
7
9
|
export { default as SentenceView } from "./SentenceView";
|
|
8
10
|
export { default as TreeView } from "./TreeView";
|
|
9
11
|
export { default as ConlluGraphViewer } from "./ConlluGraphViewer";
|
package/dist/features/index.js
CHANGED
|
@@ -2,6 +2,7 @@ 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
4
|
export { AccessUsers, AccessUser, AccessGrant, AccessControlService, EMPTY_ACCESS_SEARCH_FILTER, EMPTY_PORTAL, PortalRoleName, } from "./AccessControl";
|
|
5
|
+
export { CorpusOwner } from "./CorpusOwner";
|
|
5
6
|
export { default as SentenceView } from "./SentenceView";
|
|
6
7
|
export { default as TreeView } from "./TreeView";
|
|
7
8
|
export { default as ConlluGraphViewer } from "./ConlluGraphViewer";
|