-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exposed common EuiExpressions to separate components be able to reuse for building new for Alert Types #56466
Merged
YulNaumenko
merged 19 commits into
elastic:master
from
YulNaumenko:alerts-create-common-alert-type-expressions
Feb 7, 2020
Merged
Changes from 11 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
8c7ed23
Exposed common Expression to separate components be able to reuse
YulNaumenko e090eca
Merge remote-tracking branch 'upstream/master' into alerts-create-com…
YulNaumenko b54cdd6
Expressions with unit tests
YulNaumenko 7c5031c
Fixed type check
YulNaumenko 221194b
Merge remote-tracking branch 'upstream/master' into alerts-create-com…
YulNaumenko a110f9e
Merge remote-tracking branch 'upstream/master' into alerts-create-com…
YulNaumenko db7678b
Fixed merge issues
YulNaumenko 293d985
Fixed due to review
YulNaumenko e4e9f4b
Cleaned up some not used params and added position popover definition
YulNaumenko f310132
Merge remote-tracking branch 'upstream/master' into alerts-create-com…
YulNaumenko 73bc017
fixed type check
YulNaumenko 1ad46d5
Unbinded alerting reusable components from application context
YulNaumenko 2bd5bef
Added consumer and alertTypeId with enable change alert type button p…
YulNaumenko b8a18f4
Fixed case for default alert type id was set
YulNaumenko b9a1a56
Merge remote-tracking branch 'upstream/master' into alerts-create-com…
YulNaumenko 2fcd805
Fixed chart visualization issues
YulNaumenko e414ef7
Exposed registry in triggers and actions ui
YulNaumenko f8438c9
Fixed alert_list to enable charts
YulNaumenko c7485d5
Fixed due to comments and simplified props
YulNaumenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
608 changes: 69 additions & 539 deletions
608
...ns_ui/np_ready/public/application/components/builtin_alert_types/threshold/expression.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...s/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export interface IndexThresholdAlertParams { | ||
YulNaumenko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
index: string[]; | ||
timeField?: string; | ||
aggType: string; | ||
aggField?: string; | ||
groupBy?: string; | ||
termSize?: number; | ||
termField?: string; | ||
thresholdComparator?: string; | ||
threshold: number[]; | ||
timeWindowSize: number; | ||
timeWindowUnit: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
.../legacy/plugins/triggers_actions_ui/np_ready/public/common/constants/aggregation_types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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 { AggregationType } from '../types'; | ||
|
||
export enum AGGREGATION_TYPES { | ||
COUNT = 'count', | ||
AVERAGE = 'avg', | ||
SUM = 'sum', | ||
MIN = 'min', | ||
MAX = 'max', | ||
} | ||
|
||
export const builtInAggregationTypes: { [key: string]: AggregationType } = { | ||
count: { | ||
text: 'count()', | ||
fieldRequired: false, | ||
value: AGGREGATION_TYPES.COUNT, | ||
validNormalizedTypes: [], | ||
}, | ||
avg: { | ||
text: 'average()', | ||
fieldRequired: true, | ||
validNormalizedTypes: ['number'], | ||
value: AGGREGATION_TYPES.AVERAGE, | ||
}, | ||
sum: { | ||
text: 'sum()', | ||
fieldRequired: true, | ||
validNormalizedTypes: ['number'], | ||
value: AGGREGATION_TYPES.SUM, | ||
}, | ||
min: { | ||
text: 'min()', | ||
fieldRequired: true, | ||
validNormalizedTypes: ['number', 'date'], | ||
value: AGGREGATION_TYPES.MIN, | ||
}, | ||
max: { | ||
text: 'max()', | ||
fieldRequired: true, | ||
validNormalizedTypes: ['number', 'date'], | ||
value: AGGREGATION_TYPES.MAX, | ||
}, | ||
}; |
69 changes: 69 additions & 0 deletions
69
x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/constants/comparators.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
YulNaumenko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* 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 { i18n } from '@kbn/i18n'; | ||
import { Comparator } from '../types'; | ||
|
||
export enum COMPARATORS { | ||
GREATER_THAN = '>', | ||
GREATER_THAN_OR_EQUALS = '>=', | ||
BETWEEN = 'between', | ||
LESS_THAN = '<', | ||
LESS_THAN_OR_EQUALS = '<=', | ||
} | ||
|
||
export const builtInComparators: { [key: string]: Comparator } = { | ||
[COMPARATORS.GREATER_THAN]: { | ||
text: i18n.translate( | ||
'xpack.triggersActionsUI.sections.alertAdd.threshold.comparators.isAboveLabel', | ||
{ | ||
defaultMessage: 'Is above', | ||
} | ||
), | ||
value: COMPARATORS.GREATER_THAN, | ||
requiredValues: 1, | ||
}, | ||
[COMPARATORS.GREATER_THAN_OR_EQUALS]: { | ||
text: i18n.translate( | ||
'xpack.triggersActionsUI.sections.alertAdd.threshold.comparators.isAboveOrEqualsLabel', | ||
{ | ||
defaultMessage: 'Is above or equals', | ||
} | ||
), | ||
value: COMPARATORS.GREATER_THAN_OR_EQUALS, | ||
requiredValues: 1, | ||
}, | ||
[COMPARATORS.LESS_THAN]: { | ||
text: i18n.translate( | ||
'xpack.triggersActionsUI.sections.alertAdd.threshold.comparators.isBelowLabel', | ||
{ | ||
defaultMessage: 'Is below', | ||
} | ||
), | ||
value: COMPARATORS.LESS_THAN, | ||
requiredValues: 1, | ||
}, | ||
[COMPARATORS.LESS_THAN_OR_EQUALS]: { | ||
text: i18n.translate( | ||
'xpack.triggersActionsUI.sections.alertAdd.threshold.comparators.isBelowOrEqualsLabel', | ||
{ | ||
defaultMessage: 'Is below or equals', | ||
} | ||
), | ||
value: COMPARATORS.LESS_THAN_OR_EQUALS, | ||
requiredValues: 1, | ||
}, | ||
[COMPARATORS.BETWEEN]: { | ||
text: i18n.translate( | ||
'xpack.triggersActionsUI.sections.alertAdd.threshold.comparators.isBetweenLabel', | ||
{ | ||
defaultMessage: 'Is between', | ||
} | ||
), | ||
value: COMPARATORS.BETWEEN, | ||
requiredValues: 2, | ||
}, | ||
}; |
32 changes: 32 additions & 0 deletions
32
x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/constants/group_by_types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
YulNaumenko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* 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 { i18n } from '@kbn/i18n'; | ||
import { GroupByType } from '../types'; | ||
|
||
export const builtInGroupByTypes: { [key: string]: GroupByType } = { | ||
all: { | ||
text: i18n.translate( | ||
'xpack.triggersActionsUI.sections.alertAdd.threshold.groupByLabel.allDocumentsLabel', | ||
{ | ||
defaultMessage: 'all documents', | ||
} | ||
), | ||
sizeRequired: false, | ||
value: 'all', | ||
validNormalizedTypes: [], | ||
}, | ||
top: { | ||
text: i18n.translate( | ||
'xpack.triggersActionsUI.sections.alertAdd.threshold.groupByLabel.topLabel', | ||
{ | ||
defaultMessage: 'top', | ||
} | ||
), | ||
sizeRequired: true, | ||
value: 'top', | ||
validNormalizedTypes: ['number', 'date', 'keyword'], | ||
}, | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to avoid
any
and theas number[][][]
here?For the
any
: Looking at the underlying type, it looks like it usesnumber
explicitly, so we shouldn't need to cast this here. 🤔For the
number[][][]
: Looks the core issue is theany
ingetThresholdAlertVisualizationData
, so can we perhaps validate the result of the API call ingetThresholdAlertVisualizationData
and avoid theany
there too?