From 0a24dbc52cecdd9fa4bbbd8f660bd01b0a7253ae Mon Sep 17 00:00:00 2001 From: pablonyx Date: Thu, 27 Feb 2025 15:34:20 -0800 Subject: [PATCH] k# Please enter the commit message for your changes. Lines starting (#4144) --- web/src/app/admin/users/page.tsx | 42 +++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/web/src/app/admin/users/page.tsx b/web/src/app/admin/users/page.tsx index 5a0d3009f121..78d7933e56d4 100644 --- a/web/src/app/admin/users/page.tsx +++ b/web/src/app/admin/users/page.tsx @@ -19,6 +19,8 @@ import BulkAdd from "@/components/admin/users/BulkAdd"; import Text from "@/components/ui/text"; import { InvitedUserSnapshot } from "@/lib/types"; import { SearchBar } from "@/components/search/SearchBar"; +import { ConfirmEntityModal } from "@/components/modals/ConfirmEntityModal"; +import { NEXT_PUBLIC_CLOUD_ENABLED } from "@/lib/constants"; const UsersTables = ({ q, @@ -130,6 +132,13 @@ const AddUserButton = ({ setPopup: (spec: PopupSpec) => void; }) => { const [modal, setModal] = useState(false); + const [showConfirmation, setShowConfirmation] = useState(false); + + const { data: invitedUsers } = useSWR( + "/api/manage/users/invited", + errorHandlingFetcher + ); + const onSuccess = () => { mutate( (key) => typeof key === "string" && key.startsWith("/api/manage/users") @@ -140,6 +149,7 @@ const AddUserButton = ({ type: "success", }); }; + const onFailure = async (res: Response) => { const error = (await res.json()).detail; setPopup({ @@ -147,15 +157,45 @@ const AddUserButton = ({ type: "error", }); }; + + const handleInviteClick = () => { + if ( + !NEXT_PUBLIC_CLOUD_ENABLED && + invitedUsers && + invitedUsers.length === 0 + ) { + setShowConfirmation(true); + } else { + setModal(true); + } + }; + + const handleConfirmFirstInvite = () => { + setShowConfirmation(false); + setModal(true); + }; + return ( <> - + {showConfirmation && ( + setShowConfirmation(false)} + onSubmit={handleConfirmFirstInvite} + additionalDetails="After inviting the first user, only invited users will be able to join this platform. This is a security measure to control access to your instance." + actionButtonText="Continue" + variant="action" + /> + )} + {modal && ( setModal(false)}>