mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-05 18:18:51 +01:00
Move data provider to shared package (#582)
* create data-provider package and move code from data-provider folder to be shared between apps * fix type issues * add packages to ignore * add new data-provider package to apps * refactor: change client imports to use @librechat/data-provider package * include data-provider build script in frontend build * fix type issue after rebasing * delete admin/package.json from this branch * update test ci script to include building of data-provider package * Try using regular build for test action * Switch frontend-review back to build:ci * Remove loginRedirect from Login.tsx * Add ChatGPT back to EModelEndpoint
This commit is contained in:
parent
d0078d478d
commit
04e4259005
48 changed files with 1472 additions and 141 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { Dialog, DialogTemplate } from '../ui/';
|
||||
import { ClearChatsButton } from './SettingsTabs/';
|
||||
import { useClearConversationsMutation } from '~/data-provider';
|
||||
import { useClearConversationsMutation } from '@librechat/data-provider';
|
||||
import store from '~/store';
|
||||
|
||||
const ClearConvos = ({ open, onOpenChange }) => {
|
||||
|
|
@ -32,7 +32,9 @@ const ClearConvos = ({ open, onOpenChange }) => {
|
|||
<DialogTemplate
|
||||
title="Clear conversations"
|
||||
description="Are you sure you want to clear all conversations? This is irreversible."
|
||||
leftButtons={<ClearChatsButton showText={false} confirmClear={confirmClear} onClick={clearConvos} />}
|
||||
leftButtons={
|
||||
<ClearChatsButton showText={false} confirmClear={confirmClear} onClick={clearConvos} />
|
||||
}
|
||||
/>
|
||||
</Dialog>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { General } from './SettingsTabs/';
|
|||
import { CogIcon } from '~/components/svg';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { cn } from '~/utils/';
|
||||
import { useClearConversationsMutation } from '~/data-provider';
|
||||
import { useClearConversationsMutation } from '@librechat/data-provider';
|
||||
import store from '~/store';
|
||||
|
||||
export default function Settings({ open, onOpenChange }) {
|
||||
|
|
|
|||
|
|
@ -2,9 +2,15 @@ import * as Tabs from '@radix-ui/react-tabs';
|
|||
import { CheckIcon } from 'lucide-react';
|
||||
import { ThemeContext } from '~/hooks/ThemeContext';
|
||||
import React, { useState, useContext, useCallback } from 'react';
|
||||
import { useClearConversationsMutation } from '~/data-provider';
|
||||
import { useClearConversationsMutation } from '@librechat/data-provider';
|
||||
|
||||
export const ThemeSelector = ({ theme, onChange }: { theme: string, onChange: (value: string) => void }) => (
|
||||
export const ThemeSelector = ({
|
||||
theme,
|
||||
onChange
|
||||
}: {
|
||||
theme: string;
|
||||
onChange: (value: string) => void;
|
||||
}) => (
|
||||
<div className="flex items-center justify-between">
|
||||
<div>Theme</div>
|
||||
<select
|
||||
|
|
@ -19,7 +25,15 @@ export const ThemeSelector = ({ theme, onChange }: { theme: string, onChange: (v
|
|||
</div>
|
||||
);
|
||||
|
||||
export const ClearChatsButton = ({ confirmClear, showText = true, onClick }: { confirmClear: boolean, showText: boolean, onClick: () => void }) => (
|
||||
export const ClearChatsButton = ({
|
||||
confirmClear,
|
||||
showText = true,
|
||||
onClick
|
||||
}: {
|
||||
confirmClear: boolean;
|
||||
showText: boolean;
|
||||
onClick: () => void;
|
||||
}) => (
|
||||
<div className="flex items-center justify-between">
|
||||
{showText && <div>Clear all chats</div>}
|
||||
<button
|
||||
|
|
@ -45,7 +59,7 @@ function General() {
|
|||
const { theme, setTheme } = useContext(ThemeContext);
|
||||
const clearConvosMutation = useClearConversationsMutation();
|
||||
const [confirmClear, setConfirmClear] = useState(false);
|
||||
|
||||
|
||||
const clearConvos = useCallback(() => {
|
||||
if (confirmClear) {
|
||||
console.log('Clearing conversations...');
|
||||
|
|
@ -56,18 +70,21 @@ function General() {
|
|||
}
|
||||
}, [confirmClear, clearConvosMutation]);
|
||||
|
||||
const changeTheme = useCallback((value: string) => {
|
||||
setTheme(value);
|
||||
}, [setTheme]);
|
||||
const changeTheme = useCallback(
|
||||
(value: string) => {
|
||||
setTheme(value);
|
||||
},
|
||||
[setTheme]
|
||||
);
|
||||
|
||||
return (
|
||||
<Tabs.Content value="general" role="tabpanel" className="w-full md:min-h-[300px]" >
|
||||
<Tabs.Content value="general" role="tabpanel" className="w-full md:min-h-[300px]">
|
||||
<div className="flex flex-col gap-3 text-sm text-gray-600 dark:text-gray-300">
|
||||
<div className="border-b pb-3 last-of-type:border-b-0 dark:border-gray-700">
|
||||
<ThemeSelector theme={theme} onChange={changeTheme} />
|
||||
</div>
|
||||
<div className="border-b pb-3 last-of-type:border-b-0 dark:border-gray-700">
|
||||
<ClearChatsButton confirmClear={confirmClear} onClick={clearConvos} showText={true}/>
|
||||
<ClearChatsButton confirmClear={confirmClear} onClick={clearConvos} showText={true} />
|
||||
</div>
|
||||
</div>
|
||||
</Tabs.Content>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* eslint-disable react-hooks/exhaustive-deps */
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useGetConversationsQuery, useSearchQuery } from '~/data-provider';
|
||||
import { useGetConversationsQuery, useSearchQuery } from '@librechat/data-provider';
|
||||
import { useRecoilValue, useSetRecoilState } from 'recoil';
|
||||
|
||||
import Conversations from '../Conversations';
|
||||
|
|
@ -9,7 +9,6 @@ import NewChat from './NewChat';
|
|||
import Pages from '../Conversations/Pages';
|
||||
import Panel from '../svg/Panel';
|
||||
import Spinner from '../svg/Spinner';
|
||||
// import { ThemeContext } from '~/hooks/ThemeContext';
|
||||
import { cn } from '~/utils/';
|
||||
import store from '~/store';
|
||||
import { useAuthContext } from '~/hooks/AuthContext';
|
||||
|
|
@ -38,7 +37,6 @@ import useDebounce from '~/hooks/useDebounce';
|
|||
export default function Nav({ navVisible, setNavVisible }) {
|
||||
const [isHovering, setIsHovering] = useState(false);
|
||||
const { isAuthenticated } = useAuthContext();
|
||||
// const { theme, } = useContext(ThemeContext);
|
||||
const containerRef = useRef(null);
|
||||
const scrollPositionRef = useRef(null);
|
||||
|
||||
|
|
@ -159,7 +157,8 @@ export default function Nav({ navVisible, setNavVisible }) {
|
|||
|
||||
const isMobile = () => {
|
||||
const userAgent = typeof window.navigator === 'undefined' ? '' : navigator.userAgent;
|
||||
const mobileRegex = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i;
|
||||
const mobileRegex =
|
||||
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i;
|
||||
return mobileRegex.test(userAgent);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue