Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable send button for AI readonly mode #1954

Merged
merged 4 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/funny-beers-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-docs/gatsby-theme-docs': patch
---

Adjust readonly mode for AI assistant. It will hide the send button and enable the restart conversation button
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,11 @@ const ChatModal = () => {
};

useEffect(() => {
if (replayMessage) {
if (replayMessage && currentChatMode !== DEV_TOOLING_MODE) {
// if the chat mode changes and there is at least one message sent from
// the user, we switch mode and re-submit this latest message
// the user, we switch mode and re-submit this latest message.
// We don't want to replay the last message if the user is entering dev-tooling mode
// as free text input is going to be blocked.
submitChatMessages([replayMessage], formik.values);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down Expand Up @@ -492,7 +494,7 @@ const ChatModal = () => {
setReplayMessage();
formik.resetForm();
}}
displayPrimaryButton={!!chatConfig?.readOnly}
displayPrimaryButton={false}
isPrimaryButtonDisabled={
!(formik.isValid && formik.dirty) || formik.isSubmitting
}
Expand Down Expand Up @@ -538,9 +540,10 @@ const ChatModal = () => {
/>
</ChatMessagesWrapper>

{!chatConfig?.readOnly && !chatLocked && (
{!chatLocked && (
<ChatInputBox>
<InputTextWrapper>

{!chatConfig?.readOnly && <InputTextWrapper>
<MultilineTextField
data-testid="chat-input-field"
key="chatInput"
Expand Down Expand Up @@ -577,7 +580,7 @@ const ChatModal = () => {
}
/>
</SubmitButtonBox>
</InputTextWrapper>
</InputTextWrapper>}
<RestartButtonBox>
<FlatButton
label="Tip: Restart the conversation when changing the topic"
Expand Down
Loading