Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

User Management UI #511

Merged
merged 60 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
b371ae1
Start setup on user management feature
Apr 11, 2022
e2dc6e6
User form
Apr 12, 2022
1913522
Add set-up for some actions and profile page with form
Apr 14, 2022
c885721
Work on new user
Apr 15, 2022
533ecf1
Update row
Apr 15, 2022
04a1a2e
Clean-up navbar
Apr 15, 2022
037c892
Set active classnames in nav links
Apr 15, 2022
eb9caa4
Add privileges
Apr 15, 2022
c8913a2
Cancel functionality on new user form
Apr 15, 2022
abd4c58
User slice
Apr 23, 2022
f8a7d7d
Delete user modal
Apr 23, 2022
b04cad5
Breadcrumbs and delete user modal as menuitem
Apr 24, 2022
271e21b
User POST in slice
Apr 24, 2022
f6697b1
Update slice
Apr 25, 2022
843f7fb
Create through slice
Apr 25, 2022
058dcd2
Set-up for future api work
Apr 27, 2022
0d16ed1
Merge commit
Apr 29, 2022
e19867e
Start get
Apr 29, 2022
e06a03c
Create and Delete set-up
Apr 29, 2022
fc0f8cd
Delete user validation
May 3, 2022
fe019ef
Amend
May 3, 2022
fafaae1
Merge branch 'main' into user-management
May 3, 2022
4256fed
User search
May 3, 2022
e1aa443
Edit tweaks
May 4, 2022
ae4a365
Merge branch 'main' into user-management
May 4, 2022
f62e286
User privileges
May 5, 2022
2cf9d3f
Ui tweaks
May 5, 2022
b2ac302
Permissions
May 6, 2022
14a24d4
Merge branch 'main' into user-management
May 6, 2022
4dcda8c
Add additional user info to table
May 6, 2022
90b4f36
Checkboxes
May 6, 2022
74cec89
Some small form fixes
May 6, 2022
8ce4ed8
Refreshes and checkboxes on load
May 6, 2022
7260bc9
Default values
May 10, 2022
266038b
Merge branch 'main' into user-management
May 10, 2022
7efd4a2
Split out edit and new forms for easier flow and initial value in for…
May 10, 2022
0483358
Type checking
May 11, 2022
b0665a5
Some file cleanup
May 11, 2022
7fd6a8a
Pagination;
May 11, 2022
c14dcce
Some style tweaks
May 11, 2022
ec15cfd
Change checkbox color
May 11, 2022
498fabc
Merge branch 'main' into user-management
May 11, 2022
e71f02a
Merge branch 'main' into user-management
May 11, 2022
3eb706d
Checkboxes
May 12, 2022
38de125
Cleanup
May 12, 2022
fc3663d
Remove unused effect
May 12, 2022
32b5ad7
Merge branch 'main' into user-management
May 13, 2022
f0a9d8f
Update session with user info and fix client console warning for cont…
May 13, 2022
c9dae35
Update session in pages
May 13, 2022
29a2f76
Some form cleanup
May 13, 2022
828ca39
Clean index page
May 13, 2022
dd434ae
Edit user permissions checks
May 13, 2022
902cfa2
Feedback
May 16, 2022
e3b2cab
Merge branch 'main' into user-management
LKCSmith May 16, 2022
6481300
Remove duplicate
May 16, 2022
9e8904d
Fix checkbox bug
May 16, 2022
466ee12
Password update
May 17, 2022
39eb499
Add error handling on new user form
May 17, 2022
eec5934
Change password modal
May 17, 2022
06c0377
Remove rogue console
May 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ __pypackages__/

# Environments
.venv
.env.local
env/
venv/
ENV/
Expand Down
8 changes: 6 additions & 2 deletions clients/admin-ui/src/app/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ import {
privacyRequestApi,
reducer as privacyRequestsReducer,
} from '../features/privacy-requests';
import { reducer as userReducer } from '../features/user';
import { reducer as userReducer, userApi } from '../features/user';

const makeStore = () => {
const store = configureStore({
reducer: {
[privacyRequestApi.reducerPath]: privacyRequestApi.reducer,
subjectRequests: privacyRequestsReducer,
[userApi.reducerPath]: userApi.reducer,
user: userReducer,
},
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware().concat(privacyRequestApi.middleware),
getDefaultMiddleware().concat(
privacyRequestApi.middleware,
userApi.middleware
),
devTools: true,
});
setupListeners(store.dispatch);
Expand Down
5 changes: 3 additions & 2 deletions clients/admin-ui/src/features/common/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ const Header: React.FC<HeaderProps> = ({ username }) => (
<MenuList shadow="xl">
<Stack px={3} py={2} spacing={0}>
<Text fontWeight="medium">{username}</Text>
<Text fontSize="sm" color="gray.600">
{/* This text should only show if actually an admin */}
{/* <Text fontSize="sm" color="gray.600">
Administrator
</Text>
</Text> */}
</Stack>
<MenuDivider />
<MenuItem
Expand Down
54 changes: 54 additions & 0 deletions clients/admin-ui/src/features/common/NavBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from 'react';
import {Flex, Button } from '@fidesui/react';
import { useSession } from "next-auth/react"
import NextLink from 'next/link'
import { useRouter } from "next/router";

import { ArrowDownLineIcon } from '../../features/common/Icon';

import Header from './Header';

const NavBar = () => {
const { data: session } = useSession();
const router = useRouter();
const username: string | any = session?.username

return (
<>
<Header username={username} />
<Flex
borderBottom="1px"
borderTop="1px"
px={9}
py={1}
borderColor="gray.100"
>
<NextLink href="/" passHref>
<Button as="a" variant="ghost" mr={4} colorScheme={router.pathname === "/" ? "complimentary" : "ghost"}>
Subject Requests
</Button>
</NextLink>

<NextLink href="#" passHref>
<Button as="a" variant="ghost" disabled mr={4}>
Datastore Connections
</Button>
</NextLink>

<NextLink href="/user-management" passHref>
<Button as="a" variant="ghost" mr={4} colorScheme={router.pathname.startsWith("/user-management") ? "complimentary" : "ghost"}>
User Management
</Button>
</NextLink>

<NextLink href="#" passHref>
<Button as="a" variant="ghost" disabled rightIcon={<ArrowDownLineIcon />}>
More
</Button>
</NextLink>
</Flex>
</>
)
}

export default NavBar;
118 changes: 118 additions & 0 deletions clients/admin-ui/src/features/user-management/DeleteUserModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import React, { useState } from 'react';
import {
Button,
FormControl,
Input,
MenuItem,
Modal,
ModalBody,
ModalCloseButton,
ModalContent,
ModalFooter,
ModalHeader,
ModalOverlay,
Stack,
Text,
useDisclosure,
} from '@fidesui/react';

import { User } from '../user/types';
import { useDeleteUserMutation } from '../user/user.slice';

function DeleteUserModal(user: User) {
const [usernameValue, setUsernameValue] = useState('');
const [confirmValue, setConfirmValue] = useState('');
const { isOpen, onOpen, onClose } = useDisclosure();
const [deleteUser, deleteUserResult] = useDeleteUserMutation();

const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
if (event.target.name === 'username') {
setUsernameValue(event.target.value);
} else {
setConfirmValue(event.target.value);
}
};

const deletionValidation =
user.id &&
confirmValue &&
usernameValue &&
user.username === usernameValue &&
user.username === confirmValue
? true
: false;

const handleDeleteUser = () => {
if (deletionValidation && user.id) {
deleteUser(user.id);
onClose();
}
};

return (
<>
<MenuItem
_focus={{ color: 'complimentary.500', bg: 'gray.100' }}
onClick={onOpen}
>
<Text fontSize="sm">Delete</Text>
</MenuItem>
<Modal isOpen={isOpen} onClose={onClose}>
<ModalOverlay />
<ModalContent>
<ModalHeader>Delete User</ModalHeader>
<ModalCloseButton />
<ModalBody pb={6}>
<Stack direction={'column'} spacing="15px">
<FormControl>
<Input
isRequired
name="username"
onChange={handleChange}
placeholder="Enter username"
value={usernameValue}
/>
</FormControl>
<FormControl>
<Input
isRequired
name="confirmUsername"
onChange={handleChange}
placeholder="Confirm username"
value={confirmValue}
/>
</FormControl>
</Stack>
</ModalBody>

<ModalFooter>
<Button
onClick={onClose}
marginRight={'10px'}
size={'sm'}
variant={'solid'}
bg="white"
width={'50%'}
>
Cancel
</Button>
<Button
disabled={!deletionValidation}
onClick={handleDeleteUser}
mr={3}
size={'sm'}
variant="solid"
bg="primary.800"
color="white"
width={'50%'}
>
Delete User
</Button>
</ModalFooter>
</ModalContent>
</Modal>
</>
);
}

export default DeleteUserModal;
Loading