2023-06-17 08:50:56 +02:00
|
|
|
import React, { useEffect, useRef, useState } from "react";
|
|
|
|
import {
|
|
|
|
BookOpen,
|
|
|
|
Briefcase,
|
|
|
|
Cpu,
|
|
|
|
GitHub,
|
|
|
|
Menu,
|
|
|
|
Plus,
|
2023-07-15 00:04:25 +02:00
|
|
|
Tool,
|
2023-06-17 08:50:56 +02:00
|
|
|
} from "react-feather";
|
2023-06-04 04:28:07 +02:00
|
|
|
import IndexCount from "./IndexCount";
|
|
|
|
import LLMStatus from "./LLMStatus";
|
2023-07-15 00:04:25 +02:00
|
|
|
import SystemSettingsModal, {
|
|
|
|
useSystemSettingsModal,
|
|
|
|
} from "../Modals/Settings";
|
2023-06-04 04:28:07 +02:00
|
|
|
import NewWorkspaceModal, {
|
|
|
|
useNewWorkspaceModal,
|
|
|
|
} from "../Modals/NewWorkspace";
|
|
|
|
import ActiveWorkspaces from "./ActiveWorkspaces";
|
|
|
|
import paths from "../../utils/paths";
|
2023-07-21 21:05:39 +02:00
|
|
|
import Discord from "../Icons/Discord";
|
2023-06-04 04:28:07 +02:00
|
|
|
|
|
|
|
export default function Sidebar() {
|
|
|
|
const sidebarRef = useRef(null);
|
|
|
|
const {
|
2023-07-15 00:04:25 +02:00
|
|
|
showing: showingSystemSettingsModal,
|
|
|
|
showModal: showSystemSettingsModal,
|
|
|
|
hideModal: hideSystemSettingsModal,
|
|
|
|
} = useSystemSettingsModal();
|
2023-06-04 04:28:07 +02:00
|
|
|
const {
|
|
|
|
showing: showingNewWsModal,
|
|
|
|
showModal: showNewWsModal,
|
|
|
|
hideModal: hideNewWsModal,
|
|
|
|
} = useNewWorkspaceModal();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div
|
|
|
|
ref={sidebarRef}
|
|
|
|
style={{ height: "calc(100% - 32px)" }}
|
|
|
|
className="transition-all duration-500 relative m-[16px] rounded-[26px] bg-white dark:bg-black-900 min-w-[15.5%] p-[18px] "
|
|
|
|
>
|
|
|
|
<div className="w-full h-full flex flex-col overflow-x-hidden items-between">
|
|
|
|
{/* Header Information */}
|
|
|
|
<div className="flex w-full items-center justify-between">
|
|
|
|
<p className="text-xl font-base text-slate-600 dark:text-slate-200">
|
|
|
|
AnythingLLM
|
|
|
|
</p>
|
|
|
|
<div className="flex gap-x-2 items-center text-slate-500">
|
|
|
|
<button
|
2023-07-15 00:04:25 +02:00
|
|
|
onClick={showSystemSettingsModal}
|
2023-06-04 04:28:07 +02:00
|
|
|
className="transition-all duration-300 p-2 rounded-full bg-slate-200 text-slate-400 dark:bg-stone-800 hover:bg-slate-800 hover:text-slate-200 dark:hover:text-slate-200"
|
|
|
|
>
|
2023-07-15 00:04:25 +02:00
|
|
|
<Tool className="h-4 w-4 " />
|
2023-06-04 04:28:07 +02:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{/* Primary Body */}
|
|
|
|
<div className="h-[100%] flex flex-col w-full justify-between pt-4 overflow-y-hidden">
|
|
|
|
<div className="h-auto sidebar-items dark:sidebar-items">
|
|
|
|
<div className="flex flex-col gap-y-4 h-[65vh] pb-8 overflow-y-scroll no-scroll">
|
|
|
|
<div className="flex gap-x-2 items-center justify-between">
|
|
|
|
<button
|
|
|
|
onClick={showNewWsModal}
|
|
|
|
className="flex flex-grow w-[75%] h-[36px] gap-x-2 py-[5px] px-4 border border-slate-400 rounded-lg text-slate-800 dark:text-slate-200 justify-start items-center hover:bg-slate-100 dark:hover:bg-stone-900"
|
|
|
|
>
|
|
|
|
<Plus className="h-4 w-4" />
|
|
|
|
<p className="text-slate-800 dark:text-slate-200 text-xs leading-loose font-semibold">
|
|
|
|
New workspace
|
|
|
|
</p>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<ActiveWorkspaces />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div className="flex flex-col gap-y-2">
|
|
|
|
<div className="w-full flex items-center justify-between">
|
|
|
|
<LLMStatus />
|
|
|
|
<IndexCount />
|
|
|
|
</div>
|
|
|
|
<a
|
2023-06-08 23:26:29 +02:00
|
|
|
href={paths.hosting()}
|
|
|
|
target="_blank"
|
2023-06-04 04:28:07 +02:00
|
|
|
className="flex flex-grow w-[100%] h-[36px] gap-x-2 py-[5px] px-4 border border-slate-400 dark:border-transparent rounded-lg text-slate-800 dark:text-slate-200 justify-center items-center hover:bg-slate-100 dark:bg-stone-800 dark:hover:bg-stone-900"
|
|
|
|
>
|
|
|
|
<Cpu className="h-4 w-4" />
|
|
|
|
<p className="text-slate-800 dark:text-slate-200 text-xs leading-loose font-semibold">
|
|
|
|
Managed cloud hosting
|
|
|
|
</p>
|
|
|
|
</a>
|
|
|
|
<a
|
2023-06-08 23:26:29 +02:00
|
|
|
href={paths.hosting()}
|
|
|
|
target="_blank"
|
2023-06-04 04:28:07 +02:00
|
|
|
className="flex flex-grow w-[100%] h-[36px] gap-x-2 py-[5px] px-4 border border-slate-400 dark:border-transparent rounded-lg text-slate-800 dark:text-slate-200 justify-center items-center hover:bg-slate-100 dark:bg-stone-800 dark:hover:bg-stone-900"
|
|
|
|
>
|
|
|
|
<Briefcase className="h-4 w-4" />
|
|
|
|
<p className="text-slate-800 dark:text-slate-200 text-xs leading-loose font-semibold">
|
2023-06-08 23:26:29 +02:00
|
|
|
Enterprise Installation
|
2023-06-04 04:28:07 +02:00
|
|
|
</p>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{/* Footer */}
|
|
|
|
<div className="flex items-end justify-between mt-2">
|
|
|
|
<div className="flex gap-x-1 items-center">
|
|
|
|
<a
|
|
|
|
href={paths.github()}
|
|
|
|
className="transition-all duration-300 p-2 rounded-full bg-slate-200 text-slate-400 dark:bg-slate-800 hover:bg-slate-800 hover:text-slate-200 dark:hover:text-slate-200"
|
|
|
|
>
|
|
|
|
<GitHub className="h-4 w-4 " />
|
|
|
|
</a>
|
|
|
|
<a
|
|
|
|
href={paths.docs()}
|
|
|
|
className="transition-all duration-300 p-2 rounded-full bg-slate-200 text-slate-400 dark:bg-slate-800 hover:bg-slate-800 hover:text-slate-200 dark:hover:text-slate-200"
|
|
|
|
>
|
|
|
|
<BookOpen className="h-4 w-4 " />
|
|
|
|
</a>
|
2023-07-21 21:05:39 +02:00
|
|
|
<a
|
|
|
|
href={paths.discord()}
|
|
|
|
className="transition-all duration-300 p-2 rounded-full bg-slate-200 dark:bg-slate-800 hover:bg-slate-800 group"
|
|
|
|
>
|
|
|
|
<Discord className="h-4 w-4 stroke-slate-400 group-hover:stroke-slate-200 dark:group-hover:stroke-slate-200" />
|
|
|
|
</a>
|
2023-06-04 04:28:07 +02:00
|
|
|
</div>
|
|
|
|
<a
|
|
|
|
href={paths.mailToMintplex()}
|
|
|
|
className="transition-all duration-300 text-xs text-slate-200 dark:text-slate-600 hover:text-blue-600 dark:hover:text-blue-400"
|
|
|
|
>
|
|
|
|
@MintplexLabs
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-07-15 00:04:25 +02:00
|
|
|
{showingSystemSettingsModal && (
|
|
|
|
<SystemSettingsModal hideModal={hideSystemSettingsModal} />
|
|
|
|
)}
|
2023-06-04 04:28:07 +02:00
|
|
|
{showingNewWsModal && <NewWorkspaceModal hideModal={hideNewWsModal} />}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
2023-06-17 08:50:56 +02:00
|
|
|
|
|
|
|
export function SidebarMobileHeader() {
|
|
|
|
const [showSidebar, setShowSidebar] = useState(false);
|
|
|
|
const [showBgOverlay, setShowBgOverlay] = useState(false);
|
|
|
|
const sidebarRef = useRef(null);
|
|
|
|
const {
|
2023-07-15 00:04:25 +02:00
|
|
|
showing: showingSystemSettingsModal,
|
|
|
|
showModal: showSystemSettingsModal,
|
|
|
|
hideModal: hideSystemSettingsModal,
|
|
|
|
} = useSystemSettingsModal();
|
2023-06-17 08:50:56 +02:00
|
|
|
const {
|
|
|
|
showing: showingNewWsModal,
|
|
|
|
showModal: showNewWsModal,
|
|
|
|
hideModal: hideNewWsModal,
|
|
|
|
} = useNewWorkspaceModal();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
function handleBg() {
|
|
|
|
if (showSidebar) {
|
|
|
|
setTimeout(() => {
|
|
|
|
setShowBgOverlay(true);
|
|
|
|
}, 300);
|
|
|
|
} else {
|
|
|
|
setShowBgOverlay(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handleBg();
|
|
|
|
}, [showSidebar]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className="flex justify-between relative top-0 left-0 w-full rounded-b-lg px-2 pb-4 bg-white dark:bg-black-900 text-slate-800 dark:text-slate-200">
|
|
|
|
<button
|
|
|
|
onClick={() => setShowSidebar(true)}
|
|
|
|
className="rounded-md bg-stone-200 p-2 flex items-center justify-center text-slate-800 hover:bg-stone-300 group dark:bg-stone-800 dark:text-slate-200 dark:hover:bg-stone-900 dark:border dark:border-stone-800"
|
|
|
|
>
|
|
|
|
<Menu className="h-6 w-6" />
|
|
|
|
</button>
|
|
|
|
<p className="text-xl font-base text-slate-600 dark:text-slate-200">
|
|
|
|
AnythingLLM
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
transform: showSidebar ? `translateX(0vw)` : `translateX(-100vw)`,
|
|
|
|
}}
|
|
|
|
className={`z-99 fixed top-0 left-0 transition-all duration-500 w-[100vw] h-[100vh]`}
|
|
|
|
>
|
|
|
|
<div
|
2023-07-20 20:14:23 +02:00
|
|
|
className={`${
|
|
|
|
showBgOverlay
|
2023-06-17 08:50:56 +02:00
|
|
|
? "transition-all opacity-1"
|
|
|
|
: "transition-none opacity-0"
|
2023-07-20 20:14:23 +02:00
|
|
|
} duration-500 fixed top-0 left-0 bg-black-900 bg-opacity-75 w-screen h-screen`}
|
2023-06-17 08:50:56 +02:00
|
|
|
onClick={() => setShowSidebar(false)}
|
|
|
|
/>
|
|
|
|
<div
|
|
|
|
ref={sidebarRef}
|
|
|
|
className="h-[100vh] fixed top-0 left-0 rounded-r-[26px] bg-white dark:bg-black-900 w-[70%] p-[18px] "
|
|
|
|
>
|
|
|
|
<div className="w-full h-full flex flex-col overflow-x-hidden items-between">
|
|
|
|
{/* Header Information */}
|
|
|
|
<div className="flex w-full items-center justify-between">
|
|
|
|
<p className="text-xl font-base text-slate-600 dark:text-slate-200">
|
|
|
|
AnythingLLM
|
|
|
|
</p>
|
|
|
|
<div className="flex gap-x-2 items-center text-slate-500">
|
|
|
|
<button
|
2023-07-15 00:04:25 +02:00
|
|
|
onClick={showSystemSettingsModal}
|
2023-06-17 08:50:56 +02:00
|
|
|
className="transition-all duration-300 p-2 rounded-full bg-slate-200 text-slate-400 dark:bg-stone-800 hover:bg-slate-800 hover:text-slate-200 dark:hover:text-slate-200"
|
|
|
|
>
|
2023-07-15 00:04:25 +02:00
|
|
|
<Tool className="h-4 w-4 " />
|
2023-06-17 08:50:56 +02:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{/* Primary Body */}
|
|
|
|
<div className="h-full flex flex-col w-full justify-between pt-4 overflow-y-hidden ">
|
|
|
|
<div className="h-auto md:sidebar-items md:dark:sidebar-items">
|
|
|
|
<div
|
|
|
|
style={{ height: "calc(100vw - -3rem)" }}
|
|
|
|
className=" flex flex-col gap-y-4 pb-8 overflow-y-scroll no-scroll"
|
|
|
|
>
|
|
|
|
<div className="flex gap-x-2 items-center justify-between">
|
|
|
|
<button
|
|
|
|
onClick={showNewWsModal}
|
|
|
|
className="flex flex-grow w-[75%] h-[36px] gap-x-2 py-[5px] px-4 border border-slate-400 rounded-lg text-slate-800 dark:text-slate-200 justify-start items-center hover:bg-slate-100 dark:hover:bg-stone-900"
|
|
|
|
>
|
|
|
|
<Plus className="h-4 w-4" />
|
|
|
|
<p className="text-slate-800 dark:text-slate-200 text-xs leading-loose font-semibold">
|
|
|
|
New workspace
|
|
|
|
</p>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<ActiveWorkspaces />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div className="flex flex-col gap-y-2">
|
|
|
|
<div className="w-full flex items-center justify-between">
|
|
|
|
<LLMStatus />
|
|
|
|
<IndexCount />
|
|
|
|
</div>
|
|
|
|
<a
|
|
|
|
href={paths.hosting()}
|
|
|
|
target="_blank"
|
|
|
|
className="flex flex-grow w-[100%] h-[36px] gap-x-2 py-[5px] px-4 border border-slate-400 dark:border-transparent rounded-lg text-slate-800 dark:text-slate-200 justify-center items-center hover:bg-slate-100 dark:bg-stone-800 dark:hover:bg-stone-900"
|
|
|
|
>
|
|
|
|
<Cpu className="h-4 w-4" />
|
|
|
|
<p className="text-slate-800 dark:text-slate-200 text-xs leading-loose font-semibold">
|
|
|
|
Managed cloud hosting
|
|
|
|
</p>
|
|
|
|
</a>
|
|
|
|
<a
|
|
|
|
href={paths.hosting()}
|
|
|
|
target="_blank"
|
|
|
|
className="flex flex-grow w-[100%] h-[36px] gap-x-2 py-[5px] px-4 border border-slate-400 dark:border-transparent rounded-lg text-slate-800 dark:text-slate-200 justify-center items-center hover:bg-slate-100 dark:bg-stone-800 dark:hover:bg-stone-900"
|
|
|
|
>
|
|
|
|
<Briefcase className="h-4 w-4" />
|
|
|
|
<p className="text-slate-800 dark:text-slate-200 text-xs leading-loose font-semibold">
|
|
|
|
Enterprise Installation
|
|
|
|
</p>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{/* Footer */}
|
|
|
|
<div className="flex items-end justify-between mt-2">
|
|
|
|
<div className="flex gap-x-1 items-center">
|
|
|
|
<a
|
|
|
|
href={paths.github()}
|
|
|
|
className="transition-all duration-300 p-2 rounded-full bg-slate-200 text-slate-400 dark:bg-slate-800 hover:bg-slate-800 hover:text-slate-200 dark:hover:text-slate-200"
|
|
|
|
>
|
|
|
|
<GitHub className="h-4 w-4 " />
|
|
|
|
</a>
|
|
|
|
<a
|
|
|
|
href={paths.docs()}
|
|
|
|
className="transition-all duration-300 p-2 rounded-full bg-slate-200 text-slate-400 dark:bg-slate-800 hover:bg-slate-800 hover:text-slate-200 dark:hover:text-slate-200"
|
|
|
|
>
|
|
|
|
<BookOpen className="h-4 w-4 " />
|
|
|
|
</a>
|
2023-07-21 21:05:39 +02:00
|
|
|
<a
|
|
|
|
href={paths.discord()}
|
|
|
|
className="transition-all duration-300 p-2 rounded-full bg-slate-200 dark:bg-slate-800 hover:bg-slate-800 group"
|
|
|
|
>
|
|
|
|
<Discord className="h-4 w-4 stroke-slate-400 group-hover:stroke-slate-200 dark:group-hover:stroke-slate-200" />
|
|
|
|
</a>
|
2023-06-17 08:50:56 +02:00
|
|
|
</div>
|
|
|
|
<a
|
|
|
|
href={paths.mailToMintplex()}
|
|
|
|
className="transition-all duration-300 text-xs text-slate-200 dark:text-slate-600 hover:text-blue-600 dark:hover:text-blue-400"
|
|
|
|
>
|
|
|
|
@MintplexLabs
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-07-15 00:04:25 +02:00
|
|
|
{showingSystemSettingsModal && (
|
|
|
|
<SystemSettingsModal hideModal={hideSystemSettingsModal} />
|
|
|
|
)}
|
2023-06-17 08:50:56 +02:00
|
|
|
{showingNewWsModal && <NewWorkspaceModal hideModal={hideNewWsModal} />}
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|