mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 02:10:15 +01:00
🚀 feat: Banner (#3952)
* feat: Add banner schema and model * feat: Add optional JwtAuth To handle the conditional logic with and without authentication within the model. * feat: Add an endpoint to retrieve a banner * feat: Add implementation for client to use banner and access API * feat: Display a banner on UI * feat: Script for updating and deleting banners * style: Update banner style * fix: Adjust the height when the banner is displayed * fix: failed specs
This commit is contained in:
parent
07e5531b5b
commit
aea01f0bc5
26 changed files with 453 additions and 4 deletions
|
|
@ -3,6 +3,7 @@ import { BlinkAnimation } from './BlinkAnimation';
|
|||
import { TStartupConfig } from 'librechat-data-provider';
|
||||
import SocialLoginRender from './SocialLoginRender';
|
||||
import { ThemeSelector } from '~/components/ui';
|
||||
import { Banner } from '../Banners';
|
||||
import Footer from './Footer';
|
||||
|
||||
const ErrorRender = ({ children }: { children: React.ReactNode }) => (
|
||||
|
|
@ -56,6 +57,7 @@ function AuthLayout({
|
|||
|
||||
return (
|
||||
<div className="relative flex min-h-screen flex-col bg-white dark:bg-gray-900">
|
||||
<Banner />
|
||||
<BlinkAnimation active={isFetching}>
|
||||
<div className="mt-6 h-10 w-full bg-cover">
|
||||
<img src="/assets/logo.svg" className="h-full w-full object-contain" alt="Logo" />
|
||||
|
|
|
|||
|
|
@ -54,6 +54,11 @@ const setup = ({
|
|||
},
|
||||
},
|
||||
useGetStartupConfigReturnValue = mockStartupConfig,
|
||||
useGetBannerQueryReturnValue = {
|
||||
isLoading: false,
|
||||
isError: false,
|
||||
data: {},
|
||||
},
|
||||
} = {}) => {
|
||||
const mockUseLoginUser = jest
|
||||
.spyOn(mockDataProvider, 'useLoginUserMutation')
|
||||
|
|
@ -71,6 +76,10 @@ const setup = ({
|
|||
.spyOn(mockDataProvider, 'useRefreshTokenMutation')
|
||||
//@ts-ignore - we don't need all parameters of the QueryObserverSuccessResult
|
||||
.mockReturnValue(useRefreshTokenMutationReturnValue);
|
||||
const mockUseGetBannerQuery = jest
|
||||
.spyOn(mockDataProvider, 'useGetBannerQuery')
|
||||
//@ts-ignore - we don't need all parameters of the QueryObserverSuccessResult
|
||||
.mockReturnValue(useGetBannerQueryReturnValue);
|
||||
const mockUseOutletContext = jest.spyOn(reactRouter, 'useOutletContext').mockReturnValue({
|
||||
startupConfig: useGetStartupConfigReturnValue.data,
|
||||
});
|
||||
|
|
@ -93,6 +102,7 @@ const setup = ({
|
|||
mockUseOutletContext,
|
||||
mockUseGetStartupConfig,
|
||||
mockUseRefreshTokenMutation,
|
||||
mockUseGetBannerQuery,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -59,6 +59,11 @@ const setup = ({
|
|||
isError: false,
|
||||
data: mockStartupConfig,
|
||||
},
|
||||
useGetBannerQueryReturnValue = {
|
||||
isLoading: false,
|
||||
isError: false,
|
||||
data: {},
|
||||
},
|
||||
} = {}) => {
|
||||
const mockUseLoginUser = jest
|
||||
.spyOn(mockDataProvider, 'useLoginUserMutation')
|
||||
|
|
@ -76,11 +81,16 @@ const setup = ({
|
|||
.spyOn(mockDataProvider, 'useRefreshTokenMutation')
|
||||
//@ts-ignore - we don't need all parameters of the QueryObserverSuccessResult
|
||||
.mockReturnValue(useRefreshTokenMutationReturnValue);
|
||||
const mockUseGetBannerQuery = jest
|
||||
.spyOn(mockDataProvider, 'useGetBannerQuery')
|
||||
//@ts-ignore - we don't need all parameters of the QueryObserverSuccessResult
|
||||
.mockReturnValue(useGetBannerQueryReturnValue);
|
||||
return {
|
||||
mockUseLoginUser,
|
||||
mockUseGetUserQuery,
|
||||
mockUseGetStartupConfig,
|
||||
mockUseRefreshTokenMutation,
|
||||
mockUseGetBannerQuery,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,11 @@ const setup = ({
|
|||
user: {},
|
||||
},
|
||||
},
|
||||
useGetBannerQueryReturnValue = {
|
||||
isLoading: false,
|
||||
isError: false,
|
||||
data: {},
|
||||
},
|
||||
useGetStartupConfigReturnValue = mockStartupConfig,
|
||||
} = {}) => {
|
||||
const mockUseRegisterUserMutation = jest
|
||||
|
|
@ -71,6 +76,10 @@ const setup = ({
|
|||
const mockUseOutletContext = jest.spyOn(reactRouter, 'useOutletContext').mockReturnValue({
|
||||
startupConfig: useGetStartupConfigReturnValue.data,
|
||||
});
|
||||
const mockUseGetBannerQuery = jest
|
||||
.spyOn(mockDataProvider, 'useGetBannerQuery')
|
||||
//@ts-ignore - we don't need all parameters of the QueryObserverSuccessResult
|
||||
.mockReturnValue(useGetBannerQueryReturnValue);
|
||||
const renderResult = render(
|
||||
<AuthLayout
|
||||
startupConfig={useGetStartupConfigReturnValue.data as TStartupConfig}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue