diff --git a/x-pack/plugins/security_solution/public/cases/components/all_cases/columns.tsx b/x-pack/plugins/security_solution/public/cases/components/all_cases/columns.tsx index 86f854fd0a145..1efcdf2d792f4 100644 --- a/x-pack/plugins/security_solution/public/cases/components/all_cases/columns.tsx +++ b/x-pack/plugins/security_solution/public/cases/components/all_cases/columns.tsx @@ -14,6 +14,8 @@ import { EuiTableActionsColumnType, EuiTableComputedColumnType, EuiTableFieldDataColumnType, + EuiFlexGroup, + EuiFlexItem, } from '@elastic/eui'; import { RIGHT_ALIGNMENT } from '@elastic/eui/lib/services'; import styled from 'styled-components'; @@ -73,12 +75,12 @@ export const getCasesColumns = ( return theCase.status !== CaseStatuses.closed ? ( caseDetailsLinkComponent ) : ( - <> - {caseDetailsLinkComponent} - + + {caseDetailsLinkComponent} + {i18n.CLOSED} - - + + ); } return getEmptyTagValue(); @@ -132,7 +134,6 @@ export const getCasesColumns = ( align: RIGHT_ALIGNMENT, field: 'totalAlerts', name: ALERTS, - sortable: true, render: (totalAlerts: Case['totalAlerts']) => totalAlerts != null ? renderStringField(`${totalAlerts}`, `case-table-column-alertsCount`) @@ -142,22 +143,21 @@ export const getCasesColumns = ( align: RIGHT_ALIGNMENT, field: 'totalComment', name: i18n.COMMENTS, - sortable: true, render: (totalComment: Case['totalComment']) => totalComment != null ? renderStringField(`${totalComment}`, `case-table-column-commentCount`) : getEmptyTagValue(), }, - filterStatus === CaseStatuses.open + filterStatus === CaseStatuses.closed ? { - field: 'createdAt', - name: i18n.OPENED_ON, + field: 'closedAt', + name: i18n.CLOSED_ON, sortable: true, - render: (createdAt: Case['createdAt']) => { - if (createdAt != null) { + render: (closedAt: Case['closedAt']) => { + if (closedAt != null) { return ( - - + + ); } @@ -165,14 +165,14 @@ export const getCasesColumns = ( }, } : { - field: 'closedAt', - name: i18n.CLOSED_ON, + field: 'createdAt', + name: i18n.OPENED_ON, sortable: true, - render: (closedAt: Case['closedAt']) => { - if (closedAt != null) { + render: (createdAt: Case['createdAt']) => { + if (createdAt != null) { return ( - - + + ); } diff --git a/x-pack/plugins/security_solution/public/cases/components/all_cases/index.test.tsx b/x-pack/plugins/security_solution/public/cases/components/all_cases/index.test.tsx index 3ac0084e96fb3..c7dd392bf801c 100644 --- a/x-pack/plugins/security_solution/public/cases/components/all_cases/index.test.tsx +++ b/x-pack/plugins/security_solution/public/cases/components/all_cases/index.test.tsx @@ -827,7 +827,7 @@ describe('AllCases', () => { wrapper.find('button[data-test-subj="case-status-filter-in-progress"]').simulate('click'); await waitFor(() => { expect(setQueryParams).toBeCalledWith({ - sortField: 'updatedAt', + sortField: 'createdAt', }); }); }); diff --git a/x-pack/plugins/security_solution/public/cases/components/all_cases/index.tsx b/x-pack/plugins/security_solution/public/cases/components/all_cases/index.tsx index c5748a321c19b..9f3e23fcde1c0 100644 --- a/x-pack/plugins/security_solution/public/cases/components/all_cases/index.tsx +++ b/x-pack/plugins/security_solution/public/cases/components/all_cases/index.tsx @@ -342,7 +342,7 @@ export const AllCases = React.memo( newFilterOptions.status && newFilterOptions.status === CaseStatuses['in-progress'] ) { - setQueryParams({ sortField: SortFieldCase.updatedAt }); + setQueryParams({ sortField: SortFieldCase.createdAt }); } setFilters(newFilterOptions); refreshCases(false); diff --git a/x-pack/plugins/security_solution/public/cases/components/configure_cases/connectors_dropdown.test.tsx b/x-pack/plugins/security_solution/public/cases/components/configure_cases/connectors_dropdown.test.tsx index 1f1876756773d..ac0bb1f1c742f 100644 --- a/x-pack/plugins/security_solution/public/cases/components/configure_cases/connectors_dropdown.test.tsx +++ b/x-pack/plugins/security_solution/public/cases/components/configure_cases/connectors_dropdown.test.tsx @@ -41,6 +41,7 @@ describe('ConnectorsDropdown', () => { "inputDisplay": { "inputDisplay": { "inputDisplay": { "inputDisplay": { "inputDisplay": + @@ -77,7 +77,7 @@ const ConnectorsDropdownComponent: React.FC = ({ { value: connector.id, inputDisplay: ( - + = ({ {' '} - + {i18n.FIELD_MAPPING_FIRST_COL} diff --git a/x-pack/plugins/security_solution/public/cases/components/configure_cases/field_mapping_row_static.tsx b/x-pack/plugins/security_solution/public/cases/components/configure_cases/field_mapping_row_static.tsx index a732f403ee646..07f5fe35bc834 100644 --- a/x-pack/plugins/security_solution/public/cases/components/configure_cases/field_mapping_row_static.tsx +++ b/x-pack/plugins/security_solution/public/cases/components/configure_cases/field_mapping_row_static.tsx @@ -28,9 +28,9 @@ const FieldMappingRowComponent: React.FC = ({ selectedActionType, ]); return ( - + - + {securitySolutionField} @@ -40,7 +40,7 @@ const FieldMappingRowComponent: React.FC = ({ - + {isLoading ? ( diff --git a/x-pack/plugins/security_solution/public/cases/containers/types.ts b/x-pack/plugins/security_solution/public/cases/containers/types.ts index 6feb5a1501a76..ac60f2999c510 100644 --- a/x-pack/plugins/security_solution/public/cases/containers/types.ts +++ b/x-pack/plugins/security_solution/public/cases/containers/types.ts @@ -117,7 +117,6 @@ export interface AllCases extends CasesStatus { export enum SortFieldCase { createdAt = 'createdAt', closedAt = 'closedAt', - updatedAt = 'updatedAt', } export interface ElasticUser { diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty.tsx index f3dbfc9c363cc..cae4221e5d7ce 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty.tsx @@ -18,6 +18,7 @@ import { PagerDutyConfig, PagerDutySecrets, PagerDutyActionParams, + EventActionOptions, } from '.././types'; import pagerDutySvg from './pagerduty.svg'; import { hasMustacheTokens } from '../../../lib/has_mustache_tokens'; @@ -88,7 +89,10 @@ export function getActionType(): ActionTypeModel< ) ); } - if (!actionParams.summary?.length) { + if ( + actionParams.eventAction === EventActionOptions.TRIGGER && + !actionParams.summary?.length + ) { errors.summary.push( i18n.translate( 'xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.error.requiredSummaryText', diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.test.tsx index 4d47cbf3685a1..f67267a75ed33 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.test.tsx @@ -57,9 +57,29 @@ describe('PagerDutyParamsFields renders', () => { expect(wrapper.find('[data-test-subj="dedupKeyAddVariableButton"]').length > 0).toBeTruthy(); }); - test('params select fields dont auto set values ', () => { + test('params select fields do not auto set values eventActionSelect', () => { const actionParams = {}; + const wrapper = mountWithIntl( + {}} + index={0} + /> + ); + expect(wrapper.find('[data-test-subj="eventActionSelect"]').length > 0).toBeTruthy(); + expect( + wrapper.find('[data-test-subj="eventActionSelect"]').first().prop('value') + ).toStrictEqual(undefined); + }); + + test('params select fields do not auto set values severitySelect', () => { + const actionParams = { + eventAction: EventActionOptions.TRIGGER, + dedupKey: 'test', + }; + const wrapper = mountWithIntl( { expect(wrapper.find('[data-test-subj="severitySelect"]').first().prop('value')).toStrictEqual( undefined ); + }); + + test('only eventActionSelect is available as a payload params for PagerDuty Resolve event', () => { + const actionParams = { + eventAction: EventActionOptions.RESOLVE, + dedupKey: 'test', + }; + + const wrapper = mountWithIntl( + {}} + index={0} + /> + ); + expect(wrapper.find('[data-test-subj="dedupKeyInput"]').length > 0).toBeTruthy(); + expect(wrapper.find('[data-test-subj="dedupKeyInput"]').first().prop('value')).toStrictEqual( + 'test' + ); expect(wrapper.find('[data-test-subj="eventActionSelect"]').length > 0).toBeTruthy(); expect( wrapper.find('[data-test-subj="eventActionSelect"]').first().prop('value') - ).toStrictEqual(undefined); + ).toStrictEqual('resolve'); + expect(wrapper.find('[data-test-subj="dedupKeyInput"]').length > 0).toBeTruthy(); + expect(wrapper.find('[data-test-subj="timestampInput"]').length > 0).toBeFalsy(); + expect(wrapper.find('[data-test-subj="componentInput"]').length > 0).toBeFalsy(); + expect(wrapper.find('[data-test-subj="groupInput"]').length > 0).toBeFalsy(); + expect(wrapper.find('[data-test-subj="sourceInput"]').length > 0).toBeFalsy(); + expect(wrapper.find('[data-test-subj="summaryInput"]').length > 0).toBeFalsy(); }); }); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.tsx index 6923c8dac0001..98dd9c6bf8431 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.tsx @@ -99,32 +99,11 @@ const PagerDutyParamsFields: React.FunctionComponent - - - { - editAction('severity', e.target.value, index); - }} - /> - - - - 0 && summary !== undefined} - label={i18n.translate( - 'xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.summaryFieldLabel', - { - defaultMessage: 'Summary', - } - )} - > - - - - + + {isTriggerPagerDutyEvent ? ( + <> + 0 && timestamp !== undefined} + error={errors.summary} + isInvalid={errors.summary.length > 0 && summary !== undefined} label={i18n.translate( - 'xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.timestampTextFieldLabel', + 'xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.summaryFieldLabel', { - defaultMessage: 'Timestamp (optional)', + defaultMessage: 'Summary', } )} > @@ -218,83 +178,130 @@ const PagerDutyParamsFields: React.FunctionComponent - - - - - - - - - - - - - - - + + + + + { + editAction('severity', e.target.value, index); + }} + /> + + + + 0 && timestamp !== undefined} + label={i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.timestampTextFieldLabel', + { + defaultMessage: 'Timestamp (optional)', + } + )} + > + + + + + + + + + + + + + + + + + + + ) : null} ); }; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.tsx index 7fbe68776ca28..48c6c1b42d7af 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.tsx @@ -105,6 +105,7 @@ export const ActionTypeForm = ({ const defaultActionGroup = actionGroups?.find(({ id }) => id === defaultActionGroupId); const selectedActionGroup = actionGroups?.find(({ id }) => id === actionItem.group) ?? defaultActionGroup; + const [actionGroup, setActionGroup] = useState(); useEffect(() => { setAvailableActionVariables( @@ -120,6 +121,15 @@ export const ActionTypeForm = ({ // eslint-disable-next-line react-hooks/exhaustive-deps }, [actionItem.group]); + useEffect(() => { + if (defaultParams && actionGroup) { + for (const [key, paramValue] of Object.entries(defaultParams)) { + setActionParamsProperty(key, paramValue, index); + } + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [actionGroup]); + const canSave = hasSaveActionsCapability(capabilities); const getSelectedOptions = (actionItemId: string) => { const selectedConnector = connectors.find((connector) => connector.id === actionItemId); @@ -223,6 +233,7 @@ export const ActionTypeForm = ({ valueOfSelected={selectedActionGroup.id} onChange={(group) => { setActionGroupIdByIndex(group, index); + setActionGroup(group); }} />