Skip to content

Commit

Permalink
Fixed errors which are happening if switch between alert types
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed Mar 17, 2020
1 parent 631d93d commit 93eeb23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
getMatchingIndicesForThresholdAlertType,
getThresholdAlertTypeFields,
loadIndexPatterns,
getSavedObjectsClient,
} from './lib/api';
import { getTimeFieldOptions } from '../../../../common/lib/get_time_options';
import { ThresholdVisualization } from './visualization';
Expand Down Expand Up @@ -125,9 +126,11 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent<IndexThr
);

const getIndexPatterns = async () => {
const indexPatternObjects = await loadIndexPatterns();
const titles = indexPatternObjects.map((indexPattern: any) => indexPattern.attributes.title);
setIndexPatterns(titles);
if (getSavedObjectsClient()) {
const indexPatternObjects = await loadIndexPatterns();
const titles = indexPatternObjects.map((indexPattern: any) => indexPattern.attributes.title);
setIndexPatterns(titles);
}
};

const expressionErrorMessage = i18n.translate(
Expand Down
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

0 comments on commit 93eeb23

Please sign in to comment.