Skip to content

Commit

Permalink
Merge main, fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed Dec 29, 2022
2 parents ce9cc2a + c9070b3 commit fb71953
Show file tree
Hide file tree
Showing 200 changed files with 4,825 additions and 1,242 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,4 @@ elastic-agent.yml
fleet-server.yml
/packages/kbn-package-map/package-map.json
/packages/kbn-synthetic-package-map/
**/.synthetics/
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"@emotion/react": "^11.10.4",
"@emotion/serialize": "^1.1.0",
"@emotion/server": "^11.10.0",
"@emotion/styled": "^11.10.5",
"@grpc/grpc-js": "^1.6.7",
"@hapi/accept": "^5.0.2",
"@hapi/boom": "^9.1.4",
Expand Down Expand Up @@ -725,7 +726,7 @@
"@cypress/webpack-preprocessor": "^5.12.2",
"@elastic/eslint-plugin-eui": "0.0.2",
"@elastic/makelogs": "^6.1.1",
"@elastic/synthetics": "^1.0.0-beta.23",
"@elastic/synthetics": "^1.0.0-beta.39",
"@emotion/babel-preset-css-prop": "^11.10.0",
"@emotion/jest": "^11.10.0",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ export const SortableControl = (frameProps: SortableControlProps) => {
disabled: !isEditable,
});

frameProps.dragInfo = { ...frameProps.dragInfo, isOver: over?.id === embeddableId, isDragging };
const sortableFrameProps = {
...frameProps,
dragInfo: { ...frameProps.dragInfo, isOver: over?.id === embeddableId, isDragging },
};

return (
<SortableControlInner
key={embeddableId}
ref={setNodeRef}
{...frameProps}
{...sortableFrameProps}
{...attributes}
{...listeners}
style={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export const IndexPatternTable = ({
<EuiButton
color="danger"
iconType="trash"
data-test-subj="delete-data-views-button"
onClick={() => clickHandler(selectedItems, deleteModalMsg(selectedItems, !!spaces))}
>
<FormattedMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ describe('Index Pattern Fetcher - server', () => {
.mockResponseOnce(emptyResponse as unknown as estypes.FieldCapsResponse)
.mockResponse(response as unknown as estypes.FieldCapsResponse);
// first field caps request returns empty
const result = await indexPatterns.validatePatternListActive(['-a', 'b', 'c']);
expect(result).toEqual(['-a', 'c']);
const result = await indexPatterns.validatePatternListActive(['-a', 'b', 'c', 'a:-b']);
expect(result).toEqual(['-a', 'c', 'a:-b']);
});
it('Returns all patterns when all match indices', async () => {
esClient.fieldCaps.mockResponse(response as unknown as estypes.FieldCapsResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class IndexPatternsFetcher {
patternList
.map(async (index) => {
// perserve negated patterns
if (index.startsWith('-')) {
if (index.startsWith('-') || index.includes(':-')) {
return true;
}
const searchResponse = await this.elasticsearchClient.fieldCaps({
Expand Down
141 changes: 73 additions & 68 deletions src/plugins/discover/public/application/main/discover_main_route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { useEffect, useState, memo, useCallback, useMemo } from 'react';
import { useParams, useHistory } from 'react-router-dom';
import { DataViewListItem } from '@kbn/data-plugin/public';
import { isOfAggregateQueryType } from '@kbn/es-query';
import { DataViewSavedObjectConflictError } from '@kbn/data-views-plugin/public';
import { DataViewSavedObjectConflictError, type DataView } from '@kbn/data-views-plugin/public';
import { redirectWhenMissing } from '@kbn/kibana-utils-plugin/public';
import { useExecutionContext } from '@kbn/kibana-react-plugin/public';
import {
Expand Down Expand Up @@ -140,87 +140,92 @@ export function DiscoverMainRoute(props: Props) {
]
);

const loadSavedSearch = useCallback(async () => {
try {
setLoading(true);
const currentSavedSearch = await getSavedSearch(id, {
search: services.data.search,
savedObjectsClient: core.savedObjects.client,
spaces: services.spaces,
savedObjectsTagging: services.savedObjectsTagging,
});
const loadSavedSearch = useCallback(
async (nextDataView?: DataView) => {
try {
setLoading(true);
const currentSavedSearch = await getSavedSearch(id, {
search: services.data.search,
savedObjectsClient: core.savedObjects.client,
spaces: services.spaces,
savedObjectsTagging: services.savedObjectsTagging,
});

const currentDataView = await loadDefaultOrCurrentDataView(currentSavedSearch);
const currentDataView = nextDataView
? nextDataView
: await loadDefaultOrCurrentDataView(currentSavedSearch);

if (!currentDataView) {
return;
}
if (!currentDataView) {
return;
}

if (!currentSavedSearch.searchSource.getField('index')) {
currentSavedSearch.searchSource.setField('index', currentDataView);
}
if (!currentSavedSearch.searchSource.getField('index')) {
currentSavedSearch.searchSource.setField('index', currentDataView);
}

restoreStateFromSavedSearch({
savedSearch: currentSavedSearch,
timefilter: services.timefilter,
});
restoreStateFromSavedSearch({
savedSearch: currentSavedSearch,
timefilter: services.timefilter,
});

setSavedSearch(currentSavedSearch);
setSavedSearch(currentSavedSearch);

if (currentSavedSearch.id) {
chrome.recentlyAccessed.add(
getSavedSearchFullPathUrl(currentSavedSearch.id),
currentSavedSearch.title ?? '',
currentSavedSearch.id
);
}
setLoading(false);
} catch (e) {
if (e instanceof DataViewSavedObjectConflictError) {
setError(e);
} else {
redirectWhenMissing({
history,
navigateToApp: core.application.navigateToApp,
basePath,
mapping: {
search: '/',
'index-pattern': {
app: 'management',
path: `kibana/objects/savedSearches/${id}`,
if (currentSavedSearch.id) {
chrome.recentlyAccessed.add(
getSavedSearchFullPathUrl(currentSavedSearch.id),
currentSavedSearch.title ?? '',
currentSavedSearch.id
);
}
setLoading(false);
} catch (e) {
if (e instanceof DataViewSavedObjectConflictError) {
setError(e);
} else {
redirectWhenMissing({
history,
navigateToApp: core.application.navigateToApp,
basePath,
mapping: {
search: '/',
'index-pattern': {
app: 'management',
path: `kibana/objects/savedSearches/${id}`,
},
},
},
toastNotifications,
onBeforeRedirect() {
getUrlTracker().setTrackedUrl('/');
},
theme: core.theme,
})(e);
toastNotifications,
onBeforeRedirect() {
getUrlTracker().setTrackedUrl('/');
},
theme: core.theme,
})(e);
}
}
}
}, [
id,
services.data,
services.spaces,
services.timefilter,
services.savedObjectsTagging,
core.savedObjects.client,
core.application.navigateToApp,
core.theme,
loadDefaultOrCurrentDataView,
chrome.recentlyAccessed,
history,
basePath,
toastNotifications,
]);
},
[
id,
services.data,
services.spaces,
services.timefilter,
services.savedObjectsTagging,
core.savedObjects.client,
core.application.navigateToApp,
core.theme,
loadDefaultOrCurrentDataView,
chrome.recentlyAccessed,
history,
basePath,
toastNotifications,
]
);

const onDataViewCreated = useCallback(
async (nextDataView: unknown) => {
if (nextDataView) {
setLoading(true);
setShowNoDataPage(false);
setError(undefined);
await loadSavedSearch();
await loadSavedSearch(nextDataView as DataView);
}
},
[loadSavedSearch]
Expand Down Expand Up @@ -257,7 +262,7 @@ export function DiscoverMainRoute(props: Props) {

return (
<AnalyticsNoDataPageKibanaProvider {...analyticsServices}>
<AnalyticsNoDataPage onDataViewCreated={onDataViewCreated} />
<AnalyticsNoDataPage onDataViewCreated={onDataViewCreated} allowAdHocDataView />
</AnalyticsNoDataPageKibanaProvider>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
overviewRulerLanes: 0,
hideCursorInOverviewRuler: true,
scrollbar: {
vertical: 'hidden',
horizontal: 'hidden',
vertical: 'auto',
},
overviewRulerBorder: false,
readOnly: isDisabled,
Expand Down
65 changes: 65 additions & 0 deletions test/functional/apps/discover/group1/_greeting_screen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import expect from '@kbn/expect';

import { FtrProviderContext } from '../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const retry = getService('retry');
const kibanaServer = getService('kibanaServer');
const testSubjects = getService('testSubjects');
const esArchiver = getService('esArchiver');
const security = getService('security');
const PageObjects = getPageObjects(['common', 'header', 'discover', 'timePicker']);
const defaultSettings = {
defaultIndex: 'logstash-*',
};

describe('discover greeting screen', function describeIndexTests() {
before(async function () {
await security.testUser.setRoles(['kibana_admin', 'version_test', 'test_logstash_reader']);
await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] });
await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json');
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional');
await kibanaServer.uiSettings.replace(defaultSettings);
});

after(async () => {
await security.testUser.restoreDefaults();
});

it('should create adhoc data view when there are no data view', async () => {
await kibanaServer.uiSettings.replace(defaultSettings);
await PageObjects.common.navigateToApp('management');
await PageObjects.header.waitUntilLoadingHasFinished();
await testSubjects.click('dataViews');
await testSubjects.click('checkboxSelectAll');

await testSubjects.click('delete-data-views-button');
await testSubjects.click('confirmModalConfirmButton');

await PageObjects.common.navigateToApp('discover');
await PageObjects.header.waitUntilLoadingHasFinished();

await testSubjects.click('createDataViewButton');

await testSubjects.setValue('createIndexPatternTitleInput', 'logs', {
clearWithKeyboard: true,
typeCharByChar: true,
});
await retry.waitFor('timestamp field loaded', async () => {
const timestampField = await testSubjects.find('timestampField');
return !(await timestampField.elementHasClass('euiComboBox-isDisabled'));
});
await testSubjects.click('exploreIndexPatternButton');
await PageObjects.header.waitUntilLoadingHasFinished();
expect(await PageObjects.discover.isAdHocDataViewSelected()).to.be(true);
});
});
}
1 change: 1 addition & 0 deletions test/functional/apps/discover/group1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./_sidebar'));
loadTestFile(require.resolve('./_source_filters'));
loadTestFile(require.resolve('./_large_string'));
loadTestFile(require.resolve('./_greeting_screen'));
loadTestFile(require.resolve('./_inspector'));
loadTestFile(require.resolve('./_date_nanos'));
loadTestFile(require.resolve('./_date_nanos_mixed'));
Expand Down
6 changes: 6 additions & 0 deletions test/functional/page_objects/discover_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,12 @@ export class DiscoverPageObject extends FtrService {
}
}

public async isAdHocDataViewSelected() {
const dataView = await this.getCurrentlySelectedDataView();
await this.testSubjects.click('discover-dataView-switch-link');
return this.testSubjects.exists(`dataViewItemTempBadge-${dataView}`);
}

public async isFieldSelected(field: string) {
if (!(await this.testSubjects.exists('fieldListGroupedSelectedFields'))) {
return false;
Expand Down
18 changes: 9 additions & 9 deletions x-pack/plugins/enterprise_search/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,28 +237,28 @@ export class EnterpriseSearchPlugin implements Plugin {
* Register logs source configuration, used by LogStream components
* @see https://github.com/elastic/kibana/blob/main/x-pack/plugins/infra/public/components/log_stream/log_stream.stories.mdx#with-a-source-configuration
*/
infra.defineInternalSourceConfiguration(ENTERPRISE_SEARCH_RELEVANCE_LOGS_SOURCE_ID, {
name: 'Enterprise Search Search Relevance Logs',
infra.logViews.defineInternalLogView(ENTERPRISE_SEARCH_RELEVANCE_LOGS_SOURCE_ID, {
logIndices: {
type: 'index_name',
indexName: 'logs-app_search.search_relevance_suggestions-*',
type: 'index_name',
},
name: 'Enterprise Search Search Relevance Logs',
});

infra.defineInternalSourceConfiguration(ENTERPRISE_SEARCH_AUDIT_LOGS_SOURCE_ID, {
name: 'Enterprise Search Audit Logs',
infra.logViews.defineInternalLogView(ENTERPRISE_SEARCH_AUDIT_LOGS_SOURCE_ID, {
logIndices: {
type: 'index_name',
indexName: 'logs-enterprise_search*',
type: 'index_name',
},
name: 'Enterprise Search Audit Logs',
});

infra.defineInternalSourceConfiguration(ENTERPRISE_SEARCH_ANALYTICS_LOGS_SOURCE_ID, {
name: 'Enterprise Search Behaviorial Analytics Logs',
infra.logViews.defineInternalLogView(ENTERPRISE_SEARCH_ANALYTICS_LOGS_SOURCE_ID, {
logIndices: {
type: 'index_name',
indexName: 'logs-elastic_analytics.events-*',
type: 'index_name',
},
name: 'Enterprise Search Behaviorial Analytics Logs',
});

/**
Expand Down
Loading

0 comments on commit fb71953

Please sign in to comment.