Skip to content

Commit

Permalink
use alerting component
Browse files Browse the repository at this point in the history
Signed-off-by: Kawika Avilla <[email protected]>
  • Loading branch information
kavilla committed Feb 7, 2024
1 parent 931b56e commit a0809aa
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
3 changes: 0 additions & 3 deletions opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
"requiredEnginePlugins": {
"opensearch-alerting": "*"
},
"requiredBundles": [
"assistantDashboards"
],
"server": true,
"ui": true
}
2 changes: 1 addition & 1 deletion public/components/ContentPanel/ContentPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
EuiTitle,
EuiText,
} from '@elastic/eui';
import { IncontextInsightComponent } from '../../../../../plugins/dashboards-assistant/public';
import { IncontextInsightComponent } from './../../plugin';

const ContentPanel = ({
title = '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import moment from 'moment';
import { DEFAULT_EMPTY_DATA, MONITOR_TYPE } from '../../../../../utils/constants';
import { PLUGIN_NAME } from '../../../../../../utils/constants';
import { getItemLevelType } from './helpers';
import { IncontextInsightComponent } from '../../../../../../../../plugins/dashboards-assistant/public';
import { IncontextInsightComponent } from './../../../../../plugin';

const renderTime = (time) => {
const momentTime = moment(time);
Expand Down
35 changes: 26 additions & 9 deletions public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { PLUGIN_NAME } from '../utils/constants';
import {
Plugin,
CoreSetup,
CoreStart,
} from '../../../src/core/public';
import { Plugin, CoreSetup, CoreStart } from '../../../src/core/public';
import { ACTION_ALERTING } from './actions/alerting_dashboard_action';
import { CONTEXT_MENU_TRIGGER, EmbeddableStart } from '../../../src/plugins/embeddable/public';
import { getActions, getAdAction } from './utils/contextMenu/actions';
import { alertingTriggerAd } from './utils/contextMenu/triggers';
import { ExpressionsSetup } from '../../../src/plugins/expressions/public';
import { UiActionsSetup } from '../../../src/plugins/ui_actions/public';
import { overlayAlertsFunction } from './expressions/overlay_alerts';
import { setClient, setEmbeddable, setNotifications, setOverlays, setSavedAugmentVisLoader, setUISettings, setQueryService } from './services';
import {
setClient,
setEmbeddable,
setNotifications,
setOverlays,
setSavedAugmentVisLoader,
setUISettings,
setQueryService,
} from './services';
import { VisAugmenterStart } from '../../../src/plugins/vis_augmenter/public';
import { DataPublicPluginStart } from '../../../src/plugins/data/public';
import { AssistantPublicPluginSetup } from './../../../plugins/dashboards-assistant/public';
Expand All @@ -27,6 +32,8 @@ declare module '../../../src/plugins/ui_actions/public' {
}
}

export let IncontextInsightComponent = (props: any) => <div {...props} />;

export interface AlertingSetup {}

export interface AlertingStart {}
Expand All @@ -43,8 +50,12 @@ export interface AlertingStartDeps {
data: DataPublicPluginStart;
}

export class AlertingPlugin implements Plugin<AlertingSetup, AlertingStart, AlertingSetupDeps, AlertingStartDeps> {
public setup(core: CoreSetup<AlertingStartDeps, AlertingStart>, { expressions, uiActions, assistantDashboards }: AlertingSetupDeps): AlertingSetup {
export class AlertingPlugin
implements Plugin<AlertingSetup, AlertingStart, AlertingSetupDeps, AlertingStartDeps> {
public setup(
core: CoreSetup<AlertingStartDeps, AlertingStart>,
{ expressions, uiActions, assistantDashboards }: AlertingSetupDeps
): AlertingSetup {
core.application.register({
id: PLUGIN_NAME,
title: 'Alerting',
Expand All @@ -63,6 +74,9 @@ export class AlertingPlugin implements Plugin<AlertingSetup, AlertingStart, Aler
});

if (assistantDashboards) {
IncontextInsightComponent = (props: any) => (
<>{assistantDashboards.renderIncontextInsight(props)}</>
);
assistantDashboards.registerIncontextInsight([
{
key: 'query_level_monitor',
Expand Down Expand Up @@ -104,7 +118,10 @@ export class AlertingPlugin implements Plugin<AlertingSetup, AlertingStart, Aler
return;
}

public start(core: CoreStart, { visAugmenter, embeddable, data }: AlertingStartDeps): AlertingStart {
public start(
core: CoreStart,
{ visAugmenter, embeddable, data }: AlertingStartDeps
): AlertingStart {
setEmbeddable(embeddable);
setOverlays(core.overlays);
setQueryService(data.query);
Expand Down

0 comments on commit a0809aa

Please sign in to comment.