Skip to content

Commit b04ad67

Browse files
kartikpersistentpraveshkumar1988
authored andcommitted
format and lint fixes
1 parent c4ee4b3 commit b04ad67

File tree

17 files changed

+151
-126
lines changed

17 files changed

+151
-126
lines changed

frontend/src/HOC/CustomModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const CustomModal: React.FC<CustomModalProps> = ({
66
open,
77
onClose,
88
children,
9-
submitLabel = buttonCaptions.submit,
9+
submitLabel = buttonCaptions.submit,
1010
submitHandler,
1111
statusMessage,
1212
status,

frontend/src/components/Chatbot.tsx

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import React, { useEffect, useRef, useState } from 'react';
22
import { Button, Widget, Typography, Avatar, TextInput, IconButton, Modal, useCopyToClipboard } from '@neo4j-ndl/react';
3-
import { InformationCircleIconOutline, XMarkIconOutline, ClipboardDocumentIconOutline, SpeakerWaveIconOutline, SpeakerXMarkIconOutline } from '@neo4j-ndl/react/icons';
3+
import {
4+
InformationCircleIconOutline,
5+
XMarkIconOutline,
6+
ClipboardDocumentIconOutline,
7+
SpeakerWaveIconOutline,
8+
SpeakerXMarkIconOutline,
9+
} from '@neo4j-ndl/react/icons';
410
import ChatBotAvatar from '../assets/images/chatbot-ai.png';
511
import { ChatbotProps, Source, UserCredentials } from '../types';
612
import { useCredentials } from '../context/UserCredentials';
@@ -33,9 +39,7 @@ const Chatbot: React.FC<ChatbotProps> = (props) => {
3339
const [value, copy] = useCopyToClipboard();
3440
const { speak, cancel, supported } = useSpeechSynthesis({
3541
onEnd: () => {
36-
setListMessages((msgs) =>
37-
msgs.map((msg) => ({ ...msg, speaking: false }))
38-
);
42+
setListMessages((msgs) => msgs.map((msg) => ({ ...msg, speaking: false })));
3943
},
4044
});
4145

@@ -58,7 +62,7 @@ const Chatbot: React.FC<ChatbotProps> = (props) => {
5862
total_tokens?: number;
5963
response_time?: number;
6064
speaking?: boolean;
61-
copying?: boolean
65+
copying?: boolean;
6266
},
6367
index = 0
6468
) => {
@@ -201,24 +205,16 @@ const Chatbot: React.FC<ChatbotProps> = (props) => {
201205

202206
const handleCancel = (id: number) => {
203207
cancel();
204-
setListMessages((msgs) =>
205-
msgs.map((msg) =>
206-
(msg.id
207-
=== id ? { ...msg, speaking: false } : msg)
208-
)
209-
);
210-
}
208+
setListMessages((msgs) => msgs.map((msg) => (msg.id === id ? { ...msg, speaking: false } : msg)));
209+
};
211210

212211
const handleSpeak = (chatMessage: any, id: number) => {
213212
speak({ text: chatMessage });
214213
setListMessages((msgs) => {
215-
const messageWithSpeaking = msgs.find(msg => msg.speaking);
216-
return msgs.map((msg) =>
217-
(msg.id
218-
=== id && !messageWithSpeaking ? { ...msg, speaking: true } : msg)
219-
);
214+
const messageWithSpeaking = msgs.find((msg) => msg.speaking);
215+
return msgs.map((msg) => (msg.id === id && !messageWithSpeaking ? { ...msg, speaking: true } : msg));
220216
});
221-
}
217+
};
222218

223219
return (
224220
<div className='n-bg-palette-neutral-bg-weak flex flex-col justify-between min-h-full max-h-full overflow-hidden'>
@@ -261,14 +257,16 @@ const Chatbot: React.FC<ChatbotProps> = (props) => {
261257
<Widget
262258
header=''
263259
isElevated={true}
264-
className={`p-4 self-start ${isFullScreen ? 'max-w-[55%]' : ''} ${chat.user === 'chatbot' ? 'n-bg-palette-neutral-bg-strong' : 'n-bg-palette-primary-bg-weak'
265-
} `}
260+
className={`p-4 self-start ${isFullScreen ? 'max-w-[55%]' : ''} ${
261+
chat.user === 'chatbot' ? 'n-bg-palette-neutral-bg-strong' : 'n-bg-palette-primary-bg-weak'
262+
} `}
266263
>
267264
<div
268-
className={`${listMessages[index].isLoading && index === listMessages.length - 1 && chat.user == 'chatbot'
269-
? 'loader'
270-
: ''
271-
}`}
265+
className={`${
266+
listMessages[index].isLoading && index === listMessages.length - 1 && chat.user == 'chatbot'
267+
? 'loader'
268+
: ''
269+
}`}
272270
>
273271
<ReactMarkdown>{chat.message}</ReactMarkdown>
274272
</div>
@@ -308,19 +306,23 @@ const Chatbot: React.FC<ChatbotProps> = (props) => {
308306
<ClipboardDocumentIconOutline className='w-4 h-4 inline-block' />
309307
</IconButtonWithToolTip>
310308
{copyMessageId === chat.id && (
311-
<><span className='pt-4 text-xs'>Copied!</span>
312-
<span style={{display:'none'}}>{value}</span></>
309+
<>
310+
<span className='pt-4 text-xs'>Copied!</span>
311+
<span style={{ display: 'none' }}>{value}</span>
312+
</>
313313
)}
314-
{supported && chat.speaking ? <IconButtonWithToolTip
315-
placement='top'
316-
label='text to speak'
317-
clean
318-
onClick={() => handleCancel(chat.id)}
319-
text={chat.speaking ? tooltips.stopSpeaking : tooltips.textTospeech}
320-
disabled={chat.isTyping || chat.isLoading}
321-
>
322-
<SpeakerXMarkIconOutline className="w-4 h-4 inline-block" />
323-
</IconButtonWithToolTip> :
314+
{supported && chat.speaking ? (
315+
<IconButtonWithToolTip
316+
placement='top'
317+
label='text to speak'
318+
clean
319+
onClick={() => handleCancel(chat.id)}
320+
text={chat.speaking ? tooltips.stopSpeaking : tooltips.textTospeech}
321+
disabled={chat.isTyping || chat.isLoading}
322+
>
323+
<SpeakerXMarkIconOutline className='w-4 h-4 inline-block' />
324+
</IconButtonWithToolTip>
325+
) : (
324326
<IconButtonWithToolTip
325327
placement='top'
326328
clean
@@ -329,18 +331,18 @@ const Chatbot: React.FC<ChatbotProps> = (props) => {
329331
disabled={chat.isTyping || chat.isLoading}
330332
label='speech'
331333
>
332-
<SpeakerWaveIconOutline className="w-4 h-4 inline-block" />
334+
<SpeakerWaveIconOutline className='w-4 h-4 inline-block' />
333335
</IconButtonWithToolTip>
334-
}
336+
)}
335337
</div>
336338
)}
337339
</div>
338340
</Widget>
339341
</div>
340342
))}
341343
</div>
342-
</Widget >
343-
</div >
344+
</Widget>
345+
</div>
344346
<div className='n-bg-palette-neutral-bg-weak flex gap-2.5 bottom-0 p-2.5 w-full'>
345347
<form onSubmit={handleSubmit} className='flex gap-2.5 w-full'>
346348
<TextInput
@@ -383,7 +385,7 @@ const Chatbot: React.FC<ChatbotProps> = (props) => {
383385
total_tokens={tokensUsed}
384386
/>
385387
</Modal>
386-
</div >
388+
</div>
387389
);
388390
};
389391

frontend/src/components/ConnectionModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ export default function ConnectionModal({ open, setOpenConnection, setConnection
276276
</div>
277277
</div>
278278
<Button loading={isLoading} disabled={isDisabled} onClick={() => submitConnection()}>
279-
{buttonCaptions.connect}
279+
{buttonCaptions.connect}
280280
</Button>
281281
</Dialog.Content>
282282
</Dialog>

frontend/src/components/Content.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ const Content: React.FC<ContentProps> = ({ isLeftExpanded, isRightExpanded }) =>
425425

426426
{!connectionStatus ? (
427427
<Button className='mr-2.5' onClick={() => setOpenConnection(true)}>
428-
{buttonCaptions.connectToNeo4j}
428+
{buttonCaptions.connectToNeo4j}
429429
</Button>
430430
) : (
431431
<Button className='mr-2.5' onClick={disconnect}>
@@ -516,7 +516,8 @@ const Content: React.FC<ContentProps> = ({ isLeftExpanded, isRightExpanded }) =>
516516
disabled={disableCheck}
517517
className='mr-0.5'
518518
>
519-
{buttonCaptions.generateGraph} {selectedfileslength && !disableCheck && newFilecheck ? `(${newFilecheck})` : ''}
519+
{buttonCaptions.generateGraph}{' '}
520+
{selectedfileslength && !disableCheck && newFilecheck ? `(${newFilecheck})` : ''}
520521
</ButtonWithToolTip>
521522
<ButtonWithToolTip
522523
text={tooltips.showGraph}
@@ -536,7 +537,7 @@ const Content: React.FC<ContentProps> = ({ isLeftExpanded, isRightExpanded }) =>
536537
className='ml-0.5'
537538
label='Open Graph with Bloom'
538539
>
539-
{buttonCaptions.exploreGraphWithBloom}
540+
{buttonCaptions.exploreGraphWithBloom}
540541
</ButtonWithToolTip>
541542
<ButtonWithToolTip
542543
text={
@@ -548,7 +549,8 @@ const Content: React.FC<ContentProps> = ({ isLeftExpanded, isRightExpanded }) =>
548549
className='ml-0.5'
549550
label='Delete Files'
550551
>
551-
{buttonCaptions.deleteFiles}{selectedfileslength > 0 && `(${selectedfileslength})`}
552+
{buttonCaptions.deleteFiles}
553+
{selectedfileslength > 0 && `(${selectedfileslength})`}
552554
</ButtonWithToolTip>
553555
</Flex>
554556
</Flex>

frontend/src/components/GCSButton.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { DataComponentProps } from '../types';
33
import { buttonCaptions } from '../utils/Constants';
44
import CustomButton from './CustomButton';
55
const GCSButton: React.FC<DataComponentProps> = ({ openModal }) => {
6-
return <CustomButton title={buttonCaptions.gcs} openModal={openModal} logo={gcslogo} wrapperclassName='' className='' />;
6+
return (
7+
<CustomButton title={buttonCaptions.gcs} openModal={openModal} logo={gcslogo} wrapperclassName='' className='' />
8+
);
79
};
810
export default GCSButton;

frontend/src/components/GCSModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ const GCSModal: React.FC<S3ModalProps> = ({ hideModal, open }) => {
159159
setStatus={setStatus}
160160
submitHandler={submitHandler}
161161
status={status}
162-
submitLabel= {buttonCaptions.submit}
162+
submitLabel={buttonCaptions.submit}
163163
>
164164
<div className='w-full inline-block'>
165165
<TextInput

frontend/src/components/InfoModal.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,17 @@ const InfoModal: React.FC<chatInfoMessage> = ({ sources, model, total_tokens, re
8383
const urlObj = new URL(url);
8484
let timeInSeconds;
8585
if (startTime.includes('m')) {
86-
const parts = startTime.split('m');
87-
const minutes = parseInt(parts[0], 10);
88-
const seconds = parts[1] ? parseInt(parts[1].replace('s', ''), 10) : 0;
89-
timeInSeconds = (minutes * 60) + seconds;
86+
const parts = startTime.split('m');
87+
const minutes = parseInt(parts[0], 10);
88+
const seconds = parts[1] ? parseInt(parts[1].replace('s', ''), 10) : 0;
89+
timeInSeconds = minutes * 60 + seconds;
9090
} else {
91-
timeInSeconds = parseInt(startTime, 10);
91+
timeInSeconds = parseInt(startTime, 10);
9292
}
9393
urlObj.searchParams.set('t', timeInSeconds.toString());
9494
console.log('url', urlObj.toString());
9595
return urlObj.toString();
96-
};
96+
};
9797

9898
return (
9999
<Box className='n-bg-palette-neutral-bg-weak p-4'>
@@ -241,14 +241,17 @@ const InfoModal: React.FC<chatInfoMessage> = ({ sources, model, total_tokens, re
241241
</Typography>
242242
) : chunk.start_time ? (
243243
<div>
244-
<Typography variant='subheading-small'>
245-
File: {chunk.fileName}
246-
</Typography>
247-
<Typography as="a"
244+
<Typography variant='subheading-small'>File: {chunk.fileName}</Typography>
245+
<Typography
246+
as='a'
248247
href={generateYouTubeLink('https://www.youtube.com/watch?v=1bUy-1hGZpI', chunk.start_time)}
249248
variant='subheading-small'
250-
target='_blank' rel='noopener noreferrer'
251-
> Time {chunk.start_time}</Typography>
249+
target='_blank'
250+
rel='noopener noreferrer'
251+
>
252+
{' '}
253+
Time {chunk.start_time}
254+
</Typography>
252255
</div>
253256
) : (
254257
<></>

frontend/src/components/Layout/SideNav.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
ChatBubbleOvalLeftEllipsisIconOutline,
99
CloudArrowUpIconSolid,
1010
} from '@neo4j-ndl/react/icons';
11-
import { } from '@neo4j-ndl/react/icons';
11+
import {} from '@neo4j-ndl/react/icons';
1212
import { SideNavProps } from '../../types';
1313
import Chatbot from '../Chatbot';
1414
import { createPortal } from 'react-dom';
@@ -79,7 +79,6 @@ const SideNav: React.FC<SideNavProps> = ({
7979
)
8080
) : position === 'left' ? (
8181
<>
82-
8382
<Tip allowedPlacements={['right']}>
8483
<Tip.Trigger>
8584
<CloudArrowUpIconSolid />
@@ -96,7 +95,6 @@ const SideNav: React.FC<SideNavProps> = ({
9695
<Tip.Content>{tooltips.chat}</Tip.Content>
9796
</Tip>
9897
</>
99-
10098
)
10199
}
102100
/>

frontend/src/components/S3Bucket.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import CustomButton from './CustomButton';
44
import { buttonCaptions } from '../utils/Constants';
55

66
const S3Component: React.FC<DataComponentProps> = ({ openModal }) => {
7-
return <CustomButton title={buttonCaptions.amazon}openModal={openModal} logo={s3logo} wrapperclassName='' className='' />;
7+
return (
8+
<CustomButton title={buttonCaptions.amazon} openModal={openModal} logo={s3logo} wrapperclassName='' className='' />
9+
);
810
};
911

1012
export default S3Component;

frontend/src/components/S3Modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ const S3Modal: React.FC<S3ModalProps> = ({ hideModal, open }) => {
136136
submitHandler={() => submitHandler(bucketUrl)}
137137
status={status}
138138
setStatus={setStatus}
139-
submitLabel= {buttonCaptions.submit}
139+
submitLabel={buttonCaptions.submit}
140140
>
141141
<div className='w-full inline-block'>
142142
<TextInput

0 commit comments

Comments
 (0)