|
1 | | -import React, { useEffect, useState } from 'react'; |
2 | | -import { Dialog, SideNavigation, Tip, useMediaQuery } from '@neo4j-ndl/react'; |
| 1 | +import React, { useEffect, useRef, useState } from 'react'; |
| 2 | +import { Dialog, SideNavigation, TextLink, Tip, useMediaQuery } from '@neo4j-ndl/react'; |
3 | 3 | import { |
4 | 4 | ArrowRightIconOutline, |
5 | 5 | ArrowLeftIconOutline, |
6 | 6 | TrashIconOutline, |
7 | 7 | ArrowsPointingOutIconOutline, |
8 | 8 | ChatBubbleOvalLeftEllipsisIconOutline, |
9 | 9 | CloudArrowUpIconSolid, |
| 10 | + ArrowDownTrayIconOutline, |
10 | 11 | } from '@neo4j-ndl/react/icons'; |
11 | 12 | import { SideNavProps } from '../../types'; |
12 | 13 | import Chatbot from '../ChatBot/Chatbot'; |
13 | 14 | import { createPortal } from 'react-dom'; |
14 | 15 | import { useMessageContext } from '../../context/UserMessages'; |
15 | | -import { getIsLoading } from '../../utils/Utils'; |
| 16 | +import { downloadClickHandler, getIsLoading } from '../../utils/Utils'; |
16 | 17 | import ExpandedChatButtonContainer from '../ChatBot/ExpandedChatButtonContainer'; |
17 | 18 | import { APP_SOURCES, tooltips } from '../../utils/Constants'; |
18 | 19 | import ChatModeToggle from '../ChatBot/ChatModeToggle'; |
@@ -46,6 +47,7 @@ const SideNav: React.FC<SideNavProps> = ({ |
46 | 47 | const [showChatMode, setshowChatMode] = useState<boolean>(false); |
47 | 48 | const largedesktops = useMediaQuery(`(min-width:1440px )`); |
48 | 49 | const { connectionStatus, isReadOnlyUser } = useCredentials(); |
| 50 | + const downloadLinkRef = useRef<HTMLAnchorElement>(null); |
49 | 51 |
|
50 | 52 | const date = new Date(); |
51 | 53 | useEffect(() => { |
@@ -93,6 +95,7 @@ const SideNav: React.FC<SideNavProps> = ({ |
93 | 95 | toggleDrawer(); |
94 | 96 | } |
95 | 97 | }; |
| 98 | + |
96 | 99 | return ( |
97 | 100 | <div style={{ height: 'calc(100vh - 58px)', minHeight: '200px', display: 'flex' }}> |
98 | 101 | <SideNavigation iconMenu={true} expanded={false} position={position}> |
@@ -189,6 +192,30 @@ const SideNav: React.FC<SideNavProps> = ({ |
189 | 192 | } |
190 | 193 | /> |
191 | 194 | </Tip> |
| 195 | + <Tip allowedPlacements={['left']}> |
| 196 | + <SideNavigation.Item |
| 197 | + onClick={() => { |
| 198 | + downloadClickHandler( |
| 199 | + { conversation: messages }, |
| 200 | + downloadLinkRef, |
| 201 | + 'graph-builder-conversation.json' |
| 202 | + ); |
| 203 | + }} |
| 204 | + icon={ |
| 205 | + <> |
| 206 | + <Tip.Trigger> |
| 207 | + <ArrowDownTrayIconOutline className='n-size-token-7' /> |
| 208 | + </Tip.Trigger> |
| 209 | + <Tip.Content> |
| 210 | + Download Conversation |
| 211 | + <TextLink ref={downloadLinkRef} className='!hidden'> |
| 212 | + "" |
| 213 | + </TextLink> |
| 214 | + </Tip.Content> |
| 215 | + </> |
| 216 | + } |
| 217 | + /> |
| 218 | + </Tip> |
192 | 219 | {!isChatModalOpen && ( |
193 | 220 | <SideNavigation.Item |
194 | 221 | onClick={(e) => { |
|
0 commit comments