diff --git a/frontend/src/components/Auth/Auth.tsx b/frontend/src/components/Auth/Auth.tsx index aa4ac0511..44c67ab02 100644 --- a/frontend/src/components/Auth/Auth.tsx +++ b/frontend/src/components/Auth/Auth.tsx @@ -1,6 +1,8 @@ -import React from 'react'; + +import React, { useEffect } from 'react'; import { AppState, Auth0Provider, useAuth0 } from '@auth0/auth0-react'; -import { Navigate, useNavigate } from 'react-router'; +import { useNavigate } from 'react-router'; + const domain = process.env.VITE_AUTH0_DOMAIN; const clientId = process.env.VITE_AUTH0_CLIENT_ID; const Auth0ProviderWithHistory: React.FC<{ children: React.ReactNode }> = ({ children }) => { @@ -24,13 +26,18 @@ const Auth0ProviderWithHistory: React.FC<{ children: React.ReactNode }> = ({ chi }; export const AuthenticationGuard: React.FC<{ component: React.ComponentType }> = ({ component }) => { - const { isAuthenticated } = useAuth0(); + + const { isAuthenticated, isLoading } = useAuth0(); const Component = component; + const navigate = useNavigate(); + useEffect(() => { + if (!isLoading && !isAuthenticated) { + localStorage.setItem('isReadOnlyMode', 'true'); + navigate('/readonly', { replace: true }); + } + }, [isLoading, isAuthenticated]); + - if (!isAuthenticated) { - localStorage.setItem('isReadOnlyMode', 'true'); - return ; - } return ; }; diff --git a/frontend/src/components/ChatBot/ChunkInfo.tsx b/frontend/src/components/ChatBot/ChunkInfo.tsx index 44daf0516..6c6756549 100644 --- a/frontend/src/components/ChatBot/ChunkInfo.tsx +++ b/frontend/src/components/ChatBot/ChunkInfo.tsx @@ -47,7 +47,7 @@ const ChunkInfo: FC = ({ loading, chunks, mode }) => {
  • {chunk?.page_number ? ( <> -
    +
    <> = ({ loading, chunks, mode }) => { ) : chunk?.url && chunk?.start_time ? ( <> -
    +
    = ({ loading, chunks, mode }) => { mode !== chatModeLables['entity search+vector'] && mode !== chatModeLables.graph && ( <> - + Similarity Score: {chunk?.score} = ({ loading, chunks, mode }) => { - - {/*
    */} - - {/* handleChunkClick(chunk.element_id, 'Chunk'), - }} - > - {'View Graph'} - */} - {/*
    */} )} ) : chunk?.url && new URL(chunk.url).host === 'wikipedia.org' ? ( <> -
    +
    {chunk?.fileName}
    @@ -151,22 +138,13 @@ const ChunkInfo: FC = ({ loading, chunks, mode }) => { -
    - {/* handleChunkClick(chunk.element_id, 'Chunk'), - }} - > - {'View Graph'} - */} -
    +
    )} ) : chunk?.url && new URL(chunk.url).host === 'storage.googleapis.com' ? ( <> -
    +
    {chunk?.fileName}
    @@ -186,23 +164,12 @@ const ChunkInfo: FC = ({ loading, chunks, mode }) => { - - {/*
    - handleChunkClick(chunk.element_id, 'Chunk'), - }} - > - {'View Graph'} - -
    */} )} ) : chunk?.url && chunk?.url.startsWith('s3://') ? ( <> -
    +
    {chunk?.fileName}
    @@ -222,16 +189,6 @@ const ChunkInfo: FC = ({ loading, chunks, mode }) => { -
    - {/* handleChunkClick(chunk.element_id, 'Chunk'), - }} - > - {'View Graph'} - */} -
    )} @@ -239,7 +196,7 @@ const ChunkInfo: FC = ({ loading, chunks, mode }) => { !chunk?.url.startsWith('s3://') && !isAllowedHost(chunk?.url, ['storage.googleapis.com', 'wikipedia.org', 'youtube.com']) ? ( <> -
    +
    {chunk?.url} @@ -261,22 +218,12 @@ const ChunkInfo: FC = ({ loading, chunks, mode }) => { -
    - {/* handleChunkClick(chunk.element_id, 'Chunk'), - }} - > - {'View Graph'} - */} -
    )} ) : ( <> -
    +
    {chunk.fileSource === 'local file' ? ( @@ -306,19 +253,7 @@ const ChunkInfo: FC = ({ loading, chunks, mode }) => { - <> - {/*
    */} - - {/* handleChunkClick(chunk.element_id, 'Chunk'), - }} - > - {'View Graph'} - */} - {/*
    */} - + <>
    )} diff --git a/frontend/src/components/ChatBot/SourcesInfo.tsx b/frontend/src/components/ChatBot/SourcesInfo.tsx index 99c9ee2f9..6016b511b 100644 --- a/frontend/src/components/ChatBot/SourcesInfo.tsx +++ b/frontend/src/components/ChatBot/SourcesInfo.tsx @@ -37,8 +37,8 @@ const SourcesInfo: FC = ({ loading, mode, chunks, sources }) => { .map((c) => ({ fileName: c.fileName, fileSource: c.fileSource })) .map((s, index) => { return ( -
  • -
    +
  • +
    {s.fileSource === 'local file' ? ( ) : ( @@ -59,11 +59,11 @@ const SourcesInfo: FC = ({ loading, mode, chunks, sources }) => {
      {sources.map((link, index) => { return ( -
    • +
    • {link?.startsWith('http') || link?.startsWith('https') ? ( <> {isAllowedHost(link, ['wikipedia.org']) && ( -
      +
      Wikipedia Logo @@ -78,7 +78,7 @@ const SourcesInfo: FC = ({ loading, mode, chunks, sources }) => {
      )} {isAllowedHost(link, ['storage.googleapis.com']) && ( -
      +
      Google Cloud Storage Logo = ({ loading, mode, chunks, sources }) => { )} {youtubeLinkValidation(link) && ( <> -
      +
      @@ -107,7 +107,7 @@ const SourcesInfo: FC = ({ loading, mode, chunks, sources }) => { )} {!link?.startsWith('s3://') && !isAllowedHost(link, ['storage.googleapis.com', 'wikipedia.org', 'www.youtube.com']) && ( -
      +
      {link} @@ -116,7 +116,7 @@ const SourcesInfo: FC = ({ loading, mode, chunks, sources }) => { )} ) : link?.startsWith('s3://') ? ( -
      +
      S3 Logo = ({ loading, mode, chunks, sources }) => {
      ) : ( -
      +
      = ({ ) : ( - + { + loginWithRedirect(); + }, + }} + > {filesData.length === 0 - ? `It seems like you haven't ingested any data yet Please log in and connect to your database to proceed.` - : 'You must be logged in to process this data. Please log in and connect to your database to proceed.'} + ? `It seems like you haven't ingested any data yet Please log in to the main application.` + : 'You must be logged in to process this data. Please log in to the main application'}
      loginWithRedirect()}> diff --git a/frontend/src/components/Layout/Header.tsx b/frontend/src/components/Layout/Header.tsx index 91719f89c..0599853f7 100644 --- a/frontend/src/components/Layout/Header.tsx +++ b/frontend/src/components/Layout/Header.tsx @@ -83,7 +83,7 @@ const Header: React.FC = ({ chatOnly, deleteOnClick, setOpenConnecti id='navigation' aria-label='main navigation' > -
      +