Skip to content

Commit

Permalink
[FEATURE] Improve "list" text area UX #589
Browse files Browse the repository at this point in the history
Use expression builder instead of code editor

Signed-off-by: Jovan Cvetkovic <jovanca.cvetkovic@gmail.com>
  • Loading branch information
jovancacvetkovic committed May 30, 2023
1 parent 7ffa636 commit 3dd40db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
19 changes: 7 additions & 12 deletions cypress/integration/2_rules.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ const SAMPLE_RULE = {
name: `Cypress test rule ${uniqueId}`,
logType: 'windows',
description: 'This is a rule used to test the rule creation workflow.',
detection:
"condition: selection\nselection:\nProvider_Name|contains:\n- Service Control Manager\nEventID|contains:\n- '7045'\nServiceName|contains:\n- ZzNetSvc",
detectionLine: [
'condition: selection',
'selection:',
'condition: Selection_1',
'Selection_1:',
'Provider_Name|contains:',
'- Service Control Manager',
'EventID|contains:',
Expand Down Expand Up @@ -48,7 +46,7 @@ const YAML_RULE_LINES = [
`- '${SAMPLE_RULE.references}'`,
`author: ${SAMPLE_RULE.author}`,
`detection:`,
...SAMPLE_RULE.detection.replaceAll(' ', '').replaceAll('{backspace}', '').split('\n'),
...SAMPLE_RULE.detectionLine,
];

const checkRulesFlyout = () => {
Expand Down Expand Up @@ -180,11 +178,8 @@ describe('Rules', () => {
`${SAMPLE_RULE.falsePositive}{enter}`
);

// Enter the author
cy.get('[data-test-subj="rule_author_field"]').type(`${SAMPLE_RULE.author}{enter}`);

cy.get('[data-test-subj="detection-visual-editor-0"]').within(() => {
cy.getFieldByLabel('Name').type('selection');
cy.getFieldByLabel('Name').type('{selectall}{backspace}').type('Selection_1');
cy.getFieldByLabel('Key').type('Provider_Name');
cy.getInputByPlaceholder('Value').type('Service Control Manager');

Expand All @@ -200,9 +195,9 @@ describe('Rules', () => {
cy.getInputByPlaceholder('Value').type('ZzNetSvc');
});
});
cy.get('[data-test-subj="rule_detection_field"] textarea').type('selection', {
force: true,
});

// Enter the author
cy.get('[data-test-subj="rule_author_field"]').type(`${SAMPLE_RULE.author}`);

// Switch to YAML editor
cy.get('[data-test-subj="change-editor-type"] label:nth-child(2)').click({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const SelectionExpField: React.FC<SelectionExpFieldProps> = ({
}

setUsedExpressions(expressions);
onChange(getValue(expressions));
}, [value]);

const getValue = (usedExp: UsedSelection[]) => {
Expand Down Expand Up @@ -169,7 +170,11 @@ export const SelectionExpField: React.FC<SelectionExpFieldProps> = ({
<EuiFlexItem
grow={false}
key={`selections_${idx}`}
className={'selection-exp-field-item-with-remove'}
className={
usedExpressions.length > 1
? 'selection-exp-field-item-with-remove'
: 'selection-exp-field-item'
}
>
<EuiPopover
id={`selections_${idx}`}
Expand Down

0 comments on commit 3dd40db

Please sign in to comment.