Skip to content

Commit

Permalink
Merge branch 'main' into ELS-41
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Feb 6, 2023
2 parents 2b0a470 + daf1304 commit 8c6c55a
Show file tree
Hide file tree
Showing 172 changed files with 4,927 additions and 1,307 deletions.
14 changes: 11 additions & 3 deletions examples/guided_onboarding_example/public/components/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
EuiText,
EuiTitle,
EuiSelectOption,
EuiFlexGrid,
} from '@elastic/eui';
import type { GuideState, GuideStepIds, GuideId, GuideStep } from '@kbn/guided-onboarding';
import type { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/public';
Expand All @@ -34,7 +35,14 @@ interface MainProps {
notifications: CoreStart['notifications'];
}

const exampleGuideIds: GuideId[] = ['search', 'siem', 'kubernetes', 'testGuide'];
const exampleGuideIds: GuideId[] = [
'appSearch',
'websiteSearch',
'databaseSearch',
'siem',
'kubernetes',
'testGuide',
];
const selectOptions: EuiSelectOption[] = exampleGuideIds.map((guideId) => ({
value: guideId,
text: guideId,
Expand Down Expand Up @@ -211,7 +219,7 @@ export const Main = (props: MainProps) => {
</h3>
</EuiText>
<EuiSpacer />
<EuiFlexGroup>
<EuiFlexGrid columns={3}>
{exampleGuideIds.map((guideId) => {
const guideState = guidesState?.find((guide) => guide.guideId === guideId);
return (
Expand Down Expand Up @@ -255,7 +263,7 @@ export const Main = (props: MainProps) => {
</EuiFlexItem>
);
})}
</EuiFlexGroup>
</EuiFlexGrid>
<EuiSpacer />
<EuiHorizontalRule />
<EuiText>
Expand Down
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,19 @@
"@dnd-kit/utilities": "^2.0.0",
"@elastic/apm-rum": "^5.12.0",
"@elastic/apm-rum-react": "^1.4.2",
"@elastic/charts": "51.3.0",
"@elastic/charts": "52.0.0",
"@elastic/datemath": "5.0.3",
"@elastic/elasticsearch": "npm:@elastic/[email protected]",
"@elastic/ems-client": "8.4.0",
"@elastic/eui": "74.0.1",
"@elastic/filesaver": "1.1.2",
"@elastic/node-crypto": "1.2.1",
"@elastic/numeral": "^2.5.1",
"@elastic/react-search-ui": "^1.14.0",
"@elastic/react-search-ui": "^1.19.0",
"@elastic/request-crypto": "2.0.1",
"@elastic/search-ui-app-search-connector": "^1.14.0",
"@elastic/search-ui": "^1.19.0",
"@elastic/search-ui-app-search-connector": "^1.19.0",
"@elastic/search-ui-engines-connector": "^1.19.0",
"@emotion/cache": "^11.10.3",
"@emotion/css": "^11.10.0",
"@emotion/react": "^11.10.4",
Expand Down Expand Up @@ -421,8 +423,8 @@
"@opentelemetry/semantic-conventions": "^1.4.0",
"@reduxjs/toolkit": "1.7.2",
"@slack/webhook": "^5.0.4",
"@tanstack/react-query": "^4.23.0",
"@tanstack/react-query-devtools": "^4.23.0",
"@tanstack/react-query": "^4.24.2",
"@tanstack/react-query-devtools": "^4.24.2",
"@turf/along": "6.0.1",
"@turf/area": "6.0.1",
"@turf/bbox": "6.0.1",
Expand Down Expand Up @@ -583,7 +585,7 @@
"react-fast-compare": "^2.0.4",
"react-focus-on": "^3.7.0",
"react-grid-layout": "^1.3.4",
"react-hook-form": "^7.42.1",
"react-hook-form": "^7.43.0",
"react-intl": "^2.8.0",
"react-is": "^17.0.2",
"react-markdown": "^6.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const termsSchema = s.object({
exclude: s.maybe(s.oneOf([s.string(), s.arrayOf(s.string())])),
include: s.maybe(s.oneOf([s.string(), s.arrayOf(s.string())])),
execution_hint: s.maybe(s.string()),
missing: s.maybe(s.number()),
missing: s.maybe(s.oneOf([s.number(), s.string(), s.boolean()])),
min_doc_count: s.maybe(s.number({ min: 1 })),
size: s.maybe(s.number()),
show_term_doc_count_error: s.maybe(s.boolean()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,22 +397,6 @@ describe('validateAndConvertAggregations', () => {
);
});

it('throws an error when an attributes is not respecting its schema definition', () => {
const aggregations: AggsMap = {
someAgg: {
terms: {
missing: 'expecting a number',
},
},
};

expect(() =>
validateAndConvertAggregations(['alert'], aggregations, mockMappings)
).toThrowErrorMatchingInlineSnapshot(
`"[someAgg.terms.missing]: expected value of type [number] but got [string]"`
);
});

it('throws an error when trying to validate an unknown aggregation type', () => {
const aggregations: AggsMap = {
someAgg: {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es-query/src/kuery/node_types/wildcard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function escapeRegExp(str: string) {

// See https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters
function escapeQueryString(str: string) {
return str.replace(/[+-=&|><!(){}[\]^"~*?:\\/]/g, '\\$&'); // $& means the whole matched string
return str.replace(/[+\-=&|><!(){}[\]^"~*?:\\/]/g, '\\$&'); // $& means the whole matched string
}

export function isNode(node: KueryNode): node is KqlWildcardNode {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const guideCards: GuideCardConstants[] = [
title: i18n.translate('guidedOnboardingPackage.gettingStarted.cards.appSearch.title', {
defaultMessage: 'Build an application on top of Elasticsearch',
}),
guideId: 'search',
guideId: 'appSearch',
telemetryId: 'onboarding--search--application',
order: 1,
},
Expand All @@ -42,7 +42,7 @@ export const guideCards: GuideCardConstants[] = [
title: i18n.translate('guidedOnboardingPackage.gettingStarted.cards.websiteSearch.title', {
defaultMessage: 'Add search to my website',
}),
guideId: 'search',
guideId: 'websiteSearch',
telemetryId: 'onboarding--search--website',
order: 4,
},
Expand All @@ -51,7 +51,7 @@ export const guideCards: GuideCardConstants[] = [
title: i18n.translate('guidedOnboardingPackage.gettingStarted.cards.databaseSearch.title', {
defaultMessage: 'Search across databases and business systems',
}),
guideId: 'search',
guideId: 'databaseSearch',
telemetryId: 'onboarding--search--database',
order: 7,
},
Expand Down
8 changes: 7 additions & 1 deletion packages/kbn-guided-onboarding/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
* Side Public License, v 1.
*/

export type GuideId = 'kubernetes' | 'siem' | 'search' | 'testGuide';
export type GuideId =
| 'kubernetes'
| 'siem'
| 'appSearch'
| 'websiteSearch'
| 'databaseSearch'
| 'testGuide';

type KubernetesStepIds = 'add_data' | 'view_dashboard' | 'tour_observability';
type SiemStepIds = 'add_data' | 'rules' | 'alertsCases';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const FieldComponent: React.FC<FieldProps> = ({
placeholder,
selectedField,
acceptsCustomOptions = false,
showMappingConflicts = false,
}): JSX.Element => {
const {
isInvalid,
Expand All @@ -44,6 +45,7 @@ export const FieldComponent: React.FC<FieldProps> = ({
isRequired,
selectedField,
fieldInputWidth,
showMappingConflicts,
onChange,
});

Expand All @@ -68,6 +70,7 @@ export const FieldComponent: React.FC<FieldProps> = ({
values: { searchValuePlaceholder: '{searchValue}' },
})}
fullWidth
renderOption={renderFields}
/>
);
}
Expand Down
4 changes: 4 additions & 0 deletions packages/kbn-securitysolution-autocomplete/src/field/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { DataViewBase, DataViewFieldBase } from '@kbn/es-query';
import { FieldConflictsInfo } from '@kbn/securitysolution-list-utils';
import { GetGenericComboBoxPropsReturn } from '../get_generic_combo_box_props';

export interface FieldProps extends FieldBaseProps {
Expand All @@ -15,13 +16,15 @@ export interface FieldProps extends FieldBaseProps {
isLoading: boolean;
placeholder: string;
acceptsCustomOptions?: boolean;
showMappingConflicts?: boolean;
}
export interface FieldBaseProps {
indexPattern: DataViewBase | undefined;
fieldTypeFilter?: string[];
isRequired?: boolean;
selectedField?: DataViewFieldBase | undefined;
fieldInputWidth?: number;
showMappingConflicts?: boolean;
onChange: (a: DataViewFieldBase[]) => void;
}

Expand All @@ -32,6 +35,7 @@ export interface ComboBoxFields {

export interface GetFieldComboBoxPropsReturn extends GetGenericComboBoxPropsReturn {
disabledLabelTooltipTexts: { [label: string]: string };
mappingConflictsTooltipInfo: { [label: string]: FieldConflictsInfo[] };
}

export interface DataViewField extends DataViewFieldBase {
Expand Down
78 changes: 76 additions & 2 deletions packages/kbn-securitysolution-autocomplete/src/field/use_field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@
*/
import React from 'react';
import { useCallback, useMemo, useState } from 'react';
import { EuiComboBoxOptionOption, EuiToolTip } from '@elastic/eui';
import {
EuiComboBoxOptionOption,
EuiIcon,
EuiSpacer,
EuiToolTip,
useEuiPaddingSize,
} from '@elastic/eui';
import { DataViewBase, DataViewFieldBase } from '@kbn/es-query';

import { FieldConflictsInfo, getMappingConflictsInfo } from '@kbn/securitysolution-list-utils';
import { getGenericComboBoxProps } from '../get_generic_combo_box_props';
import * as i18n from '../translations';
import {
ComboBoxFields,
DataViewField,
Expand Down Expand Up @@ -72,6 +80,22 @@ const getDisabledLabelTooltipTexts = (fields: ComboBoxFields) => {
);
return disabledLabelTooltipTexts;
};

const getMappingConflictsTooltipInfo = (fields: ComboBoxFields) => {
const mappingConflictsTooltipInfo = fields.availableFields.reduce(
(acc: { [label: string]: FieldConflictsInfo[] }, field: DataViewField) => {
const conflictsInfo = getMappingConflictsInfo(field);
if (!conflictsInfo) {
return acc;
}
acc[field.name] = conflictsInfo;
return acc;
},
{}
);
return mappingConflictsTooltipInfo;
};

const getComboBoxProps = (fields: ComboBoxFields): GetFieldComboBoxPropsReturn => {
const { availableFields, selectedFields } = fields;

Expand All @@ -81,9 +105,11 @@ const getComboBoxProps = (fields: ComboBoxFields): GetFieldComboBoxPropsReturn =
selectedOptions: selectedFields,
});
const disabledLabelTooltipTexts = getDisabledLabelTooltipTexts(fields);
const mappingConflictsTooltipInfo = getMappingConflictsTooltipInfo(fields);
return {
...genericProps,
disabledLabelTooltipTexts,
mappingConflictsTooltipInfo,
};
};

Expand All @@ -93,11 +119,13 @@ export const useField = ({
isRequired,
selectedField,
fieldInputWidth,
showMappingConflicts,
onChange,
}: FieldBaseProps) => {
const [touched, setIsTouched] = useState(false);

const [customOption, setCustomOption] = useState<DataViewFieldBase | null>(null);
const sPaddingSize = useEuiPaddingSize('s');

const { availableFields, selectedFields } = useMemo(() => {
const indexPatternsToUse =
Expand All @@ -107,7 +135,13 @@ export const useField = ({
return getComboBoxFields(indexPatternsToUse, selectedField, fieldTypeFilter);
}, [indexPattern, fieldTypeFilter, selectedField, customOption]);

const { comboOptions, labels, selectedComboOptions, disabledLabelTooltipTexts } = useMemo(
const {
comboOptions,
labels,
selectedComboOptions,
disabledLabelTooltipTexts,
mappingConflictsTooltipInfo,
} = useMemo(
() => getComboBoxProps({ availableFields, selectedFields }),
[availableFields, selectedFields]
);
Expand Down Expand Up @@ -168,6 +202,46 @@ export const useField = ({
</EuiToolTip>
);
}

const conflictsInfo = mappingConflictsTooltipInfo[label];
if (showMappingConflicts && conflictsInfo) {
const tooltipContent = (
<>
{i18n.FIELD_CONFLICT_INDICES_WARNING_DESCRIPTION}
{conflictsInfo.map((info) => {
const groupDetails = info.groupedIndices.map(
({ name, count }) =>
`${count > 1 ? i18n.CONFLICT_MULTIPLE_INDEX_DESCRIPTION(name, count) : name}`
);
return (
<>
<EuiSpacer size="s" />
{`${
info.totalIndexCount > 1
? i18n.CONFLICT_MULTIPLE_INDEX_DESCRIPTION(info.type, info.totalIndexCount)
: info.type
}: ${groupDetails.join(', ')}`}
</>
);
})}
</>
);
return (
<EuiToolTip position="bottom" content={tooltipContent}>
<>
{label}
<EuiIcon
tabIndex={0}
type="alert"
title={i18n.FIELD_CONFLICT_INDICES_WARNING_TITLE}
size="s"
css={{ marginLeft: `${sPaddingSize}` }}
/>
</>
</EuiToolTip>
);
}

return label;
};
return {
Expand Down
Loading

0 comments on commit 8c6c55a

Please sign in to comment.