Skip to content

Commit

Permalink
fix(chat): show like/dislike/copy buttons only if content message has…
Browse files Browse the repository at this point in the history
…n't error message or content isn't empty (Issue #125) (#2865)
  • Loading branch information
Alexander-Kezik authored Dec 24, 2024
1 parent 69b9dfd commit f41850e
Showing 1 changed file with 71 additions and 68 deletions.
139 changes: 71 additions & 68 deletions apps/chat/src/components/Chat/ChatMessage/MessageButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,81 +154,84 @@ export const MessageAssistantButtons = ({
</Button>
</Tooltip>
)}
{messageCopied ? (
<Tooltip key="copied" placement="top" tooltip={t('Text copied')}>
<IconCheck size={18} className="text-secondary" />
</Tooltip>
) : (
<Tooltip
key="copy"
placement="top"
isTriggerClickable
tooltip={t('Copy text')}
>
<Button className="text-secondary" onClick={copyOnClick}>
<IconCopy size={18} />
</Button>
</Tooltip>
)}
{(message.content.trim() || !message.errorMessage) &&
(messageCopied ? (
<Tooltip key="copied" placement="top" tooltip={t('Text copied')}>
<IconCheck size={18} className="text-secondary" />
</Tooltip>
) : (
<Tooltip
key="copy"
placement="top"
isTriggerClickable
tooltip={t('Copy text')}
>
<Button className="text-secondary" onClick={copyOnClick}>
<IconCopy size={18} />
</Button>
</Tooltip>
))}
<div className="flex flex-row gap-2">
{isLikesEnabled && !!message.responseId && (
<>
{message.like !== LikeState.Disliked && (
<Tooltip
placement="top"
isTriggerClickable={message.like !== LikeState.Liked}
tooltip={
message.like !== LikeState.Liked ? t('Like') : t('Liked')
}
>
<Button
onClick={() => {
if (message.like !== LikeState.NoState) {
onLike(LikeState.Liked);
}
}}
className={
message.like !== LikeState.Liked
? 'text-secondary'
: 'text-accent-primary'
{isLikesEnabled &&
(!message.errorMessage ||
(message.content.trim() && message.errorMessage)) && (
<>
{message.like !== LikeState.Disliked && (
<Tooltip
placement="top"
isTriggerClickable={message.like !== LikeState.Liked}
tooltip={
message.like !== LikeState.Liked ? t('Like') : t('Liked')
}
disabled={message.like === LikeState.Liked}
data-qa="like"
>
<IconThumbUp size={18} />
</Button>
</Tooltip>
)}
{message.like !== LikeState.Liked && (
<Tooltip
placement="top"
isTriggerClickable={message.like !== LikeState.Disliked}
tooltip={
message.like !== LikeState.Disliked
? t('Dislike')
: t('Disliked')
}
>
<Button
onClick={() => {
if (message.like !== LikeState.NoState) {
onLike(LikeState.Disliked);
<Button
onClick={() => {
if (message.like !== LikeState.NoState) {
onLike(LikeState.Liked);
}
}}
className={
message.like !== LikeState.Liked
? 'text-secondary'
: 'text-accent-primary'
}
}}
className={
disabled={message.like === LikeState.Liked}
data-qa="like"
>
<IconThumbUp size={18} />
</Button>
</Tooltip>
)}
{message.like !== LikeState.Liked && (
<Tooltip
placement="top"
isTriggerClickable={message.like !== LikeState.Disliked}
tooltip={
message.like !== LikeState.Disliked
? 'text-secondary'
: 'text-accent-primary'
? t('Dislike')
: t('Disliked')
}
disabled={message.like === LikeState.Disliked}
data-qa="dislike"
>
<IconThumbDown size={18} />
</Button>
</Tooltip>
)}
</>
)}
<Button
onClick={() => {
if (message.like !== LikeState.NoState) {
onLike(LikeState.Disliked);
}
}}
className={
message.like !== LikeState.Disliked
? 'text-secondary'
: 'text-accent-primary'
}
disabled={message.like === LikeState.Disliked}
data-qa="dislike"
>
<IconThumbDown size={18} />
</Button>
</Tooltip>
)}
</>
)}
</div>
</div>
);
Expand Down

0 comments on commit f41850e

Please sign in to comment.