@deix/rossini-identity-management 0.1.1 → 0.2.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.jsx → page.js} +1 -1
- package/lib/app/[locale]/{layout.jsx → layout.js} +3 -4
- package/lib/app/[locale]/users/{page.jsx → page.js} +1 -1
- package/lib/app/{layout.jsx → layout.js} +4 -8
- package/lib/components/AddItemDialog.js +45 -0
- package/lib/components/DeleteConfirmationDialog.js +35 -0
- package/lib/components/SearchField.js +16 -0
- package/lib/components/groups/CreateGroupDialog.d.ts +3 -1
- package/lib/components/groups/CreateGroupDialog.d.ts.map +1 -1
- package/lib/components/groups/{CreateGroupDialog.jsx → CreateGroupDialog.js} +8 -7
- package/lib/components/groups/GroupDetails.d.ts +3 -1
- package/lib/components/groups/GroupDetails.d.ts.map +1 -1
- package/lib/components/groups/GroupDetails.js +19 -0
- package/lib/components/groups/GroupForm.d.ts +2 -1
- package/lib/components/groups/GroupForm.d.ts.map +1 -1
- package/lib/components/groups/GroupForm.js +38 -0
- package/lib/components/groups/GroupTabs.d.ts +3 -1
- package/lib/components/groups/GroupTabs.d.ts.map +1 -1
- package/lib/components/groups/GroupTabs.js +29 -0
- package/lib/components/groups/GroupUsers.js +73 -0
- package/lib/components/groups/Groups.d.ts +6 -1
- package/lib/components/groups/Groups.d.ts.map +1 -1
- package/lib/components/groups/Groups.js +83 -0
- package/lib/components/groups/GroupsTable.d.ts +1 -1
- package/lib/components/groups/GroupsTable.d.ts.map +1 -1
- package/lib/components/groups/GroupsTable.js +43 -0
- package/lib/components/users/CreateUserDialog.d.ts +3 -1
- package/lib/components/users/CreateUserDialog.d.ts.map +1 -1
- package/lib/components/users/{CreateUserDialog.jsx → CreateUserDialog.js} +8 -7
- package/lib/components/users/{UserCredentials.jsx → UserCredentials.js} +2 -5
- package/lib/components/users/UserDetails.d.ts +3 -1
- package/lib/components/users/UserDetails.d.ts.map +1 -1
- package/lib/components/users/UserDetails.js +22 -0
- package/lib/components/users/UserForm.d.ts +2 -1
- package/lib/components/users/UserForm.d.ts.map +1 -1
- package/lib/components/users/UserForm.js +64 -0
- package/lib/components/users/UserGroups.js +63 -0
- package/lib/components/users/Users.d.ts +6 -1
- package/lib/components/users/Users.d.ts.map +1 -1
- package/lib/components/users/Users.js +89 -0
- package/lib/components/users/UsersTable.d.ts +1 -1
- package/lib/components/users/UsersTable.d.ts.map +1 -1
- package/lib/components/users/UsersTable.js +62 -0
- package/lib/components/users/UsersTabs.d.ts +3 -1
- package/lib/components/users/UsersTabs.d.ts.map +1 -1
- package/lib/components/users/UsersTabs.js +32 -0
- package/lib/config/{index.jsx → index.js} +1 -3
- package/lib/lang/users.d.ts.map +1 -1
- package/lib/lang/users.js +4 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/hooks/groups.d.ts.map +1 -1
- package/lib/utils/hooks/groups.js +0 -2
- package/lib/utils/hooks/{useAPIClient.jsx → useAPIClient.js} +2 -4
- package/lib/utils/hooks/users.d.ts.map +1 -1
- package/lib/utils/hooks/users.js +0 -1
- package/package.json +2 -5
- package/lib/components/AddItemDialog.jsx +0 -50
- package/lib/components/DeleteConfirmationDialog.jsx +0 -44
- package/lib/components/SearchField.jsx +0 -18
- package/lib/components/groups/GroupDetails.jsx +0 -17
- package/lib/components/groups/GroupForm.jsx +0 -46
- package/lib/components/groups/GroupTabs.jsx +0 -33
- package/lib/components/groups/GroupUsers.jsx +0 -88
- package/lib/components/groups/Groups.jsx +0 -93
- package/lib/components/groups/GroupsTable.jsx +0 -55
- package/lib/components/users/UserDetails.jsx +0 -17
- package/lib/components/users/UserForm.jsx +0 -75
- package/lib/components/users/UserGroups.jsx +0 -78
- package/lib/components/users/Users.jsx +0 -99
- package/lib/components/users/UsersTable.jsx +0 -76
- package/lib/components/users/UsersTabs.jsx +0 -36
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box, Button, IconButton, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, } from '@mui/material';
|
|
3
|
-
import AddIcon from '@mui/icons-material/Add';
|
|
4
|
-
import DeleteIcon from '@mui/icons-material/Delete';
|
|
5
|
-
import { isStringTranslation, useLocale } from '@deix/rossini-core';
|
|
6
|
-
import { useAddUserToGroup, useRemoveUserFromGroup, useUserGroups, } from '../../utils/hooks/users';
|
|
7
|
-
import { useState } from 'react';
|
|
8
|
-
import DeleteConfirmationDialog from '../DeleteConfirmationDialog';
|
|
9
|
-
import { useQueryClient } from '@tanstack/react-query';
|
|
10
|
-
import usersTranslations from '../../lang/users';
|
|
11
|
-
import AddItemDialog from '../AddItemDialog';
|
|
12
|
-
import { useGroups } from '../../utils/hooks/groups';
|
|
13
|
-
import { useAPIClient } from '../../utils/hooks/useAPIClient';
|
|
14
|
-
const userGroupsTableColumns = [
|
|
15
|
-
{
|
|
16
|
-
id: 'name',
|
|
17
|
-
label: { en: 'Group', it: 'Gruppo' },
|
|
18
|
-
},
|
|
19
|
-
];
|
|
20
|
-
const UserGroups = ({ user }) => {
|
|
21
|
-
const locale = useLocale();
|
|
22
|
-
const apiClient = useAPIClient();
|
|
23
|
-
const queryClient = useQueryClient();
|
|
24
|
-
const { data: groups } = useGroups(apiClient);
|
|
25
|
-
const { data: userGroups } = useUserGroups(user?.id, apiClient);
|
|
26
|
-
const { mutate: addUserToGroup } = useAddUserToGroup(queryClient, apiClient);
|
|
27
|
-
const { mutate: removeUserFromGroup } = useRemoveUserFromGroup(queryClient, apiClient);
|
|
28
|
-
const [openAddGroupDialog, setOpenAddGroupDialog] = useState(false);
|
|
29
|
-
const [openConfirmationDialog, setOpenConfirmationDialog] = useState(false);
|
|
30
|
-
const [deleteId, setDeleteId] = useState();
|
|
31
|
-
return (<>
|
|
32
|
-
{userGroups && userGroups.length > 0 && (<Box maxWidth='sm'>
|
|
33
|
-
<TableContainer>
|
|
34
|
-
<Table size='small'>
|
|
35
|
-
<TableHead>
|
|
36
|
-
<TableRow>
|
|
37
|
-
{userGroupsTableColumns.map((col) => (<TableCell key={col.id} align={col.align || 'inherit'}>
|
|
38
|
-
{isStringTranslation(col.label)
|
|
39
|
-
? col.label[locale]
|
|
40
|
-
: col.label}
|
|
41
|
-
</TableCell>))}
|
|
42
|
-
<TableCell padding='none'>{''}</TableCell>
|
|
43
|
-
</TableRow>
|
|
44
|
-
</TableHead>
|
|
45
|
-
<TableBody>
|
|
46
|
-
{userGroups?.map((group, rowIdx) => (<TableRow key={rowIdx}>
|
|
47
|
-
<TableCell>{group.name}</TableCell>
|
|
48
|
-
<TableCell padding='none' align='right'>
|
|
49
|
-
<IconButton size='small' onClick={(evt) => {
|
|
50
|
-
evt.stopPropagation();
|
|
51
|
-
setOpenConfirmationDialog(true);
|
|
52
|
-
setDeleteId(group.id);
|
|
53
|
-
}}>
|
|
54
|
-
<DeleteIcon />
|
|
55
|
-
</IconButton>
|
|
56
|
-
</TableCell>
|
|
57
|
-
</TableRow>))}
|
|
58
|
-
</TableBody>
|
|
59
|
-
</Table>
|
|
60
|
-
</TableContainer>
|
|
61
|
-
</Box>)}
|
|
62
|
-
<Button variant='outlined' startIcon={<AddIcon />} onClick={() => setOpenAddGroupDialog(true)} sx={{ marginTop: 2 }}>
|
|
63
|
-
{usersTranslations.addGroup[locale]}
|
|
64
|
-
</Button>
|
|
65
|
-
<AddItemDialog open={openAddGroupDialog} onClose={() => setOpenAddGroupDialog(false)} onConfirm={(value) => {
|
|
66
|
-
if (value) {
|
|
67
|
-
addUserToGroup({ userId: user.id, groupId: value?.value });
|
|
68
|
-
}
|
|
69
|
-
}} title={usersTranslations.addGroup} options={groups?.map((group) => ({
|
|
70
|
-
value: group.id,
|
|
71
|
-
label: group.name,
|
|
72
|
-
}))}/>
|
|
73
|
-
<DeleteConfirmationDialog open={openConfirmationDialog} onClose={() => setOpenConfirmationDialog(false)} onConfirm={() => deleteId
|
|
74
|
-
? removeUserFromGroup({ userId: user.id, groupId: deleteId })
|
|
75
|
-
: {}}/>
|
|
76
|
-
</>);
|
|
77
|
-
};
|
|
78
|
-
export default UserGroups;
|
|
@@ -1,99 +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 = [] }) => {
|
|
17
|
-
const locale = useLocale();
|
|
18
|
-
const apiClient = useAPI(apiUrl);
|
|
19
|
-
const queryClient = useQueryClient();
|
|
20
|
-
const { data: users } = useUsers(apiClient);
|
|
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
|
-
useEffect(() => {
|
|
27
|
-
if (users && searchString === '') {
|
|
28
|
-
setFilteredUsers(users);
|
|
29
|
-
}
|
|
30
|
-
else if (users && searchString !== '') {
|
|
31
|
-
setFilteredUsers(users.filter((user) => user.username?.toLowerCase().includes(searchString.toLowerCase()) ||
|
|
32
|
-
user.firstName
|
|
33
|
-
?.toLowerCase()
|
|
34
|
-
.includes(searchString.toLowerCase()) ||
|
|
35
|
-
user.lastName
|
|
36
|
-
?.toLocaleLowerCase()
|
|
37
|
-
.includes(searchString.toLowerCase())));
|
|
38
|
-
}
|
|
39
|
-
}, [searchString, users, setFilteredUsers]);
|
|
40
|
-
const handleDelete = (id) => {
|
|
41
|
-
deleteUser(id);
|
|
42
|
-
setSelectedUser(undefined);
|
|
43
|
-
};
|
|
44
|
-
return (<APIClientProvider baseURL={apiUrl}>
|
|
45
|
-
<Box sx={{
|
|
46
|
-
flexGrow: 1,
|
|
47
|
-
maxWidth: '100%',
|
|
48
|
-
overflowX: 'hidden',
|
|
49
|
-
paddingTop: 3,
|
|
50
|
-
paddingLeft: 3,
|
|
51
|
-
paddingRight: 3,
|
|
52
|
-
}}>
|
|
53
|
-
{!selectedUser && (<>
|
|
54
|
-
<Grid container spacing={2} sx={{ marginBottom: 2 }}>
|
|
55
|
-
<Grid item>
|
|
56
|
-
<SearchField placeholder={usersTranslations.search[locale]} onSearch={(value) => setSearchString(value)}/>
|
|
57
|
-
</Grid>
|
|
58
|
-
<Grid item>
|
|
59
|
-
<Button variant='contained' startIcon={<PersonAddIcon />} onClick={() => {
|
|
60
|
-
setOpenCreateUserDialog(true);
|
|
61
|
-
setSelectedUser(undefined);
|
|
62
|
-
}}>
|
|
63
|
-
{usersTranslations.new[locale]}
|
|
64
|
-
</Button>
|
|
65
|
-
</Grid>
|
|
66
|
-
</Grid>
|
|
67
|
-
<UsersTable users={filteredUsers} selectedUser={selectedUser} setSelectedUser={(user) => {
|
|
68
|
-
setSelectedUser(user);
|
|
69
|
-
}} onDelete={handleDelete}/>
|
|
70
|
-
</>)}
|
|
71
|
-
{selectedUser && (<Box sx={{
|
|
72
|
-
display: 'flex',
|
|
73
|
-
flexDirection: 'column',
|
|
74
|
-
alignItems: 'flex-start',
|
|
75
|
-
width: '100%',
|
|
76
|
-
}}>
|
|
77
|
-
<Box sx={{
|
|
78
|
-
display: 'flex',
|
|
79
|
-
flexDirection: 'row',
|
|
80
|
-
alignItems: 'center',
|
|
81
|
-
}}>
|
|
82
|
-
<IconButton aria-label='delete' color='primary' onClick={() => setSelectedUser(undefined)} sx={{ mr: 2 }}>
|
|
83
|
-
<ArrowBackIcon />
|
|
84
|
-
</IconButton>
|
|
85
|
-
<Link underline='none' href='#' onClick={() => setSelectedUser(undefined)}>
|
|
86
|
-
{usersTranslations.title[locale]}
|
|
87
|
-
</Link>
|
|
88
|
-
<KeyboardArrowRightIcon />
|
|
89
|
-
{selectedUser.username}
|
|
90
|
-
</Box>
|
|
91
|
-
<UserTabs user={selectedUser} additionalTabs={additionalTabs}/>
|
|
92
|
-
</Box>)}
|
|
93
|
-
<CreateUserDialog open={openCreateUserDialog} onClose={() => {
|
|
94
|
-
setOpenCreateUserDialog(false);
|
|
95
|
-
}}/>
|
|
96
|
-
</Box>
|
|
97
|
-
</APIClientProvider>);
|
|
98
|
-
};
|
|
99
|
-
export default Users;
|
|
@@ -1,76 +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, }) => {
|
|
29
|
-
const locale = useLocale();
|
|
30
|
-
const muiTheme = useTheme();
|
|
31
|
-
const [openConfirmationDialog, setOpenConfirmationDialog] = useState(false);
|
|
32
|
-
const [deleteId, setDeleteId] = useState();
|
|
33
|
-
return (<>
|
|
34
|
-
<TableContainer>
|
|
35
|
-
<Table size='small'>
|
|
36
|
-
<TableHead>
|
|
37
|
-
<TableRow>
|
|
38
|
-
{usersTableColumns.map((col) => (<TableCell key={col.id} align={col.align || 'inherit'}>
|
|
39
|
-
{isStringTranslation(col.label)
|
|
40
|
-
? col.label[locale]
|
|
41
|
-
: col.label}
|
|
42
|
-
</TableCell>))}
|
|
43
|
-
<TableCell padding='none'>{''}</TableCell>
|
|
44
|
-
</TableRow>
|
|
45
|
-
</TableHead>
|
|
46
|
-
<TableBody>
|
|
47
|
-
{users.map((user, rowIdx) => (<TableRow key={rowIdx} onClick={() => setSelectedUser(user)} sx={{
|
|
48
|
-
cursor: 'pointer',
|
|
49
|
-
background: selectedUser && user.id === selectedUser.id
|
|
50
|
-
? muiTheme.palette.primary.light
|
|
51
|
-
: undefined,
|
|
52
|
-
}}>
|
|
53
|
-
<TableCell>{user.firstName}</TableCell>
|
|
54
|
-
<TableCell>{user.lastName}</TableCell>
|
|
55
|
-
<TableCell>{user.username}</TableCell>
|
|
56
|
-
<TableCell>{user.email}</TableCell>
|
|
57
|
-
<TableCell>
|
|
58
|
-
{user.enabled ? <CheckIcon /> : <CloseIcon />}
|
|
59
|
-
</TableCell>
|
|
60
|
-
<TableCell padding='none' align='right'>
|
|
61
|
-
<IconButton size='small' onClick={(evt) => {
|
|
62
|
-
evt.stopPropagation();
|
|
63
|
-
setOpenConfirmationDialog(true);
|
|
64
|
-
setDeleteId(user.id);
|
|
65
|
-
}}>
|
|
66
|
-
<DeleteIcon />
|
|
67
|
-
</IconButton>
|
|
68
|
-
</TableCell>
|
|
69
|
-
</TableRow>))}
|
|
70
|
-
</TableBody>
|
|
71
|
-
</Table>
|
|
72
|
-
</TableContainer>
|
|
73
|
-
<DeleteConfirmationDialog open={openConfirmationDialog} onClose={() => setOpenConfirmationDialog(false)} onConfirm={() => (deleteId ? onDelete(deleteId) : {})}/>
|
|
74
|
-
</>);
|
|
75
|
-
};
|
|
76
|
-
export default UsersTable;
|
|
@@ -1,36 +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 = [] }) => {
|
|
10
|
-
const locale = useLocale();
|
|
11
|
-
const [selectedTab, setSelectedTab] = useState('DETAILS');
|
|
12
|
-
return (<Box sx={{
|
|
13
|
-
flexGrow: 1,
|
|
14
|
-
maxWidth: '100%',
|
|
15
|
-
overflowX: 'hidden',
|
|
16
|
-
alignSelf: 'stretch',
|
|
17
|
-
}}>
|
|
18
|
-
<Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
|
|
19
|
-
<Tabs value={selectedTab} onChange={(_evt, newValue) => {
|
|
20
|
-
setSelectedTab(newValue);
|
|
21
|
-
}} aria-label='basic tabs example'>
|
|
22
|
-
<Tab label={usersTranslations.details[locale]} value='DETAILS'/>
|
|
23
|
-
<Tab label={usersTranslations.userGroups[locale]} value='USER_GROUPS'/>
|
|
24
|
-
<Tab label={usersTranslations.credentials[locale]} value='CREDENTIALS'/>
|
|
25
|
-
{additionalTabs.map((tab, index) => (<Tab key={`tab${index}`} label={tab.title[locale]} value={`ADDITIONAL_TAB_${index}`}/>))}
|
|
26
|
-
</Tabs>
|
|
27
|
-
</Box>
|
|
28
|
-
<Box sx={{ p: 1 }}>
|
|
29
|
-
{selectedTab === 'DETAILS' && <UserDetails user={user}/>}
|
|
30
|
-
{selectedTab === 'USER_GROUPS' && <UserGroups user={user}/>}
|
|
31
|
-
{selectedTab === 'CREDENTIALS' && <UserCredentials user={user}/>}
|
|
32
|
-
{additionalTabs.map((tab, index) => selectedTab === `ADDITIONAL_TAB_${index}` && (<tab.component key={`tab${index}`} user={user}/>))}
|
|
33
|
-
</Box>
|
|
34
|
-
</Box>);
|
|
35
|
-
};
|
|
36
|
-
export default UserTabs;
|