Skip to content

Commit

Permalink
[Obs AI Assistant] Fix AI Assistant Settings when plugin disabled (el…
Browse files Browse the repository at this point in the history
…astic#188160)

## Summary

Fixes elastic#187977

AI Assistant settings page doesn't load when the plugin is disabled.

### Changes

- fixes not checking for object before accessing property
- simplifies message so it makes sense for all possible states (read
only, disabled in space, plugin disabled)

### Testing steps
- create a Viewer user
- go to Stack Management -> Advanced Settings -> AI Assistant
- page should load with message that the feature is disabled

<img width="804" alt="Screenshot 2024-07-11 at 4 57 59 PM"
src="https://github.com/user-attachments/assets/98cf85a2-913f-43fd-a5f0-df4494faaf1f">

(cherry picked from commit d4ba879)
  • Loading branch information
neptunian committed Jul 15, 2024
1 parent 1fadaaf commit 023ee77
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import { useAppContext } from '../../app_context';

export function AiAssistantSelectionPage() {
const { capabilities, setBreadcrumbs, navigateToApp } = useAppContext();

const observabilityAIAssistantEnabled = capabilities.observabilityAIAssistant.show;
const observabilityAIAssistantEnabled = capabilities.observabilityAIAssistant?.show;
const securityAIAssistantEnabled = capabilities.securitySolutionAssistant?.['ai-assistant'];

useEffect(() => {
Expand Down Expand Up @@ -78,8 +77,7 @@ export function AiAssistantSelectionPage() {
title={i18n.translate(
'aiAssistantManagementSelection.aiAssistantSelectionPage.observabilityAi.thisFeatureIsDisabledCallOutLabel',
{
defaultMessage:
'This feature is disabled. It can be enabled from Spaces > Features.',
defaultMessage: 'This feature is disabled.',
}
)}
size="s"
Expand Down

0 comments on commit 023ee77

Please sign in to comment.