Skip to content

Commit

Permalink
Move "create alert" button from assistantDashboard to alertingDashboard
Browse files Browse the repository at this point in the history
Signed-off-by: Heng Qian <[email protected]>
  • Loading branch information
qianheng-aws committed Jul 17, 2024
1 parent 302123a commit 6f81cd3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 30 deletions.
2 changes: 1 addition & 1 deletion common/types/chat_saved_object_attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
1 change: 1 addition & 0 deletions public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
36 changes: 8 additions & 28 deletions public/tabs/chat/messages/message_content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,14 @@ export const MessageContent: React.FC<MessageContentProps> = React.memo((props)
<EuiMarkdownFormat>{props.message.content}</EuiMarkdownFormat>
{props.message.additionalActions &&
props.message.additionalActions.map((action, index) => (
<EuiFlexGroup key={'action' + index} justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
<EuiButton
onClick={() => {
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
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
<div key={'action-' + index}>
{chatContext.messageRenderers[action.actionType]?.(
{
...{ type: 'output', contentType: action.actionType, content: action.content },
},
{ props, chatContext }
) ?? null}
</div>
))}
</>
);
Expand Down
2 changes: 1 addition & 1 deletion server/parsers/ParserHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}));
Expand Down

0 comments on commit 6f81cd3

Please sign in to comment.