Skip to content

Commit cd51bcb

Browse files
[8.19] [AI Assistant] Security Assistant settings landed on the wrong page on basic license (#229163) (#229523)
# Backport This will backport the following commits from `main` to `8.19`: - [[AI Assistant] Security Assistant settings landed on the wrong page on basic license (#229163)](#229163) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Angela Chuang","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-07-25T22:00:43Z","message":"[AI Assistant] Security Assistant settings landed on the wrong page on basic license (#229163)\n\n## Summary\n\nhttps://github.com//issues/226409\n\nSteps to reproduce:\n\n1. Change the license of the build to basic ( Stack Management > License\nmanagement)\n2. Navigate to the Stack Management > AI Assistants\n3. Click on 'Manage settings' for 'Elastic AI Assistant for Security'\n4. Observe the navigation is to a wrong URL\n\n## Basic License: \nNow the `Elastic AI Assistant for Security` should be disabled under\n`Basic license`:\n\n<img width=\"2560\" height=\"1238\" alt=\"Screenshot 2025-07-24 at 09 48 02\"\nsrc=\"https://github.com/user-attachments/assets/f77193c4-9909-449a-8093-4e5b521e9f17\"\n/>\n\n\n**Basic license: When landing directly on**\n`/app/management/kibana/securityAiAssistantManagement`:\n<img width=\"2560\" height=\"1286\" alt=\"Screenshot 2025-07-25 at 14 21 49\"\nsrc=\"https://github.com/user-attachments/assets/074ebcde-ee4f-458f-8082-9741e2d5f8d3\"\n/>\n\n\n## Trial license:\n\n<img width=\"2560\" height=\"1240\" alt=\"Screenshot 2025-07-23 at 17 19 17\"\nsrc=\"https://github.com/user-attachments/assets/dc14e77e-1df8-40d1-813e-af49e432ab08\"\n/>\n\n\n## Trial license without Manage > AI settings Kibana feature:\n\n**No AI Assistant in the side menu:**\n\n<img width=\"1502\" height=\"814\" alt=\"Screenshot 2025-07-25 at 14 19 16\"\nsrc=\"https://github.com/user-attachments/assets/e0a389b8-4b08-4612-9699-94f6e8d941f7\"\n/>\n\n\n**Observability:**\n<img width=\"1508\" height=\"817\" alt=\"Screenshot 2025-07-25 at 14 17 49\"\nsrc=\"https://github.com/user-attachments/assets/39a50d87-c34b-4f46-a056-7ba071154b87\"\n/>\n\n**Security:**\n<img width=\"1509\" height=\"819\" alt=\"Screenshot 2025-07-25 at 14 18 14\"\nsrc=\"https://github.com/user-attachments/assets/549d6ba1-9033-4d40-b18f-6a276a481388\"\n/>\n\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"ebe304b4807fccff8e16996d1cbab835cc0391ca","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","ci:project-deploy-observability","Team:Security Generative AI","backport:version","v9.1.0","v8.19.0","v9.2.0","v9.0.5"],"title":"[AI Assistant] Security Assistant settings landed on the wrong page on basic license","number":229163,"url":"https://github.com/elastic/kibana/pull/229163","mergeCommit":{"message":"[AI Assistant] Security Assistant settings landed on the wrong page on basic license (#229163)\n\n## Summary\n\nhttps://github.com//issues/226409\n\nSteps to reproduce:\n\n1. Change the license of the build to basic ( Stack Management > License\nmanagement)\n2. Navigate to the Stack Management > AI Assistants\n3. Click on 'Manage settings' for 'Elastic AI Assistant for Security'\n4. Observe the navigation is to a wrong URL\n\n## Basic License: \nNow the `Elastic AI Assistant for Security` should be disabled under\n`Basic license`:\n\n<img width=\"2560\" height=\"1238\" alt=\"Screenshot 2025-07-24 at 09 48 02\"\nsrc=\"https://github.com/user-attachments/assets/f77193c4-9909-449a-8093-4e5b521e9f17\"\n/>\n\n\n**Basic license: When landing directly on**\n`/app/management/kibana/securityAiAssistantManagement`:\n<img width=\"2560\" height=\"1286\" alt=\"Screenshot 2025-07-25 at 14 21 49\"\nsrc=\"https://github.com/user-attachments/assets/074ebcde-ee4f-458f-8082-9741e2d5f8d3\"\n/>\n\n\n## Trial license:\n\n<img width=\"2560\" height=\"1240\" alt=\"Screenshot 2025-07-23 at 17 19 17\"\nsrc=\"https://github.com/user-attachments/assets/dc14e77e-1df8-40d1-813e-af49e432ab08\"\n/>\n\n\n## Trial license without Manage > AI settings Kibana feature:\n\n**No AI Assistant in the side menu:**\n\n<img width=\"1502\" height=\"814\" alt=\"Screenshot 2025-07-25 at 14 19 16\"\nsrc=\"https://github.com/user-attachments/assets/e0a389b8-4b08-4612-9699-94f6e8d941f7\"\n/>\n\n\n**Observability:**\n<img width=\"1508\" height=\"817\" alt=\"Screenshot 2025-07-25 at 14 17 49\"\nsrc=\"https://github.com/user-attachments/assets/39a50d87-c34b-4f46-a056-7ba071154b87\"\n/>\n\n**Security:**\n<img width=\"1509\" height=\"819\" alt=\"Screenshot 2025-07-25 at 14 18 14\"\nsrc=\"https://github.com/user-attachments/assets/549d6ba1-9033-4d40-b18f-6a276a481388\"\n/>\n\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"ebe304b4807fccff8e16996d1cbab835cc0391ca"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19","9.0"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/229163","number":229163,"mergeCommit":{"message":"[AI Assistant] Security Assistant settings landed on the wrong page on basic license (#229163)\n\n## Summary\n\nhttps://github.com//issues/226409\n\nSteps to reproduce:\n\n1. Change the license of the build to basic ( Stack Management > License\nmanagement)\n2. Navigate to the Stack Management > AI Assistants\n3. Click on 'Manage settings' for 'Elastic AI Assistant for Security'\n4. Observe the navigation is to a wrong URL\n\n## Basic License: \nNow the `Elastic AI Assistant for Security` should be disabled under\n`Basic license`:\n\n<img width=\"2560\" height=\"1238\" alt=\"Screenshot 2025-07-24 at 09 48 02\"\nsrc=\"https://github.com/user-attachments/assets/f77193c4-9909-449a-8093-4e5b521e9f17\"\n/>\n\n\n**Basic license: When landing directly on**\n`/app/management/kibana/securityAiAssistantManagement`:\n<img width=\"2560\" height=\"1286\" alt=\"Screenshot 2025-07-25 at 14 21 49\"\nsrc=\"https://github.com/user-attachments/assets/074ebcde-ee4f-458f-8082-9741e2d5f8d3\"\n/>\n\n\n## Trial license:\n\n<img width=\"2560\" height=\"1240\" alt=\"Screenshot 2025-07-23 at 17 19 17\"\nsrc=\"https://github.com/user-attachments/assets/dc14e77e-1df8-40d1-813e-af49e432ab08\"\n/>\n\n\n## Trial license without Manage > AI settings Kibana feature:\n\n**No AI Assistant in the side menu:**\n\n<img width=\"1502\" height=\"814\" alt=\"Screenshot 2025-07-25 at 14 19 16\"\nsrc=\"https://github.com/user-attachments/assets/e0a389b8-4b08-4612-9699-94f6e8d941f7\"\n/>\n\n\n**Observability:**\n<img width=\"1508\" height=\"817\" alt=\"Screenshot 2025-07-25 at 14 17 49\"\nsrc=\"https://github.com/user-attachments/assets/39a50d87-c34b-4f46-a056-7ba071154b87\"\n/>\n\n**Security:**\n<img width=\"1509\" height=\"819\" alt=\"Screenshot 2025-07-25 at 14 18 14\"\nsrc=\"https://github.com/user-attachments/assets/549d6ba1-9033-4d40-b18f-6a276a481388\"\n/>\n\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"ebe304b4807fccff8e16996d1cbab835cc0391ca"}},{"branch":"9.0","label":"v9.0.5","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Angela Chuang <[email protected]>
1 parent 8df264a commit cd51bcb

File tree

15 files changed

+82
-13
lines changed

15 files changed

+82
-13
lines changed

src/platform/plugins/shared/ai_assistant_management/selection/public/app_context.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ interface ContextValue extends StartDependencies {
2020
navigateToApp: CoreStart['application']['navigateToApp'];
2121
kibanaBranch: string;
2222
buildFlavor: BuildFlavor;
23+
securityAIAssistantEnabled: boolean;
2324
}
2425

2526
const AppContext = createContext<ContextValue>(null as any);

src/platform/plugins/shared/ai_assistant_management/selection/public/management_section/mount_section.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ interface MountParams {
2626
mountParams: ManagementAppMountParams;
2727
kibanaBranch: string;
2828
buildFlavor: BuildFlavor;
29+
securityAIAssistantEnabled: boolean;
2930
}
3031

3132
export const mountManagementSection = async ({
3233
core,
3334
mountParams,
3435
kibanaBranch,
3536
buildFlavor,
37+
securityAIAssistantEnabled,
3638
}: MountParams) => {
3739
const [coreStart, startDeps] = await core.getStartServices();
3840
const { element, history, setBreadcrumbs } = mountParams;
@@ -56,6 +58,7 @@ export const mountManagementSection = async ({
5658
setBreadcrumbs,
5759
kibanaBranch,
5860
buildFlavor,
61+
securityAIAssistantEnabled,
5962
}}
6063
>
6164
<RouterProvider history={history} router={aIAssistantManagementSelectionRouter as any}>

src/platform/plugins/shared/ai_assistant_management/selection/public/plugin.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,16 @@ export class AIAssistantManagementPlugin
8282
order: 1,
8383
mount: async (mountParams) => {
8484
const { mountManagementSection } = await import('./management_section/mount_section');
85+
const securityAIAssistantEnabled = !!management?.sections.section.kibana
86+
.getAppsEnabled()
87+
.find((app) => app.id === 'securityAiAssistantManagement' && app.enabled);
8588

8689
return mountManagementSection({
8790
core,
8891
mountParams,
8992
kibanaBranch: this.kibanaBranch,
9093
buildFlavor: this.buildFlavor,
94+
securityAIAssistantEnabled,
9195
});
9296
},
9397
});

src/platform/plugins/shared/ai_assistant_management/selection/public/routes/components/ai_assistant_selection_page.test.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,26 @@ describe('AiAssistantSelectionPage', () => {
2323
const generateMockCapabilities = (hasPermission: boolean) =>
2424
({
2525
observabilityAIAssistant: { show: hasPermission },
26-
securitySolutionAssistant: { 'ai-assistant': hasPermission },
26+
management: {
27+
kibana: {
28+
aiAssistantManagementSelection: hasPermission,
29+
},
30+
},
2731
} as unknown as CoreStart['application']['capabilities']);
2832

2933
const testCapabilities = generateMockCapabilities(true);
3034

31-
const renderComponent = (capabilities: CoreStart['application']['capabilities']) => {
35+
const renderComponent = (
36+
capabilities: CoreStart['application']['capabilities'],
37+
securityAIAssistantEnabled = true
38+
) => {
3239
(useAppContext as jest.Mock).mockReturnValue({
3340
capabilities,
3441
setBreadcrumbs,
3542
navigateToApp,
3643
kibanaBranch: 'main',
3744
buildFlavor: 'ess',
45+
securityAIAssistantEnabled,
3846
});
3947
render(<AiAssistantSelectionPage />, {
4048
wrapper: I18nProvider,
@@ -107,10 +115,12 @@ describe('AiAssistantSelectionPage', () => {
107115
describe('Security AI Assistant Card', () => {
108116
describe('when the feature is disabled', () => {
109117
it('displays the disabled callout', () => {
110-
renderComponent(generateMockCapabilities(false));
118+
const securityAIAssistantEnabled = false;
119+
renderComponent(generateMockCapabilities(false), securityAIAssistantEnabled);
111120
expect(
112121
screen.getByTestId('pluginsAiAssistantSelectionPageSecurityDocumentationCallout')
113122
).toBeInTheDocument();
123+
expect(screen.getByTestId('pluginsAiAssistantSelectionSecurityPageButton')).toBeDisabled();
114124
});
115125
});
116126

src/platform/plugins/shared/ai_assistant_management/selection/public/routes/components/ai_assistant_selection_page.tsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,21 @@ import { getDocLinks } from '@kbn/doc-links';
2626
import { useAppContext } from '../../app_context';
2727

2828
export function AiAssistantSelectionPage() {
29-
const { capabilities, setBreadcrumbs, navigateToApp, buildFlavor, kibanaBranch } =
30-
useAppContext();
29+
const {
30+
capabilities,
31+
setBreadcrumbs,
32+
navigateToApp,
33+
buildFlavor,
34+
kibanaBranch,
35+
securityAIAssistantEnabled,
36+
} = useAppContext();
37+
const aiAssistantManagementSelection =
38+
capabilities.management.kibana.aiAssistantManagementSelection;
3139
const observabilityAIAssistantEnabled = capabilities.observabilityAIAssistant?.show;
32-
const securityAIAssistantEnabled = capabilities.securitySolutionAssistant?.['ai-assistant'];
40+
3341
const observabilityDoc = getDocLinks({ buildFlavor, kibanaBranch }).observability.aiAssistant;
3442
const securityDoc = getDocLinks({ buildFlavor, kibanaBranch }).securitySolution.aiAssistant;
43+
const isSecurityAIAssistantEnabled = securityAIAssistantEnabled && aiAssistantManagementSelection;
3544

3645
useEffect(() => {
3746
setBreadcrumbs([
@@ -148,7 +157,7 @@ export function AiAssistantSelectionPage() {
148157
<EuiCard
149158
description={
150159
<div>
151-
{!securityAIAssistantEnabled ? (
160+
{!isSecurityAIAssistantEnabled ? (
152161
<>
153162
<EuiSpacer size="s" />
154163
<EuiCallOut
@@ -157,8 +166,7 @@ export function AiAssistantSelectionPage() {
157166
title={i18n.translate(
158167
'aiAssistantManagementSelection.aiAssistantSelectionPage.securityAi.thisFeatureIsDisabledCallOutLabel',
159168
{
160-
defaultMessage:
161-
'This feature is disabled. You can enable it from from Spaces > Features.',
169+
defaultMessage: 'This feature is disabled.',
162170
}
163171
)}
164172
size="s"
@@ -188,26 +196,27 @@ export function AiAssistantSelectionPage() {
188196
}}
189197
/>
190198
</p>
191-
{securityAIAssistantEnabled && (
199+
{
192200
<EuiButton
193201
data-test-subj="pluginsAiAssistantSelectionSecurityPageButton"
194202
iconType="gear"
195203
onClick={() =>
196204
navigateToApp('management', { path: 'kibana/securityAiAssistantManagement' })
197205
}
206+
disabled={!isSecurityAIAssistantEnabled}
198207
>
199208
{i18n.translate(
200209
'aiAssistantManagementSelection.aiAssistantSelectionPage.securityAssistant.manageSettingsButtonLabel',
201210
{ defaultMessage: 'Manage Settings' }
202211
)}
203212
</EuiButton>
204-
)}
213+
}
205214
</div>
206215
}
207216
display="plain"
208217
hasBorder
209218
icon={<EuiIcon size="xxl" type="logoSecurity" />}
210-
isDisabled={!securityAIAssistantEnabled}
219+
isDisabled={!isSecurityAIAssistantEnabled}
211220
title={i18n.translate(
212221
'aiAssistantManagementSelection.aiAssistantSelectionPage.securityLabel',
213222
{ defaultMessage: 'Elastic AI Assistant for Security' }

x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/settings/assistant_settings_management.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const mockContext = {
3434
assistantFeatures: { assistantModelEvaluation: true },
3535
assistantAvailability: {
3636
isAssistantEnabled: true,
37+
isAssistantManagementEnabled: true,
3738
},
3839
};
3940

x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/settings/assistant_settings_management.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export const AssistantSettingsManagement: React.FC<Props> = React.memo(
4949
http,
5050
selectedSettingsTab: contextSettingsTab,
5151
setSelectedSettingsTab,
52+
navigateToApp,
53+
assistantAvailability: { isAssistantManagementEnabled },
5254
} = useAssistantContext();
5355

5456
useEffect(() => {
@@ -115,6 +117,10 @@ export const AssistantSettingsManagement: React.FC<Props> = React.memo(
115117
}));
116118
}, [onTabChange, selectedSettingsTab, tabsConfig]);
117119

120+
if (!isAssistantManagementEnabled) {
121+
navigateToApp('management');
122+
}
123+
118124
return (
119125
<>
120126
<EuiPageTemplate.Header

x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant_context/types.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ export interface AssistantAvailability {
6565
hasSearchAILakeConfigurations: boolean;
6666
// True when user is Enterprise, or Security Complete PLI for serverless. When false, the Assistant is disabled and unavailable
6767
isAssistantEnabled: boolean;
68-
6968
// True when the Assistant is visible, i.e. the Assistant is available and the Assistant is visible in the UI
7069
isAssistantVisible: boolean;
70+
// When true, user has `All` privilege for `Management > AI Assistant`
71+
isAssistantManagementEnabled: boolean;
7172
// When true, the Assistant is hidden and unavailable
7273
hasAssistantPrivilege: boolean;
7374
// When true, user has `All` privilege for `Connectors and Actions` (show/execute/delete/save ui capabilities)

x-pack/platform/packages/shared/kbn-elastic-assistant/impl/mock/test_providers/test_providers.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const mockAssistantAvailability: AssistantAvailability = {
4343
hasManageGlobalKnowledgeBase: true,
4444
isAssistantEnabled: true,
4545
isAssistantVisible: true,
46+
isAssistantManagementEnabled: true,
4647
};
4748

4849
/** A utility for wrapping children in the providers required to run tests */

x-pack/platform/packages/shared/kbn-elastic-assistant/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ export interface UseAssistantAvailability {
193193
isAssistantEnabled: boolean;
194194
// True when the Assistant is visible, i.e. the Assistant is available and the Assistant is visible in the UI
195195
isAssistantVisible: boolean;
196+
// When true, user has `All` privilege for `Management > AI Assistant`
197+
isAssistantManagementEnabled: boolean;
196198
// When true, the Assistant is hidden and unavailable
197199
hasAssistantPrivilege: boolean;
198200
// When true, user has `All` privilege for `Connectors and Actions` (show/execute/delete/save ui capabilities)

0 commit comments

Comments
 (0)