From 273d824df4e79ab096fd2e85ecc7b6c1e3d95d90 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Wed, 6 Mar 2024 17:14:17 -0800 Subject: [PATCH 1/3] patch: do not block response if user password check failed --- server/endpoints/admin.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/server/endpoints/admin.js b/server/endpoints/admin.js index a54e0abd4..792cf2dd9 100644 --- a/server/endpoints/admin.js +++ b/server/endpoints/admin.js @@ -59,14 +59,17 @@ function adminEndpoints(app) { } const { user: newUser, error } = await User.create(newUserParams); - await EventLogs.logEvent( - "user_created", - { - userName: newUser.username, - createdBy: currUser.username, - }, - currUser.id - ); + if (!!newUser) { + await EventLogs.logEvent( + "user_created", + { + userName: newUser.username, + createdBy: currUser.username, + }, + currUser.id + ); + } + response.status(200).json({ user: newUser, error }); } catch (e) { console.error(e); From 3cb8a80e8d7fcf6bd8da42fd4f70ec4d0ee88be6 Mon Sep 17 00:00:00 2001 From: Sean Hatfield Date: Wed, 6 Mar 2024 17:22:36 -0800 Subject: [PATCH 2/3] [STYLE] Implement new side bar menus (#815) * WIP main sidebar designs * hover states and active states for main sidebar * main and settings sidebar UI updates & improve performance using Link instead of * update borders to match rest of UI in all pages * update borders of all containers to match rest of UI * remove unneeded conditional * small changes to UI to conform to designs Fix conditional hook render * add check for roles to SettingsButton component and hide button from footer when in mobile * typo --------- Co-authored-by: timothycarambat --- frontend/src/components/DefaultChat/index.jsx | 2 +- frontend/src/components/Footer/index.jsx | 13 ++- .../src/components/SettingsButton/index.jsx | 31 +++++++ .../src/components/SettingsSidebar/index.jsx | 75 +++++++--------- .../Sidebar/ActiveWorkspaces/index.jsx | 85 +++++++++++-------- frontend/src/components/Sidebar/index.jsx | 71 ++++++---------- .../components/UserMenu/UserButton/index.jsx | 4 +- .../WorkspaceChat/ChatContainer/index.jsx | 2 +- .../src/pages/Admin/Invitations/index.jsx | 2 +- frontend/src/pages/Admin/Logging/index.jsx | 2 +- frontend/src/pages/Admin/System/index.jsx | 2 +- frontend/src/pages/Admin/Users/index.jsx | 2 +- frontend/src/pages/Admin/Workspaces/index.jsx | 2 +- .../pages/GeneralSettings/ApiKeys/index.jsx | 2 +- .../GeneralSettings/Appearance/index.jsx | 2 +- .../src/pages/GeneralSettings/Chats/index.jsx | 2 +- .../GeneralSettings/EmbedChats/index.jsx | 2 +- .../GeneralSettings/EmbedConfigs/index.jsx | 2 +- .../pages/GeneralSettings/Security/index.jsx | 2 +- .../GeneralSettings/VectorDatabase/index.jsx | 4 +- .../src/pages/WorkspaceSettings/index.jsx | 4 +- frontend/tailwind.config.js | 3 +- 22 files changed, 168 insertions(+), 148 deletions(-) create mode 100644 frontend/src/components/SettingsButton/index.jsx diff --git a/frontend/src/components/DefaultChat/index.jsx b/frontend/src/components/DefaultChat/index.jsx index 8bc6c7cb7..a20e323bd 100644 --- a/frontend/src/components/DefaultChat/index.jsx +++ b/frontend/src/components/DefaultChat/index.jsx @@ -335,7 +335,7 @@ export default function DefaultChatContainer() { return (
{isMobile && } {fetchedMessages.length === 0 diff --git a/frontend/src/components/Footer/index.jsx b/frontend/src/components/Footer/index.jsx index 26b271a8c..fc51dde71 100644 --- a/frontend/src/components/Footer/index.jsx +++ b/frontend/src/components/Footer/index.jsx @@ -1,6 +1,5 @@ import System from "@/models/system"; import paths from "@/utils/paths"; -import { safeJsonParse } from "@/utils/request"; import { BookOpen, DiscordLogo, @@ -13,6 +12,8 @@ import { LinkSimple, } from "@phosphor-icons/react"; import React, { useEffect, useState } from "react"; +import SettingsButton from "../SettingsButton"; +import { isMobile } from "react-device-detect"; export const MAX_ICONS = 3; export const ICON_COMPONENTS = { @@ -44,11 +45,12 @@ export default function Footer() { if (!Array.isArray(footerData) || footerData.length === 0) { return ( -
+
); } return ( -
+ ); diff --git a/frontend/src/components/SettingsButton/index.jsx b/frontend/src/components/SettingsButton/index.jsx new file mode 100644 index 000000000..0903862db --- /dev/null +++ b/frontend/src/components/SettingsButton/index.jsx @@ -0,0 +1,31 @@ +import useUser from "@/hooks/useUser"; +import paths from "@/utils/paths"; +import { ArrowUUpLeft, Wrench } from "@phosphor-icons/react"; +import { Link } from "react-router-dom"; +import { useMatch } from "react-router-dom"; + +export default function SettingsButton() { + const isInSettings = !!useMatch("/settings/*"); + const { user } = useUser(); + + if (user && user?.role === "default") return null; + + if (isInSettings) + return ( + + + + ); + + return ( + + + + ); +} diff --git a/frontend/src/components/SettingsSidebar/index.jsx b/frontend/src/components/SettingsSidebar/index.jsx index ea4887114..112b641bf 100644 --- a/frontend/src/components/SettingsSidebar/index.jsx +++ b/frontend/src/components/SettingsSidebar/index.jsx @@ -13,7 +13,6 @@ import { Database, Lock, House, - X, List, FileCode, Plugs, @@ -25,6 +24,7 @@ import useUser from "@/hooks/useUser"; import { USER_BACKGROUND_COLOR } from "@/utils/constants"; import { isMobile } from "react-device-detect"; import Footer from "../Footer"; +import { Link } from "react-router-dom"; export default function SettingsSidebar() { const { logo } = useLogo(); @@ -112,9 +112,7 @@ export default function SettingsSidebar() {
-
-
-
+
@@ -124,50 +122,38 @@ export default function SettingsSidebar() { } return ( - <> +
+ + Logo +
-
- {/* Header Information */} -
-
- Logo -
-
- - - -
+
+
+ Instance Settings
-
- Settings -
- {/* Primary Body */} -
+
- {/* Options */}
-
-
-
+
- +
); } @@ -195,24 +181,25 @@ const Option = ({ return ( <> - {!!subOptions && (isActive || hasActiveChild) && (
{ async function getWorkspaces() { @@ -90,55 +91,60 @@ export default function ActiveWorkspaces() { href={isActive ? null : paths.workspace.chat(workspace.slug)} className={` transition-all duration-[200ms] - flex flex-grow w-[75%] gap-x-2 py-[6px] px-[12px] rounded-lg text-slate-200 justify-start items-center - hover:bg-workspace-item-selected-gradient + flex flex-grow w-[75%] gap-x-2 py-[6px] px-[12px] rounded-[4px] text-white justify-start items-center + hover:bg-workspace-item-selected-gradient border-outline ${ isActive - ? "border-2 bg-workspace-item-selected-gradient border-white" - : "border bg-workspace-item-gradient bg-opacity-60 border-transparent hover:border-slate-100 hover:border-opacity-50" + ? "bg-workspace-item-selected-gradient font-medium border-none" + : "border-[1px]" }`} >

{isActive || isHovered - ? truncate(workspace.name, 17) + ? truncate(workspace.name, 15) : truncate(workspace.name, 20)}

{(isActive || isHovered || gearHover[workspace.id]) && user?.role !== "default" ? ( -
- + onMouseLeave={() => + handleUploadMouseLeave(workspace.id) + } + className="rounded-md flex items-center justify-center ml-auto" + > + + +
handleGearMouseEnter(workspace.id)} onMouseLeave={() => handleGearMouseLeave(workspace.id)} - className="rounded-md flex items-center justify-center text-white ml-auto" + className="rounded-md flex items-center justify-center text-[#A7A8A9] hover:text-white ml-auto" > - +
+ +
) : null} diff --git a/frontend/src/components/Sidebar/index.jsx b/frontend/src/components/Sidebar/index.jsx index d14099b2b..75c854d90 100644 --- a/frontend/src/components/Sidebar/index.jsx +++ b/frontend/src/components/Sidebar/index.jsx @@ -1,14 +1,16 @@ import React, { useEffect, useRef, useState } from "react"; -import { Wrench, Plus, List } from "@phosphor-icons/react"; +import { Plus, List } from "@phosphor-icons/react"; import NewWorkspaceModal, { useNewWorkspaceModal, } from "../Modals/NewWorkspace"; import ActiveWorkspaces from "./ActiveWorkspaces"; -import paths from "@/utils/paths"; import { USER_BACKGROUND_COLOR } from "@/utils/constants"; import useLogo from "@/hooks/useLogo"; import useUser from "@/hooks/useUser"; import Footer from "../Footer"; +import SettingsButton from "../SettingsButton"; +import { Link } from "react-router-dom"; +import paths from "@/utils/paths"; export default function Sidebar() { const { user } = useUser(); @@ -21,40 +23,33 @@ export default function Sidebar() { } = useNewWorkspaceModal(); return ( - <> +
+ + Logo +
- {/* Header Information */} -
-
- Logo -
- {(!user || user?.role !== "default") && ( -
- -
- )} -
- - {/* Primary Body */} -
+
{(!user || user?.role !== "default") && (
{showingNewWsModal && } - +
); } @@ -149,11 +144,9 @@ export function SidebarMobileHeader() { style={{ objectFit: "contain" }} />
- {(!user || user?.role !== "default") && ( -
- -
- )} +
+ +
{/* Primary Body */} @@ -190,17 +183,3 @@ export function SidebarMobileHeader() { ); } - -function SettingsButton() { - const { user } = useUser(); - return ( - - - - ); -} diff --git a/frontend/src/components/UserMenu/UserButton/index.jsx b/frontend/src/components/UserMenu/UserButton/index.jsx index 99db94411..28730bfb0 100644 --- a/frontend/src/components/UserMenu/UserButton/index.jsx +++ b/frontend/src/components/UserMenu/UserButton/index.jsx @@ -61,7 +61,7 @@ export default function UserButton() { type="button" className="uppercase transition-all duration-300 w-[35px] h-[35px] text-base font-semibold rounded-full flex items-center bg-sidebar-button hover:bg-menu-item-selected-gradient justify-center text-white p-2 hover:border-slate-100 hover:border-opacity-50 border-transparent border" > - {mode === "multi" ? userDisplay() : } + {mode === "multi" ? : } {showMenu && ( @@ -109,7 +109,7 @@ export default function UserButton() { ); } -function userDisplay() { +function UserDisplay() { const { pfp } = usePfp(); const user = userFromStorage(); diff --git a/frontend/src/components/WorkspaceChat/ChatContainer/index.jsx b/frontend/src/components/WorkspaceChat/ChatContainer/index.jsx index 8a99a62a2..293da491f 100644 --- a/frontend/src/components/WorkspaceChat/ChatContainer/index.jsx +++ b/frontend/src/components/WorkspaceChat/ChatContainer/index.jsx @@ -108,7 +108,7 @@ export default function ChatContainer({ workspace, knownHistory = [] }) { return (
{isMobile && }
diff --git a/frontend/src/pages/Admin/Invitations/index.jsx b/frontend/src/pages/Admin/Invitations/index.jsx index a4a99e93b..31b2b7923 100644 --- a/frontend/src/pages/Admin/Invitations/index.jsx +++ b/frontend/src/pages/Admin/Invitations/index.jsx @@ -18,7 +18,7 @@ export default function AdminInvites() {
diff --git a/frontend/src/pages/Admin/Logging/index.jsx b/frontend/src/pages/Admin/Logging/index.jsx index 246cf2110..f405c9a68 100644 --- a/frontend/src/pages/Admin/Logging/index.jsx +++ b/frontend/src/pages/Admin/Logging/index.jsx @@ -30,7 +30,7 @@ export default function AdminLogs() {
diff --git a/frontend/src/pages/Admin/System/index.jsx b/frontend/src/pages/Admin/System/index.jsx index c561efd2e..9fe4c7183 100644 --- a/frontend/src/pages/Admin/System/index.jsx +++ b/frontend/src/pages/Admin/System/index.jsx @@ -43,7 +43,7 @@ export default function AdminSystem() {
diff --git a/frontend/src/pages/Admin/Workspaces/index.jsx b/frontend/src/pages/Admin/Workspaces/index.jsx index 62a28094b..fa612af12 100644 --- a/frontend/src/pages/Admin/Workspaces/index.jsx +++ b/frontend/src/pages/Admin/Workspaces/index.jsx @@ -18,7 +18,7 @@ export default function AdminWorkspaces() {
diff --git a/frontend/src/pages/GeneralSettings/ApiKeys/index.jsx b/frontend/src/pages/GeneralSettings/ApiKeys/index.jsx index 9ba3335f5..606dbf0f5 100644 --- a/frontend/src/pages/GeneralSettings/ApiKeys/index.jsx +++ b/frontend/src/pages/GeneralSettings/ApiKeys/index.jsx @@ -20,7 +20,7 @@ export default function AdminApiKeys() {
diff --git a/frontend/src/pages/GeneralSettings/Appearance/index.jsx b/frontend/src/pages/GeneralSettings/Appearance/index.jsx index 9aed853b2..c2311a2c3 100644 --- a/frontend/src/pages/GeneralSettings/Appearance/index.jsx +++ b/frontend/src/pages/GeneralSettings/Appearance/index.jsx @@ -11,7 +11,7 @@ export default function Appearance() {
diff --git a/frontend/src/pages/GeneralSettings/Chats/index.jsx b/frontend/src/pages/GeneralSettings/Chats/index.jsx index aeb341c1b..5afde115d 100644 --- a/frontend/src/pages/GeneralSettings/Chats/index.jsx +++ b/frontend/src/pages/GeneralSettings/Chats/index.jsx @@ -90,7 +90,7 @@ export default function WorkspaceChats() {
diff --git a/frontend/src/pages/GeneralSettings/EmbedChats/index.jsx b/frontend/src/pages/GeneralSettings/EmbedChats/index.jsx index 23c5bf189..d6079f391 100644 --- a/frontend/src/pages/GeneralSettings/EmbedChats/index.jsx +++ b/frontend/src/pages/GeneralSettings/EmbedChats/index.jsx @@ -14,7 +14,7 @@ export default function EmbedChats() {
diff --git a/frontend/src/pages/GeneralSettings/EmbedConfigs/index.jsx b/frontend/src/pages/GeneralSettings/EmbedConfigs/index.jsx index 4257b029f..73a2ca6db 100644 --- a/frontend/src/pages/GeneralSettings/EmbedConfigs/index.jsx +++ b/frontend/src/pages/GeneralSettings/EmbedConfigs/index.jsx @@ -17,7 +17,7 @@ export default function EmbedConfigs() {
diff --git a/frontend/src/pages/GeneralSettings/Security/index.jsx b/frontend/src/pages/GeneralSettings/Security/index.jsx index 26d408684..298a81ad7 100644 --- a/frontend/src/pages/GeneralSettings/Security/index.jsx +++ b/frontend/src/pages/GeneralSettings/Security/index.jsx @@ -13,7 +13,7 @@ export default function GeneralSecurity() {
diff --git a/frontend/src/pages/GeneralSettings/VectorDatabase/index.jsx b/frontend/src/pages/GeneralSettings/VectorDatabase/index.jsx index e5eacaea7..36242d146 100644 --- a/frontend/src/pages/GeneralSettings/VectorDatabase/index.jsx +++ b/frontend/src/pages/GeneralSettings/VectorDatabase/index.jsx @@ -165,7 +165,7 @@ export default function GeneralVectorDatabase() { {loading ? (
@@ -174,7 +174,7 @@ export default function GeneralVectorDatabase() { ) : (
}
- + Date: Fri, 8 Mar 2024 12:51:58 -0800 Subject: [PATCH 3/3] pin prisma versions to be the same --- server/package.json | 6 +++--- server/yarn.lock | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/server/package.json b/server/package.json index e521d4b62..c5654c36a 100644 --- a/server/package.json +++ b/server/package.json @@ -26,7 +26,7 @@ "@google/generative-ai": "^0.1.3", "@googleapis/youtube": "^9.0.0", "@pinecone-database/pinecone": "^2.0.1", - "@prisma/client": "5.3.0", + "@prisma/client": "5.3.1", "@qdrant/js-client-rest": "^1.4.0", "@xenova/transformers": "^2.14.0", "@zilliz/milvus2-sdk-node": "^2.3.5", @@ -52,7 +52,7 @@ "openai": "^3.2.1", "pinecone-client": "^1.1.0", "posthog-node": "^3.1.1", - "prisma": "^5.3.1", + "prisma": "5.3.1", "slugify": "^1.6.6", "sqlite": "^4.2.1", "sqlite3": "^5.1.6", @@ -78,4 +78,4 @@ "nodemon": "^2.0.22", "prettier": "^3.0.3" } -} +} \ No newline at end of file diff --git a/server/yarn.lock b/server/yarn.lock index 61b29e3a7..4cfbb7ffa 100644 --- a/server/yarn.lock +++ b/server/yarn.lock @@ -649,17 +649,17 @@ resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.0.tgz#7d8dacb7fdef0e4387caf7396cbd77f179867d06" integrity sha512-Zwq5OCzuwJC2jwqmpEQt7Ds1DTi6BWSwoGkbb1n9pO3hzb35BoJELx7c0T23iDkBGkh2e7tvOtjF3tr3OaQHDQ== -"@prisma/client@5.3.0": - version "5.3.0" - resolved "https://registry.yarnpkg.com/@prisma/client/-/client-5.3.0.tgz#47f07e5639993cffcf1c740a144495410562f279" - integrity sha512-cduYBlwj6oBfAUx2OI5i7t3NlpVeOtkN7pAqv0cw0B6gs4y8cY1mr8ZYywja0NUCOCqEWDkcZWBTVBwm6mnRIw== +"@prisma/client@5.3.1": + version "5.3.1" + resolved "https://registry.yarnpkg.com/@prisma/client/-/client-5.3.1.tgz#fc7fc2d91e814cc4fe18a4bc5e78bf851c26985e" + integrity sha512-ArOKjHwdFZIe1cGU56oIfy7wRuTn0FfZjGuU/AjgEBOQh+4rDkB6nF+AGHP8KaVpkBIiHGPQh3IpwQ3xDMdO0Q== dependencies: - "@prisma/engines-version" "5.3.0-36.e90b936d84779543cbe0e494bc8b9d7337fad8e4" + "@prisma/engines-version" "5.3.1-2.61e140623197a131c2a6189271ffee05a7aa9a59" -"@prisma/engines-version@5.3.0-36.e90b936d84779543cbe0e494bc8b9d7337fad8e4": - version "5.3.0-36.e90b936d84779543cbe0e494bc8b9d7337fad8e4" - resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-5.3.0-36.e90b936d84779543cbe0e494bc8b9d7337fad8e4.tgz#46ee2884e04cdba1163461ef856cec882d31c836" - integrity sha512-uftIog5FQ/OUR8Vb9TzpNBJ6L+zJnBgmd1A0uPJUzuvGMU32UmeyobpdXVzST5UprKryTdWOYXQFVyiQ2OU4Nw== +"@prisma/engines-version@5.3.1-2.61e140623197a131c2a6189271ffee05a7aa9a59": + version "5.3.1-2.61e140623197a131c2a6189271ffee05a7aa9a59" + resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-5.3.1-2.61e140623197a131c2a6189271ffee05a7aa9a59.tgz#7eb6f5c6b7628b8b39df55c903f411528a6f761c" + integrity sha512-y5qbUi3ql2Xg7XraqcXEdMHh0MocBfnBzDn5GbV1xk23S3Mq8MGs+VjacTNiBh3dtEdUERCrUUG7Z3QaJ+h79w== "@prisma/engines@5.3.1": version "5.3.1" @@ -4455,7 +4455,7 @@ prettier@^3.0.3: resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.1.1.tgz#6ba9f23165d690b6cbdaa88cb0807278f7019848" integrity sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw== -prisma@^5.3.1: +prisma@5.3.1: version "5.3.1" resolved "https://registry.yarnpkg.com/prisma/-/prisma-5.3.1.tgz#a0932c1c1a5ed4ff449d064b193d9c7e94e8bf77" integrity sha512-Wp2msQIlMPHe+5k5Od6xnsI/WNG7UJGgFUJgqv/ygc7kOECZapcSz/iU4NIEzISs3H1W9sFLjAPbg/gOqqtB7A==