Skip to content

Commit 7cd1c68

Browse files
committed
Move "create alert" button from assistantDashboard to alertingDashboard
Signed-off-by: Heng Qian <qianheng@amazon.com>
1 parent 8d237e6 commit 7cd1c68

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

public/dependencies/register_assistant.tsx

+30-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
*/
55

66
import React from 'react';
7-
import { AssistantSetup } from '../types';
7+
import { AssistantSetup, TAB_ID } from '../types';
88
import AlertContainer from './component/AlertContainer';
9+
import { EuiButton, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
10+
11+
const override: TAB_ID = 'override' as TAB_ID;
912

1013
export const registerAssistantDependencies = (setup?: AssistantSetup) => {
1114
if (!setup) return;
@@ -16,4 +19,30 @@ export const registerAssistantDependencies = (setup?: AssistantSetup) => {
1619
<AlertContainer content={rawContent}/>
1720
);
1821
});
22+
23+
setup.registerMessageRenderer('create_alert_button', (content, renderProps) => {
24+
const { content: rawContent} = content;
25+
const { chatContext } = renderProps;
26+
return (<EuiFlexGroup justifyContent="spaceBetween">
27+
<EuiFlexItem grow={false}>
28+
<EuiButton
29+
onClick={() => {
30+
if (chatContext) {
31+
if (chatContext.selectedTabId !== override) {
32+
chatContext.setSelectedTabId(override);
33+
}
34+
const component = <AlertContainer content={rawContent}/>
35+
chatContext.setFlyoutComponent(component);
36+
chatContext.setOverrideName('Create Alert');
37+
}
38+
}}
39+
fill
40+
isLoading={false}
41+
disabled={false}
42+
>
43+
Create monitor
44+
</EuiButton>
45+
</EuiFlexItem>
46+
</EuiFlexGroup>)
47+
});
1948
};

public/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
* It will give a type error when dashboards-assistant is not installed so add a ts-ignore to suppress the error.
1010
*/
1111
// @ts-ignore
12-
export type { AssistantSetup, IMessage, RenderProps } from '../../dashboards-assistant/public';
12+
export type { AssistantSetup, IMessage, RenderProps, TAB_ID } from '../../dashboards-assistant/public';

0 commit comments

Comments
 (0)