Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed Apr 29, 2020
1 parent fdc2be6 commit 16f3e32
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ export const ActionForm = ({
setIsLoadingConnectors(true);
const loadedConnectors = await loadConnectors({ http });
setConnectors(loadedConnectors);
setActionTypesAvalilability(
loadedConnectors.filter(connector => connector.isPreconfigured)
);
} catch (e) {
toastNotifications.addDanger({
title: i18n.translate(
Expand All @@ -146,20 +143,26 @@ export const ActionForm = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const setActionTypesAvalilability = (preconfiguredConnectors: ActionConnector[]) => {
const hasActionsDisabled = actions.some(
action =>
actionTypesIndex &&
!actionTypesIndex[action.actionTypeId].enabled &&
!checkActionFormActionTypeEnabled(
actionTypesIndex[action.actionTypeId],
preconfiguredConnectors
).isEnabled
);
if (setHasActionsDisabled) {
setHasActionsDisabled(hasActionsDisabled);
useEffect(() => {
const setActionTypesAvalilability = () => {
const preconfiguredConnectors = connectors.filter(connector => connector.isPreconfigured);
const hasActionsDisabled = actions.some(
action =>
!actionTypesIndex[action.actionTypeId].enabled &&
!checkActionFormActionTypeEnabled(
actionTypesIndex[action.actionTypeId],
preconfiguredConnectors
).isEnabled
);
if (setHasActionsDisabled) {
setHasActionsDisabled(hasActionsDisabled);
}
};
if (connectors.length > 0 && actionTypesIndex) {
setActionTypesAvalilability();
}
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [connectors, actionTypesIndex]);

const preconfiguredMessage = i18n.translate(
'xpack.triggersActionsUI.sections.actionForm.preconfiguredTitleMessage',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {

it('navigates to an alert details page', async () => {
const action = await alerting.actions.createAction({
name: `server-log-${Date.now()}`,
actionTypeId: '.server-log',
name: `Slack-${Date.now()}`,
actionTypeId: '.slack',
config: {},
secrets: {},
secrets: {
webhookUrl: 'https://test',
},
});

const alert = await alerting.alerts.createAlwaysFiringWithAction(
Expand Down

0 comments on commit 16f3e32

Please sign in to comment.