Skip to content

Commit

Permalink
Merge branch 'main' into elastic#8929-1
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp authored Apr 18, 2024
2 parents 9aae1f8 + 584f1f7 commit 21964c5
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 47 deletions.
13 changes: 6 additions & 7 deletions test/functional/services/selectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class SelectableService extends FtrService {
`selectableBodyTestSubjectId: ${selectableBodyTestSubjectId}, textsToSelect: ${textsToSelect}`
);

await this.openIfClosed(buttonTestSubjectId, selectableBodyTestSubjectId);
await this.ensureOpened(buttonTestSubjectId, selectableBodyTestSubjectId);

const selectableBodyContainer = await this.testSubjects.find(selectableBodyTestSubjectId);
const listContainer = await selectableBodyContainer.findByClassName('euiSelectableList');
Expand Down Expand Up @@ -92,7 +92,7 @@ export class SelectableService extends FtrService {
searchText: string,
optionText: string
) {
await this.openIfClosed(buttonTestSubjectId, selectableBodyTestSubjectId);
await this.ensureOpened(buttonTestSubjectId, selectableBodyTestSubjectId);

// Clear and set search text
await this.testSubjects.setValue(searchInputTestSubjectId, searchText, {
Expand All @@ -107,16 +107,15 @@ export class SelectableService extends FtrService {
]);
}

private async openIfClosed(buttonTestSubjectId: string, selectableBodyTestSubjectId: string) {
private async ensureOpened(buttonTestSubjectId: string, selectableBodyTestSubjectId: string) {
// Open the selectable if `selectableBodyTestSubjectId` doesn't exist
const isSelectableOpen = await this.testSubjects.exists(selectableBodyTestSubjectId, {
timeout: 500,
});
const isSelectableOpen = await this.testSubjects.exists(selectableBodyTestSubjectId);

if (!isSelectableOpen) {
await this.testSubjects.click(buttonTestSubjectId);
await this.common.sleep(500);
}

await this.testSubjects.existOrFail(selectableBodyTestSubjectId);
}
}

Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/fleet/server/constants/fleet_es_assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ export const FLEET_COMPONENT_TEMPLATES = [
];

export const STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS = `logs@settings`;
export const STACK_COMPONENT_TEMPLATE_LOGS_MAPPINGS = `logs@mappings`;
export const STACK_COMPONENT_TEMPLATE_METRICS_SETTINGS = `metrics@settings`;
export const STACK_COMPONENT_TEMPLATE_METRICS_TSDB_SETTINGS = `metrics@tsdb-settings`;
export const STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS = 'ecs@mappings';

export const STACK_COMPONENT_TEMPLATES = [
STACK_COMPONENT_TEMPLATE_LOGS_MAPPINGS,
STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS,
STACK_COMPONENT_TEMPLATE_METRICS_SETTINGS,
STACK_COMPONENT_TEMPLATE_METRICS_TSDB_SETTINGS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { elasticsearchServiceMock } from '@kbn/core/server/mocks';

import { errors } from '@elastic/elasticsearch';

import { STACK_COMPONENT_TEMPLATE_LOGS_MAPPINGS } from '../../../../constants/fleet_es_assets';

import { createAppContextStartContractMock } from '../../../../mocks';
import { appContextService } from '../../..';
import type { RegistryDataStream } from '../../../../types';
Expand All @@ -23,6 +25,7 @@ import {
FLEET_COMPONENT_TEMPLATES,
STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS,
FLEET_GLOBALS_COMPONENT_TEMPLATE_NAME,
STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS,
} from '../../../../constants';

import {
Expand Down Expand Up @@ -81,7 +84,8 @@ describe('EPM template', () => {
isIndexModeTimeSeries: false,
});
expect(template.composed_of).toStrictEqual([
'logs@settings',
STACK_COMPONENT_TEMPLATE_LOGS_MAPPINGS,
STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS,
...composedOfTemplates,
STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS,
...FLEET_COMPONENT_TEMPLATES_NAMES,
Expand Down Expand Up @@ -126,7 +130,8 @@ describe('EPM template', () => {
isIndexModeTimeSeries: false,
});
expect(template.composed_of).toStrictEqual([
'logs@settings',
STACK_COMPONENT_TEMPLATE_LOGS_MAPPINGS,
STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS,
...composedOfTemplates,
STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS,
FLEET_GLOBALS_COMPONENT_TEMPLATE_NAME,
Expand All @@ -146,7 +151,8 @@ describe('EPM template', () => {
isIndexModeTimeSeries: false,
});
expect(template.composed_of).toStrictEqual([
'logs@settings',
STACK_COMPONENT_TEMPLATE_LOGS_MAPPINGS,
STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS,
STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS,
...FLEET_COMPONENT_TEMPLATES_NAMES,
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import type {
import pMap from 'p-map';
import { isResponseError } from '@kbn/es-errors';

import { STACK_COMPONENT_TEMPLATE_LOGS_MAPPINGS } from '../../../../constants/fleet_es_assets';

import type { Field, Fields } from '../../fields/field';
import type {
RegistryDataStream,
Expand Down Expand Up @@ -135,7 +137,7 @@ const getBaseEsComponents = (type: string, isIndexModeTimeSeries: boolean): stri

return [STACK_COMPONENT_TEMPLATE_METRICS_SETTINGS];
} else if (type === 'logs') {
return [STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS];
return [STACK_COMPONENT_TEMPLATE_LOGS_MAPPINGS, STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS];
}

return [];
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
* 2.0.
*/

export * from './fields';
export * from './manifest';
export * from './utils';
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { pkgToPkgKey } from '../../../registry';

import type { CustomPackageDatasetConfiguration } from '../../install';

import { createBaseFields, createDatasetManifest } from './dataset';
import { createDatasetManifest } from './dataset';
import { createDefaultPipeline } from './dataset/ingest_pipeline';
import { createManifest } from './manifest';

Expand All @@ -38,13 +38,6 @@ export const createAssets = (assetOptions: AssetOptions) => {
},
// NOTE: buildDefaultSettings() will add a reference to the global ILM policy when
// building the index template based on the fields assets.
{
path: `${pkgToPkgKey({
name,
version,
})}/data_stream/${datasetName}/fields/base-fields.yml`,
content: Buffer.from(createBaseFields()),
},
{
path: `${pkgToPkgKey({
name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export interface UseFetchDataViewsResponse {
data: DataViewListItem[] | undefined;
}

export function useFetchDataViews(): UseFetchDataViewsResponse {
export function useFetchDataViews() {
const { dataViews } = useKibana().services;

const { isLoading, isError, isSuccess, data } = useQuery({
const { isLoading, isError, isSuccess, data, refetch } = useQuery({
queryKey: ['fetchDataViewsList'],
queryFn: async () => {
return dataViews.getIdsWithTitle();
Expand All @@ -29,5 +29,5 @@ export function useFetchDataViews(): UseFetchDataViewsResponse {
refetchOnWindowFocus: false,
});

return { isLoading, isError, isSuccess, data };
return { isLoading, isError, isSuccess, data, refetch };
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function IndexSelection() {
const { control, getFieldState, setValue, watch } = useFormContext<CreateSLOForm>();
const { dataViews: dataViewsService } = useKibana().services;

const { isLoading: isDataViewsLoading, data: dataViews = [] } = useFetchDataViews();
const { isLoading: isDataViewsLoading, data: dataViews = [], refetch } = useFetchDataViews();

const { dataViewEditor } = useKibana().services;

Expand Down Expand Up @@ -100,7 +100,8 @@ export function IndexSelection() {
setAdHocDataViews([...adHocDataViews, dataView]);
field.onChange(dataView.getIndexPattern());
} else {
field.onChange(getDataViewPatternById(dataView.id));
refetch();
field.onChange(dataView.getIndexPattern());
}
if (dataView.timeFieldName) {
setValue('indicator.params.timestampField', dataView.timeFieldName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default function (providerContext: FtrProviderContext) {
// the index template composed_of has the correct component templates in the correct order
const indexTemplate = indexTemplateResponse.index_templates[0].index_template;
expect(indexTemplate.composed_of).to.eql([
`logs@mappings`,
`logs@settings`,
`${templateName}@package`,
`${templateName}@custom`,
Expand Down

0 comments on commit 21964c5

Please sign in to comment.