From bc59ffbf37c7bcf828d3bbb7f27eec41d38e02e8 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 20 Feb 2022 19:10:58 -0500 Subject: [PATCH] Initial concept at a user table listing using Tailwind JIT & Headless UI --- package.json | 1 + .../admin/users/UsersContainerV2.tsx | 104 ++++++++++++++++++ resources/scripts/routers/AdminRouter.tsx | 4 +- yarn.lock | 11 ++ 4 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 resources/scripts/components/admin/users/UsersContainerV2.tsx diff --git a/package.json b/package.json index ea937ca0e..ef66f6e0a 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "@fortawesome/free-regular-svg-icons": "^5.15.4", "@fortawesome/free-solid-svg-icons": "^5.15.4", "@fortawesome/react-fontawesome": "^0.1.16", + "@headlessui/react": "^1.5.0", "@heroicons/react": "^1.0.5", "@hot-loader/react-dom": "^16.14.0", "axios": "^0.21.4", diff --git a/resources/scripts/components/admin/users/UsersContainerV2.tsx b/resources/scripts/components/admin/users/UsersContainerV2.tsx new file mode 100644 index 000000000..91d0fe5d0 --- /dev/null +++ b/resources/scripts/components/admin/users/UsersContainerV2.tsx @@ -0,0 +1,104 @@ +import React, { useEffect, useState } from 'react'; +import http from '@/api/http'; +import { User } from '@/api/admin/user'; +import { AdminTransformers } from '@/api/admin/transformers'; +import { Menu } from '@headlessui/react'; +import { ChevronDownIcon, LockClosedIcon } from '@heroicons/react/solid'; + +const UsersContainerV2 = () => { + const [ users, setUsers ] = useState([]); + useEffect(() => { + document.title = 'Admin | Users'; + }, []); + + useEffect(() => { + http.get('/api/application/users') + .then(({ data }) => { + setUsers(data.data.map(AdminTransformers.toUser)); + }) + .catch(console.error); + }, []); + + return ( +
+ + + + + + + + {users.map(user => ( + + + + + + ))} + +
+ Email +
+
+ +
+
+
+
+ {'User +
+
+

+ {user.email} +

+

+ {user.uuid} +

+
+
+
+ + + Options + + + +
+ + {() => ( + + + Reset Password + + )} + + + {() => ( + Delete + )} + + + + Resend Invite + + +
+
+
+
+
+ ); +}; + +export default UsersContainerV2; diff --git a/resources/scripts/routers/AdminRouter.tsx b/resources/scripts/routers/AdminRouter.tsx index 0adc0f1a2..d006c0551 100644 --- a/resources/scripts/routers/AdminRouter.tsx +++ b/resources/scripts/routers/AdminRouter.tsx @@ -15,7 +15,6 @@ import LocationEditContainer from '@/components/admin/locations/LocationEditCont import ServersContainer from '@/components/admin/servers/ServersContainer'; import NewServerContainer from '@/components/admin/servers/NewServerContainer'; import ServerRouter from '@/components/admin/servers/ServerRouter'; -import UsersContainer from '@/components/admin/users/UsersContainer'; import NewUserContainer from '@/components/admin/users/NewUserContainer'; import UserRouter from '@/components/admin/users/UserRouter'; import RolesContainer from '@/components/admin/roles/RolesContainer'; @@ -46,6 +45,7 @@ import { import CollapsedIcon from '@/assets/images/pterodactyl.svg'; import Sidebar from '@/components/admin/Sidebar'; import useUserPersistedState from '@/plugins/useUserPersistedState'; +import UsersContainerV2 from '@/components/admin/users/UsersContainerV2'; const AdminRouter = ({ location, match }: RouteComponentProps) => { const email = useStoreState((state: State) => state.user.data!.email); @@ -132,7 +132,7 @@ const AdminRouter = ({ location, match }: RouteComponentProps) => { - + diff --git a/yarn.lock b/yarn.lock index 3445720e6..c5b13323a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2474,6 +2474,16 @@ __metadata: languageName: node linkType: hard +"@headlessui/react@npm:^1.5.0": + version: 1.5.0 + resolution: "@headlessui/react@npm:1.5.0" + peerDependencies: + react: ^16 || ^17 || ^18 + react-dom: ^16 || ^17 || ^18 + checksum: e3373dfb73936950d659a87718fb9fdedc599b344b30cb0d8b1ef0a2ec13d6f405c653fa51284236788658840ece82c6a8538a5a5931e595274e9590b2020079 + languageName: node + linkType: hard + "@heroicons/react@npm:^1.0.5": version: 1.0.5 resolution: "@heroicons/react@npm:1.0.5" @@ -10933,6 +10943,7 @@ fsevents@^1.2.7: "@fortawesome/free-regular-svg-icons": ^5.15.4 "@fortawesome/free-solid-svg-icons": ^5.15.4 "@fortawesome/react-fontawesome": ^0.1.16 + "@headlessui/react": ^1.5.0 "@heroicons/react": ^1.0.5 "@hot-loader/react-dom": ^16.14.0 "@tailwindcss/forms": ^0.4.0