import React, { useEffect, useRef, useState } from "react";
import {
BookOpen,
Briefcase,
Cpu,
GitHub,
Menu,
Plus,
Shield,
Tool,
} from "react-feather";
import IndexCount from "./IndexCount";
import LLMStatus from "./LLMStatus";
import SystemSettingsModal, {
useSystemSettingsModal,
} from "../Modals/Settings";
import NewWorkspaceModal, {
useNewWorkspaceModal,
} from "../Modals/NewWorkspace";
import ActiveWorkspaces from "./ActiveWorkspaces";
import paths from "../../utils/paths";
import Discord from "../Icons/Discord";
import useUser from "../../hooks/useUser";
export default function Sidebar() {
const sidebarRef = useRef(null);
const {
showing: showingSystemSettingsModal,
showModal: showSystemSettingsModal,
hideModal: hideSystemSettingsModal,
} = useSystemSettingsModal();
const {
showing: showingNewWsModal,
showModal: showNewWsModal,
hideModal: hideNewWsModal,
} = useNewWorkspaceModal();
return (
<>
{/* Header Information */}
{/* Primary Body */}
{showingSystemSettingsModal && (
)}
{showingNewWsModal && }
>
);
}
export function SidebarMobileHeader() {
const sidebarRef = useRef(null);
const [showSidebar, setShowSidebar] = useState(false);
const [showBgOverlay, setShowBgOverlay] = useState(false);
const {
showing: showingSystemSettingsModal,
showModal: showSystemSettingsModal,
hideModal: hideSystemSettingsModal,
} = useSystemSettingsModal();
const {
showing: showingNewWsModal,
showModal: showNewWsModal,
hideModal: hideNewWsModal,
} = useNewWorkspaceModal();
useEffect(() => {
function handleBg() {
if (showSidebar) {
setTimeout(() => {
setShowBgOverlay(true);
}, 300);
} else {
setShowBgOverlay(false);
}
}
handleBg();
}, [showSidebar]);
return (
<>
AnythingLLM
setShowSidebar(false)}
/>
{/* Header Information */}
{/* Primary Body */}
{showingSystemSettingsModal && (
)}
{showingNewWsModal &&
}
>
);
}
function AdminHome() {
const { user } = useUser();
if (!user || user?.role !== "admin") return null;
return (
);
}