Skip to content

Commit

Permalink
Fixed errors which are happening if switch between alert types (elast…
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed Mar 18, 2020
1 parent 26352d5 commit 4e5faa5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export const AlertForm = ({ alert, canChangeTrigger = true, dispatch, errors }:
onClick={() => {
setAlertProperty('alertTypeId', item.id);
setAlertTypeModel(item);
setAlertProperty('params', {});
if (alertTypesIndex && alertTypesIndex[item.id]) {
setDefaultActionGroupId(alertTypesIndex[item.id].defaultActionGroupId);
}
Expand Down Expand Up @@ -194,6 +195,7 @@ export const AlertForm = ({ alert, canChangeTrigger = true, dispatch, errors }:
onClick={() => {
setAlertProperty('alertTypeId', null);
setAlertTypeModel(null);
setAlertProperty('params', {});
}}
/>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
loadIndexPatterns,
getMatchingIndicesForThresholdAlertType,
getThresholdAlertTypeFields,
getSavedObjectsClient,
} from '../lib/index_threshold_api';

export interface IOption {
Expand All @@ -18,8 +19,12 @@ export interface IOption {
}

export const getIndexPatterns = async () => {
const indexPatternObjects = await loadIndexPatterns();
return indexPatternObjects.map((indexPattern: any) => indexPattern.attributes.title);
// TODO: Implement a possibility to retrive index patterns different way to be able to expose this in consumer plugins
if (getSavedObjectsClient()) {
const indexPatternObjects = await loadIndexPatterns();
return indexPatternObjects.map((indexPattern: any) => indexPattern.attributes.title);
}
return [];
};

export const getIndexOptions = async (
Expand Down

0 comments on commit 4e5faa5

Please sign in to comment.