import { useEffect, useState } from "react";
import Sidebar from "@/components/SettingsSidebar";
import { isMobile } from "react-device-detect";
import * as Skeleton from "react-loading-skeleton";
import "react-loading-skeleton/dist/skeleton.css";
import { UserPlus } from "@phosphor-icons/react";
import Admin from "@/models/admin";
import UserRow from "./UserRow";
import useUser from "@/hooks/useUser";
import NewUserModal from "./NewUserModal";
import { useModal } from "@/hooks/useModal";
import ModalWrapper from "@/components/ModalWrapper";
import CTAButton from "@/components/lib/CTAButton";
export default function AdminUsers() {
const { isOpen, openModal, closeModal } = useModal();
return (
These are all the accounts which have an account on this instance.
Removing an account will instantly remove their access to this
instance.
Add user
);
}
function UsersContainer() {
const { user: currUser } = useUser();
const [loading, setLoading] = useState(true);
const [users, setUsers] = useState([]);
useEffect(() => {
async function fetchUsers() {
const _users = await Admin.users();
setUsers(_users);
setLoading(false);
}
fetchUsers();
}, []);
if (loading) {
return (
);
}
return (
|
Username
|
Role
|
Date Added
|
{" "}
|
{users.map((user) => (
))}
);
}
const ROLE_HINT = {
default: [
"Can only send chats with workspaces they are added to by admin or managers.",
"Cannot modify any settings at all.",
],
manager: [
"Can view, create, and delete any workspaces and modify workspace-specific settings.",
"Can create, update and invite new users to the instance.",
"Cannot modify LLM, vectorDB, embedding, or other connections.",
],
admin: [
"Highest user level privilege.",
"Can see and do everything across the system.",
],
};
export function RoleHintDisplay({ role }) {
return (
Permissions
{ROLE_HINT[role ?? "default"].map((hints, i) => {
return (
-
{hints}
);
})}
);
}
export function MessageLimitInput({ enabled, limit, updateState, role }) {
if (role === "admin") return null;
return (
Restrict this user to a number of successful queries or chats within a
24 hour window.
{enabled && (
)}
);
}