Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
EuiText,
EuiTitle,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { useAppContext } from '../../app_context';

export function AiAssistantSelectionPage() {
Expand Down Expand Up @@ -86,21 +87,25 @@ export function AiAssistantSelectionPage() {
</>
) : null}
<p>
{i18n.translate(
'aiAssistantManagementSelection.aiAssistantSelectionPage.obsAssistant.documentationLinkDescription',
{ defaultMessage: 'For more info, see our' }
)}{' '}
<EuiLink
data-test-subj="pluginsAiAssistantSelectionPageDocumentationLink"
external
target="_blank"
href="https://www.elastic.co/guide/en/observability/current/obs-ai-assistant.html"
>
{i18n.translate(
'aiAssistantManagementSelection.aiAssistantSelectionPage.obsAssistant.documentationLinkLabel',
{ defaultMessage: 'documentation' }
)}
</EuiLink>
<FormattedMessage
id="aiAssistantManagementSelection.aiAssistantSelectionPage.obsAssistant.documentationLinkDescription"
defaultMessage="For more info, see our {documentation}."
values={{
documentation: (
<EuiLink
data-test-subj="pluginsAiAssistantSelectionPageDocumentationLink"
external
target="_blank"
href="https://www.elastic.co/guide/en/observability/current/obs-ai-assistant.html"
>
{i18n.translate(
'aiAssistantManagementSelection.aiAssistantSelectionPage.obsAssistant.documentationLinkLabel',
{ defaultMessage: 'documentation' }
)}
</EuiLink>
),
}}
/>
</p>
<EuiButton
iconType="gear"
Expand Down Expand Up @@ -151,21 +156,25 @@ export function AiAssistantSelectionPage() {
</>
) : null}
<p>
{i18n.translate(
'aiAssistantManagementSelection.aiAssistantSelectionPage.securityAssistant.documentationLinkDescription',
{ defaultMessage: 'For more info, see our' }
)}{' '}
<EuiLink
data-test-subj="securityAiAssistantSelectionPageDocumentationLink"
external
target="_blank"
href="https://www.elastic.co/guide/en/security/current/security-assistant.html"
>
{i18n.translate(
'aiAssistantManagementSelection.aiAssistantSettingsPage.securityAssistant.documentationLinkLabel',
{ defaultMessage: 'documentation' }
)}
</EuiLink>
<FormattedMessage
id="aiAssistantManagementSelection.aiAssistantSelectionPage.securityAssistant.documentationLinkDescription"
defaultMessage="For more info, see our {documentation}."
values={{
documentation: (
<EuiLink
data-test-subj="securityAiAssistantSelectionPageDocumentationLink"
external
target="_blank"
href="https://www.elastic.co/guide/en/security/current/security-assistant.html"
>
{i18n.translate(
'aiAssistantManagementSelection.aiAssistantSettingsPage.securityAssistant.documentationLinkLabel',
{ defaultMessage: 'documentation' }
)}
</EuiLink>
),
}}
/>
</p>
<EuiButton
data-test-subj="pluginsAiAssistantSelectionPageButton"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,13 @@ export const bulkUpdateConversations = async (
toasts?.addError(error.body && error.body.message ? new Error(error.body.message) : error, {
title: i18n.translate('xpack.elasticAssistant.conversations.bulkActionsConversationsError', {
defaultMessage: 'Error updating conversations {error}',
values: { error },
values: {
error: error.message
Comment thread
spong marked this conversation as resolved.
? Array.isArray(error.message)
? error.message.join(',')
: error.message
: error,
},
}),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ export const bulkUpdatePrompts = async (
toasts?.addError(error.body && error.body.message ? new Error(error.body.message) : error, {
title: i18n.translate('xpack.elasticAssistant.prompts.bulkActionspromptsError', {
defaultMessage: 'Error updating prompts {error}',
values: { error },
values: {
error: error.message
Comment thread
spong marked this conversation as resolved.
? Array.isArray(error.message)
? error.message.join(',')
: error.message
: error,
},
}),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useConversation } from '../use_conversation';
import { getCombinedMessage } from '../prompt/helpers';
import { Conversation, useAssistantContext } from '../../..';
import { getMessageFromRawResponse } from '../helpers';
import { getDefaultSystemPrompt } from '../use_conversation/helpers';
import { getDefaultSystemPrompt, getDefaultNewSystemPrompt } from '../use_conversation/helpers';

export interface UseChatSendProps {
allSystemPrompts: PromptResponse[];
Expand Down Expand Up @@ -204,10 +204,11 @@ export const useChatSend = ({
}, [currentConversation, http, removeLastMessage, sendMessage, setCurrentConversation, toasts]);

const handleOnChatCleared = useCallback(async () => {
const defaultSystemPromptId = getDefaultSystemPrompt({
allSystemPrompts,
conversation: currentConversation,
})?.id;
const defaultSystemPromptId =
getDefaultSystemPrompt({
allSystemPrompts,
conversation: currentConversation,
})?.id ?? getDefaultNewSystemPrompt(allSystemPrompts)?.id;

setUserPrompt('');
setSelectedPromptContexts({});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface Props {
onClose: () => void;
onSaveCancelled: () => void;
onSaveConfirmed: () => void;
saveButtonDisabled?: boolean;
}

const FlyoutComponent: React.FC<Props> = ({
Expand All @@ -36,6 +37,7 @@ const FlyoutComponent: React.FC<Props> = ({
onClose,
onSaveCancelled,
onSaveConfirmed,
saveButtonDisabled = false,
}) => {
return flyoutVisible ? (
<EuiFlyout
Expand Down Expand Up @@ -71,6 +73,7 @@ const FlyoutComponent: React.FC<Props> = ({
data-test-subj="save-button"
onClick={onSaveConfirmed}
iconType="check"
disabled={saveButtonDisabled}
fill
>
{i18n.FLYOUT_SAVE_BUTTON_TITLE}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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 { EuiTableActionsColumnType } from '@elastic/eui';
import { useCallback } from 'react';
import * as i18n from './translations';

interface Props<T> {
disabled?: boolean;
onDelete?: (rowItem: T) => void;
onEdit?: (rowItem: T) => void;
}

export const useInlineActions = <T extends { isDefault?: boolean | undefined }>() => {
const getInlineActions = useCallback(({ disabled = false, onDelete, onEdit }: Props<T>) => {
const handleEdit = (rowItem: T) => {
onEdit?.(rowItem);
};

const handleDelete = (rowItem: T) => {
onDelete?.(rowItem);
};

const actions: EuiTableActionsColumnType<T> = {
name: i18n.ACTIONS_BUTTON,
actions: [
{
name: i18n.EDIT_BUTTON,
description: i18n.EDIT_BUTTON,
icon: 'pencil',
type: 'icon',
onClick: (rowItem: T) => {
handleEdit(rowItem);
},
enabled: () => !disabled,
available: () => onEdit != null,
},
{
name: i18n.DELETE_BUTTON,
description: i18n.DELETE_BUTTON,
icon: 'trash',
type: 'icon',
onClick: (rowItem: T) => {
handleDelete(rowItem);
},
enabled: ({ isDefault }: { isDefault?: boolean }) => !isDefault && !disabled,
available: () => onDelete != null,
color: 'danger',
},
],
};
return actions;
}, []);

return getInlineActions;
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ export const DELETE_BUTTON = i18n.translate(
defaultMessage: 'Delete',
}
);

export const ACTIONS_BUTTON = i18n.translate(
'xpack.elasticAssistant.assistant.settings.actionsButtonTitle',
{
defaultMessage: 'Actions',
}
);

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export const ConversationSelectorSettings: React.FC<Props> = React.memo(
(conversation) =>
conversation.title === conversationSelectorSettingsOption[0]?.label
) ?? conversationSelectorSettingsOption[0]?.label;

onConversationSelectionChange(newConversation);
},
[onConversationSelectionChange, conversations]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { ConversationSettings, ConversationSettingsProps } from './conversation_
import { TestProviders } from '../../../mock/test_providers/test_providers';
import { alertConvo, customConvo, welcomeConvo } from '../../../mock/conversation';
import { mockSystemPrompts } from '../../../mock/system_prompt';
import { OpenAiProviderType } from '@kbn/stack-connectors-plugin/common/openai/constants';
import { mockConnectors } from '../../../mock/connectors';
import { HttpSetup } from '@kbn/core/public';

const mockConvos = {
'1234': { ...welcomeConvo, id: '1234' },
Expand All @@ -24,18 +24,19 @@ const onSelectedConversationChange = jest.fn();
const setConversationSettings = jest.fn();
const setConversationsSettingsBulkActions = jest.fn();

const testProps = {
const testProps: ConversationSettingsProps = {
allSystemPrompts: mockSystemPrompts,
assistantStreamingEnabled: false,
connectors: mockConnectors,
conversationSettings: mockConvos,
defaultConnectorId: '123',
defaultProvider: OpenAiProviderType.OpenAi,
http: { basePath: { get: jest.fn() } },
conversationsSettingsBulkActions: {},
http: { basePath: { get: jest.fn() } } as unknown as HttpSetup,
onSelectedConversationChange,
selectedConversation: mockConvos['1234'],
setAssistantStreamingEnabled: jest.fn(),
setConversationSettings,
conversationsSettingsBulkActions: {},
setConversationsSettingsBulkActions,
} as unknown as ConversationSettingsProps;
};

jest.mock('../../../connectorland/use_load_connectors', () => ({
useLoadConnectors: () => ({
Expand Down Expand Up @@ -113,7 +114,6 @@ jest.mock('../../../connectorland/connector_selector', () => ({
/>
),
}));

describe('ConversationSettings', () => {
beforeEach(() => {
jest.clearAllMocks();
Expand Down
Loading