mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[Defend workflows] Add tooltip on automated endpoint action form (#161525)
This commit is contained in:
parent
6c2170d385
commit
9e5844f715
4 changed files with 58 additions and 14 deletions
|
@ -45,17 +45,17 @@ const ActionTypeFieldComponent = ({
|
|||
const fieldOptions = useMemo(
|
||||
() =>
|
||||
ENABLED_AUTOMATED_RESPONSE_ACTION_COMMANDS.map((name) => {
|
||||
const isDisabled =
|
||||
map(data.responseActions, 'params.command').includes(name) ||
|
||||
!getRbacControl({
|
||||
commandName: getUiCommand(name),
|
||||
privileges: endpointPrivileges,
|
||||
});
|
||||
const missingRbac = !getRbacControl({
|
||||
commandName: getUiCommand(name),
|
||||
privileges: endpointPrivileges,
|
||||
});
|
||||
const commandAlreadyExists = map(data.responseActions, 'params.command').includes(name);
|
||||
const isDisabled = commandAlreadyExists || missingRbac;
|
||||
|
||||
return {
|
||||
value: name,
|
||||
inputDisplay: name,
|
||||
dropdownDisplay: <EndpointActionText name={name} />,
|
||||
dropdownDisplay: <EndpointActionText name={name} isDisabled={missingRbac} />,
|
||||
disabled: isDisabled,
|
||||
'data-test-subj': `command-type-${name}`,
|
||||
};
|
||||
|
|
|
@ -13,12 +13,39 @@ import { get } from 'lodash';
|
|||
|
||||
interface EndpointCallOutProps {
|
||||
basePath: string;
|
||||
editDisabled: boolean;
|
||||
}
|
||||
|
||||
const EndpointActionCalloutComponent = ({ basePath }: EndpointCallOutProps) => {
|
||||
const EndpointActionCalloutComponent = ({ basePath, editDisabled }: EndpointCallOutProps) => {
|
||||
const [data] = useFormData();
|
||||
const currentCommand = get(data, `${basePath}.command`);
|
||||
|
||||
if (editDisabled) {
|
||||
return (
|
||||
<>
|
||||
<EuiSpacer size="s" />
|
||||
<EuiCallOut
|
||||
color="warning"
|
||||
iconType="warning"
|
||||
title={
|
||||
<FormattedMessage
|
||||
id="xpack.securitySolution.responseActionsList.endpoint.privileges"
|
||||
defaultMessage="Insufficient privileges"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<EuiText size={'xs'}>
|
||||
<FormattedMessage
|
||||
id="xpack.securitySolution.responseActions.endpoint.isolateTooltip"
|
||||
defaultMessage="Insufficient privileges to isolate hosts. Contact your Kibana administrator if you think you should have this permission."
|
||||
/>
|
||||
</EuiText>
|
||||
</EuiCallOut>
|
||||
<EuiSpacer size="s" />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
if (currentCommand === 'isolate') {
|
||||
return (
|
||||
<>
|
||||
|
|
|
@ -27,7 +27,7 @@ export const EndpointResponseAction = React.memo((props: EndpointResponseActionP
|
|||
readDefaultValueOnForm={!props.item.isNew}
|
||||
/>
|
||||
|
||||
<EndpointActionCallout basePath={paramsPath} />
|
||||
<EndpointActionCallout basePath={paramsPath} editDisabled={props.editDisabled} />
|
||||
|
||||
<CommentField
|
||||
basePath={paramsPath}
|
||||
|
|
|
@ -6,17 +6,19 @@
|
|||
*/
|
||||
import type { ReactNode } from 'react';
|
||||
import React from 'react';
|
||||
import { EuiText, EuiTitle, EuiSpacer } from '@elastic/eui';
|
||||
import { EuiText, EuiTitle, EuiSpacer, EuiToolTip } from '@elastic/eui';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import type { EnabledAutomatedResponseActionsCommands } from '../../../../common/endpoint/service/response_actions/constants';
|
||||
|
||||
interface EndpointActionTextProps {
|
||||
name: EnabledAutomatedResponseActionsCommands;
|
||||
isDisabled: boolean;
|
||||
}
|
||||
|
||||
const EndpointActionTextComponent = ({ name }: EndpointActionTextProps) => {
|
||||
const { title, description } = useGetCommandText(name);
|
||||
return (
|
||||
const EndpointActionTextComponent = ({ name, isDisabled }: EndpointActionTextProps) => {
|
||||
const { title, description, tooltip } = useGetCommandText(name);
|
||||
|
||||
const content = (
|
||||
<>
|
||||
<EuiTitle size="xs">
|
||||
<EuiText>{title}</EuiText>
|
||||
|
@ -25,11 +27,19 @@ const EndpointActionTextComponent = ({ name }: EndpointActionTextProps) => {
|
|||
<EuiText>{description}</EuiText>
|
||||
</>
|
||||
);
|
||||
if (isDisabled) {
|
||||
return (
|
||||
<EuiToolTip position="top" content={tooltip}>
|
||||
{content}
|
||||
</EuiToolTip>
|
||||
);
|
||||
}
|
||||
return content;
|
||||
};
|
||||
|
||||
const useGetCommandText = (
|
||||
name: EndpointActionTextProps['name']
|
||||
): { title: ReactNode; description: ReactNode } => {
|
||||
): { title: ReactNode; description: ReactNode; tooltip: ReactNode } => {
|
||||
switch (name) {
|
||||
case 'isolate':
|
||||
return {
|
||||
|
@ -45,11 +55,18 @@ const useGetCommandText = (
|
|||
defaultMessage="Quarantine a host from the network to prevent further spread of threats and limit potential damage"
|
||||
/>
|
||||
),
|
||||
tooltip: (
|
||||
<FormattedMessage
|
||||
id="xpack.securitySolution.responseActions.endpoint.isolateTooltip"
|
||||
defaultMessage="Insufficient privileges to isolate hosts. Contact your Kibana administrator if you think you should have this permission."
|
||||
/>
|
||||
),
|
||||
};
|
||||
default:
|
||||
return {
|
||||
title: '',
|
||||
description: '',
|
||||
tooltip: '',
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue