-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[AiButton/Security] Migrate ai-related buttons to use custom styles #259847
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
Changes from all commits
d8382df
3f1d976
a45a32f
c14ec22
442eedc
670afb5
8820a9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,14 +6,12 @@ | |
| */ | ||
|
|
||
| import type { EuiButtonColor } from '@elastic/eui'; | ||
| import { EuiButtonEmpty, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; | ||
| import React, { useCallback } from 'react'; | ||
| import { AssistantIcon } from '@kbn/ai-assistant-icon'; | ||
| import { AiButton } from '@kbn/shared-ux-ai-components'; | ||
| import type { EuiButtonEmptySizes } from '@elastic/eui/src/components/button/button_empty/button_empty'; | ||
| import * as i18n from './translations'; | ||
|
|
||
| export const BUTTON_TEST_ID = 'newChatByTitle'; | ||
| export const BUTTON_ICON_TEST_ID = 'newChatByTitleIcon'; | ||
| export const BUTTON_TEXT_TEST_ID = 'newChatByTitleText'; | ||
|
|
||
| export interface NewChatByTitleComponentProps { | ||
|
|
@@ -45,24 +43,17 @@ const NewChatByTitleComponent: React.FC<NewChatByTitleComponentProps> = ({ | |
| const showOverlay = useCallback(() => showAssistantOverlay(true), [showAssistantOverlay]); | ||
|
|
||
| return ( | ||
| <EuiButtonEmpty | ||
| <AiButton | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't reproduce it in UI, so please check it locally and share the screenshot here. Thank you |
||
| aria-label={i18n.ASK_AI_ASSISTANT} | ||
| color={color} | ||
| data-test-subj={BUTTON_TEST_ID} | ||
| onClick={showOverlay} | ||
| size={size} | ||
| variant="empty" | ||
| iconType="aiAssistantLogo" | ||
| iconOnly={!text} | ||
| > | ||
| <EuiFlexGroup alignItems="center" gutterSize="s"> | ||
| <EuiFlexItem grow={false}> | ||
| <AssistantIcon data-test-subj={BUTTON_ICON_TEST_ID} size="m" /> | ||
| </EuiFlexItem> | ||
| {text && ( | ||
| <EuiFlexItem data-test-subj={BUTTON_TEXT_TEST_ID} grow={false}> | ||
| {text} | ||
| </EuiFlexItem> | ||
| )} | ||
| </EuiFlexGroup> | ||
| </EuiButtonEmpty> | ||
| {text ? <span data-test-subj={BUTTON_TEXT_TEST_ID}>{text}</span> : null} | ||
| </AiButton> | ||
| ); | ||
| }; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,22 +5,22 @@ | |
| * 2.0. | ||
| */ | ||
|
|
||
| import type { EuiButtonEmptyProps } from '@elastic/eui'; | ||
| import { EuiButtonEmpty } from '@elastic/eui'; | ||
| import React from 'react'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { AiButton, type AiButtonProps } from '@kbn/shared-ux-ai-components'; | ||
|
|
||
| export function RegenerateResponseButton(props: Partial<EuiButtonEmptyProps>) { | ||
| export function RegenerateResponseButton(props: AiButtonProps) { | ||
| return ( | ||
| <EuiButtonEmpty | ||
| <AiButton | ||
| {...props} | ||
| iconType="sparkles" | ||
| size="s" | ||
| variant="empty" | ||
| data-test-subj="regenerateResponseButton" | ||
| iconType="sparkles" | ||
| {...props} | ||
| > | ||
| {i18n.translate('xpack.elasticAssistantPlugin.aiAssistant.regenerateResponseButtonLabel', { | ||
| defaultMessage: 'Regenerate', | ||
| })} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| </EuiButtonEmpty> | ||
| </AiButton> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,8 @@ | |
| */ | ||
|
|
||
| import type { EuiButtonColor } from '@elastic/eui'; | ||
| import { EuiButtonEmpty, EuiFlexGroup, EuiFlexItem, EuiIcon, EuiToolTip } from '@elastic/eui'; | ||
| import { EuiToolTip } from '@elastic/eui'; | ||
| import { AiButton } from '@kbn/shared-ux-ai-components'; | ||
| import React, { memo, useCallback } from 'react'; | ||
| import type { EuiButtonEmptySizes } from '@elastic/eui/src/components/button/button_empty/button_empty'; | ||
| import type { AgentBuilderAddToChatTelemetry } from '../hooks/use_report_add_to_chat'; | ||
|
|
@@ -71,34 +72,24 @@ export const NewAgentBuilderAttachment = memo(function NewAgentBuilderAttachment | |
| } | ||
|
|
||
| const button = ( | ||
| <EuiButtonEmpty | ||
| <AiButton | ||
| aria-label={i18n.ADD_TO_CHAT} | ||
| color={color} | ||
| variant="empty" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| data-test-subj="newAgentBuilderAttachment" | ||
| onClick={handleClick} | ||
| size={size} | ||
| disabled={isDisabled} | ||
| iconType="productAgent" | ||
| isDisabled={isDisabled} | ||
| > | ||
| <EuiFlexGroup alignItems="center" gutterSize="s"> | ||
| <EuiFlexItem grow={false}> | ||
| <EuiIcon | ||
| type="productAgent" | ||
| color={color === 'primary' ? 'default' : color} | ||
| aria-hidden={true} | ||
| /> | ||
| </EuiFlexItem> | ||
| <EuiFlexItem grow={false}>{i18n.ADD_TO_CHAT}</EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| </EuiButtonEmpty> | ||
| {i18n.ADD_TO_CHAT} | ||
| </AiButton> | ||
| ); | ||
|
|
||
| if (!shouldShowLicenseTooltip) { | ||
| return button; | ||
| } | ||
|
|
||
| return ( | ||
| <EuiToolTip content={i18n.UPGRADE_TO_ENTERPRISE_TO_USE_AGENT_BUILDER_CHAT}> | ||
| <span>{button}</span> | ||
| </EuiToolTip> | ||
| <EuiToolTip content={i18n.UPGRADE_TO_ENTERPRISE_TO_USE_AGENT_BUILDER_CHAT}>{button}</EuiToolTip> | ||
| ); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,9 +10,7 @@ import { EuiSpacer } from '@elastic/eui'; | |
| import { FormattedMessage } from '@kbn/i18n-react'; | ||
|
|
||
| import { NewChat } from '@kbn/elastic-assistant'; | ||
|
|
||
| import { AssistantIcon } from '@kbn/ai-assistant-icon'; | ||
| import { css } from '@emotion/react'; | ||
| import { AiButton } from '@kbn/shared-ux-ai-components'; | ||
| import { SecurityAgentBuilderAttachments } from '../../../../../common/constants'; | ||
| import { METRIC_TYPE, TELEMETRY_EVENT, track } from '../../../../common/lib/telemetry'; | ||
| import { useAssistantAvailability } from '../../../../assistant/use_assistant_availability'; | ||
|
|
@@ -154,13 +152,14 @@ Proposed solution should be valid and must not contain new line symbols (\\n)`; | |
| isAssistantEnabled={isAssistantEnabled} | ||
| onExportCodeBlock={handleOnExportCodeBlock} | ||
| > | ||
| <AssistantIcon | ||
| size="s" | ||
| css={css` | ||
| vertical-align: inherit; | ||
| `} | ||
| /> | ||
| {i18n.ASK_ASSISTANT_ERROR_BUTTON} | ||
| <AiButton | ||
| iconType="aiAssistantLogo" | ||
| size="xs" | ||
| variant="empty" | ||
| onClick={onShowOverlay} | ||
| > | ||
| {i18n.ASK_ASSISTANT_ERROR_BUTTON} | ||
| </AiButton> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| </NewChat> | ||
| ), | ||
| }} | ||
|
|
||



There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.