From 1b12a98e1b06730b2b929a1193cb2a1c2098ee7b Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Tue, 13 Oct 2020 09:35:34 -0600 Subject: [PATCH 01/20] Add index search query bar --- .../geo_threshold/query_builder/index.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx index b33d5e16c6eb9..5e4ff22b27ac2 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx @@ -72,6 +72,7 @@ export const GeoThresholdAlertTypeExpression: React.FunctionComponent + + + setAlertParams('indexQuery', query)} + /> + From 59339c47ec709de8b23ea6a5461db1b95408a011 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Fri, 16 Oct 2020 10:17:34 -0600 Subject: [PATCH 02/20] Add second query bar and update services used to be compatible with query context services --- .../plugins/triggers_actions_ui/kibana.json | 4 +- .../public/application/app.tsx | 6 ++- .../public/application/app_context.tsx | 7 +++- .../public/application/boot.tsx | 6 +-- .../geo_threshold/query_builder/index.tsx | 39 +++++++++++++++---- .../actions_connectors_list.test.tsx | 10 ++--- .../components/alert_details.test.tsx | 2 +- .../components/alert_details.tsx | 8 ++-- .../sections/alert_form/alert_add.test.tsx | 2 +- .../components/alerts_list.test.tsx | 8 ++-- .../alerts_list/components/alerts_list.tsx | 8 ++-- .../triggers_actions_ui/public/plugin.ts | 7 +++- 12 files changed, 72 insertions(+), 35 deletions(-) diff --git a/x-pack/plugins/triggers_actions_ui/kibana.json b/x-pack/plugins/triggers_actions_ui/kibana.json index c9187096821d8..631da0a035350 100644 --- a/x-pack/plugins/triggers_actions_ui/kibana.json +++ b/x-pack/plugins/triggers_actions_ui/kibana.json @@ -4,8 +4,8 @@ "server": true, "ui": true, "optionalPlugins": ["alerts", "stackAlerts"], - "requiredPlugins": ["management", "charts", "data", "kibanaReact"], + "requiredPlugins": ["management", "charts", "data", "kibanaReact", "savedObjects"], "configPath": ["xpack", "trigger_actions_ui"], "extraPublicDirs": ["public/common", "public/common/constants"], - "requiredBundles": ["alerts", "esUiShared"] + "requiredBundles": ["alerts", "esUiShared", "kibanaReact", "kibanaUtils"] } diff --git a/x-pack/plugins/triggers_actions_ui/public/application/app.tsx b/x-pack/plugins/triggers_actions_ui/public/application/app.tsx index c53dc0c105084..d6fc7ad29f502 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/app.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/app.tsx @@ -24,6 +24,8 @@ import { ChartsPluginStart } from '../../../../../src/plugins/charts/public'; import { DataPublicPluginStart } from '../../../../../src/plugins/data/public'; import { PluginStartContract as AlertingStart } from '../../../alerts/public'; import { suspendedComponentWithProps } from './lib/suspended_component_with_props'; +import { Storage } from '../../../../../src/plugins/kibana_utils/public'; +import { SavedObjectsStart } from '../../../../../src/plugins/saved_objects/public'; const TriggersActionsUIHome = lazy(async () => import('./home')); const AlertDetailsRoute = lazy( @@ -31,13 +33,14 @@ const AlertDetailsRoute = lazy( ); export interface AppDeps { - dataPlugin: DataPublicPluginStart; + data: DataPublicPluginStart; charts: ChartsPluginStart; chrome: ChromeStart; alerts?: AlertingStart; navigateToApp: CoreStart['application']['navigateToApp']; docLinks: DocLinksStart; toastNotifications: ToastsSetup; + storage: Storage; http: HttpSetup; uiSettings: IUiSettingsClient; setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void; @@ -45,6 +48,7 @@ export interface AppDeps { actionTypeRegistry: TypeRegistry; alertTypeRegistry: TypeRegistry; history: ScopedHistory; + savedObjects: SavedObjectsStart; } export const App = (appDeps: AppDeps) => { diff --git a/x-pack/plugins/triggers_actions_ui/public/application/app_context.tsx b/x-pack/plugins/triggers_actions_ui/public/application/app_context.tsx index bf2e0c7274e7b..a4568d069c21c 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/app_context.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/app_context.tsx @@ -5,6 +5,7 @@ */ import React, { createContext, useContext } from 'react'; +import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public'; import { AppDeps } from './app'; const AppContext = createContext(null); @@ -16,7 +17,11 @@ export const AppContextProvider = ({ appDeps: AppDeps | null; children: React.ReactNode; }) => { - return appDeps ? {children} : null; + return appDeps ? ( + + {children} + + ) : null; }; export const useAppDependencies = (): AppDeps => { diff --git a/x-pack/plugins/triggers_actions_ui/public/application/boot.tsx b/x-pack/plugins/triggers_actions_ui/public/application/boot.tsx index c157f923e4447..fbc56dce4929a 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/boot.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/boot.tsx @@ -13,14 +13,14 @@ import { setSavedObjectsClient } from '../common/lib/index_threshold_api'; interface BootDeps extends AppDeps { element: HTMLElement; - savedObjects: SavedObjectsClientContract; + savedObjectsClient: SavedObjectsClientContract; I18nContext: any; } export const boot = (bootDeps: BootDeps) => { - const { I18nContext, element, savedObjects, ...appDeps } = bootDeps; + const { I18nContext, element, savedObjectsClient, ...appDeps } = bootDeps; - setSavedObjectsClient(savedObjects); + setSavedObjectsClient(savedObjectsClient); render( diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx index 5e4ff22b27ac2..2ad7708849911 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx @@ -28,6 +28,7 @@ import { EntityByExpression } from './expressions/entity_by_expression'; import { BoundaryIndexExpression } from './expressions/boundary_index_expression'; import { IIndexPattern } from '../../../../../../../../../src/plugins/data/common/index_patterns'; import { getTimeOptions } from '../../../../../common/lib/get_time_options'; +import { Query, QueryStringInput } from '../../../../../../../../../src/plugins/data/public'; const DEFAULT_VALUES = { TRACKING_EVENT: '', @@ -102,6 +103,14 @@ export const GeoThresholdAlertTypeExpression: React.FunctionComponent({ + query: indexQuery || '', + language: 'kuery', + }); + const setTempIndexQuery = (_tempIndexQuery: Query) => { + setAlertParams('indexQuery', _tempIndexQuery.query); + _setTempIndexQuery(_tempIndexQuery); + }; const [boundaryIndexPattern, _setBoundaryIndexPattern] = useState({ id: '', fields: [], @@ -118,6 +127,14 @@ export const GeoThresholdAlertTypeExpression: React.FunctionComponent({ + query: boundaryIndexQuery || '', + language: 'kuery', + }); + const setTempBoundaryIndexQuery = (_tempBoundaryIndexQuery: Query) => { + setAlertParams('boundaryIndexQuery', _tempBoundaryIndexQuery.query); + _setTempBoundaryIndexQuery(_tempBoundaryIndexQuery); + }; const [delayOffset, _setDelayOffset] = useState(0); function setDelayOffset(_delayOffset: number) { setAlertParams('delayOffsetWithUnits', `${_delayOffset}${delayOffsetUnit}`); @@ -251,14 +268,11 @@ export const GeoThresholdAlertTypeExpression: React.FunctionComponent setAlertParams('indexQuery', query)} + query={tempIndexQuery} + onChange={setTempIndexQuery} /> @@ -329,6 +343,17 @@ export const GeoThresholdAlertTypeExpression: React.FunctionComponent + + + + + ); }; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx index c96e62df71ce4..a57f9397b1b22 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx @@ -52,7 +52,7 @@ describe('actions_connectors_list component empty', () => { const deps = { chrome, docLinks, - dataPlugin: dataPluginMock.createStartContract(), + data: dataPluginMock.createStartContract(), charts: chartPluginMock.createStartContract(), alerting: alertingPluginMock.createStartContract(), toastNotifications: mockes.notifications.toasts, @@ -159,7 +159,7 @@ describe('actions_connectors_list component with items', () => { const deps = { chrome, docLinks, - dataPlugin: dataPluginMock.createStartContract(), + data: dataPluginMock.createStartContract(), charts: chartPluginMock.createStartContract(), alerting: alertingPluginMock.createStartContract(), toastNotifications: mockes.notifications.toasts, @@ -247,7 +247,7 @@ describe('actions_connectors_list component empty with show only capability', () const deps = { chrome, docLinks, - dataPlugin: dataPluginMock.createStartContract(), + data: dataPluginMock.createStartContract(), charts: chartPluginMock.createStartContract(), alerting: alertingPluginMock.createStartContract(), toastNotifications: mockes.notifications.toasts, @@ -336,7 +336,7 @@ describe('actions_connectors_list with show only capability', () => { const deps = { chrome, docLinks, - dataPlugin: dataPluginMock.createStartContract(), + data: dataPluginMock.createStartContract(), charts: chartPluginMock.createStartContract(), alerting: alertingPluginMock.createStartContract(), toastNotifications: mockes.notifications.toasts, @@ -437,7 +437,7 @@ describe('actions_connectors_list component with disabled items', () => { const deps = { chrome, docLinks, - dataPlugin: dataPluginMock.createStartContract(), + data: dataPluginMock.createStartContract(), charts: chartPluginMock.createStartContract(), toastNotifications: mockes.notifications.toasts, injectedMetadata: mockes.injectedMetadata, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.test.tsx index 51c3e030f44eb..ecfb51cbe78b7 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.test.tsx @@ -49,7 +49,7 @@ jest.mock('../../../app_context', () => ({ toastNotifications: mockes.notifications.toasts, docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' }, uiSettings: mockes.uiSettings, - dataPlugin: jest.fn(), + data: jest.fn(), charts: jest.fn(), })), })); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.tsx index 0af01114731a3..ec4c13568150b 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.tsx @@ -72,7 +72,7 @@ export const AlertDetails: React.FunctionComponent = ({ uiSettings, docLinks, charts, - dataPlugin, + data, setBreadcrumbs, chrome, } = useAppDependencies(); @@ -174,11 +174,11 @@ export const AlertDetails: React.FunctionComponent = ({ uiSettings, docLinks, charts, - dataFieldsFormats: dataPlugin.fieldFormats, + dataFieldsFormats: data.fieldFormats, reloadAlerts: setAlert, capabilities, - dataUi: dataPlugin.ui, - dataIndexPatterns: dataPlugin.indexPatterns, + dataUi: data.ui, + dataIndexPatterns: data.indexPatterns, }} > { toastNotifications: mocks.notifications.toasts, http: mocks.http, uiSettings: mocks.uiSettings, - dataPlugin: dataPluginMock.createStartContract(), + data: dataPluginMock.createStartContract(), charts: chartPluginMock.createStartContract(), actionTypeRegistry: actionTypeRegistry as any, alertTypeRegistry: alertTypeRegistry as any, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.test.tsx index 86b9afd9565f8..59154094acd11 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.test.tsx @@ -99,7 +99,7 @@ describe('alerts_list component empty', () => { const deps = { chrome, docLinks, - dataPlugin: dataPluginMock.createStartContract(), + data: dataPluginMock.createStartContract(), charts: chartPluginMock.createStartContract(), alerting: alertingPluginMock.createStartContract(), toastNotifications: mockes.notifications.toasts, @@ -268,7 +268,7 @@ describe('alerts_list component with items', () => { const deps = { chrome, docLinks, - dataPlugin: dataPluginMock.createStartContract(), + data: dataPluginMock.createStartContract(), charts: chartPluginMock.createStartContract(), alerting: alertingPluginMock.createStartContract(), toastNotifications: mockes.notifications.toasts, @@ -349,7 +349,7 @@ describe('alerts_list component empty with show only capability', () => { const deps = { chrome, docLinks, - dataPlugin: dataPluginMock.createStartContract(), + data: dataPluginMock.createStartContract(), charts: chartPluginMock.createStartContract(), alerting: alertingPluginMock.createStartContract(), toastNotifications: mockes.notifications.toasts, @@ -468,7 +468,7 @@ describe('alerts_list with show only capability', () => { const deps = { chrome, docLinks, - dataPlugin: dataPluginMock.createStartContract(), + data: dataPluginMock.createStartContract(), charts: chartPluginMock.createStartContract(), alerting: alertingPluginMock.createStartContract(), toastNotifications: mockes.notifications.toasts, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.tsx index 1ef695f3ed112..f3f4e1a23979c 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.tsx @@ -77,7 +77,7 @@ export const AlertsList: React.FunctionComponent = () => { uiSettings, docLinks, charts, - dataPlugin, + data, } = useAppDependencies(); const canExecuteActions = hasExecuteActionsCapability(capabilities); @@ -643,10 +643,10 @@ export const AlertsList: React.FunctionComponent = () => { uiSettings, docLinks, charts, - dataFieldsFormats: dataPlugin.fieldFormats, + dataFieldsFormats: data.fieldFormats, capabilities, - dataUi: dataPlugin.ui, - dataIndexPatterns: dataPlugin.indexPatterns, + dataUi: data.ui, + dataIndexPatterns: data.indexPatterns, }} > {}; }, From fa4f0ef44b41b0915ad48ce692f123969616d613 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Mon, 19 Oct 2020 15:29:08 -0600 Subject: [PATCH 03/20] Verify syntax and send to server. Add handling for shapes only logic on server --- .../alert_types/geo_threshold/alert_type.ts | 4 ++ .../geo_threshold/es_query_builder.ts | 4 +- .../geo_threshold/geo_threshold.ts | 3 +- .../geo_threshold/query_builder/index.tsx | 60 +++++++++++++++---- 4 files changed, 56 insertions(+), 15 deletions(-) diff --git a/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/alert_type.ts b/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/alert_type.ts index 360a6eb169573..5be692d2ba6e4 100644 --- a/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/alert_type.ts +++ b/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/alert_type.ts @@ -155,6 +155,8 @@ export const ParamsSchema = schema.object({ boundaryGeoField: schema.string({ minLength: 1 }), boundaryNameField: schema.maybe(schema.string({ minLength: 1 })), delayOffsetWithUnits: schema.maybe(schema.string({ minLength: 1 })), + indexQuery: schema.maybe(schema.any({})), + boundaryIndexQuery: schema.maybe(schema.any({})), }); export interface GeoThresholdParams { @@ -170,6 +172,8 @@ export interface GeoThresholdParams { boundaryGeoField: string; boundaryNameField?: string; delayOffsetWithUnits?: string; + indexQuery?: object; + boundaryIndexQuery?: object; } export function getAlertType( diff --git a/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts b/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts index c4238e62ff261..fef8ec21022ff 100644 --- a/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts +++ b/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts @@ -21,7 +21,8 @@ export async function getShapesFilters( callCluster: ILegacyScopedClusterClient['callAsCurrentUser'], log: Logger, alertId: string, - boundaryNameField?: string + boundaryNameField?: string, + boundaryIndexQuery?: object ) { const filters: Record = {}; const shapesIdsNamesMap: Record = {}; @@ -30,6 +31,7 @@ export async function getShapesFilters( index: boundaryIndexTitle, body: { size: MAX_SHAPES_QUERY_SIZE, + ...(boundaryIndexQuery ? { query: boundaryIndexQuery } : {}), }, }); boundaryData.hits.hits.forEach(({ _index, _id }) => { diff --git a/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/geo_threshold.ts b/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/geo_threshold.ts index f30dea151ece8..205b0bf7259e6 100644 --- a/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/geo_threshold.ts +++ b/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/geo_threshold.ts @@ -194,7 +194,8 @@ export const getGeoThresholdExecutor = ({ logger: log }: { logger: Logger }) => services.callCluster, log, alertId, - params.boundaryNameField + params.boundaryNameField, + params.boundaryIndexQuery ); const executeEsQuery = await executeEsQueryFactory(params, services, log, shapesFilters); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx index 2ad7708849911..54d6f2c5ff3e6 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx @@ -28,7 +28,12 @@ import { EntityByExpression } from './expressions/entity_by_expression'; import { BoundaryIndexExpression } from './expressions/boundary_index_expression'; import { IIndexPattern } from '../../../../../../../../../src/plugins/data/common/index_patterns'; import { getTimeOptions } from '../../../../../common/lib/get_time_options'; -import { Query, QueryStringInput } from '../../../../../../../../../src/plugins/data/public'; +import { + esQuery, + Query, + QueryStringInput, +} from '../../../../../../../../../src/plugins/data/public'; +import { esKuery } from '../../../../../../../../../src/plugins/data/public'; const DEFAULT_VALUES = { TRACKING_EVENT: '', @@ -66,6 +71,31 @@ const labelForDelayOffset = ( ); +function validateQuery(query: Query) { + try { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions + query.language === 'kuery' + ? esKuery.fromKueryExpression(query.query) + : esQuery.luceneStringToDsl(query.query); + } catch (err) { + return false; + } + return true; +} + +const getEsFormattedQuery = (query: Query, indexPattern: IIndexPattern) => { + let esFormattedQuery; + + const queryLanguage = query.language; + if (queryLanguage === 'kuery') { + const ast = esKuery.fromKueryExpression(query.query); + esFormattedQuery = esKuery.toElasticsearchQuery(ast, indexPattern); + } else { + esFormattedQuery = esQuery.luceneStringToDsl(query.query); + } + return esFormattedQuery; +}; + export const GeoThresholdAlertTypeExpression: React.FunctionComponent({ + const [tempIndexQuery, setTempIndexQuery] = useState({ query: indexQuery || '', language: 'kuery', }); - const setTempIndexQuery = (_tempIndexQuery: Query) => { - setAlertParams('indexQuery', _tempIndexQuery.query); - _setTempIndexQuery(_tempIndexQuery); - }; const [boundaryIndexPattern, _setBoundaryIndexPattern] = useState({ id: '', fields: [], @@ -127,14 +153,10 @@ export const GeoThresholdAlertTypeExpression: React.FunctionComponent({ + const [tempBoundaryIndexQuery, setTempBoundaryIndexQuery] = useState({ query: boundaryIndexQuery || '', language: 'kuery', }); - const setTempBoundaryIndexQuery = (_tempBoundaryIndexQuery: Query) => { - setAlertParams('boundaryIndexQuery', _tempBoundaryIndexQuery.query); - _setTempBoundaryIndexQuery(_tempBoundaryIndexQuery); - }; const [delayOffset, _setDelayOffset] = useState(0); function setDelayOffset(_delayOffset: number) { setAlertParams('delayOffsetWithUnits', `${_delayOffset}${delayOffsetUnit}`); @@ -272,7 +294,13 @@ export const GeoThresholdAlertTypeExpression: React.FunctionComponent { + if (validateQuery(query)) { + const esFormattedQuery = getEsFormattedQuery(query, indexPattern); + setAlertParams('indexQuery', esFormattedQuery); + } + setTempIndexQuery(query); + }} /> @@ -350,7 +378,13 @@ export const GeoThresholdAlertTypeExpression: React.FunctionComponent { + if (validateQuery(query)) { + const esFormattedQuery = getEsFormattedQuery(query, boundaryIndexPattern); + setAlertParams('boundaryIndexQuery', esFormattedQuery); + } + setTempBoundaryIndexQuery(query); + }} /> From 6680db08d00302444c1b38516d0f994d93ea788f Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Mon, 2 Nov 2020 16:50:54 -0700 Subject: [PATCH 04/20] Construct es queries filters server side with interval dates --- .../geo_threshold/es_query_builder.ts | 77 ++++++++++++++----- .../geo_threshold/query_builder/index.tsx | 19 +---- 2 files changed, 59 insertions(+), 37 deletions(-) diff --git a/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts b/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts index fef8ec21022ff..8c0317f726875 100644 --- a/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts +++ b/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts @@ -7,6 +7,13 @@ import { ILegacyScopedClusterClient } from 'kibana/server'; import { SearchResponse } from 'elasticsearch'; import { Logger } from '../../types'; +import { + Query, + IIndexPattern, + fromKueryExpression, + toElasticsearchQuery, + luceneStringToDsl, +} from '../../../../../../src/plugins/data/common'; export const OTHER_CATEGORY = 'other'; // Consider dynamically obtaining from config? @@ -14,6 +21,19 @@ const MAX_TOP_LEVEL_QUERY_SIZE = 0; const MAX_SHAPES_QUERY_SIZE = 10000; const MAX_BUCKETS_LIMIT = 65535; +const getEsFormattedQuery = (query: Query, indexPattern: IIndexPattern) => { + let esFormattedQuery; + + const queryLanguage = query.language; + if (queryLanguage === 'kuery') { + const ast = fromKueryExpression(query.query); + esFormattedQuery = toElasticsearchQuery(ast, indexPattern); + } else { + esFormattedQuery = luceneStringToDsl(query.query); + } + return esFormattedQuery; +}; + export async function getShapesFilters( boundaryIndexTitle: string, boundaryGeoField: string, @@ -31,7 +51,7 @@ export async function getShapesFilters( index: boundaryIndexTitle, body: { size: MAX_SHAPES_QUERY_SIZE, - ...(boundaryIndexQuery ? { query: boundaryIndexQuery } : {}), + ...(boundaryIndexQuery ? { query: getEsFormattedQuery(boundaryIndexQuery) } : {}), }, }); boundaryData.hits.hits.forEach(({ _index, _id }) => { @@ -68,6 +88,7 @@ export async function executeEsQueryFactory( boundaryGeoField, geoField, boundaryIndexTitle, + indexQuery, }: { entity: string; index: string; @@ -76,6 +97,7 @@ export async function executeEsQueryFactory( geoField: string; boundaryIndexTitle: string; boundaryNameField?: string; + indexQuery?: object; }, { callCluster }: { callCluster: ILegacyScopedClusterClient['callAsCurrentUser'] }, log: Logger, @@ -85,6 +107,19 @@ export async function executeEsQueryFactory( gteDateTime: Date | null, ltDateTime: Date | null ): Promise | undefined> => { + let esFormattedQuery; + if (indexQuery) { + const gteEpochDateTime = new Date(gteDateTime).getTime(); + const ltEpochDateTime = new Date(ltDateTime).getTime(); + const dateRangeUpdatedQuery = + indexQuery.language === 'kuery' + ? `${indexQuery.query} and ${dateField} >= "${gteEpochDateTime}" and ${dateField} < "${ltEpochDateTime}"` + : `${dateField}:[${gteDateTime} TO ${ltDateTime}]`; + esFormattedQuery = getEsFormattedQuery({ + query: dateRangeUpdatedQuery, + language: indexQuery.language, + }); + } // eslint-disable-next-line @typescript-eslint/no-explicit-any const esQuery: Record = { index, @@ -122,27 +157,29 @@ export async function executeEsQueryFactory( }, }, }, - query: { - bool: { - must: [], - filter: [ - { - match_all: {}, - }, - { - range: { - [dateField]: { - ...(gteDateTime ? { gte: gteDateTime } : {}), - lt: ltDateTime, // 'less than' to prevent overlap between intervals - format: 'strict_date_optional_time', + query: esFormattedQuery + ? esFormattedQuery + : { + bool: { + must: [], + filter: [ + { + match_all: {}, }, - }, + { + range: { + [dateField]: { + ...(gteDateTime ? { gte: gteDateTime } : {}), + lt: ltDateTime, // 'less than' to prevent overlap between intervals + format: 'strict_date_optional_time', + }, + }, + }, + ], + should: [], + must_not: [], }, - ], - should: [], - must_not: [], - }, - }, + }, stored_fields: ['*'], docvalue_fields: [ { diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx index 2ab75428403d4..b3e342bd16529 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx @@ -83,19 +83,6 @@ function validateQuery(query: Query) { return true; } -const getEsFormattedQuery = (query: Query, indexPattern: IIndexPattern) => { - let esFormattedQuery; - - const queryLanguage = query.language; - if (queryLanguage === 'kuery') { - const ast = esKuery.fromKueryExpression(query.query); - esFormattedQuery = esKuery.toElasticsearchQuery(ast, indexPattern); - } else { - esFormattedQuery = esQuery.luceneStringToDsl(query.query); - } - return esFormattedQuery; -}; - export const GeoThresholdAlertTypeExpression: React.FunctionComponent { if (validateQuery(query)) { - const esFormattedQuery = getEsFormattedQuery(query, indexPattern); - setAlertParams('indexQuery', esFormattedQuery); + setAlertParams('indexQuery', query); } setTempIndexQuery(query); }} @@ -380,8 +366,7 @@ export const GeoThresholdAlertTypeExpression: React.FunctionComponent { if (validateQuery(query)) { - const esFormattedQuery = getEsFormattedQuery(query, boundaryIndexPattern); - setAlertParams('boundaryIndexQuery', esFormattedQuery); + setAlertParams('boundaryIndexQuery', query); } setTempBoundaryIndexQuery(query); }} From ed259c661867efd80b826092f42381ea2e8d5e24 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Tue, 3 Nov 2020 08:33:15 -0700 Subject: [PATCH 05/20] Fix how query bars repopulate for alert edit --- .../geo_threshold/query_builder/index.tsx | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx index b3e342bd16529..6e0d0919f229c 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx @@ -120,10 +120,12 @@ export const GeoThresholdAlertTypeExpression: React.FunctionComponent({ - query: indexQuery || '', - language: 'kuery', - }); + const [tempIndexQuery, setTempIndexQuery] = useState( + indexQuery || { + query: '', + language: 'kuery', + } + ); const [boundaryIndexPattern, _setBoundaryIndexPattern] = useState({ id: '', fields: [], @@ -140,10 +142,12 @@ export const GeoThresholdAlertTypeExpression: React.FunctionComponent({ - query: boundaryIndexQuery || '', - language: 'kuery', - }); + const [tempBoundaryIndexQuery, setTempBoundaryIndexQuery] = useState( + boundaryIndexQuery || { + query: '', + language: 'kuery', + } + ); const [delayOffset, _setDelayOffset] = useState(0); function setDelayOffset(_delayOffset: number) { setAlertParams('delayOffsetWithUnits', `${_delayOffset}${delayOffsetUnit}`); @@ -282,10 +286,12 @@ export const GeoThresholdAlertTypeExpression: React.FunctionComponent { - if (validateQuery(query)) { - setAlertParams('indexQuery', query); + if (query.language) { + if (validateQuery(query)) { + setAlertParams('indexQuery', query); + } + setTempIndexQuery(query); } - setTempIndexQuery(query); }} /> @@ -365,10 +371,12 @@ export const GeoThresholdAlertTypeExpression: React.FunctionComponent { - if (validateQuery(query)) { - setAlertParams('boundaryIndexQuery', query); + if (query.language) { + if (validateQuery(query)) { + setAlertParams('boundaryIndexQuery', query); + } + setTempBoundaryIndexQuery(query); } - setTempBoundaryIndexQuery(query); }} /> From 8f9fce246198685066fac1abee7c46eae21b07a9 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Tue, 3 Nov 2020 09:16:16 -0700 Subject: [PATCH 06/20] Add parenthesis to query conditions to structure conditions correctly --- .../server/alert_types/geo_threshold/es_query_builder.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts b/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts index 8c0317f726875..8a6209deb6955 100644 --- a/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts +++ b/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts @@ -113,8 +113,8 @@ export async function executeEsQueryFactory( const ltEpochDateTime = new Date(ltDateTime).getTime(); const dateRangeUpdatedQuery = indexQuery.language === 'kuery' - ? `${indexQuery.query} and ${dateField} >= "${gteEpochDateTime}" and ${dateField} < "${ltEpochDateTime}"` - : `${dateField}:[${gteDateTime} TO ${ltDateTime}]`; + ? `(${dateField} >= "${gteEpochDateTime}" and ${dateField} < "${ltEpochDateTime}") and (${indexQuery.query})` + : `(${dateField}:[${gteDateTime} TO ${ltDateTime}]) AND (${indexQuery.query})`; esFormattedQuery = getEsFormattedQuery({ query: dateRangeUpdatedQuery, language: indexQuery.language, From 4f692c4feac832b2cc95f9a12cb5ee31fc233f15 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Wed, 4 Nov 2020 15:33:29 -0700 Subject: [PATCH 07/20] Type fixes and clean up --- .../triggers_actions_ui/public/application/app.tsx | 8 +++++--- .../triggers_actions_ui/public/application/boot.tsx | 7 ++----- .../builtin_alert_types/geo_threshold/types.ts | 4 ++++ .../public/application/test_utils/index.ts | 12 ++++++------ x-pack/plugins/triggers_actions_ui/public/plugin.ts | 3 +-- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/app.tsx b/x-pack/plugins/triggers_actions_ui/public/application/app.tsx index 374330e1f99ea..37ac2e3167d29 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/app.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/app.tsx @@ -15,6 +15,7 @@ import { ChromeBreadcrumb, CoreStart, ScopedHistory, + SavedObjectsClientContract, } from 'kibana/public'; import { Section, routeToAlertDetails } from './constants'; import { KibanaFeature } from '../../../features/common'; @@ -25,7 +26,6 @@ import { DataPublicPluginStart } from '../../../../../src/plugins/data/public'; import { PluginStartContract as AlertingStart } from '../../../alerts/public'; import { suspendedComponentWithProps } from './lib/suspended_component_with_props'; import { Storage } from '../../../../../src/plugins/kibana_utils/public'; -import { SavedObjectsStart } from '../../../../../src/plugins/saved_objects/public'; const TriggersActionsUIHome = lazy(async () => import('./home')); const AlertDetailsRoute = lazy( @@ -40,7 +40,7 @@ export interface AppDeps { navigateToApp: CoreStart['application']['navigateToApp']; docLinks: DocLinksStart; toastNotifications: ToastsSetup; - storage: Storage; + storage?: Storage; http: HttpSetup; uiSettings: IUiSettingsClient; setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void; @@ -48,7 +48,9 @@ export interface AppDeps { actionTypeRegistry: ActionTypeRegistryContract; alertTypeRegistry: AlertTypeRegistryContract; history: ScopedHistory; - savedObjects: SavedObjectsStart; + savedObjects?: { + client: SavedObjectsClientContract; + }; kibanaFeatures: KibanaFeature[]; } diff --git a/x-pack/plugins/triggers_actions_ui/public/application/boot.tsx b/x-pack/plugins/triggers_actions_ui/public/application/boot.tsx index 365d943a9443c..bedd23f445bcb 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/boot.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/boot.tsx @@ -6,21 +6,18 @@ import React from 'react'; import { render, unmountComponentAtNode } from 'react-dom'; -import { SavedObjectsClientContract } from 'src/core/public'; - import { App, AppDeps } from './app'; import { setSavedObjectsClient } from '../common/lib/index_threshold_api'; interface BootDeps extends AppDeps { element: HTMLElement; - savedObjectsClient: SavedObjectsClientContract; I18nContext: any; } export const boot = (bootDeps: BootDeps) => { - const { I18nContext, element, savedObjectsClient, ...appDeps } = bootDeps; + const { I18nContext, element, ...appDeps } = bootDeps; - setSavedObjectsClient(savedObjectsClient); + setSavedObjectsClient(appDeps.savedObjects.client); render( diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/types.ts b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/types.ts index 0358fcd66a467..e165b1a307a8e 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/types.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/types.ts @@ -4,6 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ +import { Query } from '../../../../../../../../src/plugins/data/common/query'; + export enum TrackingEvent { entered = 'entered', exited = 'exited', @@ -22,6 +24,8 @@ export interface GeoThresholdAlertParams { boundaryGeoField: string; boundaryNameField?: string; delayOffsetWithUnits?: string; + indexQuery?: Query; + boundaryIndexQuery?: Query; } // Will eventually include 'geo_shape' diff --git a/x-pack/plugins/triggers_actions_ui/public/application/test_utils/index.ts b/x-pack/plugins/triggers_actions_ui/public/application/test_utils/index.ts index b5ab53d868cf1..061f3faaa6c0f 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/test_utils/index.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/test_utils/index.ts @@ -26,20 +26,20 @@ export async function getMockedAppDependencies() { const kibanaFeatures = await featuresPluginMock.createStart().getFeatures(); return { + data: dataPluginMock.createStartContract(), + charts: chartPluginMock.createStartContract(), chrome, + navigateToApp, docLinks, - dataPlugin: dataPluginMock.createStartContract(), - charts: chartPluginMock.createStartContract(), - alerting: alertingPluginMock.createStartContract(), toastNotifications: coreSetupMock.notifications.toasts, http: coreSetupMock.http, uiSettings: coreSetupMock.uiSettings, - navigateToApp, - capabilities, - history: scopedHistoryMock.create(), setBreadcrumbs: jest.fn(), + capabilities, actionTypeRegistry, alertTypeRegistry, + history: scopedHistoryMock.create(), + alerting: alertingPluginMock.createStartContract(), kibanaFeatures, }; } diff --git a/x-pack/plugins/triggers_actions_ui/public/plugin.ts b/x-pack/plugins/triggers_actions_ui/public/plugin.ts index 674e21bc44c5b..ad074914e694e 100644 --- a/x-pack/plugins/triggers_actions_ui/public/plugin.ts +++ b/x-pack/plugins/triggers_actions_ui/public/plugin.ts @@ -128,7 +128,7 @@ export class Plugin uiSettings: coreStart.uiSettings, docLinks: coreStart.docLinks, chrome: coreStart.chrome, - savedObjectsClient: coreStart.savedObjects.client, + savedObjects: coreStart.savedObjects, I18nContext: coreStart.i18n.Context, capabilities: coreStart.application.capabilities, navigateToApp: coreStart.application.navigateToApp, @@ -136,7 +136,6 @@ export class Plugin history: params.history, actionTypeRegistry, alertTypeRegistry, - savedObjects: pluginsStart.savedObjects, kibanaFeatures, }); }, From 5f5df0cb4bd57de3435116aaf96d01b982636a04 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Wed, 4 Nov 2020 15:34:24 -0700 Subject: [PATCH 08/20] More type fixes and safety checks on the server side --- .../server/alert_types/geo_threshold/alert_type.ts | 5 +++-- .../alert_types/geo_threshold/es_query_builder.ts | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/alert_type.ts b/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/alert_type.ts index 5be692d2ba6e4..8cc0804b22d4e 100644 --- a/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/alert_type.ts +++ b/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/alert_type.ts @@ -15,6 +15,7 @@ import { ActionVariable, AlertTypeState, } from '../../../../alerts/server'; +import { Query } from '../../../../../../src/plugins/data/common/query'; export const GEO_THRESHOLD_ID = '.geo-threshold'; export type TrackingEvent = 'entered' | 'exited'; @@ -172,8 +173,8 @@ export interface GeoThresholdParams { boundaryGeoField: string; boundaryNameField?: string; delayOffsetWithUnits?: string; - indexQuery?: object; - boundaryIndexQuery?: object; + indexQuery?: Query; + boundaryIndexQuery?: Query; } export function getAlertType( diff --git a/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts b/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts index 8a6209deb6955..13f5467a918e6 100644 --- a/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts +++ b/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts @@ -21,7 +21,7 @@ const MAX_TOP_LEVEL_QUERY_SIZE = 0; const MAX_SHAPES_QUERY_SIZE = 10000; const MAX_BUCKETS_LIMIT = 65535; -const getEsFormattedQuery = (query: Query, indexPattern: IIndexPattern) => { +const getEsFormattedQuery = (query: Query, indexPattern?: IIndexPattern) => { let esFormattedQuery; const queryLanguage = query.language; @@ -42,7 +42,7 @@ export async function getShapesFilters( log: Logger, alertId: string, boundaryNameField?: string, - boundaryIndexQuery?: object + boundaryIndexQuery?: Query ) { const filters: Record = {}; const shapesIdsNamesMap: Record = {}; @@ -54,6 +54,7 @@ export async function getShapesFilters( ...(boundaryIndexQuery ? { query: getEsFormattedQuery(boundaryIndexQuery) } : {}), }, }); + boundaryData.hits.hits.forEach(({ _index, _id }) => { filters[_id] = { geo_shape: { @@ -97,7 +98,7 @@ export async function executeEsQueryFactory( geoField: string; boundaryIndexTitle: string; boundaryNameField?: string; - indexQuery?: object; + indexQuery?: Query; }, { callCluster }: { callCluster: ILegacyScopedClusterClient['callAsCurrentUser'] }, log: Logger, @@ -109,8 +110,8 @@ export async function executeEsQueryFactory( ): Promise | undefined> => { let esFormattedQuery; if (indexQuery) { - const gteEpochDateTime = new Date(gteDateTime).getTime(); - const ltEpochDateTime = new Date(ltDateTime).getTime(); + const gteEpochDateTime = gteDateTime ? new Date(gteDateTime).getTime() : null; + const ltEpochDateTime = ltDateTime ? new Date(ltDateTime).getTime() : null; const dateRangeUpdatedQuery = indexQuery.language === 'kuery' ? `(${dateField} >= "${gteEpochDateTime}" and ${dateField} < "${ltEpochDateTime}") and (${indexQuery.query})` From 8e86d59cf0891dd564099c2714a2cdfa1ba0eab9 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Wed, 4 Nov 2020 16:42:50 -0700 Subject: [PATCH 09/20] Type fix --- .../plugins/triggers_actions_ui/public/application/boot.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/boot.tsx b/x-pack/plugins/triggers_actions_ui/public/application/boot.tsx index bedd23f445bcb..3d60d5fca7317 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/boot.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/boot.tsx @@ -17,7 +17,9 @@ interface BootDeps extends AppDeps { export const boot = (bootDeps: BootDeps) => { const { I18nContext, element, ...appDeps } = bootDeps; - setSavedObjectsClient(appDeps.savedObjects.client); + if (appDeps.savedObjects) { + setSavedObjectsClient(appDeps.savedObjects.client); + } render( From a7400330594b5566e4084ef606eae248e4fd18b4 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Wed, 11 Nov 2020 16:41:17 -0700 Subject: [PATCH 10/20] Add tests for esFormattedQuery --- .../geo_threshold/es_query_builder.ts | 2 +- .../tests/es_query_builder.test.ts | 67 +++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/tests/es_query_builder.test.ts diff --git a/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts b/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts index 13f5467a918e6..506a7c08e2aa8 100644 --- a/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts +++ b/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/es_query_builder.ts @@ -21,7 +21,7 @@ const MAX_TOP_LEVEL_QUERY_SIZE = 0; const MAX_SHAPES_QUERY_SIZE = 10000; const MAX_BUCKETS_LIMIT = 65535; -const getEsFormattedQuery = (query: Query, indexPattern?: IIndexPattern) => { +export const getEsFormattedQuery = (query: Query, indexPattern?: IIndexPattern) => { let esFormattedQuery; const queryLanguage = query.language; diff --git a/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/tests/es_query_builder.test.ts b/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/tests/es_query_builder.test.ts new file mode 100644 index 0000000000000..d577a88e8e2f8 --- /dev/null +++ b/x-pack/plugins/stack_alerts/server/alert_types/geo_threshold/tests/es_query_builder.test.ts @@ -0,0 +1,67 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { getEsFormattedQuery } from '../es_query_builder'; + +describe('esFormattedQuery', () => { + it('lucene queries are converted correctly', async () => { + const testLuceneQuery1 = { + query: `"airport": "Denver"`, + language: 'lucene', + }; + const esFormattedQuery1 = getEsFormattedQuery(testLuceneQuery1); + expect(esFormattedQuery1).toStrictEqual({ query_string: { query: '"airport": "Denver"' } }); + const testLuceneQuery2 = { + query: `title:"Fun with turnips" AND text:Cabbage, cabbage and more cabbage!`, + language: 'lucene', + }; + const esFormattedQuery2 = getEsFormattedQuery(testLuceneQuery2); + expect(esFormattedQuery2).toStrictEqual({ + query_string: { + query: `title:"Fun with turnips" AND text:Cabbage, cabbage and more cabbage!`, + }, + }); + }); + + it('kuery queries are converted correctly', async () => { + const testKueryQuery1 = { + query: `"airport": "Denver"`, + language: 'kuery', + }; + const esFormattedQuery1 = getEsFormattedQuery(testKueryQuery1); + expect(esFormattedQuery1).toStrictEqual({ + bool: { minimum_should_match: 1, should: [{ match_phrase: { airport: 'Denver' } }] }, + }); + const testKueryQuery2 = { + query: `"airport": "Denver" and ("animal": "goat" or "animal": "narwhal")`, + language: 'kuery', + }; + const esFormattedQuery2 = getEsFormattedQuery(testKueryQuery2); + expect(esFormattedQuery2).toStrictEqual({ + bool: { + filter: [ + { bool: { should: [{ match_phrase: { airport: 'Denver' } }], minimum_should_match: 1 } }, + { + bool: { + should: [ + { + bool: { should: [{ match_phrase: { animal: 'goat' } }], minimum_should_match: 1 }, + }, + { + bool: { + should: [{ match_phrase: { animal: 'narwhal' } }], + minimum_should_match: 1, + }, + }, + ], + minimum_should_match: 1, + }, + }, + ], + }, + }); + }); +}); From 2499530bb8158171c867955d65840a3f9d5d3f35 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Wed, 11 Nov 2020 16:42:15 -0700 Subject: [PATCH 11/20] Review feedback. Remove 'temp' in names, add 'Input' --- .../geo_threshold/query_builder/index.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx index 6e0d0919f229c..b5e0200424f8a 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/index.tsx @@ -120,7 +120,7 @@ export const GeoThresholdAlertTypeExpression: React.FunctionComponent( + const [indexQueryInput, setIndexQueryInput] = useState( indexQuery || { query: '', language: 'kuery', @@ -142,7 +142,7 @@ export const GeoThresholdAlertTypeExpression: React.FunctionComponent( + const [boundaryIndexQueryInput, setBoundaryIndexQueryInput] = useState( boundaryIndexQuery || { query: '', language: 'kuery', @@ -284,13 +284,13 @@ export const GeoThresholdAlertTypeExpression: React.FunctionComponent { if (query.language) { if (validateQuery(query)) { setAlertParams('indexQuery', query); } - setTempIndexQuery(query); + setIndexQueryInput(query); } }} /> @@ -369,13 +369,13 @@ export const GeoThresholdAlertTypeExpression: React.FunctionComponent { if (query.language) { if (validateQuery(query)) { setAlertParams('boundaryIndexQuery', query); } - setTempBoundaryIndexQuery(query); + setBoundaryIndexQueryInput(query); } }} /> From 120c0c9e262c6877cff04a54a83a75a35b50f80d Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Thu, 12 Nov 2020 09:09:33 -0700 Subject: [PATCH 12/20] Add snapshot tests of index components --- ...eshold_alert_type_expression.test.tsx.snap | 230 ++++++++++++++++++ ...o_threshold_alert_type_expression.test.tsx | 90 +++++++ 2 files changed, 320 insertions(+) create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/__snapshots__/geo_threshold_alert_type_expression.test.tsx.snap create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/geo_threshold_alert_type_expression.test.tsx diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/__snapshots__/geo_threshold_alert_type_expression.test.tsx.snap b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/__snapshots__/geo_threshold_alert_type_expression.test.tsx.snap new file mode 100644 index 0000000000000..1accadbb56bed --- /dev/null +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/__snapshots__/geo_threshold_alert_type_expression.test.tsx.snap @@ -0,0 +1,230 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render BoundaryIndexExpression 1`] = ` + + + + + + + + + + + + } +/> +`; + +exports[`should render EntityIndexExpression 1`] = ` + + + + + + } + labelType="label" + > + + + + + + + } +/> +`; + +exports[`should render EntityIndexExpression w/ invalid flag if invalid 1`] = ` + + + + + + } + labelType="label" + > + + + + + + + } +/> +`; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/geo_threshold_alert_type_expression.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/geo_threshold_alert_type_expression.test.tsx new file mode 100644 index 0000000000000..77bb1f6abe779 --- /dev/null +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/geo_threshold_alert_type_expression.test.tsx @@ -0,0 +1,90 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React, { Fragment } from 'react'; +import { shallow } from 'enzyme'; +import { EntityIndexExpression } from './expressions/entity_index_expression'; +import { IFieldType } from '../../../../../../../../../src/plugins/data/common/index_patterns/fields'; +import { KBN_FIELD_TYPES } from '../../../../../../../../../src/plugins/data/common'; +import { BoundaryIndexExpression } from './expressions/boundary_index_expression'; + +test('should render EntityIndexExpression', async () => { + const dateField: IFieldType = { + type: KBN_FIELD_TYPES.DATE, + name: KBN_FIELD_TYPES.STRING, + aggregatable: true, + }; + const geoField: IFieldType = { + type: KBN_FIELD_TYPES.GEO_POINT, + name: KBN_FIELD_TYPES.STRING, + aggregatable: true, + }; + const alertsContext = {}; + const component = shallow( + {}} + setAlertParamsGeoField={() => {}} + setAlertProperty={() => {}} + setIndexPattern={() => {}} + indexPattern={''} + isInvalid={false} + /> + ); + + expect(component).toMatchSnapshot(); +}); + +test('should render EntityIndexExpression w/ invalid flag if invalid', async () => { + const dateField: IFieldType = { + type: KBN_FIELD_TYPES.DATE, + name: KBN_FIELD_TYPES.STRING, + aggregatable: true, + }; + const geoField: IFieldType = { + type: KBN_FIELD_TYPES.GEO_POINT, + name: KBN_FIELD_TYPES.STRING, + aggregatable: true, + }; + const alertsContext = {}; + const component = shallow( + {}} + setAlertParamsGeoField={() => {}} + setAlertProperty={() => {}} + setIndexPattern={() => {}} + indexPattern={''} + isInvalid={true} + /> + ); + + expect(component).toMatchSnapshot(); +}); + +test('should render BoundaryIndexExpression', async () => { + const alertsContext = {}; + const component = shallow( + {}} + setBoundaryGeoField={() => {}} + setBoundaryNameField={() => {}} + boundaryNameField={''} + /> + ); + + expect(component).toMatchSnapshot(); +}); From 0b6fc7af386b7bca8ee9503f580367f101f06ad5 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Thu, 12 Nov 2020 16:23:03 -0700 Subject: [PATCH 13/20] Type updates --- ...o_threshold_alert_type_expression.test.tsx | 80 ++++++++++--------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/geo_threshold_alert_type_expression.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/geo_threshold_alert_type_expression.test.tsx index 77bb1f6abe779..18e8d93b0f4db 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/geo_threshold_alert_type_expression.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/geo_threshold_alert_type_expression.test.tsx @@ -4,36 +4,52 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { Fragment } from 'react'; +import React from 'react'; import { shallow } from 'enzyme'; import { EntityIndexExpression } from './expressions/entity_index_expression'; -import { IFieldType } from '../../../../../../../../../src/plugins/data/common/index_patterns/fields'; -import { KBN_FIELD_TYPES } from '../../../../../../../../../src/plugins/data/common'; import { BoundaryIndexExpression } from './expressions/boundary_index_expression'; +import { ApplicationStart, DocLinksStart, HttpSetup, ToastsStart } from 'kibana/public'; +import { + ActionTypeRegistryContract, + AlertTypeRegistryContract, + IErrorObject, +} from '../../../../../types'; +import { IIndexPattern } from '../../../../../../../../../src/plugins/data/common/index_patterns'; + +const alertsContext = { + http: (null as unknown) as HttpSetup, + alertTypeRegistry: (null as unknown) as AlertTypeRegistryContract, + actionTypeRegistry: (null as unknown) as ActionTypeRegistryContract, + toastNotifications: (null as unknown) as ToastsStart, + docLinks: (null as unknown) as DocLinksStart, + capabilities: (null as unknown) as ApplicationStart['capabilities'], +}; + +const alertParams = { + index: '', + indexId: '', + geoField: '', + entity: '', + dateField: '', + trackingEvent: '', + boundaryType: '', + boundaryIndexTitle: '', + boundaryIndexId: '', + boundaryGeoField: '', +}; test('should render EntityIndexExpression', async () => { - const dateField: IFieldType = { - type: KBN_FIELD_TYPES.DATE, - name: KBN_FIELD_TYPES.STRING, - aggregatable: true, - }; - const geoField: IFieldType = { - type: KBN_FIELD_TYPES.GEO_POINT, - name: KBN_FIELD_TYPES.STRING, - aggregatable: true, - }; - const alertsContext = {}; const component = shallow( {}} setAlertParamsGeoField={() => {}} setAlertProperty={() => {}} setIndexPattern={() => {}} - indexPattern={''} + indexPattern={('' as unknown) as IIndexPattern} isInvalid={false} /> ); @@ -42,28 +58,17 @@ test('should render EntityIndexExpression', async () => { }); test('should render EntityIndexExpression w/ invalid flag if invalid', async () => { - const dateField: IFieldType = { - type: KBN_FIELD_TYPES.DATE, - name: KBN_FIELD_TYPES.STRING, - aggregatable: true, - }; - const geoField: IFieldType = { - type: KBN_FIELD_TYPES.GEO_POINT, - name: KBN_FIELD_TYPES.STRING, - aggregatable: true, - }; - const alertsContext = {}; const component = shallow( {}} setAlertParamsGeoField={() => {}} setAlertProperty={() => {}} setIndexPattern={() => {}} - indexPattern={''} + indexPattern={('' as unknown) as IIndexPattern} isInvalid={true} /> ); @@ -72,17 +77,16 @@ test('should render EntityIndexExpression w/ invalid flag if invalid', async () }); test('should render BoundaryIndexExpression', async () => { - const alertsContext = {}; const component = shallow( {}} setBoundaryGeoField={() => {}} setBoundaryNameField={() => {}} - boundaryNameField={''} + boundaryNameField={'testNameField'} /> ); From fb27dc542d595e280ea00d0536a4c2a2f785201b Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Thu, 12 Nov 2020 16:25:01 -0700 Subject: [PATCH 14/20] Snapshot updates --- ...eshold_alert_type_expression.test.tsx.snap | 38 +++++-------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/__snapshots__/geo_threshold_alert_type_expression.test.tsx.snap b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/__snapshots__/geo_threshold_alert_type_expression.test.tsx.snap index 1accadbb56bed..d78d6ba698e16 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/__snapshots__/geo_threshold_alert_type_expression.test.tsx.snap +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/geo_threshold/query_builder/__snapshots__/geo_threshold_alert_type_expression.test.tsx.snap @@ -17,6 +17,7 @@ exports[`should render BoundaryIndexExpression 1`] = ` > @@ -81,6 +83,7 @@ exports[`should render EntityIndexExpression 1`] = ` > @@ -164,6 +155,7 @@ exports[`should render EntityIndexExpression w/ invalid flag if invalid 1`] = ` > From ff8aaef1146d5dc41e178cd6aa68900d6060d88d Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Thu, 12 Nov 2020 16:46:57 -0700 Subject: [PATCH 15/20] Update snapshot --- .../geo_threshold_alert_type_expression.test.tsx.snap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/query_builder/__snapshots__/geo_threshold_alert_type_expression.test.tsx.snap b/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/query_builder/__snapshots__/geo_threshold_alert_type_expression.test.tsx.snap index d78d6ba698e16..dae168417b0bc 100644 --- a/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/query_builder/__snapshots__/geo_threshold_alert_type_expression.test.tsx.snap +++ b/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/query_builder/__snapshots__/geo_threshold_alert_type_expression.test.tsx.snap @@ -102,7 +102,7 @@ exports[`should render EntityIndexExpression 1`] = ` label={ } @@ -174,7 +174,7 @@ exports[`should render EntityIndexExpression w/ invalid flag if invalid 1`] = ` label={ } From 56132d40295311de2b2e7393ab0f6dd536be87f7 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Thu, 12 Nov 2020 17:12:37 -0700 Subject: [PATCH 16/20] Update kibana.json to cover deps --- x-pack/plugins/stack_alerts/kibana.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/stack_alerts/kibana.json b/x-pack/plugins/stack_alerts/kibana.json index b7405c38d1611..2957f603c733b 100644 --- a/x-pack/plugins/stack_alerts/kibana.json +++ b/x-pack/plugins/stack_alerts/kibana.json @@ -3,7 +3,8 @@ "server": true, "version": "8.0.0", "kibanaVersion": "kibana", - "requiredPlugins": ["alerts", "features", "triggersActionsUi", "kibanaReact"], + "requiredPlugins": ["alerts", "features", "triggersActionsUi", "kibanaReact", "savedObjects"], "configPath": ["xpack", "stack_alerts"], - "ui": true + "ui": true, + "requiredBundles": ["kibanaReact", "kibanaUtils"] } From 870c16c5c5a89085fada47f7670adac6255a92d3 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Fri, 13 Nov 2020 17:27:02 -0700 Subject: [PATCH 17/20] Add in kibana deps missed by merge --- x-pack/plugins/stack_alerts/kibana.json | 5 ++--- .../public/alert_types/geo_threshold/query_builder/index.tsx | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/stack_alerts/kibana.json b/x-pack/plugins/stack_alerts/kibana.json index 2957f603c733b..884d33ef669e5 100644 --- a/x-pack/plugins/stack_alerts/kibana.json +++ b/x-pack/plugins/stack_alerts/kibana.json @@ -3,8 +3,7 @@ "server": true, "version": "8.0.0", "kibanaVersion": "kibana", - "requiredPlugins": ["alerts", "features", "triggersActionsUi", "kibanaReact", "savedObjects"], + "requiredPlugins": ["alerts", "features", "triggersActionsUi", "kibanaReact", "savedObjects", "data"], "configPath": ["xpack", "stack_alerts"], - "ui": true, - "requiredBundles": ["kibanaReact", "kibanaUtils"] + "ui": true } diff --git a/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/query_builder/index.tsx b/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/query_builder/index.tsx index 55bc985aede7f..64a79e15e25bf 100644 --- a/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/query_builder/index.tsx +++ b/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/query_builder/index.tsx @@ -21,6 +21,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import { AlertTypeParamsExpressionProps, + getTimeOptions, AlertsContextValue, } from '../../../../../triggers_actions_ui/public'; import { GeoThresholdAlertParams, TrackingEvent } from '../types'; From 818dade9a7b9deec7f3bf5b5fe4ca4309c1b44dc Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Mon, 16 Nov 2020 10:23:19 -0700 Subject: [PATCH 18/20] Update deps missed by merge --- .../alert_types/geo_threshold/query_builder/index.tsx | 7 ++++++- x-pack/plugins/triggers_actions_ui/kibana.json | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/query_builder/index.tsx b/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/query_builder/index.tsx index 64a79e15e25bf..623223d66ea00 100644 --- a/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/query_builder/index.tsx +++ b/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/query_builder/index.tsx @@ -30,7 +30,12 @@ import { EntityIndexExpression } from './expressions/entity_index_expression'; import { EntityByExpression } from './expressions/entity_by_expression'; import { BoundaryIndexExpression } from './expressions/boundary_index_expression'; import { IIndexPattern } from '../../../../../../../src/plugins/data/common/index_patterns'; -import { QueryStringInput } from '../../../../../../../src/plugins/data/public'; +import { + esQuery, + esKuery, + Query, + QueryStringInput, +} from '../../../../../../../src/plugins/data/public'; const DEFAULT_VALUES = { TRACKING_EVENT: '', diff --git a/x-pack/plugins/triggers_actions_ui/kibana.json b/x-pack/plugins/triggers_actions_ui/kibana.json index 54cbfa7c21a81..eeb697f147bcf 100644 --- a/x-pack/plugins/triggers_actions_ui/kibana.json +++ b/x-pack/plugins/triggers_actions_ui/kibana.json @@ -3,7 +3,7 @@ "version": "kibana", "server": true, "ui": true, - "requiredPlugins": ["management", "charts", "data", "kibanaReact", "savedObjects"], + "requiredPlugins": ["management", "charts", "data", "kibanaReact", "savedObjects", "features"], "configPath": ["xpack", "trigger_actions_ui"], "extraPublicDirs": ["public/common", "public/common/constants"], "requiredBundles": ["home", "alerts", "esUiShared", "kibanaReact", "kibanaUtils"] From a4586e071f85297b96fbb83b3bd8ede58516dd95 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Mon, 16 Nov 2020 11:00:13 -0700 Subject: [PATCH 19/20] Type updates --- .../geo_threshold_alert_type_expression.test.tsx | 4 ++-- .../stack_alerts/public/alert_types/geo_threshold/types.ts | 2 +- x-pack/plugins/triggers_actions_ui/public/index.ts | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/query_builder/geo_threshold_alert_type_expression.test.tsx b/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/query_builder/geo_threshold_alert_type_expression.test.tsx index 18e8d93b0f4db..d115dbeb76e37 100644 --- a/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/query_builder/geo_threshold_alert_type_expression.test.tsx +++ b/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/query_builder/geo_threshold_alert_type_expression.test.tsx @@ -13,8 +13,8 @@ import { ActionTypeRegistryContract, AlertTypeRegistryContract, IErrorObject, -} from '../../../../../types'; -import { IIndexPattern } from '../../../../../../../../../src/plugins/data/common/index_patterns'; +} from '../../../../../triggers_actions_ui/public'; +import { IIndexPattern } from '../../../../../../../src/plugins/data/common'; const alertsContext = { http: (null as unknown) as HttpSetup, diff --git a/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/types.ts b/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/types.ts index e165b1a307a8e..86faa4ed2fb4a 100644 --- a/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/types.ts +++ b/x-pack/plugins/stack_alerts/public/alert_types/geo_threshold/types.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Query } from '../../../../../../../../src/plugins/data/common/query'; +import { Query } from '../../../../../../src/plugins/data/common'; export enum TrackingEvent { entered = 'entered', diff --git a/x-pack/plugins/triggers_actions_ui/public/index.ts b/x-pack/plugins/triggers_actions_ui/public/index.ts index 3794112e1d502..3187451d2600e 100644 --- a/x-pack/plugins/triggers_actions_ui/public/index.ts +++ b/x-pack/plugins/triggers_actions_ui/public/index.ts @@ -17,6 +17,7 @@ export { AlertTypeModel, ActionType, ActionTypeRegistryContract, + AlertTypeRegistryContract, AlertTypeParamsExpressionProps, ValidationResult, ActionVariable, From c07d6f4b178138bf5e7dfff5c0980a2f3fa5ff16 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Wed, 18 Nov 2020 13:02:09 -0700 Subject: [PATCH 20/20] Add back optional plugin and tweak required plugins to undo merge changes --- x-pack/plugins/triggers_actions_ui/kibana.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/triggers_actions_ui/kibana.json b/x-pack/plugins/triggers_actions_ui/kibana.json index eeb697f147bcf..ab2d6c6a3c400 100644 --- a/x-pack/plugins/triggers_actions_ui/kibana.json +++ b/x-pack/plugins/triggers_actions_ui/kibana.json @@ -3,7 +3,8 @@ "version": "kibana", "server": true, "ui": true, - "requiredPlugins": ["management", "charts", "data", "kibanaReact", "savedObjects", "features"], + "optionalPlugins": ["alerts", "features", "home"], + "requiredPlugins": ["management", "charts", "data", "kibanaReact", "savedObjects"], "configPath": ["xpack", "trigger_actions_ui"], "extraPublicDirs": ["public/common", "public/common/constants"], "requiredBundles": ["home", "alerts", "esUiShared", "kibanaReact", "kibanaUtils"]