Skip to content

Commit

Permalink
[8.x] [Security Assistant] Fix Security Assistant settings link behav…
Browse files Browse the repository at this point in the history
…ior and adjust initial settings tab (#197323) (#197493)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Security Assistant] Fix Security Assistant settings link behavior
and adjust initial settings tab
(#197323)](#197323)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Steph
Milovic","email":"stephanie.milovic@elastic.co"},"sourceCommit":{"committedDate":"2024-10-23T16:06:47Z","message":"[Security
Assistant] Fix Security Assistant settings link behavior and adjust
initial settings tab
(#197323)","sha":"a6dc47ddeb15d6c7b91e1abaaf83fba3eee2fef2","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:
SecuritySolution","backport:prev-minor","Team:Security Generative
AI"],"title":"[Security Assistant] Fix Security Assistant settings link
behavior and adjust initial settings
tab","number":197323,"url":"https://github.com/elastic/kibana/pull/197323","mergeCommit":{"message":"[Security
Assistant] Fix Security Assistant settings link behavior and adjust
initial settings tab
(#197323)","sha":"a6dc47ddeb15d6c7b91e1abaaf83fba3eee2fef2"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197323","number":197323,"mergeCommit":{"message":"[Security
Assistant] Fix Security Assistant settings link behavior and adjust
initial settings tab
(#197323)","sha":"a6dc47ddeb15d6c7b91e1abaaf83fba3eee2fef2"}}]}]
BACKPORT-->

Co-authored-by: Steph Milovic <stephanie.milovic@elastic.co>
  • Loading branch information
kibanamachine and stephmilovic authored Oct 23, 2024
1 parent 0d75804 commit 942827d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const SETTINGS_PROMPT_HELP_TEXT_TITLE = i18n.translate(
export const STREAMING_TITLE = i18n.translate(
'xpack.elasticAssistant.assistant.conversations.settings.streamingTitle',
{
defaultMessage: 'STREAMING',
defaultMessage: 'Streaming',
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface Props {
dataViews: DataViewsContract;
selectedConversation: Conversation;
onTabChange?: (tabId: string) => void;
currentTab?: SettingsTabs;
currentTab: SettingsTabs;
}

/**
Expand Down Expand Up @@ -65,14 +65,14 @@ export const AssistantSettingsManagement: React.FC<Props> = React.memo(

const tabsConfig = useMemo(
() => [
{
id: CONNECTORS_TAB,
label: i18n.CONNECTORS_MENU_ITEM,
},
{
id: CONVERSATIONS_TAB,
label: i18n.CONVERSATIONS_MENU_ITEM,
},
{
id: CONNECTORS_TAB,
label: i18n.CONNECTORS_MENU_ITEM,
},
{
id: SYSTEM_PROMPTS_TAB,
label: i18n.SYSTEM_PROMPTS_MENU_ITEM,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
EuiContextMenuPanel,
EuiContextMenuItem,
EuiConfirmModal,
EuiIcon,
EuiNotificationBadge,
EuiPopover,
EuiButtonIcon,
Expand Down Expand Up @@ -68,6 +69,7 @@ export const SettingsContextMenu: React.FC<Params> = React.memo(
() =>
navigateToApp('management', {
path: 'kibana/securityAiAssistantManagement',
openInNewTab: true,
}),
[navigateToApp]
);
Expand All @@ -81,6 +83,7 @@ export const SettingsContextMenu: React.FC<Params> = React.memo(
() =>
navigateToApp('management', {
path: `kibana/securityAiAssistantManagement?tab=${KNOWLEDGE_BASE_TAB}`,
openInNewTab: true,
}),
[navigateToApp]
);
Expand All @@ -101,6 +104,13 @@ export const SettingsContextMenu: React.FC<Params> = React.memo(
data-test-subj={'ai-assistant-settings'}
>
{i18n.AI_ASSISTANT_SETTINGS}
<EuiIcon
css={css`
margin-left: ${euiThemeVars.euiSizeXS};
`}
size="s"
type="popout"
/>
</EuiContextMenuItem>,
<EuiContextMenuItem
aria-label={'knowledge-base'}
Expand All @@ -109,6 +119,13 @@ export const SettingsContextMenu: React.FC<Params> = React.memo(
data-test-subj={'knowledge-base'}
>
{i18n.KNOWLEDGE_BASE}
<EuiIcon
css={css`
margin-left: ${euiThemeVars.euiSizeXS};
`}
size="s"
type="popout"
/>
</EuiContextMenuItem>,
<EuiContextMenuItem
aria-label={'anonymization'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import { useConversation } from '@kbn/elastic-assistant/impl/assistant/use_conversation';
import type { FetchConversationsResponse } from '@kbn/elastic-assistant/impl/assistant/api';
import { SECURITY_AI_SETTINGS } from '@kbn/elastic-assistant/impl/assistant/settings/translations';
import { CONNECTORS_TAB } from '@kbn/elastic-assistant/impl/assistant/settings/const';
import { CONVERSATIONS_TAB } from '@kbn/elastic-assistant/impl/assistant/settings/const';
import type { SettingsTabs } from '@kbn/elastic-assistant/impl/assistant/settings/types';
import { useKibana } from '../../common/lib/kibana';

Expand Down Expand Up @@ -68,7 +68,7 @@ export const ManagementSettings = React.memo(() => {

const [searchParams] = useSearchParams();
const currentTab = useMemo(
() => (searchParams.get('tab') as SettingsTabs) ?? CONNECTORS_TAB,
() => (searchParams.get('tab') as SettingsTabs) ?? CONVERSATIONS_TAB,
[searchParams]
);

Expand Down

0 comments on commit 942827d

Please sign in to comment.