From 6f81cd3e2cf8c63d43c2169028c78e2e6d8e4f27 Mon Sep 17 00:00:00 2001 From: Heng Qian Date: Wed, 17 Jul 2024 15:03:18 +0800 Subject: [PATCH] Move "create alert" button from assistantDashboard to alertingDashboard Signed-off-by: Heng Qian --- common/types/chat_saved_object_attributes.ts | 2 +- public/index.ts | 1 + public/tabs/chat/messages/message_content.tsx | 36 +++++-------------- server/parsers/ParserHelper.ts | 2 +- 4 files changed, 11 insertions(+), 30 deletions(-) diff --git a/common/types/chat_saved_object_attributes.ts b/common/types/chat_saved_object_attributes.ts index 6984bca1..c25d4c0e 100644 --- a/common/types/chat_saved_object_attributes.ts +++ b/common/types/chat_saved_object_attributes.ts @@ -79,7 +79,7 @@ export type ISuggestedAction = IActionBase & ); export type IAdditionalAction = IActionBase & { - actionType: 'create_monitor_grid'; + actionType: 'create_monitor_grid' | 'create_alert_button'; content: string; }; diff --git a/public/index.ts b/public/index.ts index e2786e83..a5a14806 100644 --- a/public/index.ts +++ b/public/index.ts @@ -23,3 +23,4 @@ export function plugin(initializerContext: PluginInitializerContext) { export { AssistantSetup, RenderProps } from './types'; export { IMessage } from '../common/types/chat_saved_object_attributes'; +export { TAB_ID } from './utils/constants'; diff --git a/public/tabs/chat/messages/message_content.tsx b/public/tabs/chat/messages/message_content.tsx index 90369229..9824da44 100644 --- a/public/tabs/chat/messages/message_content.tsx +++ b/public/tabs/chat/messages/message_content.tsx @@ -34,34 +34,14 @@ export const MessageContent: React.FC = React.memo((props) {props.message.content} {props.message.additionalActions && props.message.additionalActions.map((action, index) => ( - - - { - if (chatContext) { - if (chatContext.selectedTabId !== TAB_ID.OVERRIDE) { - chatContext.setSelectedTabId(TAB_ID.OVERRIDE); - } - const actionMessage: IMessage = { - type: 'output', - contentType: action.actionType, - content: action.content, - }; - const component = chatContext.messageRenderers[ - action.actionType - ]?.(actionMessage, { props: { message: actionMessage }, chatContext }); - chatContext.setFlyoutComponent(component); - chatContext.setOverrideName('Create Alert'); - } - }} - fill - isLoading={false} - disabled={false} - > - Create monitor - - - +
+ {chatContext.messageRenderers[action.actionType]?.( + { + ...{ type: 'output', contentType: action.actionType, content: action.content }, + }, + { props, chatContext } + ) ?? null} +
))} ); diff --git a/server/parsers/ParserHelper.ts b/server/parsers/ParserHelper.ts index ef502dce..962c42bc 100644 --- a/server/parsers/ParserHelper.ts +++ b/server/parsers/ParserHelper.ts @@ -39,7 +39,7 @@ export const CreateMonitorParserHelper = (interaction: Interaction): IAdditional return [...new Set(monitorParameters)] .filter((parameters) => parameters) .map((parameters) => ({ - actionType: 'create_monitor_grid', + actionType: 'create_alert_button', message: 'Create Alert', content: Qs.stringify(parameters), }));