Skip to content

Commit

Permalink
fixed add form
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed Apr 30, 2020
1 parent ff3d8a6 commit 5a8d7ce
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ const IndexActionConnectorFields: React.FunctionComponent<ActionConnectorFieldsP

const [indexPatterns, setIndexPatterns] = useState([]);
const [indexOptions, setIndexOptions] = useState<EuiComboBoxOptionOption[]>([]);
const [timeFieldOptions, setTimeFieldOptions] = useState([firstFieldOption]);
const [timeFieldOptions, setTimeFieldOptions] = useState<Array<{ value: string; text: string }>>([
firstFieldOption,
]);
const [isIndiciesLoading, setIsIndiciesLoading] = useState<boolean>(false);

useEffect(() => {
Expand Down Expand Up @@ -160,7 +162,7 @@ const IndexActionConnectorFields: React.FunctionComponent<ActionConnectorFieldsP
return;
}
const currentEsFields = await getFields(http!, indices);
const timeFields = getTimeFieldOptions(currentEsFields as any);
const timeFields = getTimeFieldOptions(currentEsFields as unknown);

setTimeFieldOptions([firstFieldOption, ...timeFields]);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* 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, { useCallback, useReducer, useState } from 'react';
import React, { useCallback, useReducer, useState, useEffect } from 'react';
import { isObject } from 'lodash';
import { FormattedMessage } from '@kbn/i18n/react';
import {
Expand Down Expand Up @@ -60,6 +60,9 @@ export const AlertAdd = ({
const setAlert = (value: any) => {
dispatch({ command: { type: 'setAlert' }, payload: { key: 'alert', value } });
};
const setAlertProperty = (key: string, value: any) => {
dispatch({ command: { type: 'setProperty' }, payload: { key, value } });
};

const {
reloadAlerts,
Expand All @@ -70,6 +73,10 @@ export const AlertAdd = ({
docLinks,
} = useAlertsContext();

useEffect(() => {
setAlertProperty('alertTypeId', alertTypeId);
}, [alertTypeId]);

const closeFlyout = useCallback(() => {
setAddFlyoutVisibility(false);
setAlert(initialAlert);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* 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, useCallback, useReducer, useState, useEffect } from 'react';
import React, { Fragment, useCallback, useReducer, useState } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import {
EuiTitle,
Expand Down

0 comments on commit 5a8d7ce

Please sign in to comment.