diff --git a/src/apps/chat/AppChat.tsx b/src/apps/chat/AppChat.tsx index 99f365628..694555465 100644 --- a/src/apps/chat/AppChat.tsx +++ b/src/apps/chat/AppChat.tsx @@ -300,7 +300,9 @@ export function AppChat() { const handleConversationImportDialog = React.useCallback(() => setTradeConfig({ dir: 'import' }), []); - const handleConversationExport = React.useCallback((conversationId: DConversationId | null) => setTradeConfig({ dir: 'export', conversationId }), []); + const handleConversationExport = React.useCallback((conversationId: DConversationId | null, exportAll: boolean) => { + setTradeConfig({ dir: 'export', conversationId, exportAll }); + }, []); const handleConversationBranch = React.useCallback((conversationId: DConversationId, messageId: string | null): DConversationId | null => { showNextTitle.current = true; diff --git a/src/apps/chat/components/applayout/ChatDrawer.tsx b/src/apps/chat/components/applayout/ChatDrawer.tsx index a3b385f41..de4983473 100644 --- a/src/apps/chat/components/applayout/ChatDrawer.tsx +++ b/src/apps/chat/components/applayout/ChatDrawer.tsx @@ -4,8 +4,8 @@ import { shallow } from 'zustand/shallow'; import { Box, IconButton, ListDivider, ListItem, ListItemButton, ListItemDecorator, Tooltip } from '@mui/joy'; import AddIcon from '@mui/icons-material/Add'; import DeleteOutlineIcon from '@mui/icons-material/DeleteOutline'; -import FileDownloadIcon from '@mui/icons-material/FileDownload'; -import FileUploadIcon from '@mui/icons-material/FileUpload'; +import FileDownloadOutlinedIcon from '@mui/icons-material/FileDownloadOutlined'; +import FileUploadOutlinedIcon from '@mui/icons-material/FileUploadOutlined'; import FolderIcon from '@mui/icons-material/Folder'; import FolderOpenOutlinedIcon from '@mui/icons-material/FolderOpenOutlined'; import FolderOutlinedIcon from '@mui/icons-material/FolderOutlined'; @@ -87,7 +87,7 @@ function ChatDrawer(props: { disableNewButton: boolean, onConversationActivate: (conversationId: DConversationId) => void, onConversationDelete: (conversationId: DConversationId, bypassConfirmation: boolean) => void, - onConversationExportDialog: (conversationId: DConversationId | null) => void, + onConversationExportDialog: (conversationId: DConversationId | null, exportAll: boolean) => void, onConversationImportDialog: () => void, onConversationNew: () => void, onConversationsDeleteAll: () => void, @@ -300,15 +300,15 @@ function ChatDrawer(props: { - + Import {/**/} - props.onConversationExportDialog(props.activeConversationId)} sx={{ flex: 1 }}> + props.onConversationExportDialog(props.activeConversationId, true)} sx={{ flex: 1 }}> - + Export diff --git a/src/apps/chat/components/applayout/ChatDrawerItem.tsx b/src/apps/chat/components/applayout/ChatDrawerItem.tsx index e001d6da5..9f578335b 100644 --- a/src/apps/chat/components/applayout/ChatDrawerItem.tsx +++ b/src/apps/chat/components/applayout/ChatDrawerItem.tsx @@ -57,7 +57,7 @@ function ChatDrawerItem(props: { bottomBarBasis: number, onConversationActivate: (conversationId: DConversationId, closeMenu: boolean) => void, onConversationDelete: (conversationId: DConversationId) => void, - onConversationExport: (conversationId: DConversationId) => void, + onConversationExport: (conversationId: DConversationId, exportAll: boolean) => void, onConversationFolderChange: (folderChangeRequest: FolderChangeRequest) => void, }) { @@ -88,7 +88,7 @@ function ChatDrawerItem(props: { const handleConversationExport = React.useCallback((event: React.MouseEvent) => { event.stopPropagation(); - conversationId && onConversationExport(conversationId); + conversationId && onConversationExport(conversationId, false); }, [conversationId, onConversationExport]); @@ -277,7 +277,7 @@ function ChatDrawerItem(props: { - + diff --git a/src/modules/trade/ExportChats.tsx b/src/modules/trade/ExportChats.tsx index f5fe63c41..58c4ba8c6 100644 --- a/src/modules/trade/ExportChats.tsx +++ b/src/modules/trade/ExportChats.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; -import { Box, Button, Typography } from '@mui/joy'; +import { Box, Button, Grid, Typography } from '@mui/joy'; import DoneIcon from '@mui/icons-material/Done'; import FileDownloadIcon from '@mui/icons-material/FileDownload'; @@ -13,7 +13,11 @@ import { PublishExport } from './publish/PublishExport'; import { downloadAllConversationsJson, downloadConversation } from './trade.client'; -export type ExportConfig = { dir: 'export', conversationId: DConversationId | null }; +export type ExportConfig = { + dir: 'export', + conversationId: DConversationId | null, + exportAll: boolean, +}; /** @@ -29,6 +33,9 @@ export function ExportChats(props: { config: ExportConfig, onClose: () => void } // external state const enableSharing = backendCaps().hasDB; + // derived state + const { exportAll } = props.config; + // download chats @@ -61,57 +68,86 @@ export function ExportChats(props: { config: ExportConfig, onClose: () => void } return <> - + - - Share / Download current chat: - + {/* Current Chat */} + + - + {exportAll && ( + + Download or share this chat: + + )} - + - {enableSharing && ( - - )} + - + {enableSharing && ( + + )} + - {/**/} + {/*}*/} + {/* sx={{ minWidth: 240, justifyContent: 'space-between' }}*/} + {/*>*/} + {/* Share Copy · ShareGPT*/} + {/**/} - - Store / Transfer all chats: - - - + onClick={handleDownloadAllConversationsJSON} + > + Download All · JSON + + + + + )} + + ; } \ No newline at end of file diff --git a/src/modules/trade/ImportChats.tsx b/src/modules/trade/ImportChats.tsx index 961be7350..f31db0da9 100644 --- a/src/modules/trade/ImportChats.tsx +++ b/src/modules/trade/ImportChats.tsx @@ -146,23 +146,29 @@ export function ImportChats(props: { onConversationActivate: (conversationId: DC return <> - + + - Select where to import from + Select where to import from: - {!chatGptEdit && ( - )} + {/* [chatgpt] data & controls */} diff --git a/src/modules/trade/TradeModal.tsx b/src/modules/trade/TradeModal.tsx index 9f0046fd1..3b35ad55b 100644 --- a/src/modules/trade/TradeModal.tsx +++ b/src/modules/trade/TradeModal.tsx @@ -1,7 +1,5 @@ import * as React from 'react'; -import { Divider } from '@mui/joy'; - import { DConversationId } from '~/common/state/store-chats'; import { GoodModal } from '~/common/components/GoodModal'; @@ -12,11 +10,22 @@ export type TradeConfig = ImportConfig | ExportConfig; export function TradeModal(props: { config: TradeConfig, onConversationActivate: (conversationId: DConversationId) => void, onClose: () => void }) { return ( - {props.config.dir === 'import' ? 'Import ' : props.config.dir === 'export' ? 'Export ' : ''} conversations} open onClose={props.onClose}> - - {props.config.dir === 'import' && } - {props.config.dir === 'export' && } - + + {props.config.dir === 'import' ? 'Import ' : props.config.dir === 'export' ? 'Export ' : ''} {(props.config.dir === 'export' && !props.config.exportAll) ? 'conversation' : 'conversations'} + } + > + + {props.config.dir === 'import' && ( + + )} + + {props.config.dir === 'export' && ( + + )} + ); } \ No newline at end of file diff --git a/src/modules/trade/link/ChatLinkExport.tsx b/src/modules/trade/link/ChatLinkExport.tsx index dc2645a63..a9294112a 100644 --- a/src/modules/trade/link/ChatLinkExport.tsx +++ b/src/modules/trade/link/ChatLinkExport.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { Badge, Button } from '@mui/joy'; import DoneIcon from '@mui/icons-material/Done'; -import IosShareIcon from '@mui/icons-material/IosShare'; +import ExitToAppIcon from '@mui/icons-material/ExitToApp'; import { Brand } from '~/common/app.config'; import { ConfirmationModal } from '~/common/components/ConfirmationModal'; @@ -119,12 +119,14 @@ export function ChatLinkExport(props: { return <> - diff --git a/src/modules/trade/publish/PublishExport.tsx b/src/modules/trade/publish/PublishExport.tsx index c60c8d8e7..f5cd59826 100644 --- a/src/modules/trade/publish/PublishExport.tsx +++ b/src/modules/trade/publish/PublishExport.tsx @@ -79,13 +79,15 @@ export function PublishExport(props: { return <> - {/* [publish] confirmation */}