@deix/rossini-identity-management 1.1.2 → 2.0.0
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/lib/app/[locale]/groups/{page.js → page.jsx} +1 -1
- package/lib/app/[locale]/{layout.js → layout.jsx} +4 -3
- package/lib/app/[locale]/users/{page.js → page.jsx} +1 -1
- package/lib/app/{layout.js → layout.jsx} +7 -3
- package/lib/components/AddItemDialog.jsx +50 -0
- package/lib/components/DeleteConfirmationDialog.jsx +44 -0
- package/lib/components/SearchField.jsx +18 -0
- package/lib/components/groups/{CreateGroupDialog.js → CreateGroupDialog.jsx} +6 -4
- package/lib/components/groups/{GroupDetails.js → GroupDetails.jsx} +3 -2
- package/lib/components/groups/GroupForm.d.ts.map +1 -1
- package/lib/components/groups/GroupForm.jsx +46 -0
- package/lib/components/groups/GroupTabs.jsx +33 -0
- package/lib/components/groups/GroupUsers.jsx +88 -0
- package/lib/components/groups/Groups.jsx +110 -0
- package/lib/components/groups/GroupsTable.jsx +55 -0
- package/lib/components/users/{CreateUserDialog.js → CreateUserDialog.jsx} +6 -4
- package/lib/components/users/{UserCredentials.js → UserCredentials.jsx} +5 -2
- package/lib/components/users/{UserDetails.js → UserDetails.jsx} +3 -2
- package/lib/components/users/UserForm.d.ts.map +1 -1
- package/lib/components/users/UserForm.jsx +79 -0
- package/lib/components/users/UserGroups.jsx +78 -0
- package/lib/components/users/Users.d.ts +2 -1
- package/lib/components/users/Users.d.ts.map +1 -1
- package/lib/components/users/Users.jsx +116 -0
- package/lib/components/users/UsersTable.d.ts +2 -1
- package/lib/components/users/UsersTable.d.ts.map +1 -1
- package/lib/components/users/UsersTable.jsx +78 -0
- package/lib/components/users/UsersTabs.jsx +36 -0
- package/lib/config/{index.js → index.jsx} +3 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/hooks/{useAPIClient.js → useAPIClient.jsx} +4 -2
- package/package.json +17 -25
- package/lib/components/AddItemDialog.js +0 -45
- package/lib/components/DeleteConfirmationDialog.js +0 -35
- package/lib/components/SearchField.js +0 -16
- package/lib/components/groups/GroupForm.js +0 -38
- package/lib/components/groups/GroupTabs.js +0 -29
- package/lib/components/groups/GroupUsers.js +0 -73
- package/lib/components/groups/Groups.js +0 -97
- package/lib/components/groups/GroupsTable.js +0 -43
- package/lib/components/users/UserForm.js +0 -66
- package/lib/components/users/UserGroups.js +0 -63
- package/lib/components/users/Users.js +0 -103
- package/lib/components/users/UsersTable.js +0 -64
- package/lib/components/users/UsersTabs.js +0 -32
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import React, { useEffect, useState } from 'react';
|
|
3
|
-
import PersonAddIcon from '@mui/icons-material/PersonAdd';
|
|
4
|
-
import { Box, Button, Grid, IconButton, Link } from '@mui/material';
|
|
5
|
-
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
|
|
6
|
-
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
|
|
7
|
-
import { useAPI, useLocale } from '@deix/rossini-core';
|
|
8
|
-
import { useQueryClient } from '@tanstack/react-query';
|
|
9
|
-
import { SearchField } from '../../components';
|
|
10
|
-
import CreateUserDialog from './CreateUserDialog';
|
|
11
|
-
import UsersTable from './UsersTable';
|
|
12
|
-
import usersTranslations from '../../lang/users';
|
|
13
|
-
import { useDeleteUser, useUsers } from '../../utils/hooks/users';
|
|
14
|
-
import UserTabs from './UsersTabs';
|
|
15
|
-
import { APIClientProvider } from '../../utils/hooks/useAPIClient';
|
|
16
|
-
const Users = ({ apiUrl, additionalTabs = [], onUserCreate, onUserUpdate, onUserDelete, editUsername, filteredGroup, emailAsUsername = false, hideGroupsSelection = false, }) => {
|
|
17
|
-
const locale = useLocale();
|
|
18
|
-
const apiClient = useAPI(apiUrl);
|
|
19
|
-
const queryClient = useQueryClient();
|
|
20
|
-
const { data: users } = useUsers(apiClient, filteredGroup);
|
|
21
|
-
const { mutate: deleteUser } = useDeleteUser(queryClient, apiClient);
|
|
22
|
-
const [searchString, setSearchString] = useState('');
|
|
23
|
-
const [filteredUsers, setFilteredUsers] = useState();
|
|
24
|
-
const [selectedUser, setSelectedUser] = useState();
|
|
25
|
-
const [openCreateUserDialog, setOpenCreateUserDialog] = useState(false);
|
|
26
|
-
// Update the filtered users using the search string
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (users && searchString === '') {
|
|
29
|
-
setFilteredUsers(users);
|
|
30
|
-
}
|
|
31
|
-
else if (users && searchString !== '') {
|
|
32
|
-
setFilteredUsers(users.filter((user) => user.username?.toLowerCase().includes(searchString.toLowerCase()) ||
|
|
33
|
-
user.firstName
|
|
34
|
-
?.toLowerCase()
|
|
35
|
-
.includes(searchString.toLowerCase()) ||
|
|
36
|
-
user.lastName
|
|
37
|
-
?.toLocaleLowerCase()
|
|
38
|
-
.includes(searchString.toLowerCase())));
|
|
39
|
-
}
|
|
40
|
-
}, [searchString, users, setFilteredUsers]);
|
|
41
|
-
// If the user change updated the selected user to reflect the chages
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
if (selectedUser) {
|
|
44
|
-
const updatedSelectedUser = users?.find((user) => user.id === selectedUser.id);
|
|
45
|
-
if (updatedSelectedUser) {
|
|
46
|
-
setSelectedUser(updatedSelectedUser);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
// deselect the user if it doesn't exist anymore
|
|
50
|
-
setSelectedUser(undefined);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}, [users, selectedUser, setSelectedUser]);
|
|
54
|
-
const handleDelete = (user) => {
|
|
55
|
-
deleteUser(user.id);
|
|
56
|
-
if (typeof onUserDelete === 'function') {
|
|
57
|
-
onUserDelete(user);
|
|
58
|
-
}
|
|
59
|
-
setSelectedUser(undefined);
|
|
60
|
-
};
|
|
61
|
-
return (React.createElement(APIClientProvider, { baseURL: apiUrl },
|
|
62
|
-
React.createElement(Box, { sx: {
|
|
63
|
-
flexGrow: 1,
|
|
64
|
-
maxWidth: '100%',
|
|
65
|
-
overflowX: 'hidden',
|
|
66
|
-
paddingTop: 3,
|
|
67
|
-
paddingLeft: 3,
|
|
68
|
-
paddingRight: 3,
|
|
69
|
-
} },
|
|
70
|
-
!selectedUser && (React.createElement(React.Fragment, null,
|
|
71
|
-
React.createElement(Grid, { container: true, spacing: 2, sx: { marginBottom: 2 } },
|
|
72
|
-
React.createElement(Grid, { item: true },
|
|
73
|
-
React.createElement(SearchField, { placeholder: usersTranslations.search[locale], onSearch: (value) => setSearchString(value) })),
|
|
74
|
-
React.createElement(Grid, { item: true },
|
|
75
|
-
React.createElement(Button, { variant: 'contained', startIcon: React.createElement(PersonAddIcon, null), onClick: () => {
|
|
76
|
-
setOpenCreateUserDialog(true);
|
|
77
|
-
setSelectedUser(undefined);
|
|
78
|
-
} }, usersTranslations.new[locale]))),
|
|
79
|
-
React.createElement(UsersTable, { users: filteredUsers, selectedUser: selectedUser, setSelectedUser: (user) => {
|
|
80
|
-
setSelectedUser(user);
|
|
81
|
-
}, onDelete: handleDelete, emailAsUsername: emailAsUsername }))),
|
|
82
|
-
selectedUser && (React.createElement(Box, { sx: {
|
|
83
|
-
display: 'flex',
|
|
84
|
-
flexDirection: 'column',
|
|
85
|
-
alignItems: 'flex-start',
|
|
86
|
-
width: '100%',
|
|
87
|
-
} },
|
|
88
|
-
React.createElement(Box, { sx: {
|
|
89
|
-
display: 'flex',
|
|
90
|
-
flexDirection: 'row',
|
|
91
|
-
alignItems: 'center',
|
|
92
|
-
} },
|
|
93
|
-
React.createElement(IconButton, { "aria-label": 'delete', color: 'primary', onClick: () => setSelectedUser(undefined), sx: { mr: 2 } },
|
|
94
|
-
React.createElement(ArrowBackIcon, null)),
|
|
95
|
-
React.createElement(Link, { underline: 'none', href: '#', onClick: () => setSelectedUser(undefined) }, usersTranslations.title[locale]),
|
|
96
|
-
React.createElement(KeyboardArrowRightIcon, null),
|
|
97
|
-
selectedUser.username),
|
|
98
|
-
React.createElement(UserTabs, { user: selectedUser, additionalTabs: additionalTabs, onUserUpdate: onUserUpdate, editUsername: editUsername, emailAsUsername: emailAsUsername, hideGroupsSelection: hideGroupsSelection }))),
|
|
99
|
-
React.createElement(CreateUserDialog, { open: openCreateUserDialog, onClose: () => {
|
|
100
|
-
setOpenCreateUserDialog(false);
|
|
101
|
-
}, onUserCreate: onUserCreate, filteredGroup: filteredGroup, emailAsUsername: true }))));
|
|
102
|
-
};
|
|
103
|
-
export default Users;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { isStringTranslation, useLocale } from '@deix/rossini-core';
|
|
3
|
-
import CheckIcon from '@mui/icons-material/Check';
|
|
4
|
-
import CloseIcon from '@mui/icons-material/Close';
|
|
5
|
-
import DeleteIcon from '@mui/icons-material/Delete';
|
|
6
|
-
import { IconButton, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, useTheme, } from '@mui/material';
|
|
7
|
-
import { useState } from 'react';
|
|
8
|
-
import DeleteConfirmationDialog from '../DeleteConfirmationDialog';
|
|
9
|
-
const usersTableColumns = [
|
|
10
|
-
{
|
|
11
|
-
id: 'firstName',
|
|
12
|
-
label: { en: 'First Name', it: 'Nome' },
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
id: 'lastName',
|
|
16
|
-
label: { en: 'Last Name', it: 'Cognome' },
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
id: 'username',
|
|
20
|
-
label: { en: 'Username', it: 'Username' },
|
|
21
|
-
},
|
|
22
|
-
{ id: 'email', label: 'Email' },
|
|
23
|
-
{
|
|
24
|
-
id: 'enabled',
|
|
25
|
-
label: { en: 'Enabled', it: 'Utente Abilitato' },
|
|
26
|
-
},
|
|
27
|
-
];
|
|
28
|
-
const UsersTable = ({ users = [], selectedUser, setSelectedUser, onDelete, emailAsUsername = false, }) => {
|
|
29
|
-
const locale = useLocale();
|
|
30
|
-
const muiTheme = useTheme();
|
|
31
|
-
const [openConfirmationDialog, setOpenConfirmationDialog] = useState(false);
|
|
32
|
-
const [deleteUser, setDeleteUser] = useState();
|
|
33
|
-
return (React.createElement(React.Fragment, null,
|
|
34
|
-
React.createElement(TableContainer, null,
|
|
35
|
-
React.createElement(Table, { size: 'small' },
|
|
36
|
-
React.createElement(TableHead, null,
|
|
37
|
-
React.createElement(TableRow, null,
|
|
38
|
-
usersTableColumns
|
|
39
|
-
.filter((c) => c.id !== 'username' || !emailAsUsername)
|
|
40
|
-
.map((col) => (React.createElement(TableCell, { key: col.id, align: col.align || 'inherit' }, isStringTranslation(col.label)
|
|
41
|
-
? col.label[locale]
|
|
42
|
-
: col.label))),
|
|
43
|
-
React.createElement(TableCell, { padding: 'none' }, ''))),
|
|
44
|
-
React.createElement(TableBody, null, users.map((user, rowIdx) => (React.createElement(TableRow, { key: rowIdx, onClick: () => setSelectedUser(user), sx: {
|
|
45
|
-
cursor: 'pointer',
|
|
46
|
-
background: selectedUser && user.id === selectedUser.id
|
|
47
|
-
? muiTheme.palette.primary.light
|
|
48
|
-
: undefined,
|
|
49
|
-
} },
|
|
50
|
-
React.createElement(TableCell, null, user.firstName),
|
|
51
|
-
React.createElement(TableCell, null, user.lastName),
|
|
52
|
-
!emailAsUsername && React.createElement(TableCell, null, user.username),
|
|
53
|
-
React.createElement(TableCell, null, user.email),
|
|
54
|
-
React.createElement(TableCell, null, user.enabled ? React.createElement(CheckIcon, null) : React.createElement(CloseIcon, null)),
|
|
55
|
-
React.createElement(TableCell, { padding: 'none', align: 'right' },
|
|
56
|
-
React.createElement(IconButton, { size: 'small', onClick: (evt) => {
|
|
57
|
-
evt.stopPropagation();
|
|
58
|
-
setOpenConfirmationDialog(true);
|
|
59
|
-
setDeleteUser(user);
|
|
60
|
-
} },
|
|
61
|
-
React.createElement(DeleteIcon, null))))))))),
|
|
62
|
-
React.createElement(DeleteConfirmationDialog, { open: openConfirmationDialog, onClose: () => setOpenConfirmationDialog(false), onConfirm: () => (deleteUser ? onDelete(deleteUser) : {}) })));
|
|
63
|
-
};
|
|
64
|
-
export default UsersTable;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import React, { useState } from 'react';
|
|
3
|
-
import { Box, Tab, Tabs } from '@mui/material';
|
|
4
|
-
import { useLocale } from '@deix/rossini-core';
|
|
5
|
-
import usersTranslations from '../../lang/users';
|
|
6
|
-
import UserDetails from './UserDetails';
|
|
7
|
-
import UserGroups from './UserGroups';
|
|
8
|
-
import UserCredentials from './UserCredentials';
|
|
9
|
-
const UserTabs = ({ user, additionalTabs = [], onUserUpdate, editUsername, emailAsUsername = false, hideGroupsSelection = false, }) => {
|
|
10
|
-
const locale = useLocale();
|
|
11
|
-
const [selectedTab, setSelectedTab] = useState('DETAILS');
|
|
12
|
-
return (React.createElement(Box, { sx: {
|
|
13
|
-
flexGrow: 1,
|
|
14
|
-
maxWidth: '100%',
|
|
15
|
-
overflowX: 'hidden',
|
|
16
|
-
alignSelf: 'stretch',
|
|
17
|
-
} },
|
|
18
|
-
React.createElement(Box, { sx: { borderBottom: 1, borderColor: 'divider' } },
|
|
19
|
-
React.createElement(Tabs, { value: selectedTab, onChange: (_evt, newValue) => {
|
|
20
|
-
setSelectedTab(newValue);
|
|
21
|
-
}, "aria-label": 'basic tabs example' },
|
|
22
|
-
React.createElement(Tab, { label: usersTranslations.details[locale], value: 'DETAILS' }),
|
|
23
|
-
!hideGroupsSelection && (React.createElement(Tab, { label: usersTranslations.userGroups[locale], value: 'USER_GROUPS' })),
|
|
24
|
-
React.createElement(Tab, { label: usersTranslations.credentials[locale], value: 'CREDENTIALS' }),
|
|
25
|
-
additionalTabs.map((tab, index) => (React.createElement(Tab, { key: `tab${index}`, label: tab.title[locale], value: `ADDITIONAL_TAB_${index}` }))))),
|
|
26
|
-
React.createElement(Box, { sx: { p: 1 } },
|
|
27
|
-
selectedTab === 'DETAILS' && (React.createElement(UserDetails, { user: user, onUserUpdate: onUserUpdate, editUsername: editUsername, emailAsUsername: emailAsUsername })),
|
|
28
|
-
selectedTab === 'USER_GROUPS' && !hideGroupsSelection && (React.createElement(UserGroups, { user: user })),
|
|
29
|
-
selectedTab === 'CREDENTIALS' && React.createElement(UserCredentials, { user: user }),
|
|
30
|
-
additionalTabs.map((tab, index) => selectedTab === `ADDITIONAL_TAB_${index}` && (React.createElement(tab.component, { key: `tab${index}`, user: user }))))));
|
|
31
|
-
};
|
|
32
|
-
export default UserTabs;
|