@deix/rossini-identity-management 0.1.0 → 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]/users/page.js +1 -1
- package/lib/app/layout.js +1 -1
- package/lib/components/groups/CreateGroupDialog.d.ts +3 -1
- package/lib/components/groups/CreateGroupDialog.d.ts.map +1 -1
- package/lib/components/groups/CreateGroupDialog.js +7 -5
- 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 +9 -8
- 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 +3 -3
- 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 +4 -4
- package/lib/components/groups/GroupUsers.d.ts.map +1 -1
- package/lib/components/groups/GroupUsers.js +3 -4
- 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 +45 -40
- 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 +3 -3
- package/lib/components/users/CreateUserDialog.d.ts +3 -1
- package/lib/components/users/CreateUserDialog.d.ts.map +1 -1
- package/lib/components/users/CreateUserDialog.js +7 -5
- package/lib/components/users/UserCredentials.d.ts.map +1 -1
- package/lib/components/users/UserCredentials.js +3 -4
- 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 +11 -7
- 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 +7 -5
- package/lib/components/users/UserGroups.d.ts.map +1 -1
- package/lib/components/users/UserGroups.js +3 -4
- 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 +45 -40
- 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 +3 -3
- 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 +4 -4
- 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.d.ts +10 -0
- package/lib/utils/hooks/useAPIClient.d.ts.map +1 -0
- package/lib/utils/hooks/useAPIClient.js +16 -0
- package/lib/utils/hooks/users.d.ts.map +1 -1
- package/lib/utils/hooks/users.js +0 -1
- package/package.json +2 -5
|
@@ -4,6 +4,6 @@ import { useConfig } from '../../../config';
|
|
|
4
4
|
import Users from '../../../components/users/Users';
|
|
5
5
|
const UsersPage = () => {
|
|
6
6
|
const config = useConfig();
|
|
7
|
-
return React.createElement(Users, { apiUrl: config.generalProperties.apiURL });
|
|
7
|
+
return React.createElement(Users, { apiUrl: config.generalProperties.apiURL, editUsername: true });
|
|
8
8
|
};
|
|
9
9
|
export default UsersPage;
|
package/lib/app/layout.js
CHANGED
|
@@ -6,7 +6,7 @@ import '@fontsource/raleway/600.css';
|
|
|
6
6
|
import '@fontsource/raleway/700.css';
|
|
7
7
|
import { ConfigProvider } from '../config';
|
|
8
8
|
export const metadata = {
|
|
9
|
-
title: 'Rossini
|
|
9
|
+
title: 'Rossini Identity Management',
|
|
10
10
|
};
|
|
11
11
|
export default function RootLayout({ children, }) {
|
|
12
12
|
const publicRuntimeEnv = {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { Group } from '../../types/groups';
|
|
2
3
|
export interface CreateGroupDialogProps {
|
|
3
4
|
open: boolean;
|
|
4
5
|
onClose: () => void;
|
|
6
|
+
onGroupCreate?: (newGroup: Group) => void;
|
|
5
7
|
}
|
|
6
|
-
declare const CreateGroupDialog: ({ open, onClose }: CreateGroupDialogProps) => React.JSX.Element;
|
|
8
|
+
declare const CreateGroupDialog: ({ open, onClose, onGroupCreate, }: CreateGroupDialogProps) => React.JSX.Element;
|
|
7
9
|
export default CreateGroupDialog;
|
|
8
10
|
//# sourceMappingURL=CreateGroupDialog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateGroupDialog.d.ts","sourceRoot":"","sources":["../../../src/components/groups/CreateGroupDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"CreateGroupDialog.d.ts","sourceRoot":"","sources":["../../../src/components/groups/CreateGroupDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAK3C,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,KAAK,IAAI,CAAC;CAC3C;AAED,QAAA,MAAM,iBAAiB,sCAIpB,sBAAsB,sBAuBxB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useLocale } from '@deix/rossini-core';
|
|
3
3
|
import { Dialog, DialogContent, DialogTitle } from '@mui/material';
|
|
4
4
|
import { useQueryClient } from '@tanstack/react-query';
|
|
5
|
-
import { useConfig } from '../../config';
|
|
6
5
|
import groupsTranslations from '../../lang/groups';
|
|
7
6
|
import { useAddGroup } from '../../utils/hooks/groups';
|
|
8
7
|
import GroupForm from './GroupForm';
|
|
9
|
-
|
|
8
|
+
import { useAPIClient } from '../../utils/hooks/useAPIClient';
|
|
9
|
+
const CreateGroupDialog = ({ open, onClose, onGroupCreate, }) => {
|
|
10
10
|
const locale = useLocale();
|
|
11
|
-
const
|
|
12
|
-
const apiClient = useAPI(config.generalProperties.apiURL);
|
|
11
|
+
const apiClient = useAPIClient();
|
|
13
12
|
const queryClient = useQueryClient();
|
|
14
13
|
const { mutate: addGroup } = useAddGroup(queryClient, apiClient);
|
|
15
14
|
const handleSave = (group) => {
|
|
16
15
|
addGroup(group);
|
|
16
|
+
if (typeof onGroupCreate === 'function') {
|
|
17
|
+
onGroupCreate(group);
|
|
18
|
+
}
|
|
17
19
|
onClose();
|
|
18
20
|
};
|
|
19
21
|
return (React.createElement(Dialog, { open: open, fullWidth: true, maxWidth: 'sm', onClose: onClose },
|
|
@@ -2,7 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import { Group } from '../../types/groups';
|
|
3
3
|
export interface GroupDetailsProps {
|
|
4
4
|
group: Group;
|
|
5
|
+
onGroupUpdate?: (newGroup: Group, oldGroup: Group) => void;
|
|
6
|
+
editName?: boolean;
|
|
5
7
|
}
|
|
6
|
-
declare const GroupDetails: ({ group }: GroupDetailsProps) => React.JSX.Element;
|
|
8
|
+
declare const GroupDetails: ({ group, onGroupUpdate, editName, }: GroupDetailsProps) => React.JSX.Element;
|
|
7
9
|
export default GroupDetails;
|
|
8
10
|
//# sourceMappingURL=GroupDetails.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupDetails.d.ts","sourceRoot":"","sources":["../../../src/components/groups/GroupDetails.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"GroupDetails.d.ts","sourceRoot":"","sources":["../../../src/components/groups/GroupDetails.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAK3C,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,KAAK,CAAC;IACb,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,KAAK,IAAI,CAAC;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,YAAY,wCAIf,iBAAiB,sBAuBnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { useAPI } from '@deix/rossini-core';
|
|
3
2
|
import { useQueryClient } from '@tanstack/react-query';
|
|
4
|
-
import { useConfig } from '../../config';
|
|
5
3
|
import { useUpdateGroup } from '../../utils/hooks/groups';
|
|
6
4
|
import GroupForm from './GroupForm';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const apiClient =
|
|
5
|
+
import { useAPIClient } from '../../utils/hooks/useAPIClient';
|
|
6
|
+
const GroupDetails = ({ group, onGroupUpdate, editName, }) => {
|
|
7
|
+
const apiClient = useAPIClient();
|
|
10
8
|
const queryClient = useQueryClient();
|
|
11
9
|
const { mutate: updateGroup } = useUpdateGroup(queryClient, apiClient);
|
|
12
|
-
const handleUpdate = (
|
|
13
|
-
updateGroup(
|
|
10
|
+
const handleUpdate = (updatedGroup) => {
|
|
11
|
+
updateGroup(updatedGroup);
|
|
12
|
+
if (typeof onGroupUpdate === 'function') {
|
|
13
|
+
onGroupUpdate(updatedGroup, group);
|
|
14
|
+
}
|
|
14
15
|
};
|
|
15
16
|
return (React.createElement(React.Fragment, null,
|
|
16
|
-
React.createElement(GroupForm, { mode: 'modify', group: group, onSave: handleUpdate, onCancel: () => { } })));
|
|
17
|
+
React.createElement(GroupForm, { mode: 'modify', group: group, onSave: handleUpdate, onCancel: () => { }, editName: editName })));
|
|
17
18
|
};
|
|
18
19
|
export default GroupDetails;
|
|
@@ -5,7 +5,8 @@ export interface GroupFormProps {
|
|
|
5
5
|
onSave: (group: Group) => void;
|
|
6
6
|
group?: Group;
|
|
7
7
|
mode: 'create' | 'modify';
|
|
8
|
+
editName?: boolean;
|
|
8
9
|
}
|
|
9
|
-
declare const GroupForm: ({ group, onCancel, onSave, mode }: GroupFormProps) => React.JSX.Element;
|
|
10
|
+
declare const GroupForm: ({ group, onCancel, onSave, mode, editName, }: GroupFormProps) => React.JSX.Element;
|
|
10
11
|
export default GroupForm;
|
|
11
12
|
//# sourceMappingURL=GroupForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupForm.d.ts","sourceRoot":"","sources":["../../../src/components/groups/GroupForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC/B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"GroupForm.d.ts","sourceRoot":"","sources":["../../../src/components/groups/GroupForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC/B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,SAAS,iDAMZ,cAAc,sBAmEhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -4,12 +4,12 @@ import { Button, Grid, TextField } from '@mui/material';
|
|
|
4
4
|
import { Controller, useForm } from 'react-hook-form';
|
|
5
5
|
import { useEffect } from 'react';
|
|
6
6
|
import groupsTranslations from '../../lang/groups';
|
|
7
|
-
const GroupForm = ({ group, onCancel, onSave, mode }) => {
|
|
7
|
+
const GroupForm = ({ group, onCancel, onSave, mode, editName, }) => {
|
|
8
8
|
const locale = useLocale();
|
|
9
9
|
const { control, handleSubmit, setValue } = useForm({
|
|
10
10
|
defaultValues: {
|
|
11
11
|
id: group?.id,
|
|
12
|
-
name: group?.name,
|
|
12
|
+
name: group?.name || '',
|
|
13
13
|
},
|
|
14
14
|
});
|
|
15
15
|
useEffect(() => {
|
|
@@ -24,7 +24,7 @@ const GroupForm = ({ group, onCancel, onSave, mode }) => {
|
|
|
24
24
|
return (React.createElement("form", { onSubmit: (event) => void handleSubmit(onSubmit)(event) },
|
|
25
25
|
React.createElement(Grid, { container: true, spacing: 2, sx: { mt: 2, maxWidth: 'sm' }, justifyContent: 'stretch' },
|
|
26
26
|
React.createElement(Grid, { item: true, xs: 12 },
|
|
27
|
-
React.createElement(Controller, { name: 'name', control: control, render: ({ field }) => (React.createElement(TextField, { size: 'small', fullWidth: true, label: groupsTranslations.name[locale], sx: { flexShrink: 0 }, ...field })) })),
|
|
27
|
+
React.createElement(Controller, { name: 'name', control: control, render: ({ field }) => (React.createElement(TextField, { size: 'small', fullWidth: true, label: groupsTranslations.name[locale], disabled: mode === 'modify' && !editName, sx: { flexShrink: 0 }, ...field })) })),
|
|
28
28
|
React.createElement(Grid, { item: true, sx: {
|
|
29
29
|
mt: 2,
|
|
30
30
|
display: 'flex',
|
|
@@ -10,7 +10,9 @@ export interface GroupTab {
|
|
|
10
10
|
export interface GroupTabsProps {
|
|
11
11
|
group: Group;
|
|
12
12
|
additionalTabs?: GroupTab[];
|
|
13
|
+
onGroupUpdate?: (newGroup: Group, oldGroup: Group) => void;
|
|
14
|
+
editName?: boolean;
|
|
13
15
|
}
|
|
14
|
-
declare const GroupTabs: ({ group, additionalTabs }: GroupTabsProps) => React.JSX.Element;
|
|
16
|
+
declare const GroupTabs: ({ group, additionalTabs, onGroupUpdate, editName, }: GroupTabsProps) => React.JSX.Element;
|
|
15
17
|
export default GroupTabs;
|
|
16
18
|
//# sourceMappingURL=GroupTabs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupTabs.d.ts","sourceRoot":"","sources":["../../../src/components/groups/GroupTabs.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,OAAO,EAAE,iBAAiB,EAAa,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAK3C,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,iBAAiB,CAAC;IACzB,SAAS,EAAE,KAAK,CAAC,iBAAiB,CAAC;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC;CACtD;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,KAAK,CAAC;IACb,cAAc,CAAC,EAAE,QAAQ,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"GroupTabs.d.ts","sourceRoot":"","sources":["../../../src/components/groups/GroupTabs.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,OAAO,EAAE,iBAAiB,EAAa,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAK3C,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,iBAAiB,CAAC;IACzB,SAAS,EAAE,KAAK,CAAC,iBAAiB,CAAC;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC;CACtD;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,KAAK,CAAC;IACb,cAAc,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC5B,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,KAAK,IAAI,CAAC;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,SAAS,wDAKZ,cAAc,sBAkDhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { useLocale } from '@deix/rossini-core';
|
|
|
5
5
|
import GroupDetails from './GroupDetails';
|
|
6
6
|
import groupsTranslations from '../../lang/groups';
|
|
7
7
|
import GroupUsers from './GroupUsers';
|
|
8
|
-
const GroupTabs = ({ group, additionalTabs = [] }) => {
|
|
8
|
+
const GroupTabs = ({ group, additionalTabs = [], onGroupUpdate, editName, }) => {
|
|
9
9
|
const locale = useLocale();
|
|
10
10
|
const [selectedTab, setSelectedTab] = useState('DETAILS');
|
|
11
11
|
return (React.createElement(Box, { sx: {
|
|
@@ -20,10 +20,10 @@ const GroupTabs = ({ group, additionalTabs = [] }) => {
|
|
|
20
20
|
}, "aria-label": 'basic tabs example' },
|
|
21
21
|
React.createElement(Tab, { label: groupsTranslations.details[locale], value: 'DETAILS' }),
|
|
22
22
|
React.createElement(Tab, { label: groupsTranslations.users[locale], value: 'USERS' }),
|
|
23
|
-
additionalTabs.map((tab, index) => (React.createElement(Tab, { label: tab.title[locale], value: `ADDITIONAL_TAB_${index}` }))))),
|
|
23
|
+
additionalTabs.map((tab, index) => (React.createElement(Tab, { key: `tab${index}`, label: tab.title[locale], value: `ADDITIONAL_TAB_${index}` }))))),
|
|
24
24
|
React.createElement(Box, { sx: { p: 1 } },
|
|
25
|
-
selectedTab === 'DETAILS' && React.createElement(GroupDetails, { group: group }),
|
|
25
|
+
selectedTab === 'DETAILS' && (React.createElement(GroupDetails, { group: group, onGroupUpdate: onGroupUpdate, editName: editName })),
|
|
26
26
|
selectedTab === 'USERS' && React.createElement(GroupUsers, { group: group }),
|
|
27
|
-
additionalTabs.map((tab, index) => selectedTab === `ADDITIONAL_TAB_${index}` && (React.createElement(tab.component, { group: group }))))));
|
|
27
|
+
additionalTabs.map((tab, index) => selectedTab === `ADDITIONAL_TAB_${index}` && (React.createElement(tab.component, { key: `tab${index}`, group: group }))))));
|
|
28
28
|
};
|
|
29
29
|
export default GroupTabs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupUsers.d.ts","sourceRoot":"","sources":["../../../src/components/groups/GroupUsers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAe1B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"GroupUsers.d.ts","sourceRoot":"","sources":["../../../src/components/groups/GroupUsers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAe1B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AA8B3C,UAAU,eAAe;IACvB,KAAK,EAAE,KAAK,CAAC;CACd;AAED,QAAA,MAAM,UAAU,cAAe,eAAe,sBA8F7C,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -2,8 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Box, Button, IconButton, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, } from '@mui/material';
|
|
3
3
|
import AddIcon from '@mui/icons-material/Add';
|
|
4
4
|
import DeleteIcon from '@mui/icons-material/Delete';
|
|
5
|
-
import { isStringTranslation,
|
|
6
|
-
import { useConfig } from '../../config';
|
|
5
|
+
import { isStringTranslation, useLocale } from '@deix/rossini-core';
|
|
7
6
|
import { useAddUserToGroup, useRemoveUserFromGroup, useUsers, } from '../../utils/hooks/users';
|
|
8
7
|
import { useState } from 'react';
|
|
9
8
|
import DeleteConfirmationDialog from '../DeleteConfirmationDialog';
|
|
@@ -11,6 +10,7 @@ import { useQueryClient } from '@tanstack/react-query';
|
|
|
11
10
|
import AddItemDialog from '../AddItemDialog';
|
|
12
11
|
import { useGroupUsers } from '../../utils/hooks/groups';
|
|
13
12
|
import groupsTranslations from '../../lang/groups';
|
|
13
|
+
import { useAPIClient } from '../../utils/hooks/useAPIClient';
|
|
14
14
|
const groupUsersTableColumns = [
|
|
15
15
|
{
|
|
16
16
|
id: 'username',
|
|
@@ -27,8 +27,7 @@ const groupUsersTableColumns = [
|
|
|
27
27
|
];
|
|
28
28
|
const GroupUsers = ({ group }) => {
|
|
29
29
|
const locale = useLocale();
|
|
30
|
-
const
|
|
31
|
-
const apiClient = useAPI(config.generalProperties.apiURL);
|
|
30
|
+
const apiClient = useAPIClient();
|
|
32
31
|
const queryClient = useQueryClient();
|
|
33
32
|
const { data: users } = useUsers(apiClient);
|
|
34
33
|
const { data: groupUsers } = useGroupUsers(group?.id, apiClient);
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { Group } from '../../types/groups';
|
|
2
3
|
import { GroupTab } from './GroupTabs';
|
|
3
4
|
interface GroupsProps {
|
|
4
5
|
apiUrl: string;
|
|
5
6
|
additionalTabs?: GroupTab[];
|
|
7
|
+
onGroupUpdate?: (newGroup: Group, oldGroup: Group) => void;
|
|
8
|
+
onGroupCreate?: (newGroup: Group) => void;
|
|
9
|
+
onGroupDelete?: (group: Group) => void;
|
|
10
|
+
editName?: boolean;
|
|
6
11
|
}
|
|
7
|
-
declare const Groups: ({ apiUrl, additionalTabs }: GroupsProps) => React.JSX.Element;
|
|
12
|
+
declare const Groups: ({ apiUrl, additionalTabs, onGroupUpdate, onGroupCreate, onGroupDelete, editName, }: GroupsProps) => React.JSX.Element;
|
|
8
13
|
export default Groups;
|
|
9
14
|
//# sourceMappingURL=Groups.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Groups.d.ts","sourceRoot":"","sources":["../../../src/components/groups/Groups.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Groups.d.ts","sourceRoot":"","sources":["../../../src/components/groups/Groups.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAWnD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAkB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIlD,UAAU,WAAW;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,QAAQ,EAAE,CAAC;IAE5B,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,KAAK,IAAI,CAAC;IAE3D,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,KAAK,IAAI,CAAC;IAE1C,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAEvC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,MAAM,uFAOT,WAAW,sBAgIb,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -12,7 +12,8 @@ import groupsTranslations from '../../lang/groups';
|
|
|
12
12
|
import { useDeleteGroup, useGroups } from '../../utils/hooks/groups';
|
|
13
13
|
import GroupTabs from './GroupTabs';
|
|
14
14
|
import { useQueryClient } from '@tanstack/react-query';
|
|
15
|
-
|
|
15
|
+
import { APIClientProvider } from '../../utils/hooks/useAPIClient';
|
|
16
|
+
const Groups = ({ apiUrl, additionalTabs = [], onGroupUpdate, onGroupCreate, onGroupDelete, editName, }) => {
|
|
16
17
|
const locale = useLocale();
|
|
17
18
|
const apiClient = useAPI(apiUrl);
|
|
18
19
|
const queryClient = useQueryClient();
|
|
@@ -30,49 +31,53 @@ const Groups = ({ apiUrl, additionalTabs = [] }) => {
|
|
|
30
31
|
setFilteredGroups(groups.filter((group) => group.name.includes(searchString)));
|
|
31
32
|
}
|
|
32
33
|
}, [searchString, groups, setFilteredGroups]);
|
|
33
|
-
const handleDelete = (
|
|
34
|
-
deleteGroup(id);
|
|
34
|
+
const handleDelete = (group) => {
|
|
35
|
+
deleteGroup(group.id);
|
|
36
|
+
if (typeof onGroupDelete === 'function') {
|
|
37
|
+
onGroupDelete(group);
|
|
38
|
+
}
|
|
35
39
|
setSelectedGroup(undefined);
|
|
36
40
|
};
|
|
37
|
-
return (React.createElement(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
!selectedGroup && (React.createElement(React.Fragment, null,
|
|
46
|
-
React.createElement(Grid, { container: true, spacing: 2, sx: { marginBottom: 2 } },
|
|
47
|
-
React.createElement(Grid, { item: true },
|
|
48
|
-
React.createElement(SearchField, { placeholder: groupsTranslations.search[locale], onSearch: (value) => setSearchString(value) })),
|
|
49
|
-
React.createElement(Grid, { item: true },
|
|
50
|
-
React.createElement(Button, { variant: 'contained', startIcon: React.createElement(GroupAddIcon, null), onClick: () => {
|
|
51
|
-
setOpenGroupDialog(true);
|
|
52
|
-
setSelectedGroup(undefined);
|
|
53
|
-
} }, groupsTranslations.new[locale]))),
|
|
54
|
-
React.createElement(GroupsTable, { groups: filteredGroups, selectedGroup: selectedGroup, setSelectedGroup: (group) => {
|
|
55
|
-
setSelectedGroup(group);
|
|
56
|
-
}, onDelete: handleDelete }))),
|
|
57
|
-
selectedGroup && (React.createElement(Box, { sx: {
|
|
58
|
-
display: 'flex',
|
|
59
|
-
flexDirection: 'column',
|
|
60
|
-
alignItems: 'flex-start',
|
|
61
|
-
width: '100%',
|
|
41
|
+
return (React.createElement(APIClientProvider, { baseURL: apiUrl },
|
|
42
|
+
React.createElement(Box, { sx: {
|
|
43
|
+
flexGrow: 1,
|
|
44
|
+
maxWidth: '100%',
|
|
45
|
+
overflowX: 'hidden',
|
|
46
|
+
paddingTop: 3,
|
|
47
|
+
paddingLeft: 3,
|
|
48
|
+
paddingRight: 3,
|
|
62
49
|
} },
|
|
63
|
-
React.createElement(
|
|
50
|
+
!selectedGroup && (React.createElement(React.Fragment, null,
|
|
51
|
+
React.createElement(Grid, { container: true, spacing: 2, sx: { marginBottom: 2 } },
|
|
52
|
+
React.createElement(Grid, { item: true },
|
|
53
|
+
React.createElement(SearchField, { placeholder: groupsTranslations.search[locale], onSearch: (value) => setSearchString(value) })),
|
|
54
|
+
React.createElement(Grid, { item: true },
|
|
55
|
+
React.createElement(Button, { variant: 'contained', startIcon: React.createElement(GroupAddIcon, null), onClick: () => {
|
|
56
|
+
setOpenGroupDialog(true);
|
|
57
|
+
setSelectedGroup(undefined);
|
|
58
|
+
} }, groupsTranslations.new[locale]))),
|
|
59
|
+
React.createElement(GroupsTable, { groups: filteredGroups, selectedGroup: selectedGroup, setSelectedGroup: (group) => {
|
|
60
|
+
setSelectedGroup(group);
|
|
61
|
+
}, onDelete: handleDelete }))),
|
|
62
|
+
selectedGroup && (React.createElement(Box, { sx: {
|
|
64
63
|
display: 'flex',
|
|
65
|
-
flexDirection: '
|
|
66
|
-
alignItems: '
|
|
64
|
+
flexDirection: 'column',
|
|
65
|
+
alignItems: 'flex-start',
|
|
66
|
+
width: '100%',
|
|
67
67
|
} },
|
|
68
|
-
React.createElement(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
React.createElement(Box, { sx: {
|
|
69
|
+
display: 'flex',
|
|
70
|
+
flexDirection: 'row',
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
} },
|
|
73
|
+
React.createElement(IconButton, { "aria-label": 'delete', color: 'primary', onClick: () => setSelectedGroup(undefined), sx: { mr: 2 } },
|
|
74
|
+
React.createElement(ArrowBackIcon, null)),
|
|
75
|
+
React.createElement(Link, { underline: 'none', href: '#', onClick: () => setSelectedGroup(undefined) }, groupsTranslations.title[locale]),
|
|
76
|
+
React.createElement(KeyboardArrowRightIcon, null),
|
|
77
|
+
selectedGroup.name),
|
|
78
|
+
React.createElement(GroupTabs, { group: selectedGroup, additionalTabs: additionalTabs, onGroupUpdate: onGroupUpdate, editName: editName }))),
|
|
79
|
+
React.createElement(CreateGroupDialog, { open: openGroupDialog, onClose: () => {
|
|
80
|
+
setOpenGroupDialog(false);
|
|
81
|
+
}, onGroupCreate: onGroupCreate }))));
|
|
77
82
|
};
|
|
78
83
|
export default Groups;
|
|
@@ -4,7 +4,7 @@ export interface TableProps {
|
|
|
4
4
|
groups?: Group[];
|
|
5
5
|
selectedGroup?: Group;
|
|
6
6
|
setSelectedGroup: (group: Group) => void;
|
|
7
|
-
onDelete: (
|
|
7
|
+
onDelete: (group: Group) => void;
|
|
8
8
|
}
|
|
9
9
|
declare const GroupsTable: ({ groups, selectedGroup, setSelectedGroup, onDelete, }: TableProps) => React.JSX.Element;
|
|
10
10
|
export default GroupsTable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupsTable.d.ts","sourceRoot":"","sources":["../../../src/components/groups/GroupsTable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAe1B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAW3C,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,aAAa,CAAC,EAAE,KAAK,CAAC;IACtB,gBAAgB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACzC,QAAQ,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"GroupsTable.d.ts","sourceRoot":"","sources":["../../../src/components/groups/GroupsTable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAe1B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAW3C,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,aAAa,CAAC,EAAE,KAAK,CAAC;IACtB,gBAAgB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACzC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,QAAA,MAAM,WAAW,2DAKd,UAAU,sBA8DZ,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -14,7 +14,7 @@ const GroupsTable = ({ groups = [], selectedGroup, setSelectedGroup, onDelete, }
|
|
|
14
14
|
const locale = useLocale();
|
|
15
15
|
const muiTheme = useTheme();
|
|
16
16
|
const [openConfirmationDialog, setOpenConfirmationDialog] = useState(false);
|
|
17
|
-
const [
|
|
17
|
+
const [deleteGroup, setDeleteGroup] = useState();
|
|
18
18
|
return (React.createElement(React.Fragment, null,
|
|
19
19
|
React.createElement(TableContainer, null,
|
|
20
20
|
React.createElement(Table, { size: 'small' },
|
|
@@ -35,9 +35,9 @@ const GroupsTable = ({ groups = [], selectedGroup, setSelectedGroup, onDelete, }
|
|
|
35
35
|
React.createElement(IconButton, { size: 'small', onClick: (evt) => {
|
|
36
36
|
evt.stopPropagation();
|
|
37
37
|
setOpenConfirmationDialog(true);
|
|
38
|
-
|
|
38
|
+
setDeleteGroup(group);
|
|
39
39
|
} },
|
|
40
40
|
React.createElement(DeleteIcon, null))))))))),
|
|
41
|
-
React.createElement(DeleteConfirmationDialog, { open: openConfirmationDialog, onClose: () => setOpenConfirmationDialog(false), onConfirm: () => (
|
|
41
|
+
React.createElement(DeleteConfirmationDialog, { open: openConfirmationDialog, onClose: () => setOpenConfirmationDialog(false), onConfirm: () => (deleteGroup ? onDelete(deleteGroup) : {}) })));
|
|
42
42
|
};
|
|
43
43
|
export default GroupsTable;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { User } from '../../types/users';
|
|
2
3
|
export interface CreateUserDialogProps {
|
|
3
4
|
open: boolean;
|
|
4
5
|
onClose: () => void;
|
|
6
|
+
onUserCreate?: (newUser: User) => void;
|
|
5
7
|
}
|
|
6
|
-
declare const CreateUserDialog: ({ open, onClose }: CreateUserDialogProps) => React.JSX.Element;
|
|
8
|
+
declare const CreateUserDialog: ({ open, onClose, onUserCreate, }: CreateUserDialogProps) => React.JSX.Element;
|
|
7
9
|
export default CreateUserDialog;
|
|
8
10
|
//# sourceMappingURL=CreateUserDialog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateUserDialog.d.ts","sourceRoot":"","sources":["../../../src/components/users/CreateUserDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"CreateUserDialog.d.ts","sourceRoot":"","sources":["../../../src/components/users/CreateUserDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,KAAK,IAAI,CAAC;CACxC;AAED,QAAA,MAAM,gBAAgB,qCAInB,qBAAqB,sBAuBvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useLocale } from '@deix/rossini-core';
|
|
3
3
|
import { Dialog, DialogContent, DialogTitle } from '@mui/material';
|
|
4
4
|
import { useQueryClient } from '@tanstack/react-query';
|
|
5
|
-
import { useConfig } from '../../config';
|
|
6
5
|
import { useAddUser } from '../../utils/hooks/users';
|
|
7
6
|
import UserForm from './UserForm';
|
|
8
7
|
import usersTranslations from '../../lang/users';
|
|
9
|
-
|
|
8
|
+
import { useAPIClient } from '../../utils/hooks/useAPIClient';
|
|
9
|
+
const CreateUserDialog = ({ open, onClose, onUserCreate, }) => {
|
|
10
10
|
const locale = useLocale();
|
|
11
|
-
const
|
|
12
|
-
const apiClient = useAPI(config.generalProperties.apiURL);
|
|
11
|
+
const apiClient = useAPIClient();
|
|
13
12
|
const queryClient = useQueryClient();
|
|
14
13
|
const { mutate: addUser } = useAddUser(queryClient, apiClient);
|
|
15
14
|
const handleSave = (userFormData) => {
|
|
16
15
|
addUser(userFormData);
|
|
16
|
+
if (typeof onUserCreate === 'function') {
|
|
17
|
+
onUserCreate(userFormData);
|
|
18
|
+
}
|
|
17
19
|
onClose();
|
|
18
20
|
};
|
|
19
21
|
return (React.createElement(Dialog, { open: open, fullWidth: true, maxWidth: 'sm', onClose: onClose },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserCredentials.d.ts","sourceRoot":"","sources":["../../../src/components/users/UserCredentials.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAOzC,UAAU,oBAAoB;IAC5B,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,QAAA,MAAM,eAAe,aAAc,oBAAoB,
|
|
1
|
+
{"version":3,"file":"UserCredentials.d.ts","sourceRoot":"","sources":["../../../src/components/users/UserCredentials.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAOzC,UAAU,oBAAoB;IAC5B,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,QAAA,MAAM,eAAe,aAAc,oBAAoB,sBAkBtD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useLocale } from '@deix/rossini-core';
|
|
3
3
|
import { Box, Button } from '@mui/material';
|
|
4
4
|
import usersTranslations from '../../lang/users';
|
|
5
5
|
import { useSendUpdatePasswordEmail } from '../../utils/hooks/users';
|
|
6
|
-
import { useConfig } from '../../config';
|
|
7
6
|
import { useQueryClient } from '@tanstack/react-query';
|
|
7
|
+
import { useAPIClient } from '../../utils/hooks/useAPIClient';
|
|
8
8
|
const UserCredentials = ({ user }) => {
|
|
9
9
|
const locale = useLocale();
|
|
10
|
-
const
|
|
11
|
-
const apiClient = useAPI(config.generalProperties.apiURL);
|
|
10
|
+
const apiClient = useAPIClient();
|
|
12
11
|
const queryClient = useQueryClient();
|
|
13
12
|
const { mutate: sendResetPasswordEmail } = useSendUpdatePasswordEmail(queryClient, apiClient);
|
|
14
13
|
return (React.createElement(Box, { sx: { mt: 2 } },
|
|
@@ -2,7 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import { User } from '../../types/users';
|
|
3
3
|
export interface UserDetailsProps {
|
|
4
4
|
user: User;
|
|
5
|
+
onUserUpdate?: (newUser: User, oldUser: User) => void;
|
|
6
|
+
editUsername?: boolean;
|
|
5
7
|
}
|
|
6
|
-
declare const UserDetails: ({ user }: UserDetailsProps) => React.JSX.Element;
|
|
8
|
+
declare const UserDetails: ({ user, onUserUpdate, editUsername, }: UserDetailsProps) => React.JSX.Element;
|
|
7
9
|
export default UserDetails;
|
|
8
10
|
//# sourceMappingURL=UserDetails.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserDetails.d.ts","sourceRoot":"","sources":["../../../src/components/users/UserDetails.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"UserDetails.d.ts","sourceRoot":"","sources":["../../../src/components/users/UserDetails.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAKzC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,IAAI,CAAC;IACX,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,KAAK,IAAI,CAAC;IACtD,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,QAAA,MAAM,WAAW,0CAId,gBAAgB,sBA0BlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { useAPI } from '@deix/rossini-core';
|
|
3
2
|
import { useQueryClient } from '@tanstack/react-query';
|
|
4
|
-
import { useConfig } from '../../config';
|
|
5
3
|
import { useUpdateUser } from '../../utils/hooks/users';
|
|
6
4
|
import UserForm from './UserForm';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const apiClient =
|
|
5
|
+
import { useAPIClient } from '../../utils/hooks/useAPIClient';
|
|
6
|
+
const UserDetails = ({ user, onUserUpdate, editUsername, }) => {
|
|
7
|
+
const apiClient = useAPIClient();
|
|
10
8
|
const queryClient = useQueryClient();
|
|
11
9
|
const { mutate: updateUser } = useUpdateUser(queryClient, apiClient);
|
|
12
|
-
const handleUpdate = (
|
|
10
|
+
const handleUpdate = (updatedUser) => {
|
|
11
|
+
// We need to remove sendEmailOnCreation or keycloak will complain
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
|
+
const { sendEmailOnCreation, ...user } = updatedUser;
|
|
13
14
|
updateUser(user);
|
|
15
|
+
if (typeof onUserUpdate === 'function') {
|
|
16
|
+
onUserUpdate(updatedUser, user);
|
|
17
|
+
}
|
|
14
18
|
};
|
|
15
19
|
return (React.createElement(React.Fragment, null,
|
|
16
|
-
React.createElement(UserForm, { mode: 'modify', user: user, onSave: handleUpdate, onCancel: () => { } })));
|
|
20
|
+
React.createElement(UserForm, { mode: 'modify', user: user, onSave: handleUpdate, onCancel: () => { }, editUsername: editUsername })));
|
|
17
21
|
};
|
|
18
22
|
export default UserDetails;
|
|
@@ -8,7 +8,8 @@ export interface UserFormProps {
|
|
|
8
8
|
onCancel?: () => void;
|
|
9
9
|
user?: User;
|
|
10
10
|
mode?: 'create' | 'modify';
|
|
11
|
+
editUsername?: boolean;
|
|
11
12
|
}
|
|
12
|
-
declare const UserForm: ({ user, onSave, onCancel, mode, }: UserFormProps) => React.JSX.Element;
|
|
13
|
+
declare const UserForm: ({ user, onSave, onCancel, mode, editUsername, }: UserFormProps) => React.JSX.Element;
|
|
13
14
|
export default UserForm;
|
|
14
15
|
//# sourceMappingURL=UserForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserForm.d.ts","sourceRoot":"","sources":["../../../src/components/users/UserForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAc1B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,MAAM,WAAW,cAAe,SAAQ,IAAI;IAC1C,mBAAmB,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IACvC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"UserForm.d.ts","sourceRoot":"","sources":["../../../src/components/users/UserForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAc1B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,MAAM,WAAW,cAAe,SAAQ,IAAI;IAC1C,mBAAmB,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IACvC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC3B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,QAAA,MAAM,QAAQ,oDAMX,aAAa,sBA0Kf,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -4,11 +4,11 @@ import { Button, FormControlLabel, Grid, Switch, TextField, } from '@mui/materia
|
|
|
4
4
|
import { Controller, useForm } from 'react-hook-form';
|
|
5
5
|
import { useEffect } from 'react';
|
|
6
6
|
import usersTranslations from '../../lang/users';
|
|
7
|
-
const UserForm = ({ user, onSave, onCancel, mode = 'create', }) => {
|
|
7
|
+
const UserForm = ({ user, onSave, onCancel, mode = 'create', editUsername, }) => {
|
|
8
8
|
const locale = useLocale();
|
|
9
|
-
const { control, handleSubmit, setValue } = useForm({
|
|
9
|
+
const { control, formState: { errors }, handleSubmit, setValue, } = useForm({
|
|
10
10
|
defaultValues: {
|
|
11
|
-
id: user?.id
|
|
11
|
+
id: user?.id,
|
|
12
12
|
username: user?.username || '',
|
|
13
13
|
firstName: user?.firstName || '',
|
|
14
14
|
lastName: user?.lastName || '',
|
|
@@ -38,13 +38,15 @@ const UserForm = ({ user, onSave, onCancel, mode = 'create', }) => {
|
|
|
38
38
|
return (React.createElement("form", { onSubmit: (event) => void handleSubmit(onSubmit)(event) },
|
|
39
39
|
React.createElement(Grid, { container: true, spacing: 2, sx: { mt: 2, maxWidth: 'sm' }, justifyContent: 'stretch' },
|
|
40
40
|
React.createElement(Grid, { item: true, xs: 12 },
|
|
41
|
-
React.createElement(Controller, { name: 'username', control: control, render: ({ field }) => (React.createElement(TextField, { size: 'small', fullWidth: true, label: usersTranslations.username[locale], disabled: mode === 'modify', sx: { flexShrink: 0 }, ...field })) })),
|
|
41
|
+
React.createElement(Controller, { name: 'username', control: control, render: ({ field }) => (React.createElement(TextField, { size: 'small', fullWidth: true, label: usersTranslations.username[locale], disabled: mode === 'modify' && !editUsername, sx: { flexShrink: 0 }, ...field })) })),
|
|
42
42
|
React.createElement(Grid, { item: true, xs: 12 },
|
|
43
43
|
React.createElement(Controller, { name: 'firstName', control: control, render: ({ field }) => (React.createElement(TextField, { size: 'small', fullWidth: true, label: usersTranslations.firstName[locale], sx: { flexShrink: 0 }, ...field })) })),
|
|
44
44
|
React.createElement(Grid, { item: true, xs: 12 },
|
|
45
45
|
React.createElement(Controller, { name: 'lastName', control: control, render: ({ field }) => (React.createElement(TextField, { size: 'small', fullWidth: true, label: usersTranslations.lastName[locale], sx: { flexShrink: 0 }, ...field })) })),
|
|
46
46
|
React.createElement(Grid, { item: true, xs: 12 },
|
|
47
|
-
React.createElement(Controller, { name: 'email', control: control, render: ({ field }) => (React.createElement(TextField, { size: 'small', fullWidth: true,
|
|
47
|
+
React.createElement(Controller, { name: 'email', control: control, rules: { required: true }, render: ({ field }) => (React.createElement(TextField, { size: 'small', fullWidth: true, error: !!errors.email, helperText: errors.email
|
|
48
|
+
? usersTranslations.requiredField[locale]
|
|
49
|
+
: undefined, label: usersTranslations.email[locale], sx: { flexShrink: 0 }, ...field })) })),
|
|
48
50
|
React.createElement(Grid, { item: true, xs: 12 },
|
|
49
51
|
React.createElement(Controller, { name: 'enabled', control: control, render: ({ field }) => (React.createElement(FormControlLabel, { sx: { ml: 1 }, control: React.createElement(Switch, { checked: field.value, size: 'small', ...field }), label: usersTranslations.enabled[locale] })) })),
|
|
50
52
|
mode === 'create' && (React.createElement(Grid, { item: true, xs: 12 },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserGroups.d.ts","sourceRoot":"","sources":["../../../src/components/users/UserGroups.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAe1B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAsBzC,UAAU,eAAe;IACvB,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,QAAA,MAAM,UAAU,aAAc,eAAe,
|
|
1
|
+
{"version":3,"file":"UserGroups.d.ts","sourceRoot":"","sources":["../../../src/components/users/UserGroups.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAe1B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAsBzC,UAAU,eAAe;IACvB,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,QAAA,MAAM,UAAU,aAAc,eAAe,sBA4F5C,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -2,8 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Box, Button, IconButton, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, } from '@mui/material';
|
|
3
3
|
import AddIcon from '@mui/icons-material/Add';
|
|
4
4
|
import DeleteIcon from '@mui/icons-material/Delete';
|
|
5
|
-
import { isStringTranslation,
|
|
6
|
-
import { useConfig } from '../../config';
|
|
5
|
+
import { isStringTranslation, useLocale } from '@deix/rossini-core';
|
|
7
6
|
import { useAddUserToGroup, useRemoveUserFromGroup, useUserGroups, } from '../../utils/hooks/users';
|
|
8
7
|
import { useState } from 'react';
|
|
9
8
|
import DeleteConfirmationDialog from '../DeleteConfirmationDialog';
|
|
@@ -11,6 +10,7 @@ import { useQueryClient } from '@tanstack/react-query';
|
|
|
11
10
|
import usersTranslations from '../../lang/users';
|
|
12
11
|
import AddItemDialog from '../AddItemDialog';
|
|
13
12
|
import { useGroups } from '../../utils/hooks/groups';
|
|
13
|
+
import { useAPIClient } from '../../utils/hooks/useAPIClient';
|
|
14
14
|
const userGroupsTableColumns = [
|
|
15
15
|
{
|
|
16
16
|
id: 'name',
|
|
@@ -19,8 +19,7 @@ const userGroupsTableColumns = [
|
|
|
19
19
|
];
|
|
20
20
|
const UserGroups = ({ user }) => {
|
|
21
21
|
const locale = useLocale();
|
|
22
|
-
const
|
|
23
|
-
const apiClient = useAPI(config.generalProperties.apiURL);
|
|
22
|
+
const apiClient = useAPIClient();
|
|
24
23
|
const queryClient = useQueryClient();
|
|
25
24
|
const { data: groups } = useGroups(apiClient);
|
|
26
25
|
const { data: userGroups } = useUserGroups(user?.id, apiClient);
|