tycho-components 0.46.2 → 0.46.3
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.
|
@@ -8,6 +8,7 @@ type Props = {
|
|
|
8
8
|
options?: DropdownMenuItem[];
|
|
9
9
|
className?: string;
|
|
10
10
|
onClick?: () => void;
|
|
11
|
+
dataTour?: string;
|
|
11
12
|
};
|
|
12
|
-
export default function AppCard({ title, children, extraHeaderActions, footer, options, className, onClick, }: Props): import("react").JSX.Element;
|
|
13
|
+
export default function AppCard({ title, children, extraHeaderActions, footer, options, className, onClick, dataTour, }: Props): import("react").JSX.Element;
|
|
13
14
|
export {};
|
|
@@ -2,6 +2,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import cx from 'classnames';
|
|
3
3
|
import { DropdownMenu } from 'tycho-storybook';
|
|
4
4
|
import './style.scss';
|
|
5
|
-
export default function AppCard({ title, children, extraHeaderActions, footer, options, className, onClick, }) {
|
|
6
|
-
return (_jsxs("div", { className: cx('ds-app-card', className), onClick: onClick, children: [title && (_jsxs("div", { className: "header", children: [_jsx("div", { className: "title", children: title }), extraHeaderActions && (_jsx("div", { className: "extra-header-actions", children: extraHeaderActions })), options && _jsx(DropdownMenu, { list: options })] })), _jsx("div", { className: "body", children: children }), footer && _jsx("div", { className: "footer", children: footer })] }));
|
|
5
|
+
export default function AppCard({ title, children, extraHeaderActions, footer, options, className, onClick, dataTour, }) {
|
|
6
|
+
return (_jsxs("div", { className: cx('ds-app-card', className), onClick: onClick, "data-tour": dataTour, children: [title && (_jsxs("div", { className: "header", children: [_jsx("div", { className: "title", children: title }), extraHeaderActions && (_jsx("div", { className: "extra-header-actions", children: extraHeaderActions })), options && _jsx(DropdownMenu, { list: options })] })), _jsx("div", { className: "body", children: children }), footer && _jsx("div", { className: "footer", children: footer })] }));
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { AccessMode } from
|
|
3
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { AccessMode } from "../../../configs/types/Access";
|
|
3
|
+
import "./styles.scss";
|
|
4
4
|
export type AccessUsersProps = {
|
|
5
5
|
mode: AccessMode;
|
|
6
6
|
resourceUid: string;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React, { useEffect, useState } from
|
|
3
|
-
import { useTranslation } from
|
|
4
|
-
import { Tag } from
|
|
5
|
-
import { AppCard, AppLoading, AppPicture, AppPlaceholder, AppTable, EMPTY_PAGE, } from
|
|
6
|
-
import DateUtils from
|
|
7
|
-
import AccessControlService from
|
|
8
|
-
import AccessGrant from
|
|
9
|
-
import AccessUser from
|
|
10
|
-
import { EMPTY_ACCESS_SEARCH_FILTER, } from
|
|
11
|
-
import
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { Tag } from "tycho-storybook";
|
|
5
|
+
import { AppCard, AppLoading, AppPicture, AppPlaceholder, AppTable, EMPTY_PAGE, } from "../../../common";
|
|
6
|
+
import DateUtils from "../../../functions/DateUtils";
|
|
7
|
+
import AccessControlService from "../AccessControlService";
|
|
8
|
+
import AccessGrant from "../AccessGrant";
|
|
9
|
+
import AccessUser from "../AccessUser";
|
|
10
|
+
import { EMPTY_ACCESS_SEARCH_FILTER, } from "./AccessUsersFilter";
|
|
11
|
+
import "./styles.scss";
|
|
12
12
|
const STATUS_TAG_COLOR = {
|
|
13
|
-
ACTIVE:
|
|
14
|
-
INACTIVE:
|
|
13
|
+
ACTIVE: "green",
|
|
14
|
+
INACTIVE: "gray",
|
|
15
15
|
};
|
|
16
16
|
const ROLE_TAG_COLOR = {
|
|
17
|
-
ADMIN:
|
|
18
|
-
EDITOR:
|
|
19
|
-
READER:
|
|
17
|
+
ADMIN: "violet",
|
|
18
|
+
EDITOR: "blue",
|
|
19
|
+
READER: "yellow",
|
|
20
20
|
};
|
|
21
21
|
export default function AccessUsers({ mode, resourceUid }) {
|
|
22
|
-
const { t } = useTranslation(
|
|
22
|
+
const { t } = useTranslation("access");
|
|
23
23
|
const [filter, setFilter] = useState(EMPTY_ACCESS_SEARCH_FILTER);
|
|
24
24
|
const [open, setOpen] = useState(false);
|
|
25
25
|
const [loading, setLoading] = useState(true);
|
|
@@ -47,8 +47,8 @@ export default function AccessUsers({ mode, resourceUid }) {
|
|
|
47
47
|
});
|
|
48
48
|
const menuOptions = [
|
|
49
49
|
{
|
|
50
|
-
icon:
|
|
51
|
-
label: t(
|
|
50
|
+
icon: "add",
|
|
51
|
+
label: t("common:button.add"),
|
|
52
52
|
onClick: handleCreate,
|
|
53
53
|
},
|
|
54
54
|
];
|
|
@@ -57,7 +57,7 @@ export default function AccessUsers({ mode, resourceUid }) {
|
|
|
57
57
|
};
|
|
58
58
|
const addStatusToCell = (props) => {
|
|
59
59
|
const status = props.row.original.status;
|
|
60
|
-
return (_jsx(Tag, { text: t(`status.label.${status?.toLowerCase() ??
|
|
60
|
+
return (_jsx(Tag, { text: t(`status.label.${status?.toLowerCase() ?? ""}`), color: status ? STATUS_TAG_COLOR[status] : "gray", size: "small" }));
|
|
61
61
|
};
|
|
62
62
|
const addRoleToCell = (props) => {
|
|
63
63
|
const role = props.row.original.role;
|
|
@@ -69,29 +69,29 @@ export default function AccessUsers({ mode, resourceUid }) {
|
|
|
69
69
|
};
|
|
70
70
|
const columns = React.useMemo(() => [
|
|
71
71
|
{
|
|
72
|
-
id:
|
|
73
|
-
header:
|
|
72
|
+
id: "original",
|
|
73
|
+
header: "",
|
|
74
74
|
cell: addImageToCell,
|
|
75
75
|
size: 10,
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
|
-
id:
|
|
79
|
-
header: t(
|
|
78
|
+
id: "name",
|
|
79
|
+
header: t("table.label.name"),
|
|
80
80
|
accessorFn: (row) => row.name || row.email,
|
|
81
81
|
cell: addNameToCell,
|
|
82
82
|
size: 35,
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
|
-
id:
|
|
86
|
-
header: t(
|
|
87
|
-
accessorKey:
|
|
85
|
+
id: "status",
|
|
86
|
+
header: t("table.label.status"),
|
|
87
|
+
accessorKey: "status",
|
|
88
88
|
cell: addStatusToCell,
|
|
89
89
|
size: 15,
|
|
90
90
|
},
|
|
91
91
|
{
|
|
92
|
-
id:
|
|
93
|
-
header: t(
|
|
94
|
-
accessorKey:
|
|
92
|
+
id: "role",
|
|
93
|
+
header: t("table.label.role"),
|
|
94
|
+
accessorKey: "role",
|
|
95
95
|
cell: addRoleToCell,
|
|
96
96
|
size: 35,
|
|
97
97
|
},
|
|
@@ -99,11 +99,11 @@ export default function AccessUsers({ mode, resourceUid }) {
|
|
|
99
99
|
useEffect(() => {
|
|
100
100
|
paginate();
|
|
101
101
|
}, [filter, resourceUid, mode]);
|
|
102
|
-
return (_jsxs(AppCard, { title: t(
|
|
102
|
+
return (_jsxs(AppCard, { title: t("title.users"), options: menuOptions, className: "access-users-container", "data-tour": "admin-access-users-panel", children: [loading && _jsx(AppLoading, { pageLoading: true }), !loading && data.totalElements > 0 && (_jsx(AppTable, { columns: columns, data: data, className: "users-table", onClickRow: onClickRow, pagination: { pageIndex: filter.page, pageSize: filter.size }, setPagination: (p) => {
|
|
103
103
|
setFilter({ ...filter, page: p.pageIndex, size: p.pageSize });
|
|
104
104
|
}, sorting: filter.sort || [], setSorting: (s) => {
|
|
105
105
|
setFilter({ ...filter, sort: s });
|
|
106
|
-
} })), !loading && data.totalElements === 0 && (_jsx(AppPlaceholder, { text: t(
|
|
106
|
+
} })), !loading && data.totalElements === 0 && (_jsx(AppPlaceholder, { text: t("access.placeholder"), useMarginTop: true })), selected && (_jsx(AccessUser, { mode: mode, resourceUid: resourceUid, user: selected, setItems: setData, onClose: () => {
|
|
107
107
|
setSelected(undefined);
|
|
108
108
|
}, onReload: () => {
|
|
109
109
|
setSelected(undefined);
|