From 8a73528ab10acb5e10d86ac9e60a3a42d1e11f89 Mon Sep 17 00:00:00 2001 From: Viduni Wickramarachchi Date: Thu, 5 Dec 2024 07:38:33 -0500 Subject: [PATCH] [Obs AI Assistant] Update AI Assistant icon for Serverless (#202861) ## Summary ### Problem The Obs AI Assistant icon doesn't look as expected in serverless top navigation. ### Solution Update button CSS for Obs AI Assistant top nav icon for serverless. No changes to the classic navigation. ### Checklist - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --- .../public/components/nav_control/index.tsx | 59 +++++++++++++------ .../nav_control/lazy_nav_control.tsx | 3 + .../public/plugin.tsx | 4 ++ 3 files changed, 47 insertions(+), 19 deletions(-) diff --git a/x-pack/plugins/observability_solution/observability_ai_assistant_app/public/components/nav_control/index.tsx b/x-pack/plugins/observability_solution/observability_ai_assistant_app/public/components/nav_control/index.tsx index b6095ac595cea..fd198c42fda08 100644 --- a/x-pack/plugins/observability_solution/observability_ai_assistant_app/public/components/nav_control/index.tsx +++ b/x-pack/plugins/observability_solution/observability_ai_assistant_app/public/components/nav_control/index.tsx @@ -6,7 +6,7 @@ */ import React, { useEffect, useRef, useState } from 'react'; import { AssistantAvatar, useAbortableAsync } from '@kbn/observability-ai-assistant-plugin/public'; -import { EuiButton, EuiLoadingSpinner, EuiToolTip } from '@elastic/eui'; +import { EuiButton, EuiButtonEmpty, EuiLoadingSpinner, EuiToolTip } from '@elastic/eui'; import { css } from '@emotion/react'; import { v4 } from 'uuid'; import useObservable from 'react-use/lib/useObservable'; @@ -24,12 +24,14 @@ interface NavControlWithProviderDeps { appService: AIAssistantAppService; coreStart: CoreStart; pluginsStart: ObservabilityAIAssistantAppPluginStartDependencies; + isServerless?: boolean; } export const NavControlWithProvider = ({ appService, coreStart, pluginsStart, + isServerless, }: NavControlWithProviderDeps) => { return ( - + ); }; -export function NavControl() { +export function NavControl({ isServerless }: { isServerless?: boolean }) { const service = useAIAssistantAppService(); const { @@ -140,22 +142,41 @@ export function NavControl() { return ( <> - { - service.conversations.openNewConversation({ - messages: [], - }); - }} - color="primary" - size="s" - fullWidth={false} - minWidth={0} - > - {chatService.loading ? : } - + {isServerless ? ( + { + service.conversations.openNewConversation({ + messages: [], + }); + }} + color="primary" + size="s" + > + {chatService.loading ? : } + + ) : ( + { + service.conversations.openNewConversation({ + messages: [], + }); + }} + color="primary" + size="s" + fullWidth={false} + minWidth={0} + > + {chatService.loading ? : } + + )} {chatService.value ? ( diff --git a/x-pack/plugins/observability_solution/observability_ai_assistant_app/public/components/nav_control/lazy_nav_control.tsx b/x-pack/plugins/observability_solution/observability_ai_assistant_app/public/components/nav_control/lazy_nav_control.tsx index adef91ceea53e..9a6fd2f30d918 100644 --- a/x-pack/plugins/observability_solution/observability_ai_assistant_app/public/components/nav_control/lazy_nav_control.tsx +++ b/x-pack/plugins/observability_solution/observability_ai_assistant_app/public/components/nav_control/lazy_nav_control.tsx @@ -20,12 +20,14 @@ interface NavControlInitiatorProps { appService: AIAssistantAppService; coreStart: CoreStart; pluginsStart: ObservabilityAIAssistantAppPluginStartDependencies; + isServerless?: boolean; } export const NavControlInitiator = ({ appService, coreStart, pluginsStart, + isServerless, }: NavControlInitiatorProps) => { const { isVisible } = useIsNavControlVisible({ coreStart, pluginsStart }); @@ -38,6 +40,7 @@ export const NavControlInitiator = ({ appService={appService} coreStart={coreStart} pluginsStart={pluginsStart} + isServerless={isServerless} /> ); }; diff --git a/x-pack/plugins/observability_solution/observability_ai_assistant_app/public/plugin.tsx b/x-pack/plugins/observability_solution/observability_ai_assistant_app/public/plugin.tsx index 1904eebffb2a8..cd1285b0017ce 100644 --- a/x-pack/plugins/observability_solution/observability_ai_assistant_app/public/plugin.tsx +++ b/x-pack/plugins/observability_solution/observability_ai_assistant_app/public/plugin.tsx @@ -41,10 +41,13 @@ export class ObservabilityAIAssistantAppPlugin { logger: Logger; appService: AIAssistantAppService | undefined; + isServerless: boolean; constructor(context: PluginInitializerContext) { this.logger = context.logger.get(); + this.isServerless = context.env.packageInfo.buildFlavor === 'serverless'; } + setup( coreSetup: CoreSetup, _: ObservabilityAIAssistantAppPluginSetupDependencies @@ -111,6 +114,7 @@ export class ObservabilityAIAssistantAppPlugin appService={appService} coreStart={coreStart} pluginsStart={pluginsStart} + isServerless={this.isServerless} />, element, () => {}