Skip to content

Commit

Permalink
fixed multy select menu
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed Dec 10, 2020
1 parent 1bb9310 commit 2b6082e
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { useState } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiButtonEmpty, EuiFlexItem, EuiFlexGroup } from '@elastic/eui';

import { Alert } from '../../../../types';
import { AlertTableItem } from '../../../../types';
import {
withBulkAlertOperations,
ComponentOpts as BulkOperationsComponentOpts,
Expand All @@ -18,7 +18,7 @@ import './alert_quick_edit_buttons.scss';
import { useKibana } from '../../../../common/lib/kibana';

export type ComponentOpts = {
selectedItems: Alert[];
selectedItems: AlertTableItem[];
onPerformingAction?: () => void;
onActionPerformed?: () => void;
setAlertsToDelete: React.Dispatch<React.SetStateAction<string[]>>;
Expand Down Expand Up @@ -49,6 +49,10 @@ export const AlertQuickEditButtons: React.FunctionComponent<ComponentOpts> = ({
const isPerformingAction =
isMutingAlerts || isUnmutingAlerts || isEnablingAlerts || isDisablingAlerts || isDeletingAlerts;

const hasDisabledByLicenseAlertTypes = !!selectedItems.find(
(alertItem) => !alertItem.enabledInLicense
);

async function onmMuteAllClick() {
onPerformingAction();
setIsMutingAlerts(true);
Expand Down Expand Up @@ -156,7 +160,7 @@ export const AlertQuickEditButtons: React.FunctionComponent<ComponentOpts> = ({
<EuiButtonEmpty
onClick={onmMuteAllClick}
isLoading={isMutingAlerts}
isDisabled={isPerformingAction}
isDisabled={isPerformingAction || hasDisabledByLicenseAlertTypes}
data-test-subj="muteAll"
>
<FormattedMessage
Expand All @@ -171,7 +175,7 @@ export const AlertQuickEditButtons: React.FunctionComponent<ComponentOpts> = ({
<EuiButtonEmpty
onClick={onUnmuteAllClick}
isLoading={isUnmutingAlerts}
isDisabled={isPerformingAction}
isDisabled={isPerformingAction || hasDisabledByLicenseAlertTypes}
data-test-subj="unmuteAll"
>
<FormattedMessage
Expand All @@ -186,7 +190,7 @@ export const AlertQuickEditButtons: React.FunctionComponent<ComponentOpts> = ({
<EuiButtonEmpty
onClick={onEnableAllClick}
isLoading={isEnablingAlerts}
isDisabled={isPerformingAction}
isDisabled={isPerformingAction || hasDisabledByLicenseAlertTypes}
data-test-subj="enableAll"
>
<FormattedMessage
Expand All @@ -201,7 +205,7 @@ export const AlertQuickEditButtons: React.FunctionComponent<ComponentOpts> = ({
<EuiButtonEmpty
onClick={onDisableAllClick}
isLoading={isDisablingAlerts}
isDisabled={isPerformingAction}
isDisabled={isPerformingAction || hasDisabledByLicenseAlertTypes}
data-test-subj="disableAll"
>
<FormattedMessage
Expand Down Expand Up @@ -233,11 +237,11 @@ export const AlertQuickEditButtons: React.FunctionComponent<ComponentOpts> = ({

export const AlertQuickEditButtonsWithApi = withBulkAlertOperations(AlertQuickEditButtons);

function isAlertDisabled(alert: Alert) {
function isAlertDisabled(alert: AlertTableItem) {
return alert.enabled === false;
}

function isAlertMuted(alert: Alert) {
function isAlertMuted(alert: AlertTableItem) {
return alert.muteAll === true;
}

Expand Down

0 comments on commit 2b6082e

Please sign in to comment.