forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from CoenWarmer/storybook
- Loading branch information
Showing
3 changed files
with
51 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
x-pack/plugins/observability_ai_assistant/public/components/chat/chat_item_controls.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule, EuiSpacer } from '@elastic/eui'; | ||
import { Feedback, FeedbackButtons } from '../feedback_buttons'; | ||
import { MessageRole } from '../../../common'; | ||
import { RegenerateResponseButton } from '../regenerate_response_button'; | ||
|
||
interface ChatItemControls { | ||
role: MessageRole; | ||
onFeedbackClick: (feedback: Feedback) => void; | ||
onRegenerateClick: () => void; | ||
} | ||
|
||
export function ChatItemControls({ role, onFeedbackClick, onRegenerateClick }: ChatItemControls) { | ||
const canReceiveFeedback = | ||
role === MessageRole.Assistant || role === MessageRole.Elastic || role === MessageRole.Function; | ||
|
||
const canRegenerateResponse = role === MessageRole.Assistant; | ||
|
||
return canReceiveFeedback || canRegenerateResponse ? ( | ||
<> | ||
<EuiSpacer size="m" /> | ||
<EuiHorizontalRule margin="none" /> | ||
<EuiSpacer size="s" /> | ||
<EuiFlexGroup> | ||
<EuiFlexItem> | ||
{canReceiveFeedback ? <FeedbackButtons onClickFeedback={onFeedbackClick} /> : null} | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
{canRegenerateResponse ? <RegenerateResponseButton onClick={onRegenerateClick} /> : null} | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</> | ||
) : null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters