From b62a506edb38af04769086b27ff9fd44fd81988a Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 29 Nov 2023 15:04:24 +0000 Subject: [PATCH] fix where prompt deleted index is not passed correctly --- .../ui-component/cards/StarterPromptsCard.css | 5 -- .../dialog/StarterPromptsDialog.js | 63 ++++++++++++------- packages/ui/src/views/canvas/CanvasHeader.js | 1 + .../ui/src/views/chatmessage/ChatMessage.css | 2 +- 4 files changed, 42 insertions(+), 29 deletions(-) diff --git a/packages/ui/src/ui-component/cards/StarterPromptsCard.css b/packages/ui/src/ui-component/cards/StarterPromptsCard.css index 8eb3b0ad..2b8df226 100644 --- a/packages/ui/src/ui-component/cards/StarterPromptsCard.css +++ b/packages/ui/src/ui-component/cards/StarterPromptsCard.css @@ -5,12 +5,7 @@ scrollbar-width: none; /* For Firefox */ } -/*.button-container::-webkit-scrollbar {*/ -/* display: none; !* For Chrome, Safari, and Opera *!*/ -/*}*/ - .button { flex: 0 0 auto; /* Don't grow, don't shrink, base width on content */ margin: 5px; /* Adjust as needed for spacing between buttons */ - /* Add additional button styling here */ } diff --git a/packages/ui/src/ui-component/dialog/StarterPromptsDialog.js b/packages/ui/src/ui-component/dialog/StarterPromptsDialog.js index 286399a6..a9916841 100644 --- a/packages/ui/src/ui-component/dialog/StarterPromptsDialog.js +++ b/packages/ui/src/ui-component/dialog/StarterPromptsDialog.js @@ -17,7 +17,7 @@ import { List, InputAdornment } from '@mui/material' -import { IconX, IconTrash, IconPlus } from '@tabler/icons' +import { IconX, IconTrash, IconPlus, IconBulb } from '@tabler/icons' // Project import import { StyledButton } from 'ui-component/button/StyledButton' @@ -29,7 +29,7 @@ import useNotifier from 'utils/useNotifier' // API import chatflowsApi from 'api/chatflows' -const StarterPromptsDialog = ({ show, dialogProps, onCancel, onConfirm = undefined }) => { +const StarterPromptsDialog = ({ show, dialogProps, onCancel, onConfirm }) => { const portalElement = document.getElementById('portal') const dispatch = useDispatch() @@ -93,9 +93,7 @@ const StarterPromptsDialog = ({ show, dialogProps, onCancel, onConfirm = undefin }) dispatch({ type: SET_CHATFLOW, chatflow: saveResp.data }) } - if (onConfirm) { - onConfirm() - } + onConfirm() } catch (error) { const errorData = error.response.data || `${error.response.status}: ${error.response.statusText}` enqueueSnackbar({ @@ -165,12 +163,34 @@ const StarterPromptsDialog = ({ show, dialogProps, onCancel, onConfirm = undefin {dialogProps.title || 'Conversation Starter Prompts'} +
+
+ + + Starter prompts will only be shown when there is no messages on the chat yet + +
+
:not(style)': { m: 1 }, pt: 2 }}> {inputFields.map((data, index) => { return (
- + - - - + {inputFields.length > 1 && ( + removeInputFields(index)} + edge='end' + > + + + )} } /> - + {index === inputFields.length - 1 && ( - + )} - {/**/} - {/* {inputFields.length !== 1 && (*/} - {/* */} - {/* */} - {/* */} - {/* )}*/} - {/**/}
) })} diff --git a/packages/ui/src/views/canvas/CanvasHeader.js b/packages/ui/src/views/canvas/CanvasHeader.js index 2c3bdfe4..85408cd8 100644 --- a/packages/ui/src/views/canvas/CanvasHeader.js +++ b/packages/ui/src/views/canvas/CanvasHeader.js @@ -388,6 +388,7 @@ const CanvasHeader = ({ chatflow, handleSaveFlow, handleDeleteFlow, handleLoadFl setConversationStartersDialogOpen(false)} onCancel={() => setConversationStartersDialogOpen(false)} />