Skip to content

Commit

Permalink
Merge branch 'master' into canvas/by-value-embeddables
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Oct 26, 2021
2 parents dc6a861 + eb74b86 commit 542951d
Show file tree
Hide file tree
Showing 111 changed files with 1,845 additions and 931 deletions.
12 changes: 6 additions & 6 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import %workspace%/.bazelrc.common

# Remote cache settings for local env
build --remote_cache=grpcs://cloud.buildbuddy.io
build --incompatible_remote_results_ignore_disk=true
build --noremote_upload_local_results
build --remote_timeout=30
build --remote_header=x-buildbuddy-api-key=3EYk49W2NefOx2n3yMze
build --remote_accept_cached=true
# build --remote_cache=grpcs://cloud.buildbuddy.io
# build --incompatible_remote_results_ignore_disk=true
# build --noremote_upload_local_results
# build --remote_timeout=30
# build --remote_header=x-buildbuddy-api-key=3EYk49W2NefOx2n3yMze
# build --remote_accept_cached=true

# Enable this in case you want to share your build info
# build --build_metadata=VISIBILITY=PUBLIC
Expand Down
2 changes: 2 additions & 0 deletions .buildkite/pipelines/flaky_tests/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ for (let i = 1; i <= XPACK_CI_GROUPS; i++) {
inputs.push(stepInput(`xpack/cigroup/${i}`, `Default CI Group ${i}`));
}

inputs.push(stepInput(`xpack/cigroup/Docker`, 'Default CI Group Docker'));

const pipeline = {
steps: [
{
Expand Down
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@
/src/core/server/csp/ @elastic/kibana-security @elastic/kibana-core
/src/plugins/interactive_setup/ @elastic/kibana-security
/test/interactive_setup_api_integration/ @elastic/kibana-security
/test/interactive_setup_functional/ @elastic/kibana-security
/x-pack/plugins/spaces/ @elastic/kibana-security
/x-pack/plugins/encrypted_saved_objects/ @elastic/kibana-security
/x-pack/plugins/security/ @elastic/kibana-security
Expand Down
10 changes: 5 additions & 5 deletions dev_docs/tutorials/data/search.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ tags: ['kibana', 'onboarding', 'dev', 'tutorials', 'search', 'sessions', 'search

Searching data stored in Elasticsearch can be done in various ways, for example using the Elasticsearch REST API or using an `Elasticsearch Client` for low level access.

However, the recommended and easist way to search Elasticsearch is by using the low level search service. The service is exposed from the `data` plugin, and by using it, you not only gain access to the data you stored, but also to capabilities, such as Custom Search Strategies, Asynchronous Search, Partial Results, Search Sessions, and more.
However, the recommended and easiest way to search Elasticsearch is by using the low level search service. The service is exposed from the `data` plugin, and by using it, you not only gain access to the data you stored, but also to capabilities, such as Custom Search Strategies, Asynchronous Search, Partial Results, Search Sessions, and more.

Here is a basic example for using the `data.search` service from a custom plugin:

Expand Down Expand Up @@ -418,11 +418,11 @@ export class MyPlugin implements Plugin {
// return the name you want to give the saved Search Session
return `MyApp_${Math.random()}`;
},
getUrlGeneratorData: async () => {
getLocatorData: async () => {
return {
urlGeneratorId: MY_URL_GENERATOR,
initialState: getUrlGeneratorState({ ...deps, shouldRestoreSearchSession: false }),
restoreState: getUrlGeneratorState({ ...deps, shouldRestoreSearchSession: true }),
id: MY_LOCATOR,
initialState: getLocatorParams({ ...deps, shouldRestoreSearchSession: false }),
restoreState: getLocatorParams({ ...deps, shouldRestoreSearchSession: true }),
};
},
});
Expand Down
20 changes: 8 additions & 12 deletions examples/search_examples/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@

import {
AppMountParameters,
AppNavLinkStatus,
CoreSetup,
CoreStart,
Plugin,
AppNavLinkStatus,
} from '../../../src/core/public';
import {
SearchExamplesPluginSetup,
SearchExamplesPluginStart,
AppPluginSetupDependencies,
AppPluginStartDependencies,
SearchExamplesPluginSetup,
SearchExamplesPluginStart,
} from './types';
import { createSearchSessionsExampleUrlGenerator } from './search_sessions/url_generator';
import { SearchSessionsExamplesAppLocatorDefinition } from './search_sessions/app_locator';
import { PLUGIN_NAME } from '../common';
import img from './search_examples.png';

Expand Down Expand Up @@ -67,14 +67,10 @@ export class SearchExamplesPlugin
],
});

// we need an URL generator for search session examples for restoring a search session
share.urlGenerators.registerUrlGenerator(
createSearchSessionsExampleUrlGenerator(() => {
return core
.getStartServices()
.then(([coreStart]) => ({ appBasePath: coreStart.http.basePath.get() }));
})
);
// we need an locator for search session examples for restoring a search session
const getAppBasePath = () =>
core.getStartServices().then(([coreStart]) => coreStart.http.basePath.get());
share.url.locators.create(new SearchSessionsExamplesAppLocatorDefinition(getAppBasePath));

return {};
}
Expand Down
14 changes: 5 additions & 9 deletions examples/search_examples/public/search_sessions/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ import {
createStateContainer,
useContainerState,
} from '../../../../src/plugins/kibana_utils/public';
import {
getInitialStateFromUrl,
SEARCH_SESSIONS_EXAMPLES_APP_URL_GENERATOR,
SearchSessionExamplesUrlGeneratorState,
} from './url_generator';
import { getInitialStateFromUrl, SEARCH_SESSIONS_EXAMPLES_APP_LOCATOR } from './app_locator';

interface SearchSessionsExampleAppDeps {
notifications: CoreStart['notifications'];
Expand Down Expand Up @@ -140,23 +136,23 @@ export const SearchSessionsExampleApp = ({
const enableSessionStorage = useCallback(() => {
data.search.session.enableStorage({
getName: async () => 'Search sessions example',
getUrlGeneratorData: async () => ({
getLocatorData: async () => ({
initialState: {
time: data.query.timefilter.timefilter.getTime(),
filters: data.query.filterManager.getFilters(),
query: data.query.queryString.getQuery(),
indexPatternId: indexPattern?.id,
numericFieldName,
} as SearchSessionExamplesUrlGeneratorState,
},
restoreState: {
time: data.query.timefilter.timefilter.getAbsoluteTime(),
filters: data.query.filterManager.getFilters(),
query: data.query.queryString.getQuery(),
indexPatternId: indexPattern?.id,
numericFieldName,
searchSessionId: data.search.session.getSessionId(),
} as SearchSessionExamplesUrlGeneratorState,
urlGeneratorId: SEARCH_SESSIONS_EXAMPLES_APP_URL_GENERATOR,
},
id: SEARCH_SESSIONS_EXAMPLES_APP_LOCATOR,
}),
});
}, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,50 @@
* Side Public License, v 1.
*/

import { TimeRange, Filter, Query, esFilters } from '../../../../src/plugins/data/public';
import { SerializableRecord } from '@kbn/utility-types';
import { esFilters, Filter, Query, TimeRange } from '../../../../src/plugins/data/public';
import { getStatesFromKbnUrl, setStateToKbnUrl } from '../../../../src/plugins/kibana_utils/public';
import { UrlGeneratorsDefinition } from '../../../../src/plugins/share/public';
import { LocatorDefinition } from '../../../../src/plugins/share/common';

export const STATE_STORAGE_KEY = '_a';
export const GLOBAL_STATE_STORAGE_KEY = '_g';

export const SEARCH_SESSIONS_EXAMPLES_APP_URL_GENERATOR =
'SEARCH_SESSIONS_EXAMPLES_APP_URL_GENERATOR';
export const SEARCH_SESSIONS_EXAMPLES_APP_LOCATOR = 'SEARCH_SESSIONS_EXAMPLES_APP_LOCATOR';

export interface AppUrlState {
export interface AppUrlState extends SerializableRecord {
filters?: Filter[];
query?: Query;
indexPatternId?: string;
numericFieldName?: string;
searchSessionId?: string;
}

export interface GlobalUrlState {
export interface GlobalUrlState extends SerializableRecord {
filters?: Filter[];
time?: TimeRange;
}

export type SearchSessionExamplesUrlGeneratorState = AppUrlState & GlobalUrlState;
export type SearchSessionsExamplesAppLocatorParams = AppUrlState & GlobalUrlState;

export const createSearchSessionsExampleUrlGenerator = (
getStartServices: () => Promise<{
appBasePath: string;
}>
): UrlGeneratorsDefinition<typeof SEARCH_SESSIONS_EXAMPLES_APP_URL_GENERATOR> => ({
id: SEARCH_SESSIONS_EXAMPLES_APP_URL_GENERATOR,
createUrl: async (state: SearchSessionExamplesUrlGeneratorState) => {
const startServices = await getStartServices();
const appBasePath = startServices.appBasePath;
const path = `${appBasePath}/app/searchExamples/search-sessions`;
export class SearchSessionsExamplesAppLocatorDefinition
implements LocatorDefinition<SearchSessionsExamplesAppLocatorParams>
{
public readonly id = SEARCH_SESSIONS_EXAMPLES_APP_LOCATOR;

constructor(protected readonly getAppBasePath: () => Promise<string>) {}

public readonly getLocation = async (params: SearchSessionsExamplesAppLocatorParams) => {
const appBasePath = await this.getAppBasePath();
const path = `${appBasePath}/search-sessions`;

let url = setStateToKbnUrl<AppUrlState>(
STATE_STORAGE_KEY,
{
query: state.query,
filters: state.filters?.filter((f) => !esFilters.isFilterPinned(f)),
indexPatternId: state.indexPatternId,
numericFieldName: state.numericFieldName,
searchSessionId: state.searchSessionId,
query: params.query,
filters: params.filters?.filter((f) => !esFilters.isFilterPinned(f)),
indexPatternId: params.indexPatternId,
numericFieldName: params.numericFieldName,
searchSessionId: params.searchSessionId,
} as AppUrlState,
{ useHash: false, storeInHashQuery: false },
path
Expand All @@ -58,18 +58,22 @@ export const createSearchSessionsExampleUrlGenerator = (
url = setStateToKbnUrl<GlobalUrlState>(
GLOBAL_STATE_STORAGE_KEY,
{
time: state.time,
filters: state.filters?.filter((f) => esFilters.isFilterPinned(f)),
time: params.time,
filters: params.filters?.filter((f) => esFilters.isFilterPinned(f)),
} as GlobalUrlState,
{ useHash: false, storeInHashQuery: false },
url
);

return url;
},
});
return {
app: 'searchExamples',
path: url,
state: {},
};
};
}

export function getInitialStateFromUrl(): SearchSessionExamplesUrlGeneratorState {
export function getInitialStateFromUrl(): SearchSessionsExamplesAppLocatorParams {
const {
_a: { numericFieldName, indexPatternId, searchSessionId, filters: aFilters, query } = {},
_g: { filters: gFilters, time } = {},
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"@elastic/charts": "38.0.1",
"@elastic/datemath": "link:bazel-bin/packages/elastic-datemath",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.35",
"@elastic/ems-client": "7.16.0",
"@elastic/ems-client": "8.0.0",
"@elastic/eui": "40.0.0",
"@elastic/filesaver": "1.1.2",
"@elastic/maki": "6.3.0",
Expand Down Expand Up @@ -217,7 +217,7 @@
"deep-freeze-strict": "^1.1.1",
"deepmerge": "^4.2.2",
"del": "^5.1.0",
"elastic-apm-node": "^3.21.1",
"elastic-apm-node": "^3.23.0",
"execa": "^4.0.2",
"exit-hook": "^2.2.0",
"expiry-js": "0.1.7",
Expand Down Expand Up @@ -330,7 +330,7 @@
"react-moment-proptypes": "^1.7.0",
"react-monaco-editor": "^0.41.2",
"react-popper-tooltip": "^2.10.1",
"react-query": "^3.27.0",
"react-query": "^3.28.0",
"react-redux": "^7.2.0",
"react-resizable": "^1.7.5",
"react-resize-detector": "^4.2.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/kbn-apm-config-loader/src/init_apm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { mockLoadConfiguration } from './init_apm.test.mocks';
import { initApm } from './init_apm';
import apm from 'elastic-apm-node';

// TODO: unskip when https://github.com/elastic/kibana/issues/116109 is fixed
describe.skip('initApm', () => {
describe('initApm', () => {
let apmAddFilterSpy: jest.SpyInstance;
let apmStartSpy: jest.SpyInstance;
let getConfig: jest.Mock;
Expand Down
3 changes: 0 additions & 3 deletions packages/kbn-apm-config-loader/src/init_apm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ export const initApm = (
isDistributable: boolean,
serviceName: string
) => {
// TODO: re-enabled when https://github.com/elastic/kibana/issues/116109 is fixed
return;

const apmConfigLoader = loadConfiguration(argv, rootDir, isDistributable);
const apmConfig = apmConfigLoader.getConfig(serviceName);

Expand Down
8 changes: 8 additions & 0 deletions scripts/functional_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ const alwaysImportedTests = [
require.resolve(
'../test/interactive_setup_api_integration/manual_configuration_flow_without_tls.config.ts'
),
require.resolve('../test/interactive_setup_functional/enrollment_token.config.ts'),
require.resolve('../test/interactive_setup_functional/manual_configuration.config.ts'),
require.resolve(
'../test/interactive_setup_functional/manual_configuration_without_security.config.ts'
),
require.resolve(
'../test/interactive_setup_functional/manual_configuration_without_tls.config.ts'
),
];
// eslint-disable-next-line no-restricted-syntax
const onlyNotInCoverageTests = [
Expand Down
2 changes: 1 addition & 1 deletion src/dev/license_checker/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const DEV_ONLY_LICENSE_ALLOWED = ['MPL-2.0'];
export const LICENSE_OVERRIDES = {
'jsts@1.6.2': ['Eclipse Distribution License - v 1.0'], // cf. https://github.com/bjornharrtell/jsts
'@mapbox/jsonlint-lines-primitives@2.0.2': ['MIT'], // license in readme https://github.com/tmcw/jsonlint
'@elastic/ems-client@7.16.0': ['Elastic License 2.0'],
'@elastic/ems-client@8.0.0': ['Elastic License 2.0'],
'@elastic/eui@40.0.0': ['SSPL-1.0 OR Elastic License 2.0'],
'language-subtag-registry@0.3.21': ['CC-BY-4.0'], // retired ODC‑By license https://github.com/mattcg/language-subtag-registry
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
*/

import { History } from 'history';
import { DashboardConstants } from '../..';
import { DashboardAppLocatorParams, DashboardConstants } from '../..';
import { DashboardState } from '../../types';
import { getDashboardTitle } from '../../dashboard_strings';
import { DashboardSavedObject } from '../../saved_dashboards';
import { getQueryParams } from '../../services/kibana_utils';
import { createQueryParamObservable } from '../../../../kibana_utils/public';
import { DASHBOARD_APP_URL_GENERATOR, DashboardUrlGeneratorState } from '../../url_generator';
import {
DataPublicPluginStart,
noSearchSessionStorageCapabilityMessage,
SearchSessionInfoProvider,
} from '../../services/data';
import { stateToRawDashboardState } from './convert_dashboard_state';
import { DASHBOARD_APP_LOCATOR } from '../../locator';

export const getSearchSessionIdFromURL = (history: History): string | undefined =>
getQueryParams(history.location)[DashboardConstants.SEARCH_SESSION_ID] as string | undefined;
Expand All @@ -32,16 +33,14 @@ export function createSessionRestorationDataProvider(deps: {
getAppState: () => DashboardState;
getDashboardTitle: () => string;
getDashboardId: () => string;
}) {
}): SearchSessionInfoProvider<DashboardAppLocatorParams> {
return {
getName: async () => deps.getDashboardTitle(),
getUrlGeneratorData: async () => {
return {
urlGeneratorId: DASHBOARD_APP_URL_GENERATOR,
initialState: getUrlGeneratorState({ ...deps, shouldRestoreSearchSession: false }),
restoreState: getUrlGeneratorState({ ...deps, shouldRestoreSearchSession: true }),
};
},
getLocatorData: async () => ({
id: DASHBOARD_APP_LOCATOR,
initialState: getLocatorParams({ ...deps, shouldRestoreSearchSession: false }),
restoreState: getLocatorParams({ ...deps, shouldRestoreSearchSession: true }),
}),
};
}

Expand Down Expand Up @@ -93,7 +92,7 @@ export function enableDashboardSearchSessions({
* Fetches the state to store when a session is saved so that this dashboard can be recreated exactly
* as it was.
*/
function getUrlGeneratorState({
function getLocatorParams({
data,
getAppState,
kibanaVersion,
Expand All @@ -105,7 +104,7 @@ function getUrlGeneratorState({
getAppState: () => DashboardState;
getDashboardId: () => string;
shouldRestoreSearchSession: boolean;
}): DashboardUrlGeneratorState {
}): DashboardAppLocatorParams {
const appState = stateToRawDashboardState({ state: getAppState(), version: kibanaVersion });
const { filterManager, queryString } = data.query;
const { timefilter } = data.query.timefilter;
Expand Down
Loading

0 comments on commit 542951d

Please sign in to comment.