Skip to content

Commit

Permalink
[Security Solution][Detection Engine] hides 'run query' label on ES|Q…
Browse files Browse the repository at this point in the history
…L rule creation (elastic#167912)

## Summary

- hides **Run query ⌘ + Enter** label on ES|QL text editor when
create/edit rule
- On unified search side, passes property `hideTextBasedRunQueryLabel`
to underlying `TextBasedLangEditor` component

### Before

<img width="1012" alt="Screenshot 2023-10-03 at 17 16 09"
src="https://github.com/elastic/kibana/assets/92328789/8a063167-fd78-4afd-8e2a-0f1168e5a7eb">

### After

<img width="1099" alt="Screenshot 2023-10-03 at 17 16 45"
src="https://github.com/elastic/kibana/assets/92328789/59819074-aab3-4367-a398-739f718368d0">

---------

Co-authored-by: Stratoula Kalafateli <[email protected]>
  • Loading branch information
vitaliidm and stratoula authored Oct 6, 2023
1 parent 447d310 commit 01fdd67
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
onErrorClick={onErrorClick}
refreshErrors={onTextLangQuerySubmit}
detectTimestamp={detectTimestamp}
hideRunQueryText={hideRunQueryText}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,41 @@ describe('QueryBarTopRowTopRow', () => {
`);
});

it('should render query input bar with hideRunQueryText when configured', () => {
const component = mount(
wrapQueryBarTopRowInContext({
query: sqlQuery,
isDirty: false,
screenTitle: 'SQL Screen',
timeHistory: mockTimeHistory,
indexPatterns: [stubIndexPattern],
showDatePicker: true,
dateRangeFrom: 'now-7d',
dateRangeTo: 'now',
hideTextBasedRunQueryLabel: true,
})
);

expect(component.find(TEXT_BASED_EDITOR).prop('hideRunQueryText')).toBe(true);
});

it('should render query input bar with hideRunQueryText as undefined if not configured', () => {
const component = mount(
wrapQueryBarTopRowInContext({
query: sqlQuery,
isDirty: false,
screenTitle: 'SQL Screen',
timeHistory: mockTimeHistory,
indexPatterns: [stubIndexPattern],
showDatePicker: true,
dateRangeFrom: 'now-7d',
dateRangeTo: 'now',
})
);

expect(component.find(TEXT_BASED_EDITOR).prop('hideRunQueryText')).toBe(undefined);
});

it('Should render custom data view picker', () => {
const dataViewPickerOverride = <div data-test-subj="dataViewPickerOverride" />;
const { getByTestId } = render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export interface QueryBarTopRowProps<QT extends Query | AggregateQuery = Query>
dataViewPickerComponentProps?: DataViewPickerProps;
textBasedLanguageModeErrors?: Error[];
textBasedLanguageModeWarning?: string;
hideTextBasedRunQueryLabel?: boolean;
onTextBasedSavedAndExit?: ({ onSave }: OnSaveTextLanguageQueryProps) => void;
filterBar?: React.ReactNode;
showDatePickerAsBadge?: boolean;
Expand Down Expand Up @@ -664,6 +665,7 @@ export const QueryBarTopRow = React.memo(
})
}
isDisabled={props.isDisabled}
hideRunQueryText={props.hideTextBasedRunQueryLabel}
data-test-subj="unifiedTextLangEditor"
/>
)
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/unified_search/public/search_bar/search_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export interface SearchBarOwnProps<QT extends AggregateQuery | Query = Query> {
dataViewPickerComponentProps?: DataViewPickerProps;
textBasedLanguageModeErrors?: Error[];
textBasedLanguageModeWarning?: string;
hideTextBasedRunQueryLabel?: boolean;
onTextBasedSavedAndExit?: ({ onSave }: OnSaveTextLanguageQueryProps) => void;
showSubmitButton?: boolean;
submitButtonStyle?: QueryBarTopRowProps['submitButtonStyle'];
Expand Down Expand Up @@ -599,6 +600,7 @@ class SearchBarUI<QT extends (Query | AggregateQuery) | Query = Query> extends C
dataViewPickerComponentProps={this.props.dataViewPickerComponentProps}
textBasedLanguageModeErrors={this.props.textBasedLanguageModeErrors}
textBasedLanguageModeWarning={this.props.textBasedLanguageModeWarning}
hideTextBasedRunQueryLabel={this.props.hideTextBasedRunQueryLabel}
onTextBasedSavedAndExit={this.props.onTextBasedSavedAndExit}
showDatePickerAsBadge={this.shouldShowDatePickerAsBadge()}
filterBar={filterBar}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export const QueryBar = memo<QueryBarComponentProps>(
savedQuery={savedQuery}
displayStyle={displayStyle}
isDisabled={isDisabled}
hideTextBasedRunQueryLabel
/>
);
}
Expand Down

0 comments on commit 01fdd67

Please sign in to comment.