Skip to content

Commit

Permalink
Merge branch 'main' into elastic#60
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp authored Sep 25, 2024
2 parents 9292826 + 6c1f18c commit e6c64d0
Show file tree
Hide file tree
Showing 45 changed files with 1,478 additions and 113 deletions.
54 changes: 54 additions & 0 deletions oas_docs/output/kibana.serverless.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15392,6 +15392,39 @@ paths:
tags:
- Security Timeline API
- access:securitySolution
/api/risk_score/engine/dangerously_delete_data:
delete:
description: >-
Cleaning up the the Risk Engine by removing the indices, mapping and
transforms
operationId: CleanUpRiskEngine
responses:
'200':
content:
application/json; Elastic-Api-Version=2023-10-31:
schema:
type: object
properties:
cleanup_successful:
type: boolean
description: Successful response
'400':
content:
application/json; Elastic-Api-Version=2023-10-31:
schema:
$ref: >-
#/components/schemas/Security_Entity_Analytics_API_TaskManagerUnavailableResponse
description: Task manager is unavailable
default:
content:
application/json; Elastic-Api-Version=2023-10-31:
schema:
$ref: >-
#/components/schemas/Security_Entity_Analytics_API_CleanUpRiskEngineErrorResponse
description: Unexpected error
summary: Cleanup the Risk Engine
tags:
- Security Entity Analytics API
/api/risk_score/engine/schedule_now:
post:
description: >-
Expand Down Expand Up @@ -29750,6 +29783,27 @@ components:
required:
- id_value
- id_field
Security_Entity_Analytics_API_CleanUpRiskEngineErrorResponse:
type: object
properties:
cleanup_successful:
example: false
type: boolean
errors:
items:
type: object
properties:
error:
type: string
seq:
type: integer
required:
- seq
- error
type: array
required:
- cleanup_successful
- errors
Security_Entity_Analytics_API_CreateAssetCriticalityRecord:
allOf:
- $ref: >-
Expand Down
54 changes: 54 additions & 0 deletions oas_docs/output/kibana.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18822,6 +18822,39 @@ paths:
tags:
- Security Timeline API
- access:securitySolution
/api/risk_score/engine/dangerously_delete_data:
delete:
description: >-
Cleaning up the the Risk Engine by removing the indices, mapping and
transforms
operationId: CleanUpRiskEngine
responses:
'200':
content:
application/json; Elastic-Api-Version=2023-10-31:
schema:
type: object
properties:
cleanup_successful:
type: boolean
description: Successful response
'400':
content:
application/json; Elastic-Api-Version=2023-10-31:
schema:
$ref: >-
#/components/schemas/Security_Entity_Analytics_API_TaskManagerUnavailableResponse
description: Task manager is unavailable
default:
content:
application/json; Elastic-Api-Version=2023-10-31:
schema:
$ref: >-
#/components/schemas/Security_Entity_Analytics_API_CleanUpRiskEngineErrorResponse
description: Unexpected error
summary: Cleanup the Risk Engine
tags:
- Security Entity Analytics API
/api/risk_score/engine/schedule_now:
post:
description: >-
Expand Down Expand Up @@ -37759,6 +37792,27 @@ components:
required:
- id_value
- id_field
Security_Entity_Analytics_API_CleanUpRiskEngineErrorResponse:
type: object
properties:
cleanup_successful:
example: false
type: boolean
errors:
items:
type: object
properties:
error:
type: string
seq:
type: integer
required:
- seq
- error
type: array
required:
- cleanup_successful
- errors
Security_Entity_Analytics_API_CreateAssetCriticalityRecord:
allOf:
- $ref: >-
Expand Down
6 changes: 6 additions & 0 deletions packages/kbn-esql-utils/src/utils/append_to_query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,11 @@ AND \`dest\`=="Crete"`
and \`ip\`::string!="127.0.0.2/32"`
);
});

it('returns undefined for multivalue fields', () => {
expect(
appendWhereClauseToESQLQuery('from logstash-*', 'dest', ['meow'], '+', 'string')
).toBeUndefined();
});
});
});
6 changes: 5 additions & 1 deletion packages/kbn-esql-utils/src/utils/append_to_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ export function appendWhereClauseToESQLQuery(
value: unknown,
operation: '+' | '-' | 'is_not_null' | 'is_null',
fieldType?: string
): string {
): string | undefined {
// multivalues filtering is not supported yet
if (Array.isArray(value)) {
return undefined;
}
let operator;
switch (operation) {
case 'is_not_null':
Expand Down
18 changes: 16 additions & 2 deletions packages/kbn-management/settings/application/hooks/use_fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { Query } from '@elastic/eui';
import { Ast, Query } from '@elastic/eui';
import { getFieldDefinitions } from '@kbn/management-settings-field-definition';
import { FieldDefinition } from '@kbn/management-settings-types';
import { UiSettingsScope } from '@kbn/core-ui-settings-common';
import { Clause } from '@elastic/eui/src/components/search_bar/query/ast';
import { useServices } from '../services';
import { CATEGORY_FIELD } from '../query_input';
import { useSettings } from './use_settings';

/**
Expand All @@ -29,7 +31,19 @@ export const useFields = (scope: UiSettingsScope, query?: Query): FieldDefinitio
isOverridden: (key) => isOverriddenSetting(key, scope),
});
if (query) {
return Query.execute(query, fields);
const clauses: Clause[] = query.ast.clauses.map((clause) =>
// If the clause value contains `:` and is not a category filter, add it as a term clause
// This allows searching for settings that include `:` in their names
clause.type === 'field' && clause.field !== CATEGORY_FIELD
? {
type: 'term',
match: 'must',
value: `${clause.field}:${clause.value}`,
}
: clause
);

return Query.execute(new Query(Ast.create(clauses), undefined, query.text), fields);
}
return fields;
};
1 change: 1 addition & 0 deletions packages/kbn-unified-data-table/__mocks__/table_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export function buildSelectedDocsState(selectedDocIds: string[]): UseSelectedDoc
selectedDocsCount: selectedDocsSet.size,
docIdsInSelectionOrder: selectedDocIds,
toggleDocSelection: jest.fn(),
toggleMultipleDocsSelection: jest.fn(),
selectAllDocs: jest.fn(),
selectMoreDocs: jest.fn(),
deselectSomeDocs: jest.fn(),
Expand Down
10 changes: 8 additions & 2 deletions packages/kbn-unified-data-table/src/components/data_table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,14 @@ export const UnifiedDataTable = ({
const [isCompareActive, setIsCompareActive] = useState(false);
const displayedColumns = getDisplayedColumns(columns, dataView);
const defaultColumns = displayedColumns.includes('_source');
const docMap = useMemo(() => new Map(rows?.map((row) => [row.id, row]) ?? []), [rows]);
const getDocById = useCallback((id: string) => docMap.get(id), [docMap]);
const docMap = useMemo(
() =>
new Map<string, { doc: DataTableRecord; docIndex: number }>(
rows?.map((row, docIndex) => [row.id, { doc: row, docIndex }]) ?? []
),
[rows]
);
const getDocById = useCallback((id: string) => docMap.get(id)?.doc, [docMap]);
const selectedDocsState = useSelectedDocs(docMap);
const {
isDocSelected,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,13 @@ function buildEuiGridColumn({
cellActions = columnCellActions;
} else {
cellActions = dataViewField
? buildCellActions(dataViewField, toastNotifications, valueToStringConverter, onFilter)
? buildCellActions(
dataViewField,
isPlainRecord,
toastNotifications,
valueToStringConverter,
onFilter
)
: [];

if (columnCellActions?.length && cellActionsHandling === 'append') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const SelectButton = (props: EuiDataGridCellValueElementProps) => {
const { record, rowIndex } = useControlColumn(props);
const { euiTheme } = useEuiTheme();
const { selectedDocsState } = useContext(UnifiedDataTableContext);
const { isDocSelected, toggleDocSelection } = selectedDocsState;
const { isDocSelected, toggleDocSelection, toggleMultipleDocsSelection } = selectedDocsState;

const toggleDocumentSelectionLabel = i18n.translate('unifiedDataTable.grid.selectDoc', {
defaultMessage: `Select document ''{rowNumber}''`,
Expand Down Expand Up @@ -66,8 +66,12 @@ export const SelectButton = (props: EuiDataGridCellValueElementProps) => {
aria-label={toggleDocumentSelectionLabel}
checked={isDocSelected(record.id)}
data-test-subj={`dscGridSelectDoc-${record.id}`}
onChange={() => {
toggleDocSelection(record.id);
onChange={(event) => {
if ((event.nativeEvent as MouseEvent)?.shiftKey) {
toggleMultipleDocsSelection(record.id);
} else {
toggleDocSelection(record.id);
}
}}
/>
</EuiFlexItem>
Expand Down
Loading

0 comments on commit e6c64d0

Please sign in to comment.