Skip to content

Commit ef6db6d

Browse files
authored
[Security Solution][Detections] Rule Form Fixes (#84169) (#84288)
* 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 f93ffd2 commit ef6db6d

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

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

Lines changed: 3 additions & 2 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 {
@@ -215,8 +216,7 @@ describe('Custom detection rules creation', () => {
215216
});
216217
});
217218

218-
// FLAKY: https://github.com/elastic/kibana/issues/83772
219-
describe.skip('Custom detection rules deletion and edition', () => {
219+
describe('Custom detection rules deletion and edition', () => {
220220
beforeEach(() => {
221221
esArchiverLoad('custom_rules');
222222
loginAndWaitForPageWithoutDateRange(DETECTIONS_URL);
@@ -328,6 +328,7 @@ describe.skip('Custom detection rules deletion and edition', () => {
328328
cy.get(ACTIONS_THROTTLE_INPUT).invoke('val').should('eql', 'no_actions');
329329

330330
goToAboutStepTab();
331+
cy.get(TAGS_CLEAR_BUTTON).click({ force: true });
331332
fillAboutRule(editedRule);
332333
saveEditedRule();
333334

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
@@ -146,6 +146,9 @@ export const TAGS_FIELD =
146146
export const TAGS_INPUT =
147147
'[data-test-subj="detectionEngineStepAboutRuleTags"] [data-test-subj="comboBoxSearchInput"]';
148148

149+
export const TAGS_CLEAR_BUTTON =
150+
'[data-test-subj="detectionEngineStepAboutRuleTags"] [data-test-subj="comboBoxClearButton"]';
151+
149152
export const THRESHOLD_FIELD_SELECTION = '.euiFilterSelectItem';
150153

151154
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)