mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-28 12:58:41 +02:00
k# Please enter the commit message for your changes. Lines starting (#4144)
This commit is contained in:
@@ -19,6 +19,8 @@ import BulkAdd from "@/components/admin/users/BulkAdd";
|
|||||||
import Text from "@/components/ui/text";
|
import Text from "@/components/ui/text";
|
||||||
import { InvitedUserSnapshot } from "@/lib/types";
|
import { InvitedUserSnapshot } from "@/lib/types";
|
||||||
import { SearchBar } from "@/components/search/SearchBar";
|
import { SearchBar } from "@/components/search/SearchBar";
|
||||||
|
import { ConfirmEntityModal } from "@/components/modals/ConfirmEntityModal";
|
||||||
|
import { NEXT_PUBLIC_CLOUD_ENABLED } from "@/lib/constants";
|
||||||
|
|
||||||
const UsersTables = ({
|
const UsersTables = ({
|
||||||
q,
|
q,
|
||||||
@@ -130,6 +132,13 @@ const AddUserButton = ({
|
|||||||
setPopup: (spec: PopupSpec) => void;
|
setPopup: (spec: PopupSpec) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [modal, setModal] = useState(false);
|
const [modal, setModal] = useState(false);
|
||||||
|
const [showConfirmation, setShowConfirmation] = useState(false);
|
||||||
|
|
||||||
|
const { data: invitedUsers } = useSWR<InvitedUserSnapshot[]>(
|
||||||
|
"/api/manage/users/invited",
|
||||||
|
errorHandlingFetcher
|
||||||
|
);
|
||||||
|
|
||||||
const onSuccess = () => {
|
const onSuccess = () => {
|
||||||
mutate(
|
mutate(
|
||||||
(key) => typeof key === "string" && key.startsWith("/api/manage/users")
|
(key) => typeof key === "string" && key.startsWith("/api/manage/users")
|
||||||
@@ -140,6 +149,7 @@ const AddUserButton = ({
|
|||||||
type: "success",
|
type: "success",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const onFailure = async (res: Response) => {
|
const onFailure = async (res: Response) => {
|
||||||
const error = (await res.json()).detail;
|
const error = (await res.json()).detail;
|
||||||
setPopup({
|
setPopup({
|
||||||
@@ -147,15 +157,45 @@ const AddUserButton = ({
|
|||||||
type: "error",
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button className="my-auto w-fit" onClick={() => setModal(true)}>
|
<Button className="my-auto w-fit" onClick={handleInviteClick}>
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
<FiPlusSquare className="my-auto mr-2" />
|
<FiPlusSquare className="my-auto mr-2" />
|
||||||
Invite Users
|
Invite Users
|
||||||
</div>
|
</div>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
{showConfirmation && (
|
||||||
|
<ConfirmEntityModal
|
||||||
|
entityType="First User Invitation"
|
||||||
|
entityName="your Access Logic"
|
||||||
|
onClose={() => 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 && (
|
{modal && (
|
||||||
<Modal title="Bulk Add Users" onOutsideClick={() => setModal(false)}>
|
<Modal title="Bulk Add Users" onOutsideClick={() => setModal(false)}>
|
||||||
<div className="flex flex-col gap-y-4">
|
<div className="flex flex-col gap-y-4">
|
||||||
|
Reference in New Issue
Block a user