Skip to content

Commit b77b072

Browse files
authored
[Security Solution][Detections] Rule Form Fixes (#84169) (#84289)
* Prevent error from being displayed when choosing action throttle Addresses #83230. This field was previously refactored to not require a callback prop; simply updating the value via `field.setValue` is sufficient for our use case. This fix removes the errant code that assumed a callback prop, since such a prop does not exist on the underlying component. * Fix UI bug on ML Jobs popover EUI links now add an SVG if they're an external link; our use of a div was causing that to wrap. Since the div was only needed to change the text size, a refactor makes this all work. * Exercise editing of tags in E2E tests These tests were recently skipped due to their improper teardown. Since that's a broader issue across most of these tests, I'm reopening these so we can get the coverage provided here for the time being. * useFetchIndex defaults to isLoading: false In the case where no index pattern is provided, the hook exits without doing any work but does not update the loading state; this had the downstream effect of disabling a form field that was waiting for this hook to stop loading. * Move situational action into ... the situation We only need to clear existing tags in the case where we're editing the rule (and it has tags); in all other cases, this method fails. This fixes things by moving that conditional logic (clear the tags field) into the test that needs it (editing custom rules).
1 parent 607f6df commit b77b072

File tree

6 files changed

+15
-8
lines changed

6 files changed

+15
-8
lines changed

x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_custom.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
SCHEDULE_INTERVAL_AMOUNT_INPUT,
3939
SCHEDULE_INTERVAL_UNITS_INPUT,
4040
SEVERITY_DROPDOWN,
41+
TAGS_CLEAR_BUTTON,
4142
TAGS_FIELD,
4243
} from '../screens/create_new_rule';
4344
import {
@@ -323,6 +324,7 @@ describe('Custom detection rules deletion and edition', () => {
323324
cy.get(ACTIONS_THROTTLE_INPUT).invoke('val').should('eql', 'no_actions');
324325

325326
goToAboutStepTab();
327+
cy.get(TAGS_CLEAR_BUTTON).click({ force: true });
326328
fillAboutRule(editedRule);
327329
saveEditedRule();
328330

x-pack/plugins/security_solution/cypress/objects/rule.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,4 +265,5 @@ export const editedRule = {
265265
...existingRule,
266266
severity: 'Medium',
267267
description: 'Edited Rule description',
268+
tags: [...existingRule.tags, 'edited'],
268269
};

x-pack/plugins/security_solution/cypress/screens/create_new_rule.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ export const TAGS_FIELD =
140140
export const TAGS_INPUT =
141141
'[data-test-subj="detectionEngineStepAboutRuleTags"] [data-test-subj="comboBoxSearchInput"]';
142142

143+
export const TAGS_CLEAR_BUTTON =
144+
'[data-test-subj="detectionEngineStepAboutRuleTags"] [data-test-subj="comboBoxClearButton"]';
145+
143146
export const THRESHOLD_FIELD_SELECTION = '.euiFilterSelectItem';
144147

145148
export const THRESHOLD_INPUT_AREA = '[data-test-subj="thresholdInput"]';

x-pack/plugins/security_solution/public/common/components/ml_popover/jobs_table/jobs_table.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ const JobName = ({ id, description, basePath }: JobNameProps) => {
5757

5858
return (
5959
<JobNameWrapper>
60-
<EuiLink data-test-subj="jobs-table-link" href={jobUrl} target="_blank">
61-
<EuiText size="s">{id}</EuiText>
62-
</EuiLink>
60+
<EuiText size="s">
61+
<EuiLink data-test-subj="jobs-table-link" href={jobUrl} target="_blank">
62+
{id}
63+
</EuiLink>
64+
</EuiText>
6365
<EuiText color="subdued" size="xs">
6466
{description.length > truncateThreshold
6567
? `${description.substring(0, truncateThreshold)}...`

x-pack/plugins/security_solution/public/common/containers/source/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export const useFetchIndex = (
126126
const { data, notifications } = useKibana().services;
127127
const abortCtrl = useRef(new AbortController());
128128
const previousIndexesName = useRef<string[]>([]);
129-
const [isLoading, setLoading] = useState(true);
129+
const [isLoading, setLoading] = useState(false);
130130

131131
const [state, setState] = useState<FetchIndexReturn>({
132132
browserFields: DEFAULT_BROWSER_FIELDS,

x-pack/plugins/security_solution/public/detections/components/rules/throttle_select_field/index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@ export const DEFAULT_THROTTLE_OPTION = THROTTLE_OPTIONS[0];
2525
type ThrottleSelectField = typeof SelectField;
2626

2727
export const ThrottleSelectField: ThrottleSelectField = (props) => {
28+
const { setValue } = props.field;
2829
const onChange = useCallback(
2930
(e) => {
3031
const throttle = e.target.value;
31-
props.field.setValue(throttle);
32-
props.handleChange(throttle);
32+
setValue(throttle);
3333
},
34-
// eslint-disable-next-line react-hooks/exhaustive-deps
35-
[props.field.setValue, props.handleChange]
34+
[setValue]
3635
);
3736
const newEuiFieldProps = { ...props.euiFieldProps, onChange };
3837
return <SelectField {...props} euiFieldProps={newEuiFieldProps} />;

0 commit comments

Comments
 (0)