Skip to content

Commit

Permalink
chore: add @ as alias for frontend root (#414)
Browse files Browse the repository at this point in the history
* chore: add @ as alias for frontend root

* fix: remove bad tag
  • Loading branch information
timothycarambat authored Dec 7, 2023
1 parent 33de34f commit f48e6b1
Show file tree
Hide file tree
Showing 69 changed files with 259 additions and 307 deletions.
7 changes: 6 additions & 1 deletion frontend/jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"compilerOptions": {
"module": "commonjs",
"target": "esnext",
"jsx": "react"
"jsx": "react",
"paths": {
"@/*": [
"./src/*"
],
}
}
}
40 changes: 19 additions & 21 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
import React, { lazy, Suspense } from "react";
import { Routes, Route } from "react-router-dom";
import { ContextWrapper } from "./AuthContext";
import { ContextWrapper } from "@/AuthContext";
import PrivateRoute, {
AdminRoute,
ManagerRoute,
} from "./components/PrivateRoute";
} from "@/components/PrivateRoute";
import { ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import Login from "./pages/Login";
import Login from "@/pages/Login";

const Main = lazy(() => import("./pages/Main"));
const InvitePage = lazy(() => import("./pages/Invite"));
const WorkspaceChat = lazy(() => import("./pages/WorkspaceChat"));
const AdminUsers = lazy(() => import("./pages/Admin/Users"));
const AdminInvites = lazy(() => import("./pages/Admin/Invitations"));
const AdminWorkspaces = lazy(() => import("./pages/Admin/Workspaces"));
const AdminSystem = lazy(() => import("./pages/Admin/System"));
const GeneralChats = lazy(() => import("./pages/GeneralSettings/Chats"));
const Main = lazy(() => import("@/pages/Main"));
const InvitePage = lazy(() => import("@/pages/Invite"));
const WorkspaceChat = lazy(() => import("@/pages/WorkspaceChat"));
const AdminUsers = lazy(() => import("@/pages/Admin/Users"));
const AdminInvites = lazy(() => import("@/pages/Admin/Invitations"));
const AdminWorkspaces = lazy(() => import("@/pages/Admin/Workspaces"));
const AdminSystem = lazy(() => import("@/pages/Admin/System"));
const GeneralChats = lazy(() => import("@/pages/GeneralSettings/Chats"));
const GeneralAppearance = lazy(() =>
import("./pages/GeneralSettings/Appearance")
import("@/pages/GeneralSettings/Appearance")
);
const GeneralApiKeys = lazy(() => import("./pages/GeneralSettings/ApiKeys"));

const GeneralApiKeys = lazy(() => import("@/pages/GeneralSettings/ApiKeys"));
const GeneralLLMPreference = lazy(() =>
import("./pages/GeneralSettings/LLMPreference")
import("@/pages/GeneralSettings/LLMPreference")
);
const GeneralEmbeddingPreference = lazy(() =>
import("./pages/GeneralSettings/EmbeddingPreference")
import("@/pages/GeneralSettings/EmbeddingPreference")
);
const GeneralVectorDatabase = lazy(() =>
import("./pages/GeneralSettings/VectorDatabase")
import("@/pages/GeneralSettings/VectorDatabase")
);
const GeneralExportImport = lazy(() =>
import("./pages/GeneralSettings/ExportImport")
import("@/pages/GeneralSettings/ExportImport")
);
const GeneralSecurity = lazy(() => import("./pages/GeneralSettings/Security"));

const OnboardingFlow = lazy(() => import("./pages/OnboardingFlow"));
const GeneralSecurity = lazy(() => import("@/pages/GeneralSettings/Security"));
const OnboardingFlow = lazy(() => import("@/pages/OnboardingFlow"));

export default function App() {
return (
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/AuthContext.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, createContext } from "react";
import { AUTH_TIMESTAMP, AUTH_TOKEN, AUTH_USER } from "./utils/constants";
import { AUTH_TIMESTAMP, AUTH_TOKEN, AUTH_USER } from "@/utils/constants";

export const AuthContext = createContext(null);
export function ContextWrapper(props) {
Expand Down
7 changes: 2 additions & 5 deletions frontend/src/components/ChatBubble/index.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import React from "react";
import Jazzicon from "../UserIcon";
import { userFromStorage } from "../../utils/request";
import {
AI_BACKGROUND_COLOR,
USER_BACKGROUND_COLOR,
} from "../../utils/constants";
import { userFromStorage } from "@/utils/request";
import { AI_BACKGROUND_COLOR, USER_BACKGROUND_COLOR } from "@/utils/constants";

export default function ChatBubble({ message, type, popMsg }) {
const isUser = type === "user";
Expand Down
12 changes: 4 additions & 8 deletions frontend/src/components/DefaultChat/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@ import {
EnvelopeSimple,
Plus,
} from "@phosphor-icons/react";

import NewWorkspaceModal, {
useNewWorkspaceModal,
} from "../Modals/NewWorkspace";
import paths from "../../utils/paths";
import paths from "@/utils/paths";
import { isMobile } from "react-device-detect";
import { SidebarMobileHeader } from "../Sidebar";
import ChatBubble from "../ChatBubble";
import System from "../../models/system";
import System from "@/models/system";
import Jazzicon from "../UserIcon";
import { userFromStorage } from "../../utils/request";
import {
AI_BACKGROUND_COLOR,
USER_BACKGROUND_COLOR,
} from "../../utils/constants";
import { userFromStorage } from "@/utils/request";
import { AI_BACKGROUND_COLOR, USER_BACKGROUND_COLOR } from "@/utils/constants";

export default function DefaultChatContainer() {
const [mockMsgs, setMockMessages] = useState([]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from "react";
import System from "../../../models/system";
import System from "@/models/system";

export default function LocalAiOptions({ settings }) {
const [basePathValue, setBasePathValue] = useState(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Info } from "@phosphor-icons/react";
import paths from "../../../utils/paths";
import paths from "@/utils/paths";

export default function AnthropicAiOptions({ settings, showAlert = false }) {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Info } from "@phosphor-icons/react";
import paths from "../../../utils/paths";
import paths from "@/utils/paths";

export default function LMStudioOptions({ settings, showAlert = false }) {
return (
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/LLMSelection/LocalAiOptions/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useState } from "react";
import { Info } from "@phosphor-icons/react";
import paths from "../../../utils/paths";
import System from "../../../models/system";
import paths from "@/utils/paths";
import System from "@/models/system";

export default function LocalAiOptions({ settings, showAlert = false }) {
const [basePathValue, setBasePathValue] = useState(settings?.LocalAiBasePath);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useEffect } from "react";
import System from "../../../models/system";
import System from "@/models/system";

export default function OpenAiOptions({ settings }) {
const [inputValue, setInputValue] = useState(settings?.OpenAiKey);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Modals/NewWorkspace.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useRef, useState } from "react";
import { X } from "@phosphor-icons/react";
import Workspace from "../../models/workspace";
import paths from "../../utils/paths";
import Workspace from "@/models/workspace";
import paths from "@/utils/paths";

const noop = () => false;
export default function NewWorkspaceModal({ hideModal = noop }) {
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/PrivateRoute/index.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useEffect, useState } from "react";
import { Navigate } from "react-router-dom";
import { FullScreenLoader } from "../Preloader";
import validateSessionTokenForUser from "../../utils/session";
import paths from "../../utils/paths";
import { AUTH_TIMESTAMP, AUTH_TOKEN, AUTH_USER } from "../../utils/constants";
import { userFromStorage } from "../../utils/request";
import System from "../../models/system";
import validateSessionTokenForUser from "@/utils/session";
import paths from "@/utils/paths";
import { AUTH_TIMESTAMP, AUTH_TOKEN, AUTH_USER } from "@/utils/constants";
import { userFromStorage } from "@/utils/request";
import System from "@/models/system";
import UserMenu from "../UserMenu";

// Used only for Multi-user mode only as we permission specific pages based on auth role.
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/SettingsSidebar/index.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useEffect, useRef, useState } from "react";
// import IndexCount from "../Sidebar/IndexCount";
// import LLMStatus from "../Sidebar/LLMStatus";
import paths from "../../utils/paths";
import useLogo from "../../hooks/useLogo";
import paths from "@/utils/paths";
import useLogo from "@/hooks/useLogo";
import {
DiscordLogo,
EnvelopeSimple,
Expand All @@ -23,8 +23,8 @@ import {
List,
FileCode,
} from "@phosphor-icons/react";
import useUser from "../../hooks/useUser";
import { USER_BACKGROUND_COLOR } from "../../utils/constants";
import useUser from "@/hooks/useUser";
import { USER_BACKGROUND_COLOR } from "@/utils/constants";

export default function SettingsSidebar() {
const { logo } = useLogo();
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/Sidebar/ActiveWorkspaces/index.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React, { useState, useEffect, useCallback } from "react";
import * as Skeleton from "react-loading-skeleton";
import "react-loading-skeleton/dist/skeleton.css";
import Workspace from "../../../models/workspace";
import Workspace from "@/models/workspace";
import ManageWorkspace, {
useManageWorkspaceModal,
} from "../../Modals/MangeWorkspace";
import paths from "../../../utils/paths";
import paths from "@/utils/paths";
import { useParams } from "react-router-dom";
import { GearSix, SquaresFour } from "@phosphor-icons/react";
import truncate from "truncate";
import useUser from "../../../hooks/useUser";
import useUser from "@/hooks/useUser";

export default function ActiveWorkspaces() {
const { slug } = useParams();
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Sidebar/IndexCount.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pluralize from "pluralize";
import React, { useEffect, useState } from "react";
import System from "../../models/system";
import { numberWithCommas } from "../../utils/numbers";
import System from "@/models/system";
import { numberWithCommas } from "@/utils/numbers";

export default function IndexCount() {
const [indexes, setIndexes] = useState(null);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Sidebar/LLMStatus.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from "react";
import { WarningCircle, Circle } from "@phosphor-icons/react";
import System from "../../models/system";
import System from "@/models/system";

export default function LLMStatus() {
const [status, setStatus] = useState(null);
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/Sidebar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ 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 paths from "@/utils/paths";
import { USER_BACKGROUND_COLOR } from "@/utils/constants";
import useLogo from "@/hooks/useLogo";
import useUser from "@/hooks/useUser";

export default function Sidebar() {
const { user } = useUser();
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/UserMenu/index.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useState, useEffect, useRef } from "react";
import { isMobile } from "react-device-detect";
import paths from "../../utils/paths";
import { AUTH_TIMESTAMP, AUTH_TOKEN, AUTH_USER } from "../../utils/constants";
import paths from "@/utils/paths";
import { AUTH_TIMESTAMP, AUTH_TOKEN, AUTH_USER } from "@/utils/constants";
import { Person, SignOut } from "@phosphor-icons/react";
import { userFromStorage } from "../../utils/request";
import { userFromStorage } from "@/utils/request";

export default function UserMenu({ children }) {
if (isMobile) return <>{children}</>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { memo, forwardRef } from "react";
import { Warning } from "@phosphor-icons/react";
import Jazzicon from "../../../../UserIcon";
import renderMarkdown from "../../../../../utils/chat/markdown";
import { userFromStorage } from "../../../../../utils/request";
import renderMarkdown from "@/utils/chat/markdown";
import { userFromStorage } from "@/utils/request";
import Citations from "../Citation";
import {
AI_BACKGROUND_COLOR,
USER_BACKGROUND_COLOR,
} from "../../../../../utils/constants";
import { AI_BACKGROUND_COLOR, USER_BACKGROUND_COLOR } from "@/utils/constants";
import { v4 } from "uuid";

const HistoricalMessage = forwardRef(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { forwardRef, memo } from "react";
import { Warning } from "@phosphor-icons/react";
import Jazzicon from "../../../../UserIcon";
import renderMarkdown from "../../../../../utils/chat/markdown";
import renderMarkdown from "@/utils/chat/markdown";
import Citations from "../Citation";

const PromptReply = forwardRef(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { isMobile } from "react-device-detect";
import ManageWorkspace, {
useManageWorkspaceModal,
} from "../../../Modals/MangeWorkspace";
import useUser from "../../../../hooks/useUser";
import useUser from "@/hooks/useUser";

export default function PromptInput({
workspace,
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/WorkspaceChat/ChatContainer/index.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useState, useEffect } from "react";
import ChatHistory from "./ChatHistory";
import PromptInput from "./PromptInput";
import Workspace from "../../../models/workspace";
import handleChat from "../../../utils/chat";
import Workspace from "@/models/workspace";
import handleChat from "@/utils/chat";
import { isMobile } from "react-device-detect";
import { SidebarMobileHeader } from "../../Sidebar";

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/WorkspaceChat/index.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useEffect, useState } from "react";
import Workspace from "../../models/workspace";
import Workspace from "@/models/workspace";
import LoadingChat from "./LoadingChat";
import ChatContainer from "./ChatContainer";
import paths from "../../utils/paths";
import paths from "@/utils/paths";

export default function WorkspaceChat({ loading, workspace }) {
const [history, setHistory] = useState([]);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/hooks/useLogo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from "react";
import System from "../models/system";
import AnythingLLM from "../media/logo/anything-llm.png";
import System from "@/models/system";
import AnythingLLM from "@/media/logo/anything-llm.png";

export default function useLogo() {
const [logo, setLogo] = useState("");
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/hooks/useUser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useContext } from "react";
import { AuthContext } from "../AuthContext";
import { AuthContext } from "@/AuthContext";

// interface IStore {
// store: {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from "react";
import ReactDOM from "react-dom/client";
import { BrowserRouter as Router } from "react-router-dom";
import App from "./App.jsx";
import "./index.css";
import App from "@/App.jsx";
import "@/index.css";
const isDev = process.env.NODE_ENV !== "production";
const REACTWRAP = isDev ? React.Fragment : React.StrictMode;

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/models/admin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { API_BASE } from "../utils/constants";
import { baseHeaders } from "../utils/request";
import { API_BASE } from "@/utils/constants";
import { baseHeaders } from "@/utils/request";

const Admin = {
// User Management
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/models/invite.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { API_BASE } from "../utils/constants";
import { API_BASE } from "@/utils/constants";

const Invite = {
checkInvite: async (inviteCode) => {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/models/system.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { API_BASE, AUTH_TIMESTAMP } from "../utils/constants";
import { baseHeaders } from "../utils/request";
import { API_BASE, AUTH_TIMESTAMP } from "@/utils/constants";
import { baseHeaders } from "@/utils/request";

const System = {
ping: async function () {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/models/workspace.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { API_BASE } from "../utils/constants";
import { baseHeaders } from "../utils/request";
import { API_BASE } from "@/utils/constants";
import { baseHeaders } from "@/utils/request";
import { fetchEventSource } from "@microsoft/fetch-event-source";
import { v4 } from "uuid";

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Admin/Invitations/InviteRow/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useRef, useState } from "react";
import { titleCase } from "text-case";
import Admin from "../../../../models/admin";
import Admin from "@/models/admin";
import { Trash } from "@phosphor-icons/react";

export default function InviteRow({ invite }) {
Expand Down
Loading

0 comments on commit f48e6b1

Please sign in to comment.