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

[Security Solution] AI settings #184678

Merged
merged 42 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c316c0a
connectors tab
angorayc Jun 3, 2024
f6a81d4
connectors tab
angorayc Jun 4, 2024
0f053ba
conversation tab
angorayc Jun 6, 2024
889ef91
add prompts
angorayc Jun 17, 2024
84f05a4
revert changes
angorayc Jun 17, 2024
fd873ae
evaluation tab
angorayc Jun 18, 2024
d5892f1
system prompt
angorayc Jun 20, 2024
b591eb5
connector title
angorayc Jun 20, 2024
376d82e
clean up
angorayc Jun 21, 2024
f97b701
default page size to 25
angorayc Jun 21, 2024
d3fe407
Merge branch 'main' of github.com:elastic/kibana into ai-settings
angorayc Jun 21, 2024
577128e
revert evaluation tab
angorayc Jun 21, 2024
ce38466
unit tests
angorayc Jun 21, 2024
6aac96e
fix update connector from modal
angorayc Jun 21, 2024
d758032
fix types
angorayc Jun 22, 2024
d229af8
unit tests
angorayc Jun 22, 2024
6cd1778
types
angorayc Jun 23, 2024
7c226ba
pending changes
angorayc Jun 23, 2024
7fe3085
types
angorayc Jun 23, 2024
0bfdeed
update connector and model
angorayc Jun 24, 2024
b457625
Merge branch 'ai-settings' of github.com:angorayc/kibana into ai-sett…
angorayc Jun 24, 2024
5353d20
refetch conversations
angorayc Jun 24, 2024
559478a
fix create conversations from system prompt tab
angorayc Jun 24, 2024
d53a830
Merge branch 'main' of github.com:elastic/kibana into ai-settings
angorayc Jun 25, 2024
3a3f4bc
fix prompts
angorayc Jun 25, 2024
bcdd052
rm updatedAt
angorayc Jun 25, 2024
cdfe570
styling
angorayc Jun 25, 2024
d838821
types
angorayc Jun 25, 2024
842e9e0
revert ui-action changes
angorayc Jun 25, 2024
70ef92d
avoid prompt saved automatically
angorayc Jun 25, 2024
302a901
tests
angorayc Jun 26, 2024
bbbc345
unit tests
angorayc Jun 26, 2024
01decb1
remove additional props
angorayc Jun 26, 2024
a635288
styling
angorayc Jun 27, 2024
8b8f545
add unit tests
angorayc Jun 27, 2024
6213419
Merge branch 'main' into ai-settings
angorayc Jun 27, 2024
379bf18
i18n
angorayc Jun 27, 2024
ff48987
add pageSizeOptions
angorayc Jun 27, 2024
c78da14
Merge branch 'ai-settings' of github.com:angorayc/kibana into ai-sett…
angorayc Jun 27, 2024
60f271e
fix typo and pagination
angorayc Jun 27, 2024
e63e692
store pagination and sorting in seession
angorayc Jun 28, 2024
7c30b20
fix jumping cursor
angorayc Jun 28, 2024
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 @@ -9,6 +9,7 @@
import React, { useEffect } from 'react';
import { i18n } from '@kbn/i18n';
import {
EuiButton,
EuiCallOut,
EuiCard,
EuiFlexGrid,
Expand Down Expand Up @@ -86,32 +87,48 @@ export function AiAssistantSelectionPage() {
<EuiSpacer size="s" />
</>
) : null}
<EuiLink
data-test-subj="pluginsAiAssistantSelectionPageDocumentationLink"
external
target="_blank"
href="https://www.elastic.co/guide/en/observability/current/obs-ai-assistant.html"
<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>
</p>
<EuiButton
iconType="gear"
data-test-subj="pluginsAiAssistantSelectionPageButton"
onClick={() =>
navigateToApp('management', {
path: 'kibana/observabilityAiAssistantManagement',
})
}
>
{i18n.translate(
'aiAssistantManagementSelection.aiAssistantSettingsPage.obsAssistant.documentationLinkLabel',
{ defaultMessage: 'Documentation' }
'aiAssistantManagementSelection.aiAssistantSelectionPage.obsAssistant.manageSettingsButtonLabel',
{ defaultMessage: 'Manage Settings' }
)}
</EuiLink>
</EuiButton>
</div>
}
display="plain"
hasBorder
icon={<EuiIcon size="l" type="logoObservability" />}
icon={<EuiIcon size="xxl" type="logoObservability" />}
isDisabled={!observabilityAIAssistantEnabled}
layout="horizontal"
title={i18n.translate(
'aiAssistantManagementSelection.aiAssistantSelectionPage.observabilityLabel',
{ defaultMessage: 'Elastic AI Assistant for Observability' }
)}
titleSize="xs"
onClick={() =>
navigateToApp('management', { path: 'kibana/observabilityAiAssistantManagement' })
}
/>
</EuiFlexItem>
<EuiFlexItem grow>
Expand All @@ -135,32 +152,46 @@ export function AiAssistantSelectionPage() {
<EuiSpacer size="s" />
</>
) : null}
<EuiLink
data-test-subj="securityAiAssistantSelectionPageDocumentationLink"
external
target="_blank"
href="https://www.elastic.co/guide/en/security/current/security-assistant.html"
<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>
</p>
<EuiButton
data-test-subj="pluginsAiAssistantSelectionPageButton"
iconType="gear"
onClick={() =>
navigateToApp('management', { path: 'kibana/securityAiAssistantManagement' })
}
>
{i18n.translate(
'aiAssistantManagementSelection.aiAssistantSettingsPage.securityAssistant.documentationLinkLabel',
{ defaultMessage: 'Documentation' }
'aiAssistantManagementSelection.aiAssistantSelectionPage.securityAssistant.manageSettingsButtonLabel',
{ defaultMessage: 'Manage Settings' }
)}
</EuiLink>
</EuiButton>
</div>
}
display="plain"
hasBorder
icon={<EuiIcon size="l" type="logoSecurity" />}
icon={<EuiIcon size="xxl" type="logoSecurity" />}
isDisabled={!securityAIAssistantEnabled}
layout="horizontal"
title={i18n.translate(
'aiAssistantManagementSelection.aiAssistantSelectionPage.securityLabel',
{ defaultMessage: 'Elastic AI Assistant for Security' }
)}
titleSize="xs"
onClick={() =>
navigateToApp('management', { path: 'kibana/securityAiAssistantManagement' })
}
/>
</EuiFlexItem>
</EuiFlexGrid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ interface OwnProps {
setChatHistoryVisible?: React.Dispatch<React.SetStateAction<boolean>>;
onConversationSelected: ({ cId, cTitle }: { cId: string; cTitle: string }) => void;
conversations: Record<string, Conversation>;
conversationsLoaded: boolean;
refetchConversationsState: () => Promise<void>;
onConversationCreate: () => Promise<void>;
isAssistantEnabled: boolean;
Expand All @@ -69,6 +70,7 @@ export const AssistantHeaderFlyout: React.FC<Props> = ({
onCloseFlyout,
onConversationSelected,
conversations,
conversationsLoaded,
refetchConversationsState,
onConversationCreate,
isAssistantEnabled,
Expand Down Expand Up @@ -158,6 +160,7 @@ export const AssistantHeaderFlyout: React.FC<Props> = ({
setIsSettingsModalVisible={setIsSettingsModalVisible}
onConversationSelected={onConversationSelected}
conversations={conversations}
conversationsLoaded={conversationsLoaded}
refetchConversationsState={refetchConversationsState}
isFlyoutMode={true}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const mockConversations = {
[welcomeConvo.title]: welcomeConvo,
};
const testProps = {
conversationsLoaded: true,
currentConversation: welcomeConvo,
title: 'Test Title',
docLinks: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface OwnProps {
showAnonymizedValues: boolean;
title: string;
conversations: Record<string, Conversation>;
conversationsLoaded: boolean;
refetchConversationsState: () => Promise<void>;
}

Expand All @@ -61,6 +62,7 @@ export const AssistantHeader: React.FC<Props> = ({
showAnonymizedValues,
title,
conversations,
conversationsLoaded,
refetchConversationsState,
}) => {
const showAnonymizedValuesChecked = useMemo(
Expand Down Expand Up @@ -151,6 +153,7 @@ export const AssistantHeader: React.FC<Props> = ({
setIsSettingsModalVisible={setIsSettingsModalVisible}
onConversationSelected={onConversationSelected}
conversations={conversations}
conversationsLoaded={conversationsLoaded}
refetchConversationsState={refetchConversationsState}
isFlyoutMode={false}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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 { EuiBadge } from '@elastic/eui';
import React from 'react';

export const BadgesColumn: React.FC<{ items: string[] | null | undefined; prefix: string }> =
React.memo(({ items, prefix }) =>
items && items.length > 0 ? (
<div>
{items.map((c, idx) => (
<EuiBadge key={`${prefix}-${idx}`} color="hollow">
{c}
</EuiBadge>
))}
</div>
) : null
);
BadgesColumn.displayName = 'BadgesColumn';
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* 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 {
EuiButton,
EuiButtonEmpty,
EuiFlexGroup,
EuiFlexItem,
EuiFlyout,
EuiFlyoutBody,
EuiFlyoutFooter,
EuiFlyoutHeader,
EuiTitle,
} from '@elastic/eui';
import { css } from '@emotion/react';
import React from 'react';
import * as i18n from './translations';

interface Props {
children: React.ReactNode;
title: string;
flyoutVisible: boolean;
onClose: () => void;
onSaveCancelled: () => void;
onSaveConfirmed: () => void;
}

const FlyoutComponent: React.FC<Props> = ({
title,
flyoutVisible,
children,
onClose,
onSaveCancelled,
onSaveConfirmed,
}) => {
return flyoutVisible ? (
<EuiFlyout
ownFocus
onClose={onClose}
css={css`
max-width: 656px;
`}
>
<EuiFlyoutHeader>
<EuiTitle size={'s'}>
<h2>{title}</h2>
</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody>{children}</EuiFlyoutBody>
<EuiFlyoutFooter>
<EuiFlexGroup justifyContent="spaceBetween" gutterSize="s">
<EuiFlexItem grow={false}>
<EuiButtonEmpty
size="m"
color="text"
iconType="cross"
data-test-subj="cancel-button"
onClick={onSaveCancelled}
>
{i18n.FLYOUT_CANCEL_BUTTON_TITLE}
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
size="m"
type="submit"
data-test-subj="save-button"
onClick={onSaveConfirmed}
iconType="check"
fill
>
{i18n.FLYOUT_SAVE_BUTTON_TITLE}
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlyoutFooter>
</EuiFlyout>
) : null;
};

export const Flyout = React.memo(FlyoutComponent);
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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 { i18n } from '@kbn/i18n';

export const FLYOUT_SAVE_BUTTON_TITLE = i18n.translate(
'xpack.elasticAssistant.assistant.settings.flyout.saveButtonTitle',
{
defaultMessage: 'Save',
}
);

export const FLYOUT_CANCEL_BUTTON_TITLE = i18n.translate(
'xpack.elasticAssistant.assistant.settings.flyout.cancelButtonTitle',
{
defaultMessage: 'Cancel',
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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 { useMemo, useState } from 'react';

export const useFlyoutModalVisibility = () => {
const [isFlyoutOpen, setIsFlyoutOpen] = useState(false);

const openFlyout = () => {
setIsFlyoutOpen(true);
};

const closeFlyout = () => {
setIsFlyoutOpen(false);
};

return useMemo(
() => ({
isFlyoutOpen,
openFlyout,
closeFlyout,
}),
[isFlyoutOpen]
);
};
Loading