diff --git a/src/components/modals/add-user-modal/AddUserModal.tsx b/src/components/modals/add-user-modal/AddUserModal.tsx index c724720b..15c58b37 100644 --- a/src/components/modals/add-user-modal/AddUserModal.tsx +++ b/src/components/modals/add-user-modal/AddUserModal.tsx @@ -1,5 +1,5 @@ -import { Button, Col, Divider, Form, Input, Modal, notification, Row, Select, Switch } from 'antd'; -import { MouseEvent, useCallback, useEffect, useMemo, useState } from 'react'; +import { Button, Col, Divider, Form, Input, Modal, notification, Row, Switch } from 'antd'; +import { MouseEvent, useCallback, useEffect, useState } from 'react'; import { useStore } from '@/store/store'; import '../CustomModal.scss'; import { extractErrorMsg } from '@/utils/ServiceUtils'; @@ -24,12 +24,6 @@ export default function AddUserModal({ isOpen, onCreateUser, onCancel }: AddUser const isAdminVal = Form.useWatch('isadmin', form); const passwordVal = Form.useWatch('password', form); - const userGroups = useMemo(() => { - const groups = new Set(); - users.forEach((u) => u.groups?.forEach((g) => groups.add(g))); - return Array.from(groups); - }, [users]); - const resetModal = () => { form.resetFields(); }; @@ -88,7 +82,7 @@ export default function AddUserModal({ isOpen, onCreateUser, onCancel }: AddUser >
-
+ @@ -119,6 +113,7 @@ export default function AddUserModal({ isOpen, onCreateUser, onCancel }: AddUser { if (newVal) { form.setFieldValue('networks', []); @@ -127,59 +122,6 @@ export default function AddUserModal({ isOpen, onCreateUser, onCancel }: AddUser /> - {isServerEE && ( - - - - - ({ label: n.netid, value: n.netid }))} - /> - - - - - - - - diff --git a/src/pages/users/UsersPage.tsx b/src/pages/users/UsersPage.tsx index a681c30d..8799b4bf 100644 --- a/src/pages/users/UsersPage.tsx +++ b/src/pages/users/UsersPage.tsx @@ -12,7 +12,6 @@ import { notification, Row, Skeleton, - Switch, Table, TableColumnsType, Tabs, @@ -45,8 +44,6 @@ export default function UsersPage(props: PageProps) { const [userGroups, setUserGroups] = useState([]); const [isLoading, setIsLoading] = useState(true); const [usersSearch, setUsersSearch] = useState(''); - const [networksSearch, setNetworksSearch] = useState(''); - const [groupSearch, setGroupSearch] = useState(''); const [isAddGroupModalOpen, setIsAddGroupModalOpen] = useState(false); const [selectedGroup, setSelectedGroup] = useState(null); const [isUpdateGroupModalOpen, setIsUpdateGroupModalOpen] = useState(false); @@ -105,39 +102,11 @@ export default function UsersPage(props: PageProps) { [notify] ); - const confirmDeleteGroup = useCallback( - async (group: UserGroup) => { - Modal.confirm({ - title: 'Delete user group', - content: `Are you sure you want to delete group ${group}?`, - onOk: async () => { - try { - await UsersService.deleteUserGroup(group); - notify.success({ message: `User group ${group} deleted` }); - loadUsers(); - loadUserGroups(); - } catch (err) { - notify.error({ - message: 'Failed to delete user group', - description: extractErrorMsg(err as any), - }); - } - }, - }); - }, - [loadUserGroups, loadUsers, notify] - ); - const onEditUser = useCallback((user: User) => { setSelectedUser(user); setIsUpdateUserModalOpen(true); }, []); - const onEditGroup = useCallback((group: UserGroup) => { - setSelectedGroup(group); - setIsUpdateGroupModalOpen(true); - }, []); - const onAddUser = useCallback(() => { if (isSaasBuild) { window.location = getAmuiUrl('invite-user') as any; @@ -159,25 +128,10 @@ export default function UsersPage(props: PageProps) { }, { title: 'Role', - width: '10rem', render(_, user) { return {user.isadmin ? 'Admin' : 'User'}; }, }, - { - title: 'Networks', - render(_, user) { - return {user.isadmin ? 'n/a' : user.networks?.join(', ')}; - }, - }, - isServerEE - ? { - title: 'Groups', - render(_, user) { - return {user.groups?.join(', ')}; - }, - } - : {}, { width: '1rem', render(_, user) { @@ -222,166 +176,15 @@ export default function UsersPage(props: PageProps) { }, }, ], - [confirmDeleteUser, isServerEE, onEditUser, store.username] - ); - - const networksTableColumns: TableColumnsType = useMemo( - () => [ - { - title: 'Network', - dataIndex: 'netid', - render(_, network) { - return ( - { - setSelectedNetwork(network); - setIsNetworkPermissionsModalOpen(true); - }} - > - {network.netid} - - ); - }, - sorter(a, b) { - return a.netid.localeCompare(b.netid); - }, - defaultSortOrder: 'ascend', - }, - { - title: 'Default Access Level', - render(_, network) { - switch (network.prosettings?.defaultaccesslevel) { - case 0: - return 0 - Network Admin; - case 1: - return 1 - Host Access; - case 2: - return 2 - Client Access; - case 3: - return 3 - No Access; - } - }, - sorter(a, b) { - return (a.prosettings?.defaultaccesslevel ?? 0) - (b.prosettings?.defaultaccesslevel ?? 0); - }, - }, - { - title: 'Allowed Groups', - render(_, network) { - return network.prosettings?.allowedgroups.length; - }, - sorter(a, b) { - return (a.prosettings?.allowedgroups.length ?? 0) - (b.prosettings?.allowedgroups.length ?? 0); - }, - }, - { - title: 'Allowed Users', - render(_, network) { - return network.prosettings?.allowedusers.length; - }, - sorter(a, b) { - return (a.prosettings?.allowedusers.length ?? 0) - (b.prosettings?.allowedusers.length ?? 0); - }, - }, - ], - [] - ); - - const groupTableCols: TableColumnsType<{ name: UserGroup }> = useMemo( - () => [ - { - title: 'Name', - render(_, group) { - return {group.name}; - }, - sorter(a, b) { - return a.name.localeCompare(b.name); - }, - defaultSortOrder: 'ascend', - }, - { - title: 'Users', - render(_, group) { - let usersCount = 0; - users.forEach((u) => { - if (u.groups?.includes(group.name)) { - usersCount++; - } - }); - return {usersCount}; - }, - }, - { - width: '1rem', - render(_, group) { - return ( - { - ev.domEvent.stopPropagation(); - onEditGroup(group.name); - }, - }, - { - key: 'delete', - label: ( - { - ev.stopPropagation(); - confirmDeleteGroup(group.name); - }} - > - Delete - - ), - }, - ] as MenuProps['items'], - }} - > -