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 8d237e6 commit 7cd1c68
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
31 changes: 30 additions & 1 deletion public/dependencies/register_assistant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
*/

import React from 'react';
import { AssistantSetup } from '../types';
import { AssistantSetup, TAB_ID } from '../types';
import AlertContainer from './component/AlertContainer';
import { EuiButton, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';

const override: TAB_ID = 'override' as TAB_ID;

export const registerAssistantDependencies = (setup?: AssistantSetup) => {
if (!setup) return;
Expand All @@ -16,4 +19,30 @@ export const registerAssistantDependencies = (setup?: AssistantSetup) => {
<AlertContainer content={rawContent}/>
);
});

setup.registerMessageRenderer('create_alert_button', (content, renderProps) => {
const { content: rawContent} = content;
const { chatContext } = renderProps;
return (<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
<EuiButton
onClick={() => {
if (chatContext) {
if (chatContext.selectedTabId !== override) {
chatContext.setSelectedTabId(override);
}
const component = <AlertContainer content={rawContent}/>
chatContext.setFlyoutComponent(component);
chatContext.setOverrideName('Create Alert');
}
}}
fill
isLoading={false}
disabled={false}
>
Create monitor
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>)
});
};
2 changes: 1 addition & 1 deletion public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
* It will give a type error when dashboards-assistant is not installed so add a ts-ignore to suppress the error.
*/
// @ts-ignore
export type { AssistantSetup, IMessage, RenderProps } from '../../dashboards-assistant/public';
export type { AssistantSetup, IMessage, RenderProps, TAB_ID } from '../../dashboards-assistant/public';

0 comments on commit 7cd1c68

Please sign in to comment.