(handler: RequestHandler) => RequestHandler
;
-// @public
-export function resolveSavedObjectsImportErrors({ readStream, objectLimit, retries, savedObjectsClient, typeRegistry, namespace, createNewCopies, }: SavedObjectsResolveImportErrorsOptions): Promise;
-
// @public
export type ResponseError = string | Error | {
message: string | Error;
@@ -2049,6 +2049,13 @@ export interface SavedObjectAttributes {
// @public
export type SavedObjectAttributeSingle = string | number | boolean | null | undefined | SavedObjectAttributes;
+// @public (undocumented)
+export interface SavedObjectExportBaseOptions {
+ excludeExportDetails?: boolean;
+ includeReferencesDeep?: boolean;
+ namespace?: string;
+}
+
// @public
export interface SavedObjectMigrationContext {
log: SavedObjectsMigrationLogger;
@@ -2350,19 +2357,43 @@ export class SavedObjectsErrorHelpers {
}
// @public
-export interface SavedObjectsExportOptions {
- excludeExportDetails?: boolean;
- exportSizeLimit: number;
- hasReference?: SavedObjectsFindOptionsReference[];
- includeReferencesDeep?: boolean;
- namespace?: string;
- objects?: Array<{
+export interface SavedObjectsExportByObjectOptions extends SavedObjectExportBaseOptions {
+ objects: Array<{
id: string;
type: string;
}>;
- savedObjectsClient: SavedObjectsClientContract;
+}
+
+// @public
+export interface SavedObjectsExportByTypeOptions extends SavedObjectExportBaseOptions {
+ hasReference?: SavedObjectsFindOptionsReference[];
search?: string;
- types?: string[];
+ types: string[];
+}
+
+// @public (undocumented)
+export class SavedObjectsExporter {
+ // (undocumented)
+ #private;
+ constructor({ savedObjectsClient, exportSizeLimit, }: {
+ savedObjectsClient: SavedObjectsClientContract;
+ exportSizeLimit: number;
+ });
+ exportByObjects(options: SavedObjectsExportByObjectOptions): Promise;
+ exportByTypes(options: SavedObjectsExportByTypeOptions): Promise;
+ }
+
+// @public (undocumented)
+export class SavedObjectsExportError extends Error {
+ constructor(type: string, message: string, attributes?: Record | undefined);
+ // (undocumented)
+ readonly attributes?: Record | undefined;
+ // (undocumented)
+ static exportSizeExceeded(limit: number): SavedObjectsExportError;
+ // (undocumented)
+ static objectFetchError(objects: SavedObject[]): SavedObjectsExportError;
+ // (undocumented)
+ readonly type: string;
}
// @public
@@ -2452,8 +2483,39 @@ export interface SavedObjectsImportConflictError {
type: 'conflict';
}
+// @public (undocumented)
+export class SavedObjectsImporter {
+ // (undocumented)
+ #private;
+ constructor({ savedObjectsClient, typeRegistry, importSizeLimit, }: {
+ savedObjectsClient: SavedObjectsClientContract;
+ typeRegistry: ISavedObjectTypeRegistry;
+ importSizeLimit: number;
+ });
+ import({ readStream, createNewCopies, namespace, overwrite, }: SavedObjectsImportOptions): Promise;
+ resolveImportErrors({ readStream, createNewCopies, namespace, retries, }: SavedObjectsResolveImportErrorsOptions): Promise;
+}
+
+// @public (undocumented)
+export class SavedObjectsImportError extends Error {
+ // (undocumented)
+ readonly attributes?: Record | undefined;
+ // (undocumented)
+ static importSizeExceeded(limit: number): SavedObjectsImportError;
+ // (undocumented)
+ static nonUniqueImportObjects(nonUniqueEntries: string[]): SavedObjectsImportError;
+ // (undocumented)
+ static nonUniqueRetryDestinations(nonUniqueRetryDestinations: string[]): SavedObjectsImportError;
+ // (undocumented)
+ static nonUniqueRetryObjects(nonUniqueRetryObjects: string[]): SavedObjectsImportError;
+ // (undocumented)
+ static referencesFetchError(objects: SavedObject[]): SavedObjectsImportError;
+ // (undocumented)
+ readonly type: string;
+}
+
// @public
-export interface SavedObjectsImportError {
+export interface SavedObjectsImportFailure {
// (undocumented)
error: SavedObjectsImportConflictError | SavedObjectsImportAmbiguousConflictError | SavedObjectsImportUnsupportedTypeError | SavedObjectsImportMissingReferencesError | SavedObjectsImportUnknownError;
// (undocumented)
@@ -2485,17 +2547,14 @@ export interface SavedObjectsImportMissingReferencesError {
export interface SavedObjectsImportOptions {
createNewCopies: boolean;
namespace?: string;
- objectLimit: number;
overwrite: boolean;
readStream: Readable;
- savedObjectsClient: SavedObjectsClientContract;
- typeRegistry: ISavedObjectTypeRegistry;
}
// @public
export interface SavedObjectsImportResponse {
// (undocumented)
- errors?: SavedObjectsImportError[];
+ errors?: SavedObjectsImportFailure[];
// (undocumented)
success: boolean;
// (undocumented)
@@ -2656,11 +2715,8 @@ export interface SavedObjectsRepositoryFactory {
export interface SavedObjectsResolveImportErrorsOptions {
createNewCopies: boolean;
namespace?: string;
- objectLimit: number;
readStream: Readable;
retries: SavedObjectsImportRetry[];
- savedObjectsClient: SavedObjectsClientContract;
- typeRegistry: ISavedObjectTypeRegistry;
}
// @public
@@ -2676,13 +2732,14 @@ export class SavedObjectsSerializer {
// @public
export interface SavedObjectsServiceSetup {
addClientWrapper: (priority: number, id: string, factory: SavedObjectsClientWrapperFactory) => void;
- getImportExportObjectLimit: () => number;
registerType: (type: SavedObjectsType) => void;
setClientFactoryProvider: (clientFactoryProvider: SavedObjectsClientFactoryProvider) => void;
}
// @public
export interface SavedObjectsServiceStart {
+ createExporter: (client: SavedObjectsClientContract) => ISavedObjectsExporter;
+ createImporter: (client: SavedObjectsClientContract) => ISavedObjectsImporter;
createInternalRepository: (includedHiddenTypes?: string[]) => ISavedObjectsRepository;
createScopedRepository: (req: KibanaRequest, includedHiddenTypes?: string[]) => ISavedObjectsRepository;
createSerializer: () => SavedObjectsSerializer;
diff --git a/src/dev/run_find_plugins_ready_migrate_to_ts_refs.ts b/src/dev/run_find_plugins_ready_migrate_to_ts_refs.ts
index 30ec0ac8ef52e..cfbef768f6874 100644
--- a/src/dev/run_find_plugins_ready_migrate_to_ts_refs.ts
+++ b/src/dev/run_find_plugins_ready_migrate_to_ts_refs.ts
@@ -19,6 +19,7 @@
import Path from 'path';
import Fs from 'fs';
+import JSON5 from 'json5';
import { get } from 'lodash';
import { run, KibanaPlatformPlugin } from '@kbn/dev-utils';
import { getPluginDeps, findPlugins } from './plugin_discovery';
@@ -46,7 +47,8 @@ run(
id: pluginId,
});
- if (deps.size === 0 && errors.size === 0) {
+ const allDepsMigrated = [...deps].every((p) => isMigratedToTsProjectRefs(p.directory));
+ if (allDepsMigrated && errors.size === 0) {
readyToMigrate.add(pluginMap.get(pluginId)!);
}
}
@@ -82,7 +84,7 @@ function isMigratedToTsProjectRefs(dir: string): boolean {
try {
const path = Path.join(dir, 'tsconfig.json');
const content = Fs.readFileSync(path, { encoding: 'utf8' });
- return get(JSON.parse(content), 'compilerOptions.composite', false);
+ return get(JSON5.parse(content), 'compilerOptions.composite', false);
} catch (e) {
return false;
}
diff --git a/src/dev/run_find_plugins_without_ts_refs.ts b/src/dev/run_find_plugins_without_ts_refs.ts
index ad63884671e24..995a22bf3e583 100644
--- a/src/dev/run_find_plugins_without_ts_refs.ts
+++ b/src/dev/run_find_plugins_without_ts_refs.ts
@@ -19,6 +19,7 @@
import Path from 'path';
import Fs from 'fs';
+import JSON5 from 'json5';
import { get } from 'lodash';
import { run } from '@kbn/dev-utils';
import { getPluginDeps, findPlugins } from './plugin_discovery';
@@ -88,7 +89,7 @@ function isMigratedToTsProjectRefs(dir: string): boolean {
try {
const path = Path.join(dir, 'tsconfig.json');
const content = Fs.readFileSync(path, { encoding: 'utf8' });
- return get(JSON.parse(content), 'compilerOptions.composite', false);
+ return get(JSON5.parse(content), 'compilerOptions.composite', false);
} catch (e) {
return false;
}
diff --git a/src/plugins/apm_oss/tsconfig.json b/src/plugins/apm_oss/tsconfig.json
new file mode 100644
index 0000000000000..aeb6837c69a99
--- /dev/null
+++ b/src/plugins/apm_oss/tsconfig.json
@@ -0,0 +1,18 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "composite": true,
+ "outDir": "./target/types",
+ "emitDeclarationOnly": true,
+ "declaration": true,
+ "declarationMap": true
+ },
+ "include": [
+ "common/**/*",
+ "public/**/*",
+ "server/**/*",
+ // have to declare *.json explicitly due to https://github.com/microsoft/TypeScript/issues/25636
+ "server/tutorial/index_pattern.json"
+ ],
+ "references": [{ "path": "../../core/tsconfig.json" }, { "path": "../home/tsconfig.json" }]
+}
diff --git a/src/plugins/bfetch/tsconfig.json b/src/plugins/bfetch/tsconfig.json
new file mode 100644
index 0000000000000..173ff725d07d0
--- /dev/null
+++ b/src/plugins/bfetch/tsconfig.json
@@ -0,0 +1,15 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "composite": true,
+ "outDir": "./target/types",
+ "emitDeclarationOnly": true,
+ "declaration": true,
+ "declarationMap": true
+ },
+ "include": ["common/**/*", "public/**/*", "server/**/*", "index.ts"],
+ "references": [
+ { "path": "../../core/tsconfig.json" },
+ { "path": "../kibana_utils/tsconfig.json" },
+ ]
+}
diff --git a/src/plugins/dashboard/public/application/dashboard_app.tsx b/src/plugins/dashboard/public/application/dashboard_app.tsx
index 845d64c16500d..f33383427342b 100644
--- a/src/plugins/dashboard/public/application/dashboard_app.tsx
+++ b/src/plugins/dashboard/public/application/dashboard_app.tsx
@@ -74,7 +74,10 @@ export function DashboardApp({
const [indexPatterns, setIndexPatterns] = useState([]);
const savedDashboard = useSavedDashboard(savedDashboardId, history);
- const dashboardStateManager = useDashboardStateManager(savedDashboard, history);
+ const { dashboardStateManager, viewMode, setViewMode } = useDashboardStateManager(
+ savedDashboard,
+ history
+ );
const dashboardContainer = useDashboardContainer(dashboardStateManager, history, false);
const refreshDashboardContainer = useCallback(
@@ -113,6 +116,10 @@ export function DashboardApp({
removeQueryParam(history, DashboardConstants.SEARCH_SESSION_ID, true);
}
+ if (changes.viewMode) {
+ setViewMode(changes.viewMode);
+ }
+
dashboardContainer.updateInput({
...changes,
// do not start a new session if this is irrelevant state change to prevent excessive searches
@@ -123,6 +130,7 @@ export function DashboardApp({
[
history,
data.query,
+ setViewMode,
embedSettings,
dashboardContainer,
data.search.session,
@@ -222,7 +230,7 @@ export function DashboardApp({
return (
- {savedDashboard && dashboardStateManager && dashboardContainer && (
+ {savedDashboard && dashboardStateManager && dashboardContainer && viewMode && (
<>
{
diff --git a/src/plugins/dashboard/public/application/hooks/use_dashboard_state_manager.ts b/src/plugins/dashboard/public/application/hooks/use_dashboard_state_manager.ts
index 7aadfe40ebf08..5c606504bfa9a 100644
--- a/src/plugins/dashboard/public/application/hooks/use_dashboard_state_manager.ts
+++ b/src/plugins/dashboard/public/application/hooks/use_dashboard_state_manager.ts
@@ -39,16 +39,23 @@ import { createSessionRestorationDataProvider } from '../lib/session_restoration
import { DashboardStateManager } from '../dashboard_state_manager';
import { getDashboardTitle } from '../../dashboard_strings';
import { DashboardAppServices } from '../types';
+import { ViewMode } from '../../services/embeddable';
// TS is picky with type guards, we can't just inline `() => false`
function defaultTaggingGuard(_obj: SavedObject): _obj is TagDecoratedSavedObject {
return false;
}
+interface DashboardStateManagerReturn {
+ dashboardStateManager: DashboardStateManager | null;
+ viewMode: ViewMode | null;
+ setViewMode: (value: ViewMode) => void;
+}
+
export const useDashboardStateManager = (
savedDashboard: DashboardSavedObject | null,
history: History
-): DashboardStateManager | null => {
+): DashboardStateManagerReturn => {
const {
data: dataPlugin,
core,
@@ -72,6 +79,7 @@ export const useDashboardStateManager = (
const [dashboardStateManager, setDashboardStateManager] = useState(
null
);
+ const [viewMode, setViewMode] = useState(null);
const hasTaggingCapabilities = savedObjectsTagging?.ui.hasTagDecoration || defaultTaggingGuard;
@@ -172,6 +180,7 @@ export const useDashboardStateManager = (
);
setDashboardStateManager(stateManager);
+ setViewMode(stateManager.getViewMode());
return () => {
stateManager?.destroy();
@@ -196,5 +205,5 @@ export const useDashboardStateManager = (
usageCollection,
]);
- return dashboardStateManager;
+ return { dashboardStateManager, viewMode, setViewMode };
};
diff --git a/src/plugins/dashboard/public/application/top_nav/dashboard_top_nav.tsx b/src/plugins/dashboard/public/application/top_nav/dashboard_top_nav.tsx
index 87ccbf29b99f7..e800c84e24295 100644
--- a/src/plugins/dashboard/public/application/top_nav/dashboard_top_nav.tsx
+++ b/src/plugins/dashboard/public/application/top_nav/dashboard_top_nav.tsx
@@ -76,6 +76,7 @@ export interface DashboardTopNavProps {
indexPatterns: IndexPattern[];
redirectTo: DashboardRedirect;
lastDashboardId?: string;
+ viewMode: ViewMode;
}
export function DashboardTopNav({
@@ -88,6 +89,7 @@ export function DashboardTopNav({
indexPatterns,
redirectTo,
timefilter,
+ viewMode,
}: DashboardTopNavProps) {
const {
core,
@@ -422,7 +424,7 @@ export function DashboardTopNav({
const showSearchBar = showQueryBar || showFilterBar;
const topNav = getTopNavConfig(
- dashboardStateManager.getViewMode(),
+ viewMode,
dashboardTopNavActions,
dashboardCapabilities.hideWriteControls
);
@@ -469,7 +471,7 @@ export function DashboardTopNav({
return (
<>
- {!dashboardStateManager.getIsViewMode() ? (
+ {viewMode !== ViewMode.VIEW ? (
) : null}
>
diff --git a/src/plugins/data/common/index_patterns/index_patterns/fixtures/logstash_fields.js b/src/plugins/data/common/index_patterns/index_patterns/fixtures/logstash_fields.js
new file mode 100644
index 0000000000000..e421877724f56
--- /dev/null
+++ b/src/plugins/data/common/index_patterns/index_patterns/fixtures/logstash_fields.js
@@ -0,0 +1,85 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+import { shouldReadFieldFromDocValues, castEsToKbnFieldTypeName } from '../../../../server';
+
+function stubbedLogstashFields() {
+ return [
+ // |aggregatable
+ // | |searchable
+ // name esType | | |metadata | subType
+ ['bytes', 'long', true, true, { count: 10 }],
+ ['ssl', 'boolean', true, true, { count: 20 }],
+ ['@timestamp', 'date', true, true, { count: 30 }],
+ ['time', 'date', true, true, { count: 30 }],
+ ['@tags', 'keyword', true, true],
+ ['utc_time', 'date', true, true],
+ ['phpmemory', 'integer', true, true],
+ ['ip', 'ip', true, true],
+ ['request_body', 'attachment', true, true],
+ ['point', 'geo_point', true, true],
+ ['area', 'geo_shape', true, true],
+ ['hashed', 'murmur3', false, true],
+ ['geo.coordinates', 'geo_point', true, true],
+ ['extension', 'text', true, true],
+ ['extension.keyword', 'keyword', true, true, {}, { multi: { parent: 'extension' } }],
+ ['machine.os', 'text', true, true],
+ ['machine.os.raw', 'keyword', true, true, {}, { multi: { parent: 'machine.os' } }],
+ ['geo.src', 'keyword', true, true],
+ ['_id', '_id', true, true],
+ ['_type', '_type', true, true],
+ ['_source', '_source', true, true],
+ ['non-filterable', 'text', true, false],
+ ['non-sortable', 'text', false, false],
+ ['custom_user_field', 'conflict', true, true],
+ ['script string', 'text', true, false, { script: "'i am a string'" }],
+ ['script number', 'long', true, false, { script: '1234' }],
+ ['script date', 'date', true, false, { script: '1234', lang: 'painless' }],
+ ['script murmur3', 'murmur3', true, false, { script: '1234' }],
+ ].map(function (row) {
+ const [name, esType, aggregatable, searchable, metadata = {}, subType = undefined] = row;
+
+ const {
+ count = 0,
+ script,
+ lang = script ? 'expression' : undefined,
+ scripted = !!script,
+ } = metadata;
+
+ // the conflict type is actually a kbnFieldType, we
+ // don't have any other way to represent it here
+ const type = esType === 'conflict' ? esType : castEsToKbnFieldTypeName(esType);
+
+ return {
+ name,
+ type,
+ esTypes: [esType],
+ readFromDocValues: shouldReadFieldFromDocValues(aggregatable, esType),
+ aggregatable,
+ searchable,
+ count,
+ script,
+ lang,
+ scripted,
+ subType,
+ };
+ });
+}
+
+export default stubbedLogstashFields;
diff --git a/src/plugins/data/common/index_patterns/index_patterns/fixtures/stubbed_saved_object_index_pattern.ts b/src/plugins/data/common/index_patterns/index_patterns/fixtures/stubbed_saved_object_index_pattern.ts
new file mode 100644
index 0000000000000..261e451db5452
--- /dev/null
+++ b/src/plugins/data/common/index_patterns/index_patterns/fixtures/stubbed_saved_object_index_pattern.ts
@@ -0,0 +1,37 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+// @ts-expect-error
+import stubbedLogstashFields from './logstash_fields';
+
+const mockLogstashFields = stubbedLogstashFields();
+
+export function stubbedSavedObjectIndexPattern(id: string | null = null) {
+ return {
+ id,
+ type: 'index-pattern',
+ attributes: {
+ timeFieldName: 'timestamp',
+ customFormats: {},
+ fields: mockLogstashFields,
+ title: 'title',
+ },
+ version: '2',
+ };
+}
diff --git a/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts b/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts
index 145901509d1c5..af2bbf241487c 100644
--- a/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts
+++ b/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts
@@ -23,8 +23,8 @@ import { IndexPattern } from './index_pattern';
import { DuplicateField } from '../../../../kibana_utils/common';
// @ts-expect-error
-import mockLogStashFields from '../../../../../fixtures/logstash_fields';
-import { stubbedSavedObjectIndexPattern } from '../../../../../fixtures/stubbed_saved_object_index_pattern';
+import mockLogStashFields from './fixtures/logstash_fields';
+import { stubbedSavedObjectIndexPattern } from './fixtures/stubbed_saved_object_index_pattern';
import { IndexPatternField } from '../fields';
import { fieldFormatsMock } from '../../field_formats/mocks';
diff --git a/src/plugins/data/common/index_patterns/index_patterns/index_patterns.test.ts b/src/plugins/data/common/index_patterns/index_patterns/index_patterns.test.ts
index 3d32742c168ad..18f18ede86181 100644
--- a/src/plugins/data/common/index_patterns/index_patterns/index_patterns.test.ts
+++ b/src/plugins/data/common/index_patterns/index_patterns/index_patterns.test.ts
@@ -20,7 +20,7 @@
import { defaults } from 'lodash';
import { IndexPatternsService, IndexPattern } from '.';
import { fieldFormatsMock } from '../../field_formats/mocks';
-import { stubbedSavedObjectIndexPattern } from '../../../../../fixtures/stubbed_saved_object_index_pattern';
+import { stubbedSavedObjectIndexPattern } from './fixtures/stubbed_saved_object_index_pattern';
import { UiSettingsCommon, SavedObjectsClientCommon, SavedObject } from '../types';
const createFieldsFetcher = jest.fn().mockImplementation(() => ({
diff --git a/src/plugins/data/common/search/tabify/fixtures/fake_hierarchical_data.ts b/src/plugins/data/common/search/tabify/fixtures/fake_hierarchical_data.ts
new file mode 100644
index 0000000000000..4480caae39664
--- /dev/null
+++ b/src/plugins/data/common/search/tabify/fixtures/fake_hierarchical_data.ts
@@ -0,0 +1,632 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export const metricOnly = {
+ hits: { total: 1000, hits: [], max_score: 0 },
+ aggregations: {
+ agg_1: { value: 412032 },
+ },
+};
+
+export const threeTermBuckets = {
+ hits: { total: 1000, hits: [], max_score: 0 },
+ aggregations: {
+ agg_2: {
+ buckets: [
+ {
+ key: 'png',
+ doc_count: 50,
+ agg_1: { value: 412032 },
+ agg_3: {
+ buckets: [
+ {
+ key: 'IT',
+ doc_count: 10,
+ agg_1: { value: 9299 },
+ agg_4: {
+ buckets: [
+ { key: 'win', doc_count: 4, agg_1: { value: 0 } },
+ { key: 'mac', doc_count: 6, agg_1: { value: 9299 } },
+ ],
+ },
+ },
+ {
+ key: 'US',
+ doc_count: 20,
+ agg_1: { value: 8293 },
+ agg_4: {
+ buckets: [
+ { key: 'linux', doc_count: 12, agg_1: { value: 3992 } },
+ { key: 'mac', doc_count: 8, agg_1: { value: 3029 } },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ {
+ key: 'css',
+ doc_count: 20,
+ agg_1: { value: 412032 },
+ agg_3: {
+ buckets: [
+ {
+ key: 'MX',
+ doc_count: 7,
+ agg_1: { value: 9299 },
+ agg_4: {
+ buckets: [
+ { key: 'win', doc_count: 3, agg_1: { value: 4992 } },
+ { key: 'mac', doc_count: 4, agg_1: { value: 5892 } },
+ ],
+ },
+ },
+ {
+ key: 'US',
+ doc_count: 13,
+ agg_1: { value: 8293 },
+ agg_4: {
+ buckets: [
+ { key: 'linux', doc_count: 12, agg_1: { value: 3992 } },
+ { key: 'mac', doc_count: 1, agg_1: { value: 3029 } },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ {
+ key: 'html',
+ doc_count: 90,
+ agg_1: { value: 412032 },
+ agg_3: {
+ buckets: [
+ {
+ key: 'CN',
+ doc_count: 85,
+ agg_1: { value: 9299 },
+ agg_4: {
+ buckets: [
+ { key: 'win', doc_count: 46, agg_1: { value: 4992 } },
+ { key: 'mac', doc_count: 39, agg_1: { value: 5892 } },
+ ],
+ },
+ },
+ {
+ key: 'FR',
+ doc_count: 15,
+ agg_1: { value: 8293 },
+ agg_4: {
+ buckets: [
+ { key: 'win', doc_count: 3, agg_1: { value: 3992 } },
+ { key: 'mac', doc_count: 12, agg_1: { value: 3029 } },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+};
+
+export const oneTermOneHistogramBucketWithTwoMetricsOneTopHitOneDerivative = {
+ hits: { total: 1000, hits: [], max_score: 0 },
+ aggregations: {
+ agg_3: {
+ buckets: [
+ {
+ key: 'png',
+ doc_count: 50,
+ agg_4: {
+ buckets: [
+ {
+ key_as_string: '2014-09-28T00:00:00.000Z',
+ key: 1411862400000,
+ doc_count: 1,
+ agg_1: { value: 9283 },
+ agg_2: { value: 1411862400000 },
+ agg_6: {
+ hits: {
+ total: 2,
+ hits: [
+ {
+ fields: {
+ bytes: 23,
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ key_as_string: '2014-09-29T00:00:00.000Z',
+ key: 1411948800000,
+ doc_count: 2,
+ agg_1: { value: 28349 },
+ agg_2: { value: 1411948800000 },
+ agg_5: { value: 203 },
+ agg_6: {
+ hits: {
+ total: 2,
+ hits: [
+ {
+ fields: {
+ bytes: 39,
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ key_as_string: '2014-09-30T00:00:00.000Z',
+ key: 1412035200000,
+ doc_count: 3,
+ agg_1: { value: 84330 },
+ agg_2: { value: 1412035200000 },
+ agg_5: { value: 200 },
+ agg_6: {
+ hits: {
+ total: 2,
+ hits: [
+ {
+ fields: {
+ bytes: 329,
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ key_as_string: '2014-10-01T00:00:00.000Z',
+ key: 1412121600000,
+ doc_count: 4,
+ agg_1: { value: 34992 },
+ agg_2: { value: 1412121600000 },
+ agg_5: { value: 103 },
+ agg_6: {
+ hits: {
+ total: 2,
+ hits: [
+ {
+ fields: {
+ bytes: 22,
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ key_as_string: '2014-10-02T00:00:00.000Z',
+ key: 1412208000000,
+ doc_count: 5,
+ agg_1: { value: 145432 },
+ agg_2: { value: 1412208000000 },
+ agg_5: { value: 153 },
+ agg_6: {
+ hits: {
+ total: 2,
+ hits: [
+ {
+ fields: {
+ bytes: 93,
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ key_as_string: '2014-10-03T00:00:00.000Z',
+ key: 1412294400000,
+ doc_count: 35,
+ agg_1: { value: 220943 },
+ agg_2: { value: 1412294400000 },
+ agg_5: { value: 239 },
+ agg_6: {
+ hits: {
+ total: 2,
+ hits: [
+ {
+ fields: {
+ bytes: 72,
+ },
+ },
+ ],
+ },
+ },
+ },
+ ],
+ },
+ },
+ {
+ key: 'css',
+ doc_count: 20,
+ agg_4: {
+ buckets: [
+ {
+ key_as_string: '2014-09-28T00:00:00.000Z',
+ key: 1411862400000,
+ doc_count: 1,
+ agg_1: { value: 9283 },
+ agg_2: { value: 1411862400000 },
+ agg_6: {
+ hits: {
+ total: 2,
+ hits: [
+ {
+ fields: {
+ bytes: 75,
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ key_as_string: '2014-09-29T00:00:00.000Z',
+ key: 1411948800000,
+ doc_count: 2,
+ agg_1: { value: 28349 },
+ agg_2: { value: 1411948800000 },
+ agg_5: { value: 10 },
+ agg_6: {
+ hits: {
+ total: 2,
+ hits: [
+ {
+ fields: {
+ bytes: 11,
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ key_as_string: '2014-09-30T00:00:00.000Z',
+ key: 1412035200000,
+ doc_count: 3,
+ agg_1: { value: 84330 },
+ agg_2: { value: 1412035200000 },
+ agg_5: { value: 24 },
+ agg_6: {
+ hits: {
+ total: 2,
+ hits: [
+ {
+ fields: {
+ bytes: 238,
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ key_as_string: '2014-10-01T00:00:00.000Z',
+ key: 1412121600000,
+ doc_count: 4,
+ agg_1: { value: 34992 },
+ agg_2: { value: 1412121600000 },
+ agg_5: { value: 49 },
+ agg_6: {
+ hits: {
+ total: 2,
+ hits: [
+ {
+ fields: {
+ bytes: 343,
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ key_as_string: '2014-10-02T00:00:00.000Z',
+ key: 1412208000000,
+ doc_count: 5,
+ agg_1: { value: 145432 },
+ agg_2: { value: 1412208000000 },
+ agg_5: { value: 100 },
+ agg_6: {
+ hits: {
+ total: 2,
+ hits: [
+ {
+ fields: {
+ bytes: 837,
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ key_as_string: '2014-10-03T00:00:00.000Z',
+ key: 1412294400000,
+ doc_count: 5,
+ agg_1: { value: 220943 },
+ agg_2: { value: 1412294400000 },
+ agg_5: { value: 23 },
+ agg_6: {
+ hits: {
+ total: 2,
+ hits: [
+ {
+ fields: {
+ bytes: 302,
+ },
+ },
+ ],
+ },
+ },
+ },
+ ],
+ },
+ },
+ {
+ key: 'html',
+ doc_count: 90,
+ agg_4: {
+ buckets: [
+ {
+ key_as_string: '2014-09-28T00:00:00.000Z',
+ key: 1411862400000,
+ doc_count: 10,
+ agg_1: { value: 9283 },
+ agg_2: { value: 1411862400000 },
+ agg_6: {
+ hits: {
+ total: 2,
+ hits: [
+ {
+ fields: {
+ bytes: 30,
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ key_as_string: '2014-09-29T00:00:00.000Z',
+ key: 1411948800000,
+ doc_count: 20,
+ agg_1: { value: 28349 },
+ agg_2: { value: 1411948800000 },
+ agg_5: { value: 1 },
+ agg_6: {
+ hits: {
+ total: 2,
+ hits: [
+ {
+ fields: {
+ bytes: 43,
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ key_as_string: '2014-09-30T00:00:00.000Z',
+ key: 1412035200000,
+ doc_count: 30,
+ agg_1: { value: 84330 },
+ agg_2: { value: 1412035200000 },
+ agg_5: { value: 5 },
+ agg_6: {
+ hits: {
+ total: 2,
+ hits: [
+ {
+ fields: {
+ bytes: 88,
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ key_as_string: '2014-10-01T00:00:00.000Z',
+ key: 1412121600000,
+ doc_count: 11,
+ agg_1: { value: 34992 },
+ agg_2: { value: 1412121600000 },
+ agg_5: { value: 10 },
+ agg_6: {
+ hits: {
+ total: 2,
+ hits: [
+ {
+ fields: {
+ bytes: 91,
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ key_as_string: '2014-10-02T00:00:00.000Z',
+ key: 1412208000000,
+ doc_count: 12,
+ agg_1: { value: 145432 },
+ agg_2: { value: 1412208000000 },
+ agg_5: { value: 43 },
+ agg_6: {
+ hits: {
+ total: 2,
+ hits: [
+ {
+ fields: {
+ bytes: 534,
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ key_as_string: '2014-10-03T00:00:00.000Z',
+ key: 1412294400000,
+ doc_count: 7,
+ agg_1: { value: 220943 },
+ agg_2: { value: 1412294400000 },
+ agg_5: { value: 1 },
+ agg_6: {
+ hits: {
+ total: 2,
+ hits: [
+ {
+ fields: {
+ bytes: 553,
+ },
+ },
+ ],
+ },
+ },
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+};
+
+export const oneRangeBucket = {
+ took: 35,
+ timed_out: false,
+ _shards: {
+ total: 1,
+ successful: 1,
+ failed: 0,
+ },
+ hits: {
+ total: 6039,
+ max_score: 0,
+ hits: [],
+ },
+ aggregations: {
+ agg_2: {
+ buckets: {
+ '0.0-1000.0': {
+ from: 0,
+ from_as_string: '0.0',
+ to: 1000,
+ to_as_string: '1000.0',
+ doc_count: 606,
+ },
+ '1000.0-2000.0': {
+ from: 1000,
+ from_as_string: '1000.0',
+ to: 2000,
+ to_as_string: '2000.0',
+ doc_count: 298,
+ },
+ },
+ },
+ },
+};
+
+export const oneFilterBucket = {
+ took: 11,
+ timed_out: false,
+ _shards: {
+ total: 1,
+ successful: 1,
+ failed: 0,
+ },
+ hits: {
+ total: 6005,
+ max_score: 0,
+ hits: [],
+ },
+ aggregations: {
+ agg_2: {
+ buckets: {
+ 'type:apache': {
+ doc_count: 4844,
+ },
+ 'type:nginx': {
+ doc_count: 1161,
+ },
+ },
+ },
+ },
+};
+
+export const oneHistogramBucket = {
+ took: 37,
+ timed_out: false,
+ _shards: {
+ total: 6,
+ successful: 6,
+ failed: 0,
+ },
+ hits: {
+ total: 49208,
+ max_score: 0,
+ hits: [],
+ },
+ aggregations: {
+ agg_2: {
+ buckets: [
+ {
+ key_as_string: '2014-09-28T00:00:00.000Z',
+ key: 1411862400000,
+ doc_count: 8247,
+ },
+ {
+ key_as_string: '2014-09-29T00:00:00.000Z',
+ key: 1411948800000,
+ doc_count: 8184,
+ },
+ {
+ key_as_string: '2014-09-30T00:00:00.000Z',
+ key: 1412035200000,
+ doc_count: 8269,
+ },
+ {
+ key_as_string: '2014-10-01T00:00:00.000Z',
+ key: 1412121600000,
+ doc_count: 8141,
+ },
+ {
+ key_as_string: '2014-10-02T00:00:00.000Z',
+ key: 1412208000000,
+ doc_count: 8148,
+ },
+ {
+ key_as_string: '2014-10-03T00:00:00.000Z',
+ key: 1412294400000,
+ doc_count: 8219,
+ },
+ ],
+ },
+ },
+};
diff --git a/src/plugins/data/common/search/tabify/tabify.test.ts b/src/plugins/data/common/search/tabify/tabify.test.ts
index 6b9d520b11436..1ee5d23230396 100644
--- a/src/plugins/data/common/search/tabify/tabify.test.ts
+++ b/src/plugins/data/common/search/tabify/tabify.test.ts
@@ -21,7 +21,7 @@ import { tabifyAggResponse } from './tabify';
import { IndexPattern } from '../../index_patterns/index_patterns/index_pattern';
import { AggConfigs, IAggConfig, IAggConfigs } from '../aggs';
import { mockAggTypesRegistry } from '../aggs/test_helpers';
-import { metricOnly, threeTermBuckets } from 'fixtures/fake_hierarchical_data';
+import { metricOnly, threeTermBuckets } from './fixtures/fake_hierarchical_data';
describe('tabifyAggResponse Integration', () => {
const typesRegistry = mockAggTypesRegistry();
diff --git a/src/plugins/data/public/index.ts b/src/plugins/data/public/index.ts
index 7b15e2576e704..bcb65aa0ee205 100644
--- a/src/plugins/data/public/index.ts
+++ b/src/plugins/data/public/index.ts
@@ -385,7 +385,7 @@ export {
SearchRequest,
SearchSourceFields,
SortDirection,
- SessionState,
+ SearchSessionState,
// expression functions and types
EsdslExpressionFunctionDefinition,
EsRawResponseExpressionTypeDefinition,
diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md
index 3493844a71ac1..27a40b4e5ffcb 100644
--- a/src/plugins/data/public/public.api.md
+++ b/src/plugins/data/public/public.api.md
@@ -2311,6 +2311,17 @@ export interface SearchSessionInfoProvider;
}
+// @public
+export enum SearchSessionState {
+ BackgroundCompleted = "backgroundCompleted",
+ BackgroundLoading = "backgroundLoading",
+ Canceled = "canceled",
+ Completed = "completed",
+ Loading = "loading",
+ None = "none",
+ Restored = "restored"
+}
+
// @public (undocumented)
export class SearchSource {
// Warning: (ae-forgotten-export) The symbol "SearchSourceDependencies" needs to be exported by the entry point index.d.ts
@@ -2418,17 +2429,6 @@ export class SearchTimeoutError extends KbnError {
mode: TimeoutErrorMode;
}
-// @public
-export enum SessionState {
- BackgroundCompleted = "backgroundCompleted",
- BackgroundLoading = "backgroundLoading",
- Canceled = "canceled",
- Completed = "completed",
- Loading = "loading",
- None = "none",
- Restored = "restored"
-}
-
// Warning: (ae-missing-release-tag) "SortDirection" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -2620,7 +2620,7 @@ export const UI_SETTINGS: {
// src/plugins/data/public/index.ts:433:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:436:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/query/state_sync/connect_to_query_state.ts:45:5 - (ae-forgotten-export) The symbol "FilterStateStore" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/search/session/session_service.ts:46:5 - (ae-forgotten-export) The symbol "UrlGeneratorStateMapping" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/search/session/session_service.ts:50:5 - (ae-forgotten-export) The symbol "UrlGeneratorStateMapping" needs to be exported by the entry point index.d.ts
// (No @packageDocumentation comment for this package)
diff --git a/src/plugins/data/public/search/index.ts b/src/plugins/data/public/search/index.ts
index 2a767d1bf7c0d..47aedd49d66e9 100644
--- a/src/plugins/data/public/search/index.ts
+++ b/src/plugins/data/public/search/index.ts
@@ -45,7 +45,7 @@ export {
SessionService,
ISessionService,
SearchSessionInfoProvider,
- SessionState,
+ SearchSessionState,
SessionsClient,
ISessionsClient,
} from './session';
diff --git a/src/plugins/data/public/search/session/index.ts b/src/plugins/data/public/search/session/index.ts
index ee0121aacad5e..a40b8857fc0e0 100644
--- a/src/plugins/data/public/search/session/index.ts
+++ b/src/plugins/data/public/search/session/index.ts
@@ -18,5 +18,5 @@
*/
export { SessionService, ISessionService, SearchSessionInfoProvider } from './session_service';
-export { SessionState } from './session_state';
+export { SearchSessionState } from './search_session_state';
export { SessionsClient, ISessionsClient } from './sessions_client';
diff --git a/src/plugins/data/public/search/session/mocks.ts b/src/plugins/data/public/search/session/mocks.ts
index 0ff99b3080365..ea0cd8be03f27 100644
--- a/src/plugins/data/public/search/session/mocks.ts
+++ b/src/plugins/data/public/search/session/mocks.ts
@@ -20,7 +20,7 @@
import { BehaviorSubject, Subject } from 'rxjs';
import { ISessionsClient } from './sessions_client';
import { ISessionService } from './session_service';
-import { SessionState } from './session_state';
+import { SearchSessionState } from './search_session_state';
export function getSessionsClientMock(): jest.Mocked {
return {
@@ -39,7 +39,7 @@ export function getSessionServiceMock(): jest.Mocked {
restore: jest.fn(),
getSessionId: jest.fn(),
getSession$: jest.fn(() => new BehaviorSubject(undefined).asObservable()),
- state$: new BehaviorSubject(SessionState.None).asObservable(),
+ state$: new BehaviorSubject(SearchSessionState.None).asObservable(),
setSearchSessionInfoProvider: jest.fn(),
trackSearch: jest.fn((searchDescriptor) => () => {}),
destroy: jest.fn(),
diff --git a/src/plugins/data/public/search/session/session_state.test.ts b/src/plugins/data/public/search/session/search_session_state.test.ts
similarity index 61%
rename from src/plugins/data/public/search/session/session_state.test.ts
rename to src/plugins/data/public/search/session/search_session_state.test.ts
index 5f709c75bb5d2..539fc8252b2a5 100644
--- a/src/plugins/data/public/search/session/session_state.test.ts
+++ b/src/plugins/data/public/search/session/search_session_state.test.ts
@@ -17,7 +17,7 @@
* under the License.
*/
-import { createSessionStateContainer, SessionState } from './session_state';
+import { createSessionStateContainer, SearchSessionState } from './search_session_state';
describe('Session state container', () => {
const { stateContainer: state } = createSessionStateContainer();
@@ -29,7 +29,7 @@ describe('Session state container', () => {
describe('transitions', () => {
test('start', () => {
state.transitions.start();
- expect(state.selectors.getState()).toBe(SessionState.None);
+ expect(state.selectors.getState()).toBe(SearchSessionState.None);
expect(state.get().sessionId).not.toBeUndefined();
});
@@ -39,22 +39,22 @@ describe('Session state container', () => {
state.transitions.start();
state.transitions.trackSearch({});
- expect(state.selectors.getState()).toBe(SessionState.Loading);
+ expect(state.selectors.getState()).toBe(SearchSessionState.Loading);
});
test('untrack', () => {
state.transitions.start();
const search = {};
state.transitions.trackSearch(search);
- expect(state.selectors.getState()).toBe(SessionState.Loading);
+ expect(state.selectors.getState()).toBe(SearchSessionState.Loading);
state.transitions.unTrackSearch(search);
- expect(state.selectors.getState()).toBe(SessionState.Completed);
+ expect(state.selectors.getState()).toBe(SearchSessionState.Completed);
});
test('clear', () => {
state.transitions.start();
state.transitions.clear();
- expect(state.selectors.getState()).toBe(SessionState.None);
+ expect(state.selectors.getState()).toBe(SearchSessionState.None);
expect(state.get().sessionId).toBeUndefined();
});
@@ -64,11 +64,11 @@ describe('Session state container', () => {
state.transitions.start();
const search = {};
state.transitions.trackSearch(search);
- expect(state.selectors.getState()).toBe(SessionState.Loading);
+ expect(state.selectors.getState()).toBe(SearchSessionState.Loading);
state.transitions.cancel();
- expect(state.selectors.getState()).toBe(SessionState.Canceled);
+ expect(state.selectors.getState()).toBe(SearchSessionState.Canceled);
state.transitions.clear();
- expect(state.selectors.getState()).toBe(SessionState.None);
+ expect(state.selectors.getState()).toBe(SearchSessionState.None);
});
test('store -> completed', () => {
@@ -77,48 +77,48 @@ describe('Session state container', () => {
state.transitions.start();
const search = {};
state.transitions.trackSearch(search);
- expect(state.selectors.getState()).toBe(SessionState.Loading);
+ expect(state.selectors.getState()).toBe(SearchSessionState.Loading);
state.transitions.store();
- expect(state.selectors.getState()).toBe(SessionState.BackgroundLoading);
+ expect(state.selectors.getState()).toBe(SearchSessionState.BackgroundLoading);
state.transitions.unTrackSearch(search);
- expect(state.selectors.getState()).toBe(SessionState.BackgroundCompleted);
+ expect(state.selectors.getState()).toBe(SearchSessionState.BackgroundCompleted);
state.transitions.clear();
- expect(state.selectors.getState()).toBe(SessionState.None);
+ expect(state.selectors.getState()).toBe(SearchSessionState.None);
});
test('store -> cancel', () => {
state.transitions.start();
const search = {};
state.transitions.trackSearch(search);
- expect(state.selectors.getState()).toBe(SessionState.Loading);
+ expect(state.selectors.getState()).toBe(SearchSessionState.Loading);
state.transitions.store();
- expect(state.selectors.getState()).toBe(SessionState.BackgroundLoading);
+ expect(state.selectors.getState()).toBe(SearchSessionState.BackgroundLoading);
state.transitions.cancel();
- expect(state.selectors.getState()).toBe(SessionState.Canceled);
+ expect(state.selectors.getState()).toBe(SearchSessionState.Canceled);
state.transitions.trackSearch(search);
- expect(state.selectors.getState()).toBe(SessionState.Canceled);
+ expect(state.selectors.getState()).toBe(SearchSessionState.Canceled);
state.transitions.start();
- expect(state.selectors.getState()).toBe(SessionState.None);
+ expect(state.selectors.getState()).toBe(SearchSessionState.None);
});
test('restore', () => {
const id = 'id';
state.transitions.restore(id);
- expect(state.selectors.getState()).toBe(SessionState.None);
+ expect(state.selectors.getState()).toBe(SearchSessionState.None);
const search = {};
state.transitions.trackSearch(search);
- expect(state.selectors.getState()).toBe(SessionState.BackgroundLoading);
+ expect(state.selectors.getState()).toBe(SearchSessionState.BackgroundLoading);
state.transitions.unTrackSearch(search);
- expect(state.selectors.getState()).toBe(SessionState.Restored);
+ expect(state.selectors.getState()).toBe(SearchSessionState.Restored);
expect(() => state.transitions.store()).toThrowError();
- expect(state.selectors.getState()).toBe(SessionState.Restored);
+ expect(state.selectors.getState()).toBe(SearchSessionState.Restored);
expect(() => state.transitions.cancel()).toThrowError();
- expect(state.selectors.getState()).toBe(SessionState.Restored);
+ expect(state.selectors.getState()).toBe(SearchSessionState.Restored);
state.transitions.start();
- expect(state.selectors.getState()).toBe(SessionState.None);
+ expect(state.selectors.getState()).toBe(SearchSessionState.None);
});
});
});
diff --git a/src/plugins/data/public/search/session/session_state.ts b/src/plugins/data/public/search/session/search_session_state.ts
similarity index 86%
rename from src/plugins/data/public/search/session/session_state.ts
rename to src/plugins/data/public/search/session/search_session_state.ts
index 087417263e5bf..7a35a65a600d7 100644
--- a/src/plugins/data/public/search/session/session_state.ts
+++ b/src/plugins/data/public/search/session/search_session_state.ts
@@ -27,7 +27,7 @@ import { createStateContainer, StateContainer } from '../../../../kibana_utils/p
*
* @public
*/
-export enum SessionState {
+export enum SearchSessionState {
/**
* Session is not active, e.g. didn't start
*/
@@ -39,18 +39,18 @@ export enum SessionState {
Loading = 'loading',
/**
- * No action was taken and the page completed loading without background session creation.
+ * No action was taken and the page completed loading without search session creation.
*/
Completed = 'completed',
/**
- * Search request was sent to the background.
+ * Search session was sent to the background.
* The page is loading in background.
*/
BackgroundLoading = 'backgroundLoading',
/**
- * Page load completed with background session created.
+ * Page load completed with search session created.
*/
BackgroundCompleted = 'backgroundCompleted',
@@ -68,7 +68,7 @@ export enum SessionState {
/**
* Internal state of SessionService
- * {@link SessionState} is inferred from this state
+ * {@link SearchSessionState} is inferred from this state
*
* @private
*/
@@ -179,27 +179,29 @@ export interface SessionPureSelectors<
SearchDescriptor = unknown,
S = SessionStateInternal
> {
- getState: (state: S) => () => SessionState;
+ getState: (state: S) => () => SearchSessionState;
}
export const sessionPureSelectors: SessionPureSelectors = {
getState: (state) => () => {
- if (!state.sessionId) return SessionState.None;
- if (!state.isStarted) return SessionState.None;
- if (state.isCanceled) return SessionState.Canceled;
+ if (!state.sessionId) return SearchSessionState.None;
+ if (!state.isStarted) return SearchSessionState.None;
+ if (state.isCanceled) return SearchSessionState.Canceled;
switch (true) {
case state.isRestore:
return state.pendingSearches.length > 0
- ? SessionState.BackgroundLoading
- : SessionState.Restored;
+ ? SearchSessionState.BackgroundLoading
+ : SearchSessionState.Restored;
case state.isStored:
return state.pendingSearches.length > 0
- ? SessionState.BackgroundLoading
- : SessionState.BackgroundCompleted;
+ ? SearchSessionState.BackgroundLoading
+ : SearchSessionState.BackgroundCompleted;
default:
- return state.pendingSearches.length > 0 ? SessionState.Loading : SessionState.Completed;
+ return state.pendingSearches.length > 0
+ ? SearchSessionState.Loading
+ : SearchSessionState.Completed;
}
- return SessionState.None;
+ return SearchSessionState.None;
},
};
@@ -213,7 +215,7 @@ export const createSessionStateContainer = (
{ freeze = true }: { freeze: boolean } = { freeze: true }
): {
stateContainer: SessionStateContainer;
- sessionState$: Observable;
+ sessionState$: Observable;
} => {
const stateContainer = createStateContainer(
createSessionDefaultState(),
@@ -222,7 +224,7 @@ export const createSessionStateContainer = (
freeze ? undefined : { freeze: (s) => s }
) as SessionStateContainer;
- const sessionState$: Observable = stateContainer.state$.pipe(
+ const sessionState$: Observable = stateContainer.state$.pipe(
map(() => stateContainer.selectors.getState()),
distinctUntilChanged(),
shareReplay(1)
diff --git a/src/plugins/data/public/search/session/session_service.test.ts b/src/plugins/data/public/search/session/session_service.test.ts
index 83c3185ead63e..cf083239b1571 100644
--- a/src/plugins/data/public/search/session/session_service.test.ts
+++ b/src/plugins/data/public/search/session/session_service.test.ts
@@ -22,11 +22,11 @@ import { coreMock } from '../../../../../core/public/mocks';
import { take, toArray } from 'rxjs/operators';
import { getSessionsClientMock } from './mocks';
import { BehaviorSubject } from 'rxjs';
-import { SessionState } from './session_state';
+import { SearchSessionState } from './search_session_state';
describe('Session service', () => {
let sessionService: ISessionService;
- let state$: BehaviorSubject;
+ let state$: BehaviorSubject;
beforeEach(() => {
const initializerContext = coreMock.createPluginInitializerContext();
@@ -36,7 +36,7 @@ describe('Session service', () => {
getSessionsClientMock(),
{ freezeState: false } // needed to use mocks inside state container
);
- state$ = new BehaviorSubject(SessionState.None);
+ state$ = new BehaviorSubject(SearchSessionState.None);
sessionService.state$.subscribe(state$);
});
@@ -65,17 +65,17 @@ describe('Session service', () => {
it('Tracks searches for current session', () => {
expect(() => sessionService.trackSearch({ abort: () => {} })).toThrowError();
- expect(state$.getValue()).toBe(SessionState.None);
+ expect(state$.getValue()).toBe(SearchSessionState.None);
sessionService.start();
const untrack1 = sessionService.trackSearch({ abort: () => {} });
- expect(state$.getValue()).toBe(SessionState.Loading);
+ expect(state$.getValue()).toBe(SearchSessionState.Loading);
const untrack2 = sessionService.trackSearch({ abort: () => {} });
- expect(state$.getValue()).toBe(SessionState.Loading);
+ expect(state$.getValue()).toBe(SearchSessionState.Loading);
untrack1();
- expect(state$.getValue()).toBe(SessionState.Loading);
+ expect(state$.getValue()).toBe(SearchSessionState.Loading);
untrack2();
- expect(state$.getValue()).toBe(SessionState.Completed);
+ expect(state$.getValue()).toBe(SearchSessionState.Completed);
});
it('Cancels all tracked searches within current session', async () => {
diff --git a/src/plugins/data/public/search/session/session_service.ts b/src/plugins/data/public/search/session/session_service.ts
index ef0b36a33be52..2bbb762fcfe9f 100644
--- a/src/plugins/data/public/search/session/session_service.ts
+++ b/src/plugins/data/public/search/session/session_service.ts
@@ -23,7 +23,11 @@ import { Observable, Subject, Subscription } from 'rxjs';
import { PluginInitializerContext, StartServicesAccessor } from 'kibana/public';
import { UrlGeneratorId, UrlGeneratorStateMapping } from '../../../../share/public/';
import { ConfigSchema } from '../../../config';
-import { createSessionStateContainer, SessionState, SessionStateContainer } from './session_state';
+import {
+ createSessionStateContainer,
+ SearchSessionState,
+ SessionStateContainer,
+} from './search_session_state';
import { ISessionsClient } from './sessions_client';
export type ISessionService = PublicContract;
@@ -33,12 +37,12 @@ export interface TrackSearchDescriptor {
}
/**
- * Provide info about current search session to be stored in backgroundSearch saved object
+ * Provide info about current search session to be stored in the Search Session saved object
*/
export interface SearchSessionInfoProvider {
/**
* User-facing name of the session.
- * e.g. will be displayed in background sessions management list
+ * e.g. will be displayed in saved Search Sessions management list
*/
getName: () => Promise;
getUrlGeneratorData: () => Promise<{
@@ -52,7 +56,7 @@ export interface SearchSessionInfoProvider;
+ public readonly state$: Observable;
private readonly state: SessionStateContainer;
private searchSessionInfoProvider?: SearchSessionInfoProvider;
@@ -95,7 +99,7 @@ export class SessionService {
/**
* Set a provider of info about current session
- * This will be used for creating a background session saved object
+ * This will be used for creating a search session saved object
* @param searchSessionInfoProvider
*/
public setSearchSessionInfoProvider(
@@ -184,7 +188,7 @@ export class SessionService {
private refresh$ = new Subject();
/**
* Observable emits when search result refresh was requested
- * For example, search to background UI could have it's own "refresh" button
+ * For example, the UI could have it's own "refresh" button
* Application would use this observable to handle user interaction on that button
*/
public onRefresh$ = this.refresh$.asObservable();
diff --git a/src/plugins/data/public/search/session/sessions_client.ts b/src/plugins/data/public/search/session/sessions_client.ts
index 38be647a37c7a..a8031e4e467e7 100644
--- a/src/plugins/data/public/search/session/sessions_client.ts
+++ b/src/plugins/data/public/search/session/sessions_client.ts
@@ -27,7 +27,7 @@ export interface SessionsClientDeps {
}
/**
- * CRUD backgroundSession SO
+ * CRUD Search Session SO
*/
export class SessionsClient {
private readonly http: HttpSetup;
diff --git a/src/plugins/data/public/search/types.ts b/src/plugins/data/public/search/types.ts
index 057b242c22f20..7b0b501af8169 100644
--- a/src/plugins/data/public/search/types.ts
+++ b/src/plugins/data/public/search/types.ts
@@ -45,7 +45,7 @@ export interface ISearchSetup {
*/
session: ISessionService;
/**
- * Background search sessions SO CRUD
+ * Search sessions SO CRUD
* {@link ISessionsClient}
*/
sessionsClient: ISessionsClient;
@@ -84,7 +84,7 @@ export interface ISearchStart {
*/
session: ISessionService;
/**
- * Background search sessions SO CRUD
+ * Search sessions SO CRUD
* {@link ISessionsClient}
*/
sessionsClient: ISessionsClient;
diff --git a/src/plugins/data/public/ui/filter_bar/filter_item.tsx b/src/plugins/data/public/ui/filter_bar/filter_item.tsx
index 7b65805a482dd..0d730aed0b28a 100644
--- a/src/plugins/data/public/ui/filter_bar/filter_item.tsx
+++ b/src/plugins/data/public/ui/filter_bar/filter_item.tsx
@@ -153,7 +153,14 @@ export function FilterItem(props: Props) {
const dataTestSubjNegated = filter.meta.negate ? 'filter-negated' : '';
const dataTestSubjDisabled = `filter-${isDisabled(labelConfig) ? 'disabled' : 'enabled'}`;
const dataTestSubjPinned = `filter-${isFilterPinned(filter) ? 'pinned' : 'unpinned'}`;
- return `filter ${dataTestSubjDisabled} ${dataTestSubjKey} ${dataTestSubjValue} ${dataTestSubjPinned} ${dataTestSubjNegated}`;
+ return classNames(
+ 'filter',
+ dataTestSubjDisabled,
+ dataTestSubjKey,
+ dataTestSubjValue,
+ dataTestSubjPinned,
+ dataTestSubjNegated
+ );
}
function getPanels() {
diff --git a/src/plugins/data/server/search/session/session_service.ts b/src/plugins/data/server/search/session/session_service.ts
index 15021436d8821..37484185cb779 100644
--- a/src/plugins/data/server/search/session/session_service.ts
+++ b/src/plugins/data/server/search/session/session_service.ts
@@ -23,7 +23,7 @@ import { ISearchStrategy } from '../types';
import { ISessionService } from './types';
/**
- * The OSS session service. See data_enhanced in X-Pack for the background session service.
+ * The OSS session service. See data_enhanced in X-Pack for the search session service.
*/
export class SessionService implements ISessionService {
constructor() {}
diff --git a/src/plugins/data/tsconfig.json b/src/plugins/data/tsconfig.json
new file mode 100644
index 0000000000000..81bcb3b02e100
--- /dev/null
+++ b/src/plugins/data/tsconfig.json
@@ -0,0 +1,21 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "composite": true,
+ "outDir": "./target/types",
+ "emitDeclarationOnly": true,
+ "declaration": true,
+ "declarationMap": true
+ },
+ "include": ["common/**/*", "public/**/*", "server/**/*", "config.ts"],
+ "references": [
+ { "path": "../../core/tsconfig.json" },
+ { "path": "../bfetch/tsconfig.json" },
+ { "path": "../ui_actions/tsconfig.json" },
+ { "path": "../share/tsconfig.json" },
+ { "path": "../inspector/tsconfig.json" },
+ { "path": "../usage_collection/tsconfig.json" },
+ { "path": "../kibana_utils/tsconfig.json" },
+ { "path": "../kibana_react/tsconfig.json" },
+ ]
+}
diff --git a/src/plugins/discover/public/application/angular/discover.js b/src/plugins/discover/public/application/angular/discover.js
index 639e2212392cc..4c5cb864b5111 100644
--- a/src/plugins/discover/public/application/angular/discover.js
+++ b/src/plugins/discover/public/application/angular/discover.js
@@ -204,7 +204,7 @@ function discoverController($element, $route, $scope, $timeout, Promise, uiCapab
};
const history = getHistory();
- // used for restoring background session
+ // used for restoring a search session
let isInitialSearch = true;
// search session requested a data refresh
diff --git a/src/plugins/embeddable/public/lib/embeddables/embeddable_renderer.test.tsx b/src/plugins/embeddable/public/lib/embeddables/embeddable_renderer.test.tsx
index bcd9d31dade26..1b18d588d8f82 100644
--- a/src/plugins/embeddable/public/lib/embeddables/embeddable_renderer.test.tsx
+++ b/src/plugins/embeddable/public/lib/embeddables/embeddable_renderer.test.tsx
@@ -24,7 +24,7 @@ import {
HelloWorldEmbeddable,
HelloWorldEmbeddableFactoryDefinition,
HELLO_WORLD_EMBEDDABLE,
-} from '../../../../../../examples/embeddable_examples/public/hello_world';
+} from '../../tests/fixtures';
import { EmbeddableRenderer } from './embeddable_renderer';
import { embeddablePluginMock } from '../../mocks';
diff --git a/src/plugins/embeddable/public/lib/embeddables/embeddable_root.test.tsx b/src/plugins/embeddable/public/lib/embeddables/embeddable_root.test.tsx
index cb900884fde97..fa1515b27c53d 100644
--- a/src/plugins/embeddable/public/lib/embeddables/embeddable_root.test.tsx
+++ b/src/plugins/embeddable/public/lib/embeddables/embeddable_root.test.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
-import { HelloWorldEmbeddable } from '../../../../../../examples/embeddable_examples/public';
+import { HelloWorldEmbeddable } from '../../tests/fixtures';
import { EmbeddableRoot } from './embeddable_root';
import { mount } from 'enzyme';
import { findTestSubject } from '@elastic/eui/lib/test';
diff --git a/src/plugins/embeddable/public/plugin.test.ts b/src/plugins/embeddable/public/plugin.test.ts
index 5d47463344434..757a1989d8fc7 100644
--- a/src/plugins/embeddable/public/plugin.test.ts
+++ b/src/plugins/embeddable/public/plugin.test.ts
@@ -20,7 +20,7 @@ import { coreMock } from '../../../core/public/mocks';
import { testPlugin } from './tests/test_plugin';
import { EmbeddableFactoryProvider } from './types';
import { defaultEmbeddableFactoryProvider } from './lib';
-import { HelloWorldEmbeddable } from '../../../../examples/embeddable_examples/public';
+import { HelloWorldEmbeddable } from './tests/fixtures';
test('can set custom embeddable factory provider', async () => {
const coreSetup = coreMock.createSetup();
diff --git a/src/plugins/embeddable/public/tests/container.test.ts b/src/plugins/embeddable/public/tests/container.test.ts
index bb3e35c949666..1eb5cbbd340a3 100644
--- a/src/plugins/embeddable/public/tests/container.test.ts
+++ b/src/plugins/embeddable/public/tests/container.test.ts
@@ -36,10 +36,7 @@ import { ERROR_EMBEDDABLE_TYPE } from '../lib/embeddables/error_embeddable';
import { FilterableEmbeddableFactory } from '../lib/test_samples/embeddables/filterable_embeddable_factory';
import { CONTACT_CARD_EMBEDDABLE } from '../lib/test_samples/embeddables/contact_card/contact_card_embeddable_factory';
import { SlowContactCardEmbeddableFactory } from '../lib/test_samples/embeddables/contact_card/slow_contact_card_embeddable_factory';
-import {
- HELLO_WORLD_EMBEDDABLE,
- HelloWorldEmbeddableFactoryDefinition,
-} from '../../../../../examples/embeddable_examples/public';
+import { HELLO_WORLD_EMBEDDABLE, HelloWorldEmbeddableFactoryDefinition } from './fixtures';
import { HelloWorldContainer } from '../lib/test_samples/embeddables/hello_world_container';
import {
ContactCardEmbeddableInput,
diff --git a/src/plugins/embeddable/public/tests/explicit_input.test.ts b/src/plugins/embeddable/public/tests/explicit_input.test.ts
index 531fbcee94db6..7ab50de40582b 100644
--- a/src/plugins/embeddable/public/tests/explicit_input.test.ts
+++ b/src/plugins/embeddable/public/tests/explicit_input.test.ts
@@ -27,10 +27,7 @@ import {
import { FilterableEmbeddableFactory } from '../lib/test_samples/embeddables/filterable_embeddable_factory';
import { CONTACT_CARD_EMBEDDABLE } from '../lib/test_samples/embeddables/contact_card/contact_card_embeddable_factory';
import { SlowContactCardEmbeddableFactory } from '../lib/test_samples/embeddables/contact_card/slow_contact_card_embeddable_factory';
-import {
- HELLO_WORLD_EMBEDDABLE,
- HelloWorldEmbeddableFactoryDefinition,
-} from '../../../../../examples/embeddable_examples/public';
+import { HELLO_WORLD_EMBEDDABLE, HelloWorldEmbeddableFactoryDefinition } from './fixtures';
import { FilterableContainer } from '../lib/test_samples/embeddables/filterable_container';
import { isErrorEmbeddable } from '../lib';
import { HelloWorldContainer } from '../lib/test_samples/embeddables/hello_world_container';
diff --git a/src/plugins/embeddable/public/tests/fixtures/hello_world_embeddable.tsx b/src/plugins/embeddable/public/tests/fixtures/hello_world_embeddable.tsx
new file mode 100644
index 0000000000000..55385d4125790
--- /dev/null
+++ b/src/plugins/embeddable/public/tests/fixtures/hello_world_embeddable.tsx
@@ -0,0 +1,54 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { Embeddable, EmbeddableInput, IContainer } from '../../';
+
+export const HELLO_WORLD_EMBEDDABLE = 'HELLO_WORLD_EMBEDDABLE';
+
+export class HelloWorldEmbeddable extends Embeddable {
+ // The type of this embeddable. This will be used to find the appropriate factory
+ // to instantiate this kind of embeddable.
+ public readonly type = HELLO_WORLD_EMBEDDABLE;
+
+ constructor(initialInput: EmbeddableInput, parent?: IContainer) {
+ super(
+ // Input state is irrelevant to this embeddable, just pass it along.
+ initialInput,
+ // Initial output state - this embeddable does not do anything with output, so just
+ // pass along an empty object.
+ {},
+ // Optional parent component, this embeddable can optionally be rendered inside a container.
+ parent
+ );
+ }
+
+ /**
+ * Render yourself at the dom node using whatever framework you like, angular, react, or just plain
+ * vanilla js.
+ * @param node
+ */
+ public render(node: HTMLElement) {
+ node.innerHTML = 'HELLO WORLD!
';
+ }
+
+ /**
+ * This is mostly relevant for time based embeddables which need to update data
+ * even if EmbeddableInput has not changed at all.
+ */
+ public reload() {}
+}
diff --git a/src/plugins/embeddable/public/tests/fixtures/hello_world_embeddable_factory.ts b/src/plugins/embeddable/public/tests/fixtures/hello_world_embeddable_factory.ts
new file mode 100644
index 0000000000000..5c651e254e284
--- /dev/null
+++ b/src/plugins/embeddable/public/tests/fixtures/hello_world_embeddable_factory.ts
@@ -0,0 +1,46 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { i18n } from '@kbn/i18n';
+import { IContainer, EmbeddableInput, EmbeddableFactoryDefinition, EmbeddableFactory } from '../..';
+import { HelloWorldEmbeddable, HELLO_WORLD_EMBEDDABLE } from './hello_world_embeddable';
+
+export type HelloWorldEmbeddableFactory = EmbeddableFactory;
+export class HelloWorldEmbeddableFactoryDefinition implements EmbeddableFactoryDefinition {
+ public readonly type = HELLO_WORLD_EMBEDDABLE;
+
+ /**
+ * In our simple example, we let everyone have permissions to edit this. Most
+ * embeddables should check the UI Capabilities service to be sure of
+ * the right permissions.
+ */
+ public async isEditable() {
+ return true;
+ }
+
+ public async create(initialInput: EmbeddableInput, parent?: IContainer) {
+ return new HelloWorldEmbeddable(initialInput, parent);
+ }
+
+ public getDisplayName() {
+ return i18n.translate('embeddableApi.helloworld.displayName', {
+ defaultMessage: 'hello world',
+ });
+ }
+}
diff --git a/src/plugins/embeddable/public/tests/fixtures/index.ts b/src/plugins/embeddable/public/tests/fixtures/index.ts
new file mode 100644
index 0000000000000..f47b4f5e5b847
--- /dev/null
+++ b/src/plugins/embeddable/public/tests/fixtures/index.ts
@@ -0,0 +1,21 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export * from './hello_world_embeddable';
+export * from './hello_world_embeddable_factory';
diff --git a/src/plugins/embeddable/tsconfig.json b/src/plugins/embeddable/tsconfig.json
new file mode 100644
index 0000000000000..27a887500fb68
--- /dev/null
+++ b/src/plugins/embeddable/tsconfig.json
@@ -0,0 +1,23 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "composite": true,
+ "outDir": "./target/types",
+ "emitDeclarationOnly": true,
+ "declaration": true,
+ "declarationMap": true
+ },
+ "include": [
+ "common/**/*",
+ "public/**/*",
+ "server/**/*"
+ ],
+ "references": [
+ { "path": "../../core/tsconfig.json" },
+ { "path": "../inspector/tsconfig.json" },
+ { "path": "../saved_objects/tsconfig.json" },
+ { "path": "../kibana_utils/tsconfig.json" },
+ { "path": "../kibana_react/tsconfig.json" },
+ { "path": "../ui_actions/tsconfig.json" },
+ ]
+}
diff --git a/src/plugins/expressions/tsconfig.json b/src/plugins/expressions/tsconfig.json
new file mode 100644
index 0000000000000..cce71013cefa5
--- /dev/null
+++ b/src/plugins/expressions/tsconfig.json
@@ -0,0 +1,16 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "composite": true,
+ "outDir": "./target/types",
+ "emitDeclarationOnly": true,
+ "declaration": true,
+ "declarationMap": true
+ },
+ "include": ["common/**/*", "public/**/*", "server/**/*", "./index.ts"],
+ "references": [
+ { "path": "../../core/tsconfig.json" },
+ { "path": "../kibana_utils/tsconfig.json" },
+ { "path": "../inspector/tsconfig.json" },
+ ]
+}
diff --git a/src/plugins/home/tsconfig.json b/src/plugins/home/tsconfig.json
new file mode 100644
index 0000000000000..b2613eeecdfb0
--- /dev/null
+++ b/src/plugins/home/tsconfig.json
@@ -0,0 +1,24 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "composite": true,
+ "outDir": "./target/types",
+ "emitDeclarationOnly": true,
+ "declaration": true,
+ "declarationMap": true
+ },
+ "include": [
+ "common/**/*",
+ "public/**/*",
+ "server/**/*",
+ "config.ts",
+ ],
+ "references": [
+ { "path": "../../core/tsconfig.json" },
+ { "path": "../data/tsconfig.json" },
+ { "path": "../kibana_react/tsconfig.json" },
+ { "path": "../url_forwarding/tsconfig.json" },
+ { "path": "../usage_collection/tsconfig.json" },
+ { "path": "../telemetry/tsconfig.json" },
+ ]
+}
diff --git a/src/plugins/navigation/tsconfig.json b/src/plugins/navigation/tsconfig.json
new file mode 100644
index 0000000000000..07cfe10d7d81f
--- /dev/null
+++ b/src/plugins/navigation/tsconfig.json
@@ -0,0 +1,16 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "composite": true,
+ "outDir": "./target/types",
+ "emitDeclarationOnly": true,
+ "declaration": true,
+ "declarationMap": true
+ },
+ "include": ["public/**/*"],
+ "references": [
+ { "path": "../../core/tsconfig.json" },
+ { "path": "../kibana_react/tsconfig.json" },
+ { "path": "../data/tsconfig.json" },
+ ]
+}
diff --git a/src/plugins/runtime_fields/README.mdx b/src/plugins/runtime_fields/README.mdx
new file mode 100644
index 0000000000000..15985b07caf96
--- /dev/null
+++ b/src/plugins/runtime_fields/README.mdx
@@ -0,0 +1,4 @@
+
+# Runtime Fields
+
+The runtime fields plugin provides types and constants for OSS and xpack runtime field related code.
diff --git a/src/plugins/runtime_fields/common/constants.ts b/src/plugins/runtime_fields/common/constants.ts
new file mode 100644
index 0000000000000..568003508f4bd
--- /dev/null
+++ b/src/plugins/runtime_fields/common/constants.ts
@@ -0,0 +1,20 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export const RUNTIME_FIELD_TYPES = ['keyword', 'long', 'double', 'date', 'ip', 'boolean'] as const;
diff --git a/src/plugins/runtime_fields/common/index.ts b/src/plugins/runtime_fields/common/index.ts
new file mode 100644
index 0000000000000..b08ac661a4bd6
--- /dev/null
+++ b/src/plugins/runtime_fields/common/index.ts
@@ -0,0 +1,21 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export * from './constants';
+export * from './types';
diff --git a/src/plugins/runtime_fields/common/types.ts b/src/plugins/runtime_fields/common/types.ts
new file mode 100644
index 0000000000000..f16d3d75d6ecf
--- /dev/null
+++ b/src/plugins/runtime_fields/common/types.ts
@@ -0,0 +1,29 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { RUNTIME_FIELD_TYPES } from './constants';
+
+export type RuntimeType = typeof RUNTIME_FIELD_TYPES[number];
+export interface RuntimeField {
+ name: string;
+ type: RuntimeType;
+ script: {
+ source: string;
+ };
+}
diff --git a/src/plugins/runtime_fields/kibana.json b/src/plugins/runtime_fields/kibana.json
new file mode 100644
index 0000000000000..e71116f81532e
--- /dev/null
+++ b/src/plugins/runtime_fields/kibana.json
@@ -0,0 +1,6 @@
+{
+ "id": "runtimeFields",
+ "version": "kibana",
+ "server": false,
+ "ui": true
+}
diff --git a/src/plugins/runtime_fields/public/index.ts b/src/plugins/runtime_fields/public/index.ts
new file mode 100644
index 0000000000000..a7a94b07ac6e8
--- /dev/null
+++ b/src/plugins/runtime_fields/public/index.ts
@@ -0,0 +1,28 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export * from '../common';
+
+export function plugin() {
+ return {
+ setup() {},
+ start() {},
+ stop() {},
+ };
+}
diff --git a/src/plugins/saved_objects/tsconfig.json b/src/plugins/saved_objects/tsconfig.json
new file mode 100644
index 0000000000000..d9045b91b9dfa
--- /dev/null
+++ b/src/plugins/saved_objects/tsconfig.json
@@ -0,0 +1,17 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "composite": true,
+ "outDir": "./target/types",
+ "emitDeclarationOnly": true,
+ "declaration": true,
+ "declarationMap": true
+ },
+ "include": ["common/**/*", "public/**/*", "server/**/*"],
+ "references": [
+ { "path": "../../core/tsconfig.json" },
+ { "path": "../data/tsconfig.json" },
+ { "path": "../kibana_utils/tsconfig.json" },
+ { "path": "../kibana_react/tsconfig.json" },
+ ]
+}
diff --git a/src/plugins/saved_objects_management/public/lib/import_file.ts b/src/plugins/saved_objects_management/public/lib/import_file.ts
index 84177bda3eb43..bc15954cc2c20 100644
--- a/src/plugins/saved_objects_management/public/lib/import_file.ts
+++ b/src/plugins/saved_objects_management/public/lib/import_file.ts
@@ -17,13 +17,13 @@
* under the License.
*/
-import { HttpStart, SavedObjectsImportError } from 'src/core/public';
+import { HttpStart, SavedObjectsImportFailure } from 'src/core/public';
import { ImportMode } from '../management_section/objects_table/components/import_mode_control';
interface ImportResponse {
success: boolean;
successCount: number;
- errors?: SavedObjectsImportError[];
+ errors?: SavedObjectsImportFailure[];
}
export async function importFile(
diff --git a/src/plugins/saved_objects_management/public/lib/process_import_response.ts b/src/plugins/saved_objects_management/public/lib/process_import_response.ts
index bb7492bb9b3de..bfa376b176f8d 100644
--- a/src/plugins/saved_objects_management/public/lib/process_import_response.ts
+++ b/src/plugins/saved_objects_management/public/lib/process_import_response.ts
@@ -24,12 +24,12 @@ import {
SavedObjectsImportUnsupportedTypeError,
SavedObjectsImportMissingReferencesError,
SavedObjectsImportUnknownError,
- SavedObjectsImportError,
+ SavedObjectsImportFailure,
SavedObjectsImportSuccess,
} from 'src/core/public';
export interface FailedImport {
- obj: Omit;
+ obj: Omit;
error:
| SavedObjectsImportConflictError
| SavedObjectsImportAmbiguousConflictError
@@ -40,7 +40,7 @@ export interface FailedImport {
interface UnmatchedReference {
existingIndexPatternId: string;
- list: Array>;
+ list: Array>;
newIndexPatternId?: string;
}
diff --git a/src/plugins/saved_objects_tagging_oss/tsconfig.json b/src/plugins/saved_objects_tagging_oss/tsconfig.json
new file mode 100644
index 0000000000000..b0059c71424bf
--- /dev/null
+++ b/src/plugins/saved_objects_tagging_oss/tsconfig.json
@@ -0,0 +1,18 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "composite": true,
+ "outDir": "./target/types",
+ "emitDeclarationOnly": true,
+ "declaration": true,
+ "declarationMap": true
+ },
+ "include": [
+ "common/**/*",
+ "public/**/*",
+ ],
+ "references": [
+ { "path": "../../core/tsconfig.json" },
+ { "path": "../saved_objects/tsconfig.json" },
+ ]
+}
diff --git a/src/plugins/ui_actions/public/triggers/row_click_trigger.ts b/src/plugins/ui_actions/public/triggers/row_click_trigger.ts
index 3d47e017675c3..77d0090406409 100644
--- a/src/plugins/ui_actions/public/triggers/row_click_trigger.ts
+++ b/src/plugins/ui_actions/public/triggers/row_click_trigger.ts
@@ -19,7 +19,7 @@
import { i18n } from '@kbn/i18n';
import { Trigger } from '.';
-import { Datatable } from '../../../expressions';
+import type { Datatable } from '../../../expressions';
export const ROW_CLICK_TRIGGER = 'ROW_CLICK_TRIGGER';
diff --git a/src/plugins/ui_actions/tsconfig.json b/src/plugins/ui_actions/tsconfig.json
new file mode 100644
index 0000000000000..a871d7215cdc5
--- /dev/null
+++ b/src/plugins/ui_actions/tsconfig.json
@@ -0,0 +1,17 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "composite": true,
+ "outDir": "./target/types",
+ "emitDeclarationOnly": true,
+ "declaration": true,
+ "declarationMap": true
+ },
+ "include": ["public/**/*"],
+ "references": [
+ { "path": "../../core/tsconfig.json" },
+ { "path": "../expressions/tsconfig.json" },
+ { "path": "../kibana_utils/tsconfig.json" },
+ { "path": "../kibana_react/tsconfig.json" },
+ ]
+}
diff --git a/src/plugins/visualize/public/application/components/visualize_top_nav.tsx b/src/plugins/visualize/public/application/components/visualize_top_nav.tsx
index af74c0d275076..627d5cd00147b 100644
--- a/src/plugins/visualize/public/application/components/visualize_top_nav.tsx
+++ b/src/plugins/visualize/public/application/components/visualize_top_nav.tsx
@@ -98,7 +98,6 @@ const TopNav = ({
stateTransfer: services.stateTransferService,
savedObjectsClient,
embeddableId,
- onAppLeave,
},
services
);
@@ -117,7 +116,6 @@ const TopNav = ({
services,
embeddableId,
savedObjectsClient,
- onAppLeave,
]);
const [indexPatterns, setIndexPatterns] = useState(
vis.data.indexPattern ? [vis.data.indexPattern] : []
@@ -145,8 +143,9 @@ const TopNav = ({
// Confirm when the user has made any changes to an existing visualizations
// or when the user has configured something without saving
if (
- ((originatingApp && originatingApp === 'dashboards') || originatingApp === 'canvas') &&
- (hasUnappliedChanges || hasUnsavedChanges)
+ originatingApp &&
+ (hasUnappliedChanges || hasUnsavedChanges) &&
+ !services.stateTransferService.isTransferInProgress
) {
return actions.confirm(
i18n.translate('visualize.confirmModal.confirmTextDescription', {
@@ -161,10 +160,11 @@ const TopNav = ({
});
}, [
onAppLeave,
- hasUnappliedChanges,
+ originatingApp,
hasUnsavedChanges,
+ hasUnappliedChanges,
visualizeCapabilities.save,
- originatingApp,
+ services.stateTransferService.isTransferInProgress,
]);
useEffect(() => {
diff --git a/src/plugins/visualize/public/application/types.ts b/src/plugins/visualize/public/application/types.ts
index e9bb7ecf654f6..1729d273e24bc 100644
--- a/src/plugins/visualize/public/application/types.ts
+++ b/src/plugins/visualize/public/application/types.ts
@@ -129,6 +129,7 @@ export interface SavedVisInstance {
export interface ByValueVisInstance {
vis: Vis;
+ savedVis: VisSavedObject;
savedSearch?: SavedObject;
embeddableHandler: VisualizeEmbeddableContract;
}
diff --git a/src/plugins/visualize/public/application/utils/get_top_nav_config.tsx b/src/plugins/visualize/public/application/utils/get_top_nav_config.tsx
index 34a618fdefd3f..2420c972977b8 100644
--- a/src/plugins/visualize/public/application/utils/get_top_nav_config.tsx
+++ b/src/plugins/visualize/public/application/utils/get_top_nav_config.tsx
@@ -21,7 +21,6 @@ import React from 'react';
import { i18n } from '@kbn/i18n';
import { TopNavMenuData } from 'src/plugins/navigation/public';
-import { AppMountParameters } from 'kibana/public';
import { VISUALIZE_EMBEDDABLE_TYPE, VisualizeInput } from '../../../../visualizations/public';
import {
showSaveModal,
@@ -55,7 +54,6 @@ interface TopNavConfigParams {
stateTransfer: EmbeddableStateTransfer;
savedObjectsClient: SavedObjectsClientContract;
embeddableId?: string;
- onAppLeave: AppMountParameters['onAppLeave'];
}
export const getTopNavConfig = (
@@ -72,12 +70,10 @@ export const getTopNavConfig = (
visualizationIdFromUrl,
stateTransfer,
embeddableId,
- onAppLeave,
}: TopNavConfigParams,
{
application,
chrome,
- embeddable,
history,
share,
setActiveUrl,
@@ -89,14 +85,11 @@ export const getTopNavConfig = (
}: VisualizeServices
) => {
const { vis, embeddableHandler } = visInstance;
- const savedVis = 'savedVis' in visInstance ? visInstance.savedVis : undefined;
+ const savedVis = visInstance.savedVis;
/**
* Called when the user clicks "Save" button.
*/
async function doSave(saveOptions: SavedObjectSaveOpts) {
- if (!savedVis) {
- return {};
- }
const newlyCreated = !Boolean(savedVis.id) || savedVis.copyOnSave;
// vis.title was not bound and it's needed to reflect title into visState
stateContainer.transitions.setVis({
@@ -122,15 +115,21 @@ export const getTopNavConfig = (
});
if (originatingApp && saveOptions.returnToOrigin) {
- const appPath = `${VisualizeConstants.EDIT_PATH}/${encodeURIComponent(id)}`;
+ if (!embeddableId) {
+ const appPath = `${VisualizeConstants.EDIT_PATH}/${encodeURIComponent(id)}`;
- // Manually insert a new url so the back button will open the saved visualization.
- history.replace(appPath);
- setActiveUrl(appPath);
+ // Manually insert a new url so the back button will open the saved visualization.
+ history.replace(appPath);
+ setActiveUrl(appPath);
+ }
if (newlyCreated && stateTransfer) {
stateTransfer.navigateToWithEmbeddablePackage(originatingApp, {
- state: { type: VISUALIZE_EMBEDDABLE_TYPE, input: { savedObjectId: id } },
+ state: {
+ type: VISUALIZE_EMBEDDABLE_TYPE,
+ input: { savedObjectId: id },
+ embeddableId,
+ },
});
} else {
application.navigateToApp(originatingApp);
@@ -192,6 +191,24 @@ export const getTopNavConfig = (
}
};
+ const saveButtonLabel =
+ embeddableId ||
+ (!savedVis.id && dashboard.dashboardFeatureFlagConfig.allowByValueEmbeddables && originatingApp)
+ ? i18n.translate('visualize.topNavMenu.saveVisualizationToLibraryButtonLabel', {
+ defaultMessage: 'Save to library',
+ })
+ : originatingApp && (embeddableId || savedVis.id)
+ ? i18n.translate('visualize.topNavMenu.saveVisualizationAsButtonLabel', {
+ defaultMessage: 'Save as',
+ })
+ : i18n.translate('visualize.topNavMenu.saveVisualizationButtonLabel', {
+ defaultMessage: 'Save',
+ });
+
+ const showSaveAndReturn =
+ originatingApp &&
+ (savedVis?.id || dashboard.dashboardFeatureFlagConfig.allowByValueEmbeddables);
+
const topNavMenu: TopNavMenuData[] = [
{
id: 'inspector',
@@ -243,7 +260,7 @@ export const getTopNavConfig = (
// disable the Share button if no action specified
disableButton: !share || !!embeddableId,
},
- ...(originatingApp === 'dashboards' || originatingApp === 'canvas'
+ ...(originatingApp
? [
{
id: 'cancel',
@@ -268,24 +285,16 @@ export const getTopNavConfig = (
},
]
: []),
- ...(visualizeCapabilities.save && !embeddableId
+ ...(visualizeCapabilities.save
? [
{
id: 'save',
- iconType: savedVis?.id && originatingApp ? undefined : 'save',
- label:
- savedVis?.id && originatingApp
- ? i18n.translate('visualize.topNavMenu.saveVisualizationAsButtonLabel', {
- defaultMessage: 'save as',
- })
- : i18n.translate('visualize.topNavMenu.saveVisualizationButtonLabel', {
- defaultMessage: 'save',
- }),
- emphasize: (savedVis && !savedVis.id) || !originatingApp,
+ iconType: showSaveAndReturn ? undefined : 'save',
+ label: saveButtonLabel,
+ emphasize: !showSaveAndReturn,
description: i18n.translate('visualize.topNavMenu.saveVisualizationButtonAriaLabel', {
defaultMessage: 'Save Visualization',
}),
- className: savedVis?.id && originatingApp ? 'saveAsButton' : '',
testId: 'visualizeSaveButton',
disableButton: hasUnappliedChanges,
tooltip() {
@@ -298,7 +307,7 @@ export const getTopNavConfig = (
);
}
},
- run: (anchorElement: HTMLElement) => {
+ run: () => {
const onSave = async ({
newTitle,
newCopyOnSave,
@@ -308,10 +317,6 @@ export const getTopNavConfig = (
returnToOrigin,
dashboardId,
}: OnSaveProps & { returnToOrigin?: boolean } & { dashboardId?: string | null }) => {
- if (!savedVis) {
- return;
- }
-
const currentTitle = savedVis.title;
savedVis.title = newTitle;
embeddableHandler.updateInput({ title: newTitle });
@@ -371,12 +376,10 @@ export const getTopNavConfig = (
let selectedTags: string[] = [];
let tagOptions: React.ReactNode | undefined;
- if (
- savedVis &&
- savedObjectsTagging &&
- savedObjectsTagging.ui.hasTagDecoration(savedVis)
- ) {
- selectedTags = savedVis.getTags();
+ if (savedObjectsTagging) {
+ if (savedVis && savedObjectsTagging.ui.hasTagDecoration(savedVis)) {
+ selectedTags = savedVis.getTags();
+ }
tagOptions = (
{}}
originatingApp={originatingApp}
+ returnToOriginSwitchLabel={
+ originatingApp && embeddableId
+ ? i18n.translate('visualize.topNavMenu.updatePanel', {
+ defaultMessage: 'Update panel on {originatingAppName}',
+ values: {
+ originatingAppName: stateTransfer.getAppNameFromId(originatingApp),
+ },
+ })
+ : undefined
+ }
/>
) : (
);
-
- const isSaveAsButton = anchorElement.classList.contains('saveAsButton');
- onAppLeave((actions) => {
- return actions.default();
- });
- if (
- originatingApp === 'dashboards' &&
- dashboard.dashboardFeatureFlagConfig.allowByValueEmbeddables &&
- !isSaveAsButton
- ) {
- createVisReference();
- } else if (savedVis) {
- showSaveModal(saveModal, I18nContext);
- }
+ showSaveModal(saveModal, I18nContext);
},
},
]
: []),
- ...(originatingApp && ((savedVis && savedVis.id) || embeddableId)
+ ...(visualizeCapabilities.save && showSaveAndReturn
? [
{
id: 'saveAndReturn',
@@ -455,20 +455,13 @@ export const getTopNavConfig = (
}
},
run: async () => {
+ if (!savedVis?.id) {
+ return createVisReference();
+ }
const saveOptions = {
confirmOverwrite: false,
returnToOrigin: true,
};
- onAppLeave((actions) => {
- return actions.default();
- });
- if (
- originatingApp === 'dashboards' &&
- dashboard.dashboardFeatureFlagConfig.allowByValueEmbeddables &&
- !savedVis
- ) {
- return createVisReference();
- }
return doSave(saveOptions);
},
},
diff --git a/src/plugins/visualize/public/application/utils/get_visualization_instance.ts b/src/plugins/visualize/public/application/utils/get_visualization_instance.ts
index 6010c4f8b163e..148e2c16c7824 100644
--- a/src/plugins/visualize/public/application/utils/get_visualization_instance.ts
+++ b/src/plugins/visualize/public/application/utils/get_visualization_instance.ts
@@ -71,8 +71,14 @@ export const getVisualizationInstanceFromInput = async (
visualizeServices: VisualizeServices,
input: VisualizeInput
) => {
- const { visualizations } = visualizeServices;
+ const { visualizations, savedVisualizations } = visualizeServices;
const visState = input.savedVis as SerializedVis;
+
+ /**
+ * A saved vis is needed even in by value mode to support 'save to library' which converts the 'by value'
+ * state of the visualization, into a new saved object.
+ */
+ const savedVis: VisSavedObject = await savedVisualizations.get();
let vis = await visualizations.createVis(visState.type, cloneDeep(visState));
if (vis.type.setup) {
try {
@@ -87,6 +93,7 @@ export const getVisualizationInstanceFromInput = async (
);
return {
vis,
+ savedVis,
embeddableHandler,
savedSearch,
};
diff --git a/src/plugins/visualize/public/application/utils/use/use_saved_vis_instance.ts b/src/plugins/visualize/public/application/utils/use/use_saved_vis_instance.ts
index 9dd29a2ba433a..3f9b3ca9b8b73 100644
--- a/src/plugins/visualize/public/application/utils/use/use_saved_vis_instance.ts
+++ b/src/plugins/visualize/public/application/utils/use/use_saved_vis_instance.ts
@@ -45,6 +45,7 @@ export const useSavedVisInstance = (
savedVisInstance?: SavedVisInstance;
visEditorController?: IEditorController;
}>({});
+
const visEditorRef = useRef(null);
const visId = useRef('');
@@ -132,7 +133,6 @@ export const useSavedVisInstance = (
embeddableHandler.render(visEditorRef.current);
}
}
-
setState({
savedVisInstance,
visEditorController,
@@ -189,13 +189,13 @@ export const useSavedVisInstance = (
getSavedVisInstance();
}
}, [
+ services,
eventEmitter,
- isChromeVisible,
originatingApp,
- services,
+ isChromeVisible,
+ visualizationIdFromUrl,
state.savedVisInstance,
state.visEditorController,
- visualizationIdFromUrl,
]);
useEffect(() => {
diff --git a/test/api_integration/apis/saved_objects/export.ts b/test/api_integration/apis/saved_objects/export.ts
index 7254f3b3fcf31..43bf37275c00f 100644
--- a/test/api_integration/apis/saved_objects/export.ts
+++ b/test/api_integration/apis/saved_objects/export.ts
@@ -167,7 +167,7 @@ export default function ({ getService }: FtrProviderContext) {
expect(resp.body).to.eql({
statusCode: 400,
error: 'Bad Request',
- message: 'Bad Request',
+ message: 'Error fetching objects to export',
attributes: {
objects: [
{
diff --git a/test/api_integration/apis/saved_objects/import.ts b/test/api_integration/apis/saved_objects/import.ts
index bdb695ef20dd1..b661822f4dcd3 100644
--- a/test/api_integration/apis/saved_objects/import.ts
+++ b/test/api_integration/apis/saved_objects/import.ts
@@ -20,12 +20,12 @@
import expect from '@kbn/expect';
import { join } from 'path';
import dedent from 'dedent';
-import type { SavedObjectsImportError } from 'src/core/server';
+import type { SavedObjectsImportFailure } from 'src/core/server';
import type { FtrProviderContext } from '../../ftr_provider_context';
const createConflictError = (
- object: Omit
-): SavedObjectsImportError => ({
+ object: Omit
+): SavedObjectsImportFailure => ({
...object,
title: object.meta.title,
error: { type: 'conflict' },
diff --git a/test/functional/page_objects/dashboard_page.ts b/test/functional/page_objects/dashboard_page.ts
index 8924d22cdb50f..cc1420e4825c2 100644
--- a/test/functional/page_objects/dashboard_page.ts
+++ b/test/functional/page_objects/dashboard_page.ts
@@ -33,6 +33,7 @@ export function DashboardPageProvider({ getService, getPageObjects }: FtrProvide
const dashboardAddPanel = getService('dashboardAddPanel');
const renderable = getService('renderable');
const listingTable = getService('listingTable');
+ const elasticChart = getService('elasticChart');
const PageObjects = getPageObjects(['common', 'header', 'visualize']);
interface SaveDashboardOptions {
@@ -275,6 +276,20 @@ export function DashboardPageProvider({ getService, getPageObjects }: FtrProvide
}
}
+ public async isColorSyncOn() {
+ log.debug('isColorSyncOn');
+ await this.openOptions();
+ return await testSubjects.getAttribute('dashboardSyncColorsCheckbox', 'checked');
+ }
+
+ public async useColorSync(on = true) {
+ await this.openOptions();
+ const isColorSyncOn = await this.isColorSyncOn();
+ if (isColorSyncOn !== 'on') {
+ return await testSubjects.click('dashboardSyncColorsCheckbox');
+ }
+ }
+
public async gotoDashboardEditMode(dashboardName: string) {
await this.loadSavedDashboard(dashboardName);
await this.switchToEditMode();
@@ -554,6 +569,10 @@ export function DashboardPageProvider({ getService, getPageObjects }: FtrProvide
return 0;
}
}
+
+ public async getPanelChartDebugState(panelIndex: number) {
+ return await elasticChart.getChartDebugData(undefined, panelIndex);
+ }
}
return new DashboardPage();
diff --git a/test/functional/services/dashboard/visualizations.ts b/test/functional/services/dashboard/visualizations.ts
index 22e1769145f88..ff1e934c7f265 100644
--- a/test/functional/services/dashboard/visualizations.ts
+++ b/test/functional/services/dashboard/visualizations.ts
@@ -149,8 +149,8 @@ export function DashboardVisualizationProvider({ getService, getPageObjects }: F
await PageObjects.visualize.clickAggBasedVisualizations();
await PageObjects.visualize.clickMetric();
await find.clickByCssSelector('li.euiListGroupItem:nth-of-type(2)');
- await testSubjects.exists('visualizeSaveButton');
- await testSubjects.click('visualizeSaveButton');
+ await testSubjects.exists('visualizesaveAndReturnButton');
+ await testSubjects.click('visualizesaveAndReturnButton');
}
async createAndEmbedMarkdown({ name, markdown }: { name: string; markdown: string }) {
@@ -163,7 +163,7 @@ export function DashboardVisualizationProvider({ getService, getPageObjects }: F
await PageObjects.visualize.clickMarkdownWidget();
await PageObjects.visEditor.setMarkdownTxt(markdown);
await PageObjects.visEditor.clickGo();
- await testSubjects.click('visualizeSaveButton');
+ await testSubjects.click('visualizesaveAndReturnButton');
}
})();
}
diff --git a/test/functional/services/filter_bar.ts b/test/functional/services/filter_bar.ts
index de895918efbba..546f83e5b710a 100644
--- a/test/functional/services/filter_bar.ts
+++ b/test/functional/services/filter_bar.ts
@@ -17,6 +17,7 @@
* under the License.
*/
+import classNames from 'classnames';
import { FtrProviderContext } from '../ftr_provider_context';
export function FilterBarProvider({ getService, getPageObjects }: FtrProviderContext) {
@@ -45,7 +46,14 @@ export function FilterBarProvider({ getService, getPageObjects }: FtrProviderCon
const filterPinnedState = pinned ? 'pinned' : 'unpinned';
const filterNegatedState = negated ? 'filter-negated' : '';
return testSubjects.exists(
- `filter filter-${filterActivationState} filter-key-${key} filter-value-${value} filter-${filterPinnedState} ${filterNegatedState}`,
+ classNames(
+ 'filter',
+ `filter-${filterActivationState}`,
+ key !== '' && `filter-key-${key}`,
+ value !== '' && `filter-value-${value}`,
+ `filter-${filterPinnedState}`,
+ filterNegatedState
+ ),
{
allowHidden: true,
}
diff --git a/test/functional/services/visualizations/elastic_chart.ts b/test/functional/services/visualizations/elastic_chart.ts
index 1f1f7df45f460..86ca4d1c1e31e 100644
--- a/test/functional/services/visualizations/elastic_chart.ts
+++ b/test/functional/services/visualizations/elastic_chart.ts
@@ -81,19 +81,23 @@ export function ElasticChartProvider({ getService }: FtrProviderContext) {
}
}
- private async getChart(dataTestSubj?: string, timeout?: number): Promise {
+ private async getChart(
+ dataTestSubj?: string,
+ timeout?: number,
+ match: number = 0
+ ): Promise {
if (dataTestSubj) {
if (!(await testSubjects.exists(dataTestSubj, { timeout }))) {
throw Error(`Failed to find an elastic-chart with testSubject '${dataTestSubj}'`);
}
- return await testSubjects.find(dataTestSubj);
+ return (await testSubjects.findAll(dataTestSubj))[match];
} else {
const charts = await this.getAllCharts(timeout);
if (charts.length === 0) {
throw Error(`Failed to find any elastic-charts on the page`);
} else {
- return charts[0];
+ return charts[match];
}
}
}
@@ -106,8 +110,11 @@ export function ElasticChartProvider({ getService }: FtrProviderContext) {
* used to get chart data from `@elastic/charts`
* requires `window._echDebugStateFlag` to be true
*/
- public async getChartDebugData(dataTestSubj?: string): Promise {
- const chart = await this.getChart(dataTestSubj);
+ public async getChartDebugData(
+ dataTestSubj?: string,
+ match: number = 0
+ ): Promise {
+ const chart = await this.getChart(dataTestSubj, undefined, match);
try {
const visContainer = await chart.findByCssSelector('.echChartStatus');
diff --git a/test/scripts/test/mocha.sh b/test/scripts/test/mocha.sh
index e5f3259926e42..5e005c89330ca 100755
--- a/test/scripts/test/mocha.sh
+++ b/test/scripts/test/mocha.sh
@@ -2,5 +2,6 @@
source src/dev/ci_setup/setup_env.sh
-checks-reporter-with-killswitch "Mocha Tests" \
- node scripts/mocha
+# TODO: will remove mocha in another PR
+# checks-reporter-with-killswitch "Mocha Tests" \
+# node scripts/mocha
diff --git a/test/tsconfig.json b/test/tsconfig.json
index df26441b0806f..5a0d2670a843c 100644
--- a/test/tsconfig.json
+++ b/test/tsconfig.json
@@ -8,13 +8,21 @@
"exclude": ["plugin_functional/plugins/**/*", "interpreter_functional/plugins/**/*"],
"references": [
{ "path": "../src/core/tsconfig.json" },
+ { "path": "../src/plugins/bfetch/tsconfig.json" },
+ { "path": "../src/plugins/embeddable/tsconfig.json" },
+ { "path": "../src/plugins/expressions/tsconfig.json" },
+ { "path": "../src/plugins/home/tsconfig.json" },
{ "path": "../src/plugins/inspector/tsconfig.json" },
{ "path": "../src/plugins/kibana_react/tsconfig.json" },
{ "path": "../src/plugins/kibana_usage_collection/tsconfig.json" },
{ "path": "../src/plugins/kibana_utils/tsconfig.json" },
+ { "path": "../src/plugins/navigation/tsconfig.json" },
{ "path": "../src/plugins/newsfeed/tsconfig.json" },
+ { "path": "../src/plugins/saved_objects/tsconfig.json" },
+ { "path": "../src/plugins/saved_objects_tagging_oss/tsconfig.json" },
{ "path": "../src/plugins/telemetry_collection_manager/tsconfig.json" },
{ "path": "../src/plugins/telemetry/tsconfig.json" },
- { "path": "../src/plugins/usage_collection/tsconfig.json" }
+ { "path": "../src/plugins/ui_actions/tsconfig.json" },
+ { "path": "../src/plugins/usage_collection/tsconfig.json" },
]
}
diff --git a/tsconfig.json b/tsconfig.json
index 02048414f678e..d882697bbf484 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -7,19 +7,29 @@
"exclude": [
"src/**/__fixtures__/**/*",
"src/core/**/*",
+ "src/plugins/apm_oss/**/*",
+ "src/plugins/bfetch/**/*",
+ "src/plugins/data/**/*",
"src/plugins/dev_tools/**/*",
+ "src/plugins/embeddable/**/*",
+ "src/plugins/expressions/**/*",
+ "src/plugins/home/**/*",
"src/plugins/inspector/**/*",
"src/plugins/kibana_legacy/**/*",
"src/plugins/kibana_react/**/*",
"src/plugins/kibana_usage_collection/**/*",
"src/plugins/kibana_utils/**/*",
+ "src/plugins/navigation/**/*",
"src/plugins/newsfeed/**/*",
+ "src/plugins/saved_objects/**/*",
"src/plugins/security_oss/**/*",
+ "src/plugins/saved_objects_tagging_oss/**/*",
"src/plugins/share/**/*",
"src/plugins/telemetry/**/*",
"src/plugins/telemetry_collection_manager/**/*",
+ "src/plugins/ui_actions/**/*",
"src/plugins/url_forwarding/**/*",
- "src/plugins/usage_collection/**/*",
+ "src/plugins/usage_collection/**/*"
// In the build we actually exclude **/public/**/* from this config so that
// we can run the TSC on both this and the .browser version of this config
// file, but if we did it during development IDEs would not be able to find
@@ -28,18 +38,28 @@
],
"references": [
{ "path": "./src/core/tsconfig.json" },
+ { "path": "./src/plugins/apm_oss/tsconfig.json" },
+ { "path": "./src/plugins/bfetch/tsconfig.json" },
+ { "path": "./src/plugins/data/tsconfig.json" },
{ "path": "./src/plugins/dev_tools/tsconfig.json" },
+ { "path": "./src/plugins/embeddable/tsconfig.json" },
+ { "path": "./src/plugins/expressions/tsconfig.json" },
+ { "path": "./src/plugins/home/tsconfig.json" },
{ "path": "./src/plugins/inspector/tsconfig.json" },
{ "path": "./src/plugins/kibana_legacy/tsconfig.json" },
{ "path": "./src/plugins/kibana_react/tsconfig.json" },
{ "path": "./src/plugins/kibana_usage_collection/tsconfig.json" },
{ "path": "./src/plugins/kibana_utils/tsconfig.json" },
+ { "path": "./src/plugins/navigation/tsconfig.json" },
{ "path": "./src/plugins/newsfeed/tsconfig.json" },
+ { "path": "./src/plugins/saved_objects/tsconfig.json" },
+ { "path": "./src/plugins/saved_objects_tagging_oss/tsconfig.json" },
{ "path": "./src/plugins/security_oss/tsconfig.json" },
{ "path": "./src/plugins/share/tsconfig.json" },
{ "path": "./src/plugins/telemetry/tsconfig.json" },
{ "path": "./src/plugins/telemetry_collection_manager/tsconfig.json" },
+ { "path": "./src/plugins/ui_actions/tsconfig.json" },
{ "path": "./src/plugins/url_forwarding/tsconfig.json" },
- { "path": "./src/plugins/usage_collection/tsconfig.json" },
+ { "path": "./src/plugins/usage_collection/tsconfig.json" }
]
}
diff --git a/tsconfig.refs.json b/tsconfig.refs.json
index a99d4d57d3f0a..c712d46204f35 100644
--- a/tsconfig.refs.json
+++ b/tsconfig.refs.json
@@ -2,18 +2,28 @@
"include": [],
"references": [
{ "path": "./src/core/tsconfig.json" },
+ { "path": "./src/plugins/apm_oss/tsconfig.json" },
+ { "path": "./src/plugins/bfetch/tsconfig.json" },
+ { "path": "./src/plugins/data/tsconfig.json" },
{ "path": "./src/plugins/dev_tools/tsconfig.json" },
+ { "path": "./src/plugins/embeddable/tsconfig.json" },
+ { "path": "./src/plugins/expressions/tsconfig.json" },
+ { "path": "./src/plugins/home/tsconfig.json" },
{ "path": "./src/plugins/inspector/tsconfig.json" },
{ "path": "./src/plugins/kibana_legacy/tsconfig.json" },
{ "path": "./src/plugins/kibana_react/tsconfig.json" },
{ "path": "./src/plugins/kibana_usage_collection/tsconfig.json" },
{ "path": "./src/plugins/kibana_utils/tsconfig.json" },
+ { "path": "./src/plugins/navigation/tsconfig.json" },
{ "path": "./src/plugins/newsfeed/tsconfig.json" },
+ { "path": "./src/plugins/saved_objects/tsconfig.json" },
+ { "path": "./src/plugins/saved_objects_tagging_oss/tsconfig.json" },
{ "path": "./src/plugins/security_oss/tsconfig.json" },
{ "path": "./src/plugins/share/tsconfig.json" },
{ "path": "./src/plugins/telemetry/tsconfig.json" },
{ "path": "./src/plugins/telemetry_collection_manager/tsconfig.json" },
+ { "path": "./src/plugins/ui_actions/tsconfig.json" },
{ "path": "./src/plugins/url_forwarding/tsconfig.json" },
- { "path": "./src/plugins/usage_collection/tsconfig.json" },
+ { "path": "./src/plugins/usage_collection/tsconfig.json" }
]
}
diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json
index 6937862d20536..7380d25930bc0 100644
--- a/x-pack/.i18nrc.json
+++ b/x-pack/.i18nrc.json
@@ -42,7 +42,7 @@
"xpack.remoteClusters": "plugins/remote_clusters",
"xpack.reporting": ["plugins/reporting"],
"xpack.rollupJobs": ["plugins/rollup"],
- "xpack.runtimeFields": "plugins/runtime_fields",
+ "xpack.runtimeFields": "plugins/runtime_field_editor",
"xpack.searchProfiler": "plugins/searchprofiler",
"xpack.security": "plugins/security",
"xpack.server": "legacy/server",
diff --git a/x-pack/plugins/alerts/server/invalidate_pending_api_keys/task.ts b/x-pack/plugins/alerts/server/invalidate_pending_api_keys/task.ts
index 1c7320d3df6f3..5e26a5776f9fe 100644
--- a/x-pack/plugins/alerts/server/invalidate_pending_api_keys/task.ts
+++ b/x-pack/plugins/alerts/server/invalidate_pending_api_keys/task.ts
@@ -12,7 +12,7 @@ import {
SavedObjectsClientContract,
} from 'kibana/server';
import { EncryptedSavedObjectsClient } from '../../../encrypted_saved_objects/server';
-import { InvalidateAPIKeyParams, SecurityPluginStart } from '../../../security/server';
+import { InvalidateAPIKeysParams, SecurityPluginStart } from '../../../security/server';
import {
RunContext,
TaskManagerSetupContract,
@@ -27,8 +27,8 @@ import { InvalidatePendingApiKey } from '../types';
const TASK_TYPE = 'alerts_invalidate_api_keys';
export const TASK_ID = `Alerts-${TASK_TYPE}`;
-const invalidateAPIKey = async (
- params: InvalidateAPIKeyParams,
+const invalidateAPIKeys = async (
+ params: InvalidateAPIKeysParams,
securityPluginStart?: SecurityPluginStart
): Promise => {
if (!securityPluginStart) {
@@ -193,30 +193,35 @@ async function invalidateApiKeys(
encryptedSavedObjectsClient: EncryptedSavedObjectsClient,
securityPluginStart?: SecurityPluginStart
) {
- // TODO: This could probably send a single request to ES now that the invalidate API supports multiple ids in a single request
let totalInvalidated = 0;
- await Promise.all(
+ const apiKeyIds = await Promise.all(
apiKeysToInvalidate.saved_objects.map(async (apiKeyObj) => {
const decryptedApiKey = await encryptedSavedObjectsClient.getDecryptedAsInternalUser(
'api_key_pending_invalidation',
apiKeyObj.id
);
- const apiKeyId = decryptedApiKey.attributes.apiKeyId;
- const response = await invalidateAPIKey({ id: apiKeyId }, securityPluginStart);
- if (response.apiKeysEnabled === true && response.result.error_count > 0) {
- logger.error(`Failed to invalidate API Key [id="${apiKeyObj.attributes.apiKeyId}"]`);
- } else {
- try {
- await savedObjectsClient.delete('api_key_pending_invalidation', apiKeyObj.id);
- totalInvalidated++;
- } catch (err) {
- logger.error(
- `Failed to cleanup api key "${apiKeyObj.attributes.apiKeyId}". Error: ${err.message}`
- );
- }
- }
+ return decryptedApiKey.attributes.apiKeyId;
})
);
- logger.debug(`Total invalidated api keys "${totalInvalidated}"`);
+ if (apiKeyIds.length > 0) {
+ const response = await invalidateAPIKeys({ ids: apiKeyIds }, securityPluginStart);
+ if (response.apiKeysEnabled === true && response.result.error_count > 0) {
+ logger.error(`Failed to invalidate API Keys [ids="${apiKeyIds.join(', ')}"]`);
+ } else {
+ await Promise.all(
+ apiKeysToInvalidate.saved_objects.map(async (apiKeyObj) => {
+ try {
+ await savedObjectsClient.delete('api_key_pending_invalidation', apiKeyObj.id);
+ totalInvalidated++;
+ } catch (err) {
+ logger.error(
+ `Failed to delete invalidated API key "${apiKeyObj.attributes.apiKeyId}". Error: ${err.message}`
+ );
+ }
+ })
+ );
+ }
+ }
+ logger.debug(`Total invalidated API keys "${totalInvalidated}"`);
return totalInvalidated;
}
diff --git a/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/List.test.tsx b/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/List.test.tsx
similarity index 78%
rename from x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/List.test.tsx
rename to x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/List.test.tsx
index 4022caedadaab..e6555ed900a6d 100644
--- a/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/List.test.tsx
+++ b/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/List.test.tsx
@@ -6,11 +6,11 @@
import { mount } from 'enzyme';
import React from 'react';
-import { MockApmPluginContextWrapper } from '../../../../../context/apm_plugin/mock_apm_plugin_context';
-import { MockUrlParamsContextProvider } from '../../../../../context/url_params_context/mock_url_params_context_provider';
-import { mockMoment, toJson } from '../../../../../utils/testHelpers';
-import { ErrorGroupList } from '../index';
-import props from './props.json';
+import { MockApmPluginContextWrapper } from '../../../../context/apm_plugin/mock_apm_plugin_context';
+import { MockUrlParamsContextProvider } from '../../../../context/url_params_context/mock_url_params_context_provider';
+import { mockMoment, toJson } from '../../../../utils/testHelpers';
+import { ErrorGroupList } from './index';
+import props from './__fixtures__/props.json';
import { MemoryRouter } from 'react-router-dom';
jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => {
diff --git a/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/props.json b/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/__fixtures__/props.json
similarity index 100%
rename from x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/props.json
rename to x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/__fixtures__/props.json
diff --git a/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/__snapshots__/List.test.tsx.snap b/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/__snapshots__/List.test.tsx.snap
similarity index 100%
rename from x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/__snapshots__/List.test.tsx.snap
rename to x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/__snapshots__/List.test.tsx.snap
diff --git a/x-pack/plugins/apm/public/components/app/RumDashboard/URLFilter/URLSearch/__tests__/SelectableUrlList.test.tsx b/x-pack/plugins/apm/public/components/app/RumDashboard/URLFilter/URLSearch/SelectableUrlList.test.tsx
similarity index 86%
rename from x-pack/plugins/apm/public/components/app/RumDashboard/URLFilter/URLSearch/__tests__/SelectableUrlList.test.tsx
rename to x-pack/plugins/apm/public/components/app/RumDashboard/URLFilter/URLSearch/SelectableUrlList.test.tsx
index a492938deffab..c469a2c21c34a 100644
--- a/x-pack/plugins/apm/public/components/app/RumDashboard/URLFilter/URLSearch/__tests__/SelectableUrlList.test.tsx
+++ b/x-pack/plugins/apm/public/components/app/RumDashboard/URLFilter/URLSearch/SelectableUrlList.test.tsx
@@ -5,9 +5,9 @@
*/
import React from 'react';
import { createMemoryHistory } from 'history';
-import * as fetcherHook from '../../../../../../hooks/use_fetcher';
-import { SelectableUrlList } from '../SelectableUrlList';
-import { render } from '../../../utils/test_helper';
+import * as fetcherHook from '../../../../../hooks/use_fetcher';
+import { SelectableUrlList } from './SelectableUrlList';
+import { render } from '../../utils/test_helper';
describe('SelectableUrlList', () => {
it('it uses search term value from url', () => {
diff --git a/x-pack/plugins/apm/public/components/app/RumDashboard/UXMetrics/__tests__/FormatToSec.test.ts b/x-pack/plugins/apm/public/components/app/RumDashboard/UXMetrics/FormatToSec.test.ts
similarity index 94%
rename from x-pack/plugins/apm/public/components/app/RumDashboard/UXMetrics/__tests__/FormatToSec.test.ts
rename to x-pack/plugins/apm/public/components/app/RumDashboard/UXMetrics/FormatToSec.test.ts
index 6cdf469d980fa..764d662615031 100644
--- a/x-pack/plugins/apm/public/components/app/RumDashboard/UXMetrics/__tests__/FormatToSec.test.ts
+++ b/x-pack/plugins/apm/public/components/app/RumDashboard/UXMetrics/FormatToSec.test.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { formatToSec } from '../KeyUXMetrics';
+import { formatToSec } from './KeyUXMetrics';
describe('FormatToSec', () => {
test('it returns the expected value', () => {
diff --git a/x-pack/plugins/apm/public/components/app/RumDashboard/UXMetrics/__tests__/KeyUXMetrics.test.tsx b/x-pack/plugins/apm/public/components/app/RumDashboard/UXMetrics/KeyUXMetrics.test.tsx
similarity index 93%
rename from x-pack/plugins/apm/public/components/app/RumDashboard/UXMetrics/__tests__/KeyUXMetrics.test.tsx
rename to x-pack/plugins/apm/public/components/app/RumDashboard/UXMetrics/KeyUXMetrics.test.tsx
index 5d73cbc4cd3c8..804eeaec26655 100644
--- a/x-pack/plugins/apm/public/components/app/RumDashboard/UXMetrics/__tests__/KeyUXMetrics.test.tsx
+++ b/x-pack/plugins/apm/public/components/app/RumDashboard/UXMetrics/KeyUXMetrics.test.tsx
@@ -5,8 +5,8 @@
*/
import React from 'react';
import { render } from '@testing-library/react';
-import * as fetcherHook from '../../../../../hooks/use_fetcher';
-import { KeyUXMetrics } from '../KeyUXMetrics';
+import * as fetcherHook from '../../../../hooks/use_fetcher';
+import { KeyUXMetrics } from './KeyUXMetrics';
describe('KeyUXMetrics', () => {
it('renders metrics with correct formats', () => {
diff --git a/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__tests__/EmbeddedMap.test.tsx b/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/EmbeddedMap.test.tsx
similarity index 79%
rename from x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__tests__/EmbeddedMap.test.tsx
rename to x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/EmbeddedMap.test.tsx
index 388a8824bc73d..125c57f514a59 100644
--- a/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__tests__/EmbeddedMap.test.tsx
+++ b/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/EmbeddedMap.test.tsx
@@ -7,9 +7,9 @@
import { render } from 'enzyme';
import React from 'react';
-import { EmbeddedMap } from '../EmbeddedMap';
-import { KibanaContextProvider } from '../../../../../../../../../src/plugins/kibana_react/public';
-import { embeddablePluginMock } from '../../../../../../../../../src/plugins/embeddable/public/mocks';
+import { EmbeddedMap } from './EmbeddedMap';
+import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public';
+import { embeddablePluginMock } from '../../../../../../../../src/plugins/embeddable/public/mocks';
describe('Embedded Map', () => {
test('it renders', () => {
diff --git a/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__tests__/MapToolTip.test.tsx b/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/MapToolTip.test.tsx
similarity index 93%
rename from x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__tests__/MapToolTip.test.tsx
rename to x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/MapToolTip.test.tsx
index cbaae40b04361..89f20bf24ccba 100644
--- a/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__tests__/MapToolTip.test.tsx
+++ b/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/MapToolTip.test.tsx
@@ -7,7 +7,7 @@
import { render, shallow } from 'enzyme';
import React from 'react';
-import { MapToolTip } from '../MapToolTip';
+import { MapToolTip } from './MapToolTip';
describe('Map Tooltip', () => {
test('it shallow renders', () => {
diff --git a/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__tests__/__mocks__/regions_layer.mock.ts b/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__mocks__/regions_layer.mock.ts
similarity index 100%
rename from x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__tests__/__mocks__/regions_layer.mock.ts
rename to x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__mocks__/regions_layer.mock.ts
diff --git a/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__tests__/__snapshots__/EmbeddedMap.test.tsx.snap b/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__snapshots__/EmbeddedMap.test.tsx.snap
similarity index 100%
rename from x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__tests__/__snapshots__/EmbeddedMap.test.tsx.snap
rename to x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__snapshots__/EmbeddedMap.test.tsx.snap
diff --git a/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__tests__/__snapshots__/MapToolTip.test.tsx.snap b/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__snapshots__/MapToolTip.test.tsx.snap
similarity index 100%
rename from x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__tests__/__snapshots__/MapToolTip.test.tsx.snap
rename to x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__snapshots__/MapToolTip.test.tsx.snap
diff --git a/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__tests__/useLayerList.test.ts b/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/useLayerList.test.ts
similarity index 92%
rename from x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__tests__/useLayerList.test.ts
rename to x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/useLayerList.test.ts
index 872553452b263..a63ab11263e5f 100644
--- a/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__tests__/useLayerList.test.ts
+++ b/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/useLayerList.test.ts
@@ -6,7 +6,7 @@
import { renderHook } from '@testing-library/react-hooks';
import { mockLayerList } from './__mocks__/regions_layer.mock';
-import { useLayerList } from '../useLayerList';
+import { useLayerList } from './useLayerList';
describe('useLayerList', () => {
test('it returns the region layer', () => {
diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Distribution/__test__/distribution.test.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/Distribution/distribution.test.ts
similarity index 96%
rename from x-pack/plugins/apm/public/components/app/TransactionDetails/Distribution/__test__/distribution.test.ts
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/Distribution/distribution.test.ts
index 1586e1f4903a2..0453b113f41de 100644
--- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Distribution/__test__/distribution.test.ts
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Distribution/distribution.test.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { getFormattedBuckets } from '../index';
+import { getFormattedBuckets } from './index';
describe('Distribution', () => {
it('getFormattedBuckets', () => {
diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/__test__/get_agent_marks.test.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_agent_marks.test.ts
similarity index 90%
rename from x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/__test__/get_agent_marks.test.ts
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_agent_marks.test.ts
index 72533cf2930d2..7666db35d43cf 100644
--- a/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/__test__/get_agent_marks.test.ts
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_agent_marks.test.ts
@@ -4,8 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { Transaction } from '../../../../../../../../typings/es_schemas/ui/transaction';
-import { getAgentMarks } from '../get_agent_marks';
+import { Transaction } from '../../../../../../../typings/es_schemas/ui/transaction';
+import { getAgentMarks } from './get_agent_marks';
describe('getAgentMarks', () => {
it('should sort the marks by time', () => {
diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/__test__/get_error_marks.test.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_error_marks.test.ts
similarity index 94%
rename from x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/__test__/get_error_marks.test.ts
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_error_marks.test.ts
index abfecc3f70d24..0eb7a5b89aa3a 100644
--- a/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/__test__/get_error_marks.test.ts
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_error_marks.test.ts
@@ -4,8 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { IWaterfallError } from '../../Waterfall/waterfall_helpers/waterfall_helpers';
-import { getErrorMarks } from '../get_error_marks';
+import { IWaterfallError } from '../Waterfall/waterfall_helpers/waterfall_helpers';
+import { getErrorMarks } from './get_error_marks';
describe('getErrorMarks', () => {
describe('returns empty array', () => {
diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/FlyoutTopLevelProperties.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/FlyoutTopLevelProperties.tsx
index b0ef28fbb7b0d..0568930f8157d 100644
--- a/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/FlyoutTopLevelProperties.tsx
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/FlyoutTopLevelProperties.tsx
@@ -13,7 +13,7 @@ import {
import { Transaction } from '../../../../../../../typings/es_schemas/ui/transaction';
import { TransactionDetailLink } from '../../../../../shared/Links/apm/TransactionDetailLink';
import { StickyProperties } from '../../../../../shared/StickyProperties';
-import { ServiceOrTransactionsOverviewLink } from '../../../../../shared/Links/apm/service_transactions_overview';
+import { ServiceOrTransactionsOverviewLink } from '../../../../../shared/Links/apm/service_transactions_overview_link';
interface Props {
transaction?: Transaction;
diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/StickySpanProperties.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/StickySpanProperties.tsx
index ca5b4938ff42e..6bcb9a764a352 100644
--- a/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/StickySpanProperties.tsx
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/StickySpanProperties.tsx
@@ -15,7 +15,7 @@ import {
import { NOT_AVAILABLE_LABEL } from '../../../../../../../../common/i18n';
import { Span } from '../../../../../../../../typings/es_schemas/ui/span';
import { StickyProperties } from '../../../../../../shared/StickyProperties';
-import { ServiceOrTransactionsOverviewLink } from '../../../../../../shared/Links/apm/service_transactions_overview';
+import { ServiceOrTransactionsOverviewLink } from '../../../../../../shared/Links/apm/service_transactions_overview_link';
import { TransactionDetailLink } from '../../../../../../shared/Links/apm/TransactionDetailLink';
interface Props {
diff --git a/x-pack/plugins/apm/public/components/app/service_details/service_detail_tabs.tsx b/x-pack/plugins/apm/public/components/app/service_details/service_detail_tabs.tsx
index 961320baa6a4e..958d25a88434c 100644
--- a/x-pack/plugins/apm/public/components/app/service_details/service_detail_tabs.tsx
+++ b/x-pack/plugins/apm/public/components/app/service_details/service_detail_tabs.tsx
@@ -10,20 +10,20 @@ import React, { ReactNode } from 'react';
import { isJavaAgentName, isRumAgentName } from '../../../../common/agent_name';
import { enableServiceOverview } from '../../../../common/ui_settings_keys';
import { useApmPluginContext } from '../../../context/apm_plugin/use_apm_plugin_context';
+import { useApmServiceContext } from '../../../context/apm_service/use_apm_service_context';
import { useErrorOverviewHref } from '../../shared/Links/apm/ErrorOverviewLink';
import { useMetricOverviewHref } from '../../shared/Links/apm/MetricOverviewLink';
import { useServiceMapHref } from '../../shared/Links/apm/ServiceMapLink';
import { useServiceNodeOverviewHref } from '../../shared/Links/apm/ServiceNodeOverviewLink';
import { useServiceOverviewHref } from '../../shared/Links/apm/service_overview_link';
-import { useServiceOrTransactionsOverviewHref } from '../../shared/Links/apm/service_transactions_overview';
+import { useTransactionsOverviewHref } from '../../shared/Links/apm/transaction_overview_link';
import { MainTabs } from '../../shared/main_tabs';
import { ErrorGroupOverview } from '../ErrorGroupOverview';
import { ServiceMap } from '../ServiceMap';
-import { ServiceMetrics } from '../service_metrics';
import { ServiceNodeOverview } from '../ServiceNodeOverview';
+import { ServiceMetrics } from '../service_metrics';
import { ServiceOverview } from '../service_overview';
import { TransactionOverview } from '../transaction_overview';
-import { useApmServiceContext } from '../../../context/apm_service/use_apm_service_context';
interface Tab {
key: string;
@@ -60,7 +60,7 @@ export function ServiceDetailTabs({ serviceName, tab }: Props) {
const transactionsTab = {
key: 'transactions',
- href: useServiceOrTransactionsOverviewHref(serviceName),
+ href: useTransactionsOverviewHref(serviceName),
text: i18n.translate('xpack.apm.serviceDetails.transactionsTabLabel', {
defaultMessage: 'Transactions',
}),
diff --git a/x-pack/plugins/apm/public/components/app/service_inventory/ServiceList/index.tsx b/x-pack/plugins/apm/public/components/app/service_inventory/ServiceList/index.tsx
index 8ae286b2404ae..1f8ff6fdcaf19 100644
--- a/x-pack/plugins/apm/public/components/app/service_inventory/ServiceList/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/service_inventory/ServiceList/index.tsx
@@ -27,7 +27,7 @@ import { NOT_AVAILABLE_LABEL } from '../../../../../common/i18n';
import { fontSizes, px, truncate, unit } from '../../../../style/variables';
import { ManagedTable, ITableColumn } from '../../../shared/ManagedTable';
import { EnvironmentBadge } from '../../../shared/EnvironmentBadge';
-import { ServiceOrTransactionsOverviewLink } from '../../../shared/Links/apm/service_transactions_overview';
+import { ServiceOrTransactionsOverviewLink } from '../../../shared/Links/apm/service_transactions_overview_link';
import { AgentIcon } from '../../../shared/AgentIcon';
import { HealthBadge } from './HealthBadge';
import { ServiceListMetric } from './ServiceListMetric';
diff --git a/x-pack/plugins/apm/public/components/app/service_inventory/service_inventory.test.tsx b/x-pack/plugins/apm/public/components/app/service_inventory/service_inventory.test.tsx
index 6bb1ea2919c16..e501dd3bb7a56 100644
--- a/x-pack/plugins/apm/public/components/app/service_inventory/service_inventory.test.tsx
+++ b/x-pack/plugins/apm/public/components/app/service_inventory/service_inventory.test.tsx
@@ -21,7 +21,7 @@ import {
import { FETCH_STATUS } from '../../../hooks/use_fetcher';
import * as useLocalUIFilters from '../../../hooks/useLocalUIFilters';
import * as useDynamicIndexPatternHooks from '../../../hooks/use_dynamic_index_pattern';
-import { SessionStorageMock } from '../../../services/__test__/SessionStorageMock';
+import { SessionStorageMock } from '../../../services/__mocks__/SessionStorageMock';
import { MockUrlParamsContextProvider } from '../../../context/url_params_context/mock_url_params_context_provider';
import * as hook from './use_anomaly_detection_jobs_fetcher';
diff --git a/x-pack/plugins/apm/public/components/app/service_overview/service_overview_transactions_table/index.tsx b/x-pack/plugins/apm/public/components/app/service_overview/service_overview_transactions_table/index.tsx
index 4b262f1f51319..7c90ea68d6f84 100644
--- a/x-pack/plugins/apm/public/components/app/service_overview/service_overview_transactions_table/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/service_overview/service_overview_transactions_table/index.tsx
@@ -32,7 +32,7 @@ import { px, unit } from '../../../../style/variables';
import { SparkPlot } from '../../../shared/charts/spark_plot';
import { ImpactBar } from '../../../shared/ImpactBar';
import { TransactionDetailLink } from '../../../shared/Links/apm/TransactionDetailLink';
-import { TransactionOverviewLink } from '../../../shared/Links/apm/transaction_overview_ink';
+import { TransactionOverviewLink } from '../../../shared/Links/apm/transaction_overview_link';
import { TableFetchWrapper } from '../../../shared/table_fetch_wrapper';
import { TruncateWithTooltip } from '../../../shared/truncate_with_tooltip';
import { ServiceOverviewTableContainer } from '../service_overview_table_container';
diff --git a/x-pack/plugins/apm/public/components/shared/ImpactBar/__test__/ImpactBar.test.js b/x-pack/plugins/apm/public/components/shared/ImpactBar/ImpactBar.test.js
similarity index 95%
rename from x-pack/plugins/apm/public/components/shared/ImpactBar/__test__/ImpactBar.test.js
rename to x-pack/plugins/apm/public/components/shared/ImpactBar/ImpactBar.test.js
index d4b3f223f726f..4e94ea85c120b 100644
--- a/x-pack/plugins/apm/public/components/shared/ImpactBar/__test__/ImpactBar.test.js
+++ b/x-pack/plugins/apm/public/components/shared/ImpactBar/ImpactBar.test.js
@@ -6,7 +6,7 @@
import { shallow } from 'enzyme';
import React from 'react';
-import { ImpactBar } from '..';
+import { ImpactBar } from '.';
describe('ImpactBar component', () => {
it('should render with default values', () => {
diff --git a/x-pack/plugins/apm/public/components/shared/ImpactBar/__test__/__snapshots__/ImpactBar.test.js.snap b/x-pack/plugins/apm/public/components/shared/ImpactBar/__snapshots__/ImpactBar.test.js.snap
similarity index 100%
rename from x-pack/plugins/apm/public/components/shared/ImpactBar/__test__/__snapshots__/ImpactBar.test.js.snap
rename to x-pack/plugins/apm/public/components/shared/ImpactBar/__snapshots__/ImpactBar.test.js.snap
diff --git a/x-pack/plugins/apm/public/components/shared/KeyValueTable/__test__/KeyValueTable.test.tsx b/x-pack/plugins/apm/public/components/shared/KeyValueTable/KeyValueTable.test.tsx
similarity index 94%
rename from x-pack/plugins/apm/public/components/shared/KeyValueTable/__test__/KeyValueTable.test.tsx
rename to x-pack/plugins/apm/public/components/shared/KeyValueTable/KeyValueTable.test.tsx
index 5a9e8809ea734..a08ade8e559d0 100644
--- a/x-pack/plugins/apm/public/components/shared/KeyValueTable/__test__/KeyValueTable.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/KeyValueTable/KeyValueTable.test.tsx
@@ -5,9 +5,9 @@
*/
import React from 'react';
-import { KeyValueTable } from '..';
+import { KeyValueTable } from '.';
import { render } from '@testing-library/react';
-import { renderWithTheme } from '../../../../utils/testHelpers';
+import { renderWithTheme } from '../../../utils/testHelpers';
function getKeys(output: ReturnType) {
const keys = output.getAllByTestId('dot-key');
diff --git a/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverErrorButton.test.tsx b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverErrorButton.test.tsx
similarity index 92%
rename from x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverErrorButton.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverErrorButton.test.tsx
index f71c8b71aa2ee..3a41c19c53f6d 100644
--- a/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverErrorButton.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverErrorButton.test.tsx
@@ -6,8 +6,8 @@
import { shallow, ShallowWrapper } from 'enzyme';
import React from 'react';
-import { APMError } from '../../../../../../typings/es_schemas/ui/apm_error';
-import { DiscoverErrorLink } from '../DiscoverErrorLink';
+import { APMError } from '../../../../../typings/es_schemas/ui/apm_error';
+import { DiscoverErrorLink } from './DiscoverErrorLink';
describe('DiscoverErrorLink without kuery', () => {
let wrapper: ShallowWrapper;
diff --git a/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverErrorLink.test.tsx b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverErrorLink.test.tsx
similarity index 92%
rename from x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverErrorLink.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverErrorLink.test.tsx
index f71c8b71aa2ee..3a41c19c53f6d 100644
--- a/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverErrorLink.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverErrorLink.test.tsx
@@ -6,8 +6,8 @@
import { shallow, ShallowWrapper } from 'enzyme';
import React from 'react';
-import { APMError } from '../../../../../../typings/es_schemas/ui/apm_error';
-import { DiscoverErrorLink } from '../DiscoverErrorLink';
+import { APMError } from '../../../../../typings/es_schemas/ui/apm_error';
+import { DiscoverErrorLink } from './DiscoverErrorLink';
describe('DiscoverErrorLink without kuery', () => {
let wrapper: ShallowWrapper;
diff --git a/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverLinks.integration.test.tsx b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverLinks.integration.test.tsx
similarity index 87%
rename from x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverLinks.integration.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverLinks.integration.test.tsx
index ca02abc395992..e77d4d7185273 100644
--- a/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverLinks.integration.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverLinks.integration.test.tsx
@@ -6,13 +6,13 @@
import { Location } from 'history';
import React from 'react';
-import { APMError } from '../../../../../../typings/es_schemas/ui/apm_error';
-import { Span } from '../../../../../../typings/es_schemas/ui/span';
-import { Transaction } from '../../../../../../typings/es_schemas/ui/transaction';
-import { getRenderedHref } from '../../../../../utils/testHelpers';
-import { DiscoverErrorLink } from '../DiscoverErrorLink';
-import { DiscoverSpanLink } from '../DiscoverSpanLink';
-import { DiscoverTransactionLink } from '../DiscoverTransactionLink';
+import { APMError } from '../../../../../typings/es_schemas/ui/apm_error';
+import { Span } from '../../../../../typings/es_schemas/ui/span';
+import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
+import { getRenderedHref } from '../../../../utils/testHelpers';
+import { DiscoverErrorLink } from './DiscoverErrorLink';
+import { DiscoverSpanLink } from './DiscoverSpanLink';
+import { DiscoverTransactionLink } from './DiscoverTransactionLink';
describe('DiscoverLinks', () => {
it('produces the correct URL for a transaction', async () => {
diff --git a/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverTransactionLink.test.tsx b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverTransactionLink.test.tsx
similarity index 84%
rename from x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverTransactionLink.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverTransactionLink.test.tsx
index 48d8bb2b41644..0ded3fb6619e3 100644
--- a/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverTransactionLink.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverTransactionLink.test.tsx
@@ -4,10 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { Transaction } from '../../../../../../typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
// @ts-expect-error
import configureStore from '../../../../../store/config/configureStore';
-import { getDiscoverQuery } from '../DiscoverTransactionLink';
+import { getDiscoverQuery } from './DiscoverTransactionLink';
function getMockTransaction() {
return {
diff --git a/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/mock_transaction.json b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__fixtures__/mock_transaction.json
similarity index 100%
rename from x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/mock_transaction.json
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__fixtures__/mock_transaction.json
diff --git a/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverErrorButton.test.tsx.snap b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__snapshots__/DiscoverErrorButton.test.tsx.snap
similarity index 100%
rename from x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverErrorButton.test.tsx.snap
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__snapshots__/DiscoverErrorButton.test.tsx.snap
diff --git a/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverErrorLink.test.tsx.snap b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__snapshots__/DiscoverErrorLink.test.tsx.snap
similarity index 100%
rename from x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverErrorLink.test.tsx.snap
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__snapshots__/DiscoverErrorLink.test.tsx.snap
diff --git a/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverTransactionLink.test.tsx.snap b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__snapshots__/DiscoverTransactionLink.test.tsx.snap
similarity index 100%
rename from x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverTransactionLink.test.tsx.snap
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__snapshots__/DiscoverTransactionLink.test.tsx.snap
diff --git a/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/discover_transaction_button.test.tsx.snap b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__snapshots__/discover_transaction_button.test.tsx.snap
similarity index 100%
rename from x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/discover_transaction_button.test.tsx.snap
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__snapshots__/discover_transaction_button.test.tsx.snap
diff --git a/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/discover_transaction_button.test.tsx b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/discover_transaction_button.test.tsx
similarity index 82%
rename from x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/discover_transaction_button.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/discover_transaction_button.test.tsx
index 4a68a5c0b4904..75fe18913618d 100644
--- a/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/discover_transaction_button.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/discover_transaction_button.test.tsx
@@ -6,12 +6,12 @@
import { shallow } from 'enzyme';
import React from 'react';
-import { Transaction } from '../../../../../../typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
import {
DiscoverTransactionLink,
getDiscoverQuery,
-} from '../DiscoverTransactionLink';
-import mockTransaction from './mock_transaction.json';
+} from './DiscoverTransactionLink';
+import mockTransaction from './__fixtures__/mock_transaction.json';
describe('DiscoverTransactionLink component', () => {
it('should render with data', () => {
diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/MetricOverviewLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/MetricOverviewLink.tsx
index de7130e878608..8031b6088d420 100644
--- a/x-pack/plugins/apm/public/components/shared/Links/apm/MetricOverviewLink.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/apm/MetricOverviewLink.tsx
@@ -3,11 +3,10 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
+import { EuiLink } from '@elastic/eui';
import React from 'react';
-import { pickKeys } from '../../../../../common/utils/pick_keys';
-import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { APMQueryParams } from '../url_helpers';
-import { APMLink, APMLinkExtendProps, useAPMHref } from './APMLink';
+import { APMLinkExtendProps, useAPMHref } from './APMLink';
const persistedFilters: Array = [
'host',
@@ -25,13 +24,6 @@ interface Props extends APMLinkExtendProps {
}
export function MetricOverviewLink({ serviceName, ...rest }: Props) {
- const { urlParams } = useUrlParams();
-
- return (
-
- );
+ const href = useMetricOverviewHref(serviceName);
+ return ;
}
diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceMapLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceMapLink.tsx
index ae5dc86608a90..670b7137219e1 100644
--- a/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceMapLink.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceMapLink.tsx
@@ -3,15 +3,15 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
+import { EuiLink } from '@elastic/eui';
import React from 'react';
-import { APMLink, APMLinkExtendProps, useAPMHref } from './APMLink';
-
-function pathFor(serviceName?: string) {
- return serviceName ? `/services/${serviceName}/service-map` : '/service-map';
-}
+import { APMLinkExtendProps, useAPMHref } from './APMLink';
export function useServiceMapHref(serviceName?: string) {
- return useAPMHref(pathFor(serviceName));
+ const pathFor = serviceName
+ ? `/services/${serviceName}/service-map`
+ : '/service-map';
+ return useAPMHref(pathFor);
}
interface ServiceMapLinkProps extends APMLinkExtendProps {
@@ -19,6 +19,6 @@ interface ServiceMapLinkProps extends APMLinkExtendProps {
}
export function ServiceMapLink({ serviceName, ...rest }: ServiceMapLinkProps) {
- const path = pathFor(serviceName);
- return ;
+ const href = useServiceMapHref(serviceName);
+ return ;
}
diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceNodeOverviewLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceNodeOverviewLink.tsx
index c107b436717c2..279c038d95a80 100644
--- a/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceNodeOverviewLink.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceNodeOverviewLink.tsx
@@ -3,11 +3,8 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
-import React from 'react';
-import { APMLink, APMLinkExtendProps, useAPMHref } from './APMLink';
-import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
-import { pickKeys } from '../../../../../common/utils/pick_keys';
import { APMQueryParams } from '../url_helpers';
+import { useAPMHref } from './APMLink';
const persistedFilters: Array = [
'host',
@@ -19,19 +16,3 @@ const persistedFilters: Array = [
export function useServiceNodeOverviewHref(serviceName: string) {
return useAPMHref(`/services/${serviceName}/nodes`, persistedFilters);
}
-
-interface Props extends APMLinkExtendProps {
- serviceName: string;
-}
-
-export function ServiceNodeOverviewLink({ serviceName, ...rest }: Props) {
- const { urlParams } = useUrlParams();
-
- return (
-
- );
-}
diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/TraceOverviewLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/TraceOverviewLink.tsx
index caa1498e6df87..3cb0009a12c94 100644
--- a/x-pack/plugins/apm/public/components/shared/Links/apm/TraceOverviewLink.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/apm/TraceOverviewLink.tsx
@@ -9,11 +9,8 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
-import React from 'react';
-import { pickKeys } from '../../../../../common/utils/pick_keys';
-import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { APMQueryParams } from '../url_helpers';
-import { APMLink, APMLinkExtendProps, useAPMHref } from './APMLink';
+import { useAPMHref } from './APMLink';
const persistedFilters: Array = [
'transactionResult',
@@ -25,15 +22,3 @@ const persistedFilters: Array = [
export function useTraceOverviewHref() {
return useAPMHref('/traces', persistedFilters);
}
-
-export function TraceOverviewLink(props: APMLinkExtendProps) {
- const { urlParams } = useUrlParams();
-
- return (
-
- );
-}
diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/service_inventory_link.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/service_inventory_link.tsx
index 318a1590be77c..c3b80cbeb701b 100644
--- a/x-pack/plugins/apm/public/components/shared/Links/apm/service_inventory_link.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/apm/service_inventory_link.tsx
@@ -9,22 +9,11 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
-import React from 'react';
-import { pickKeys } from '../../../../../common/utils/pick_keys';
-import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { APMQueryParams } from '../url_helpers';
-import { APMLink, APMLinkExtendProps, useAPMHref } from './APMLink';
+import { useAPMHref } from './APMLink';
const persistedFilters: Array = ['host', 'agentName'];
export function useServiceInventoryHref() {
return useAPMHref('/services', persistedFilters);
}
-
-export function ServiceInventoryLink(props: APMLinkExtendProps) {
- const { urlParams } = useUrlParams();
-
- const query = pickKeys(urlParams as APMQueryParams, ...persistedFilters);
-
- return ;
-}
diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/service_overview_link.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/service_overview_link.tsx
index 1f74f1f9890cf..ba53243a6bc75 100644
--- a/x-pack/plugins/apm/public/components/shared/Links/apm/service_overview_link.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/apm/service_overview_link.tsx
@@ -8,11 +8,10 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
+import { EuiLink } from '@elastic/eui';
import React from 'react';
-import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
-import { pickKeys } from '../../../../../common/utils/pick_keys';
import { APMQueryParams } from '../url_helpers';
-import { APMLink, APMLinkExtendProps, useAPMHref } from './APMLink';
+import { APMLinkExtendProps, useAPMHref } from './APMLink';
interface ServiceOverviewLinkProps extends APMLinkExtendProps {
serviceName: string;
@@ -30,13 +29,6 @@ export function ServiceOverviewLink({
serviceName,
...rest
}: ServiceOverviewLinkProps) {
- const { urlParams } = useUrlParams();
-
- return (
-
- );
+ const href = useServiceOverviewHref(serviceName);
+ return ;
}
diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/service_transactions_overview_link.test.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/service_transactions_overview_link.test.tsx
new file mode 100644
index 0000000000000..4c826ecf37682
--- /dev/null
+++ b/x-pack/plugins/apm/public/components/shared/Links/apm/service_transactions_overview_link.test.tsx
@@ -0,0 +1,87 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+import { render } from '@testing-library/react';
+import { renderHook } from '@testing-library/react-hooks';
+import { createMemoryHistory } from 'history';
+import React from 'react';
+import { Router } from 'react-router-dom';
+import { MockApmPluginContextWrapper } from '../../../../context/apm_plugin/mock_apm_plugin_context';
+import { MockUrlParamsContextProvider } from '../../../../context/url_params_context/mock_url_params_context_provider';
+import {
+ ServiceOrTransactionsOverviewLink,
+ useServiceOrTransactionsOverviewHref,
+} from './service_transactions_overview_link';
+
+const history = createMemoryHistory();
+
+function wrapper({ queryParams }: { queryParams?: Record }) {
+ return ({ children }: { children: React.ReactElement }) => (
+
+
+
+ {children}
+
+
+
+ );
+}
+
+describe('Service or transactions overview link', () => {
+ describe('useServiceOrTransactionsOverviewHref', () => {
+ it('returns service link', () => {
+ const { result } = renderHook(
+ () => useServiceOrTransactionsOverviewHref('foo'),
+ { wrapper: wrapper({}) }
+ );
+ expect(result.current).toEqual('/basepath/app/apm/services/foo');
+ });
+
+ it('returns service link with persisted query items', () => {
+ const { result } = renderHook(
+ () => useServiceOrTransactionsOverviewHref('foo'),
+ { wrapper: wrapper({ queryParams: { latencyAggregationType: 'avg' } }) }
+ );
+ expect(result.current).toEqual(
+ '/basepath/app/apm/services/foo?latencyAggregationType=avg'
+ );
+ });
+ });
+ describe('ServiceOrTransactionsOverviewLink', () => {
+ function getHref(container: HTMLElement) {
+ return ((container as HTMLDivElement).children[0] as HTMLAnchorElement)
+ .href;
+ }
+ it('returns service link', () => {
+ const Component = wrapper({});
+ const { container } = render(
+
+
+ Service name
+
+
+ );
+ expect(getHref(container)).toEqual(
+ 'http://localhost/basepath/app/apm/services/foo'
+ );
+ });
+
+ it('returns service link with persisted query items', () => {
+ const Component = wrapper({
+ queryParams: { latencyAggregationType: 'avg' },
+ });
+ const { container } = render(
+
+
+ Service name
+
+
+ );
+ expect(getHref(container)).toEqual(
+ 'http://localhost/basepath/app/apm/services/foo?latencyAggregationType=avg'
+ );
+ });
+ });
+});
diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/service_transactions_overview.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/service_transactions_overview_link.tsx
similarity index 59%
rename from x-pack/plugins/apm/public/components/shared/Links/apm/service_transactions_overview.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/apm/service_transactions_overview_link.tsx
index 24a78e5d64749..8b96ba8ab233a 100644
--- a/x-pack/plugins/apm/public/components/shared/Links/apm/service_transactions_overview.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/apm/service_transactions_overview_link.tsx
@@ -3,11 +3,10 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
+import { EuiLink } from '@elastic/eui';
import React from 'react';
-import { APMLink, APMLinkExtendProps, useAPMHref } from './APMLink';
-import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
-import { pickKeys } from '../../../../../common/utils/pick_keys';
import { APMQueryParams } from '../url_helpers';
+import { APMLinkExtendProps, useAPMHref } from './APMLink';
const persistedFilters: Array = [
'transactionResult',
@@ -19,7 +18,7 @@ const persistedFilters: Array = [
];
export function useServiceOrTransactionsOverviewHref(serviceName: string) {
- return useAPMHref(`/services/${serviceName}/transactions`, persistedFilters);
+ return useAPMHref(`/services/${serviceName}`, persistedFilters);
}
interface Props extends APMLinkExtendProps {
@@ -30,13 +29,6 @@ export function ServiceOrTransactionsOverviewLink({
serviceName,
...rest
}: Props) {
- const { urlParams } = useUrlParams();
-
- return (
-
- );
+ const href = useServiceOrTransactionsOverviewHref(serviceName);
+ return ;
}
diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/transaction_overview_link.test.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/transaction_overview_link.test.tsx
new file mode 100644
index 0000000000000..3ab6feaf5ae12
--- /dev/null
+++ b/x-pack/plugins/apm/public/components/shared/Links/apm/transaction_overview_link.test.tsx
@@ -0,0 +1,87 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+import { render } from '@testing-library/react';
+import { renderHook } from '@testing-library/react-hooks';
+import { createMemoryHistory } from 'history';
+import React from 'react';
+import { Router } from 'react-router-dom';
+import { MockApmPluginContextWrapper } from '../../../../context/apm_plugin/mock_apm_plugin_context';
+import { MockUrlParamsContextProvider } from '../../../../context/url_params_context/mock_url_params_context_provider';
+import {
+ TransactionOverviewLink,
+ useTransactionsOverviewHref,
+} from './transaction_overview_link';
+
+const history = createMemoryHistory();
+
+function wrapper({ queryParams }: { queryParams?: Record }) {
+ return ({ children }: { children: React.ReactElement }) => (
+
+
+
+ {children}
+
+
+
+ );
+}
+
+describe('Transactions overview link', () => {
+ describe('useTransactionsOverviewHref', () => {
+ it('returns transaction link', () => {
+ const { result } = renderHook(() => useTransactionsOverviewHref('foo'), {
+ wrapper: wrapper({}),
+ });
+ expect(result.current).toEqual(
+ '/basepath/app/apm/services/foo/transactions'
+ );
+ });
+
+ it('returns transaction link with persisted query items', () => {
+ const { result } = renderHook(() => useTransactionsOverviewHref('foo'), {
+ wrapper: wrapper({ queryParams: { latencyAggregationType: 'avg' } }),
+ });
+ expect(result.current).toEqual(
+ '/basepath/app/apm/services/foo/transactions?latencyAggregationType=avg'
+ );
+ });
+ });
+ describe('TransactionOverviewLink', () => {
+ function getHref(container: HTMLElement) {
+ return ((container as HTMLDivElement).children[0] as HTMLAnchorElement)
+ .href;
+ }
+ it('returns transaction link', () => {
+ const Component = wrapper({});
+ const { container } = render(
+
+
+ Service name
+
+
+ );
+ expect(getHref(container)).toEqual(
+ 'http://localhost/basepath/app/apm/services/foo/transactions'
+ );
+ });
+
+ it('returns transaction link with persisted query items', () => {
+ const Component = wrapper({
+ queryParams: { latencyAggregationType: 'avg' },
+ });
+ const { container } = render(
+
+
+ Service name
+
+
+ );
+ expect(getHref(container)).toEqual(
+ 'http://localhost/basepath/app/apm/services/foo/transactions?latencyAggregationType=avg'
+ );
+ });
+ });
+});
diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/transaction_overview_ink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/transaction_overview_link.tsx
similarity index 56%
rename from x-pack/plugins/apm/public/components/shared/Links/apm/transaction_overview_ink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/apm/transaction_overview_link.tsx
index d2978b3c02d53..cd6d70b2e2e6d 100644
--- a/x-pack/plugins/apm/public/components/shared/Links/apm/transaction_overview_ink.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/apm/transaction_overview_link.tsx
@@ -4,11 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/
+import { EuiLink } from '@elastic/eui';
import React from 'react';
-import { pickKeys } from '../../../../../common/utils/pick_keys';
-import { APMLink, APMLinkExtendProps } from './APMLink';
-import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { APMQueryParams } from '../url_helpers';
+import { APMLinkExtendProps, useAPMHref } from './APMLink';
interface Props extends APMLinkExtendProps {
serviceName: string;
@@ -18,14 +17,11 @@ const persistedFilters: Array = [
'latencyAggregationType',
];
-export function TransactionOverviewLink({ serviceName, ...rest }: Props) {
- const { urlParams } = useUrlParams();
+export function useTransactionsOverviewHref(serviceName: string) {
+ return useAPMHref(`/services/${serviceName}/transactions`, persistedFilters);
+}
- return (
-
- );
+export function TransactionOverviewLink({ serviceName, ...rest }: Props) {
+ const href = useTransactionsOverviewHref(serviceName);
+ return ;
}
diff --git a/x-pack/plugins/apm/public/components/shared/ManagedTable/__test__/ManagedTable.test.js b/x-pack/plugins/apm/public/components/shared/ManagedTable/ManagedTable.test.js
similarity index 96%
rename from x-pack/plugins/apm/public/components/shared/ManagedTable/__test__/ManagedTable.test.js
rename to x-pack/plugins/apm/public/components/shared/ManagedTable/ManagedTable.test.js
index 38f260b04e252..88e1c57e62354 100644
--- a/x-pack/plugins/apm/public/components/shared/ManagedTable/__test__/ManagedTable.test.js
+++ b/x-pack/plugins/apm/public/components/shared/ManagedTable/ManagedTable.test.js
@@ -6,7 +6,7 @@
import { shallow } from 'enzyme';
import React from 'react';
-import { UnoptimizedManagedTable } from '..';
+import { UnoptimizedManagedTable } from '.';
describe('ManagedTable component', () => {
let people;
diff --git a/x-pack/plugins/apm/public/components/shared/ManagedTable/__test__/__snapshots__/ManagedTable.test.js.snap b/x-pack/plugins/apm/public/components/shared/ManagedTable/__snapshots__/ManagedTable.test.js.snap
similarity index 100%
rename from x-pack/plugins/apm/public/components/shared/ManagedTable/__test__/__snapshots__/ManagedTable.test.js.snap
rename to x-pack/plugins/apm/public/components/shared/ManagedTable/__snapshots__/ManagedTable.test.js.snap
diff --git a/x-pack/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/__test__/ErrorMetadata.test.tsx b/x-pack/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/ErrorMetadata.test.tsx
similarity index 92%
rename from x-pack/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/__test__/ErrorMetadata.test.tsx
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/ErrorMetadata.test.tsx
index 8f44d98cecdf7..8a50bc2cde520 100644
--- a/x-pack/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/__test__/ErrorMetadata.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/ErrorMetadata.test.tsx
@@ -7,13 +7,13 @@
import { render } from '@testing-library/react';
import React, { ReactNode } from 'react';
import { MemoryRouter } from 'react-router-dom';
-import { ErrorMetadata } from '..';
-import { APMError } from '../../../../../../typings/es_schemas/ui/apm_error';
-import { MockApmPluginContextWrapper } from '../../../../../context/apm_plugin/mock_apm_plugin_context';
+import { ErrorMetadata } from '.';
+import { APMError } from '../../../../../typings/es_schemas/ui/apm_error';
+import { MockApmPluginContextWrapper } from '../../../../context/apm_plugin/mock_apm_plugin_context';
import {
expectTextsInDocument,
expectTextsNotInDocument,
-} from '../../../../../utils/testHelpers';
+} from '../../../../utils/testHelpers';
function Wrapper({ children }: { children?: ReactNode }) {
return (
diff --git a/x-pack/plugins/apm/public/components/shared/MetadataTable/__test__/MetadataTable.test.tsx b/x-pack/plugins/apm/public/components/shared/MetadataTable/MetadataTable.test.tsx
similarity index 87%
rename from x-pack/plugins/apm/public/components/shared/MetadataTable/__test__/MetadataTable.test.tsx
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/MetadataTable.test.tsx
index 8a4cd588c8260..9bd3278033f92 100644
--- a/x-pack/plugins/apm/public/components/shared/MetadataTable/__test__/MetadataTable.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/MetadataTable/MetadataTable.test.tsx
@@ -7,10 +7,10 @@
import { render } from '@testing-library/react';
import React, { ReactNode } from 'react';
import { MemoryRouter } from 'react-router-dom';
-import { MetadataTable } from '..';
-import { MockApmPluginContextWrapper } from '../../../../context/apm_plugin/mock_apm_plugin_context';
-import { expectTextsInDocument } from '../../../../utils/testHelpers';
-import { SectionsWithRows } from '../helper';
+import { MetadataTable } from '.';
+import { MockApmPluginContextWrapper } from '../../../context/apm_plugin/mock_apm_plugin_context';
+import { expectTextsInDocument } from '../../../utils/testHelpers';
+import { SectionsWithRows } from './helper';
function Wrapper({ children }: { children?: ReactNode }) {
return (
diff --git a/x-pack/plugins/apm/public/components/shared/MetadataTable/__test__/Section.test.tsx b/x-pack/plugins/apm/public/components/shared/MetadataTable/Section.test.tsx
similarity index 83%
rename from x-pack/plugins/apm/public/components/shared/MetadataTable/__test__/Section.test.tsx
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/Section.test.tsx
index 7a150f81580d8..3dd19778430b7 100644
--- a/x-pack/plugins/apm/public/components/shared/MetadataTable/__test__/Section.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/MetadataTable/Section.test.tsx
@@ -5,8 +5,8 @@
*/
import React from 'react';
import { render } from '@testing-library/react';
-import { Section } from '../Section';
-import { expectTextsInDocument } from '../../../../utils/testHelpers';
+import { Section } from './Section';
+import { expectTextsInDocument } from '../../../utils/testHelpers';
describe('Section', () => {
it('shows "empty state message" if no data is available', () => {
diff --git a/x-pack/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/__test__/SpanMetadata.test.tsx b/x-pack/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/SpanMetadata.test.tsx
similarity index 92%
rename from x-pack/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/__test__/SpanMetadata.test.tsx
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/SpanMetadata.test.tsx
index c97e506187347..c9ed2c4c2b32f 100644
--- a/x-pack/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/__test__/SpanMetadata.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/SpanMetadata.test.tsx
@@ -7,13 +7,13 @@
import { render } from '@testing-library/react';
import React, { ReactNode } from 'react';
import { MemoryRouter } from 'react-router-dom';
-import { SpanMetadata } from '..';
-import { Span } from '../../../../../../typings/es_schemas/ui/span';
-import { MockApmPluginContextWrapper } from '../../../../../context/apm_plugin/mock_apm_plugin_context';
+import { SpanMetadata } from '.';
+import { Span } from '../../../../../typings/es_schemas/ui/span';
+import { MockApmPluginContextWrapper } from '../../../../context/apm_plugin/mock_apm_plugin_context';
import {
expectTextsInDocument,
expectTextsNotInDocument,
-} from '../../../../../utils/testHelpers';
+} from '../../../../utils/testHelpers';
function Wrapper({ children }: { children?: ReactNode }) {
return (
diff --git a/x-pack/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/__test__/TransactionMetadata.test.tsx b/x-pack/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/TransactionMetadata.test.tsx
similarity index 93%
rename from x-pack/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/__test__/TransactionMetadata.test.tsx
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/TransactionMetadata.test.tsx
index 4080a300ba17f..6a5a122f23954 100644
--- a/x-pack/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/__test__/TransactionMetadata.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/TransactionMetadata.test.tsx
@@ -7,13 +7,13 @@
import { render } from '@testing-library/react';
import React, { ReactNode } from 'react';
import { MemoryRouter } from 'react-router-dom';
-import { TransactionMetadata } from '..';
-import { Transaction } from '../../../../../../typings/es_schemas/ui/transaction';
-import { MockApmPluginContextWrapper } from '../../../../../context/apm_plugin/mock_apm_plugin_context';
+import { TransactionMetadata } from '.';
+import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
+import { MockApmPluginContextWrapper } from '../../../../context/apm_plugin/mock_apm_plugin_context';
import {
expectTextsInDocument,
expectTextsNotInDocument,
-} from '../../../../../utils/testHelpers';
+} from '../../../../utils/testHelpers';
function Wrapper({ children }: { children?: ReactNode }) {
return (
diff --git a/x-pack/plugins/apm/public/components/shared/MetadataTable/__test__/helper.test.ts b/x-pack/plugins/apm/public/components/shared/MetadataTable/helper.test.ts
similarity index 92%
rename from x-pack/plugins/apm/public/components/shared/MetadataTable/__test__/helper.test.ts
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/helper.test.ts
index ac776e0b8980c..8f3e675c7aeae 100644
--- a/x-pack/plugins/apm/public/components/shared/MetadataTable/__test__/helper.test.ts
+++ b/x-pack/plugins/apm/public/components/shared/MetadataTable/helper.test.ts
@@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { getSectionsWithRows, filterSectionsByTerm } from '../helper';
-import { LABELS, HTTP, SERVICE } from '../sections';
-import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
+import { getSectionsWithRows, filterSectionsByTerm } from './helper';
+import { LABELS, HTTP, SERVICE } from './sections';
+import { Transaction } from '../../../../typings/es_schemas/ui/transaction';
describe('MetadataTable Helper', () => {
const sections = [
diff --git a/x-pack/plugins/apm/public/components/shared/Summary/__test__/ErrorCountSummaryItemBadge.test.tsx b/x-pack/plugins/apm/public/components/shared/Summary/ErrorCountSummaryItemBadge.test.tsx
similarity index 86%
rename from x-pack/plugins/apm/public/components/shared/Summary/__test__/ErrorCountSummaryItemBadge.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Summary/ErrorCountSummaryItemBadge.test.tsx
index 26087e1fd85cc..fd531f79c9ac6 100644
--- a/x-pack/plugins/apm/public/components/shared/Summary/__test__/ErrorCountSummaryItemBadge.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Summary/ErrorCountSummaryItemBadge.test.tsx
@@ -5,11 +5,11 @@
*/
import React from 'react';
-import { ErrorCountSummaryItemBadge } from '../ErrorCountSummaryItemBadge';
+import { ErrorCountSummaryItemBadge } from './ErrorCountSummaryItemBadge';
import {
expectTextsInDocument,
renderWithTheme,
-} from '../../../../utils/testHelpers';
+} from '../../../utils/testHelpers';
describe('ErrorCountSummaryItemBadge', () => {
it('shows singular error message', () => {
diff --git a/x-pack/plugins/apm/public/components/shared/Summary/HttpInfoSummaryItem/__test__/HttpInfoSummaryItem.test.tsx b/x-pack/plugins/apm/public/components/shared/Summary/HttpInfoSummaryItem/HttpInfoSummaryItem.test.tsx
similarity index 95%
rename from x-pack/plugins/apm/public/components/shared/Summary/HttpInfoSummaryItem/__test__/HttpInfoSummaryItem.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Summary/HttpInfoSummaryItem/HttpInfoSummaryItem.test.tsx
index d0e1f08aabbbc..9465d94e16dc8 100644
--- a/x-pack/plugins/apm/public/components/shared/Summary/HttpInfoSummaryItem/__test__/HttpInfoSummaryItem.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Summary/HttpInfoSummaryItem/HttpInfoSummaryItem.test.tsx
@@ -6,8 +6,8 @@
import React from 'react';
import { shallow, mount } from 'enzyme';
-import { HttpInfoSummaryItem } from '../';
-import * as exampleTransactions from '../../__fixtures__/transactions';
+import { HttpInfoSummaryItem } from '.';
+import * as exampleTransactions from '../__fixtures__/transactions';
describe('HttpInfoSummaryItem', () => {
describe('render', () => {
diff --git a/x-pack/plugins/apm/public/components/shared/Summary/HttpStatusBadge/__test__/HttpStatusBadge.test.tsx b/x-pack/plugins/apm/public/components/shared/Summary/HttpStatusBadge/HttpStatusBadge.test.tsx
similarity index 95%
rename from x-pack/plugins/apm/public/components/shared/Summary/HttpStatusBadge/__test__/HttpStatusBadge.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Summary/HttpStatusBadge/HttpStatusBadge.test.tsx
index ecbf41486a3fd..0df23883d3127 100644
--- a/x-pack/plugins/apm/public/components/shared/Summary/HttpStatusBadge/__test__/HttpStatusBadge.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Summary/HttpStatusBadge/HttpStatusBadge.test.tsx
@@ -6,13 +6,13 @@
import React from 'react';
import { mount } from 'enzyme';
-import { HttpStatusBadge } from '../index';
+import { HttpStatusBadge } from './index';
import {
successColor,
neutralColor,
warningColor,
errorColor,
-} from '../../../../../utils/httpStatusCodeToColor';
+} from '../../../../utils/httpStatusCodeToColor';
describe('HttpStatusBadge', () => {
describe('render', () => {
diff --git a/x-pack/plugins/apm/public/components/shared/TimestampTooltip/__test__/index.test.tsx b/x-pack/plugins/apm/public/components/shared/TimestampTooltip/index.test.tsx
similarity index 94%
rename from x-pack/plugins/apm/public/components/shared/TimestampTooltip/__test__/index.test.tsx
rename to x-pack/plugins/apm/public/components/shared/TimestampTooltip/index.test.tsx
index b4678b287dc16..dd36827ea94f2 100644
--- a/x-pack/plugins/apm/public/components/shared/TimestampTooltip/__test__/index.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/TimestampTooltip/index.test.tsx
@@ -7,8 +7,8 @@
import { shallow } from 'enzyme';
import React from 'react';
import moment from 'moment-timezone';
-import { TimestampTooltip } from '../index';
-import { mockNow } from '../../../../utils/testHelpers';
+import { TimestampTooltip } from './index';
+import { mockNow } from '../../../utils/testHelpers';
describe('TimestampTooltip', () => {
const timestamp = 1570720000123; // Oct 10, 2019, 08:06:40.123 (UTC-7)
diff --git a/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/TransactionActionMenu.test.tsx b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/TransactionActionMenu.test.tsx
similarity index 95%
rename from x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/TransactionActionMenu.test.tsx
rename to x-pack/plugins/apm/public/components/shared/TransactionActionMenu/TransactionActionMenu.test.tsx
index 8cb863c8fc385..6ff395db594f1 100644
--- a/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/TransactionActionMenu.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/TransactionActionMenu.test.tsx
@@ -7,18 +7,18 @@
import { act, fireEvent, render } from '@testing-library/react';
import React from 'react';
import { MemoryRouter } from 'react-router-dom';
-import { License } from '../../../../../../licensing/common/license';
-import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
-import { MockApmPluginContextWrapper } from '../../../../context/apm_plugin/mock_apm_plugin_context';
-import { LicenseContext } from '../../../../context/license/license_context';
-import * as hooks from '../../../../hooks/use_fetcher';
-import * as apmApi from '../../../../services/rest/createCallApmApi';
+import { License } from '../../../../../licensing/common/license';
+import { Transaction } from '../../../../typings/es_schemas/ui/transaction';
+import { MockApmPluginContextWrapper } from '../../../context/apm_plugin/mock_apm_plugin_context';
+import { LicenseContext } from '../../../context/license/license_context';
+import * as hooks from '../../../hooks/use_fetcher';
+import * as apmApi from '../../../services/rest/createCallApmApi';
import {
expectTextsInDocument,
expectTextsNotInDocument,
-} from '../../../../utils/testHelpers';
-import { TransactionActionMenu } from '../TransactionActionMenu';
-import * as Transactions from './mockData';
+} from '../../../utils/testHelpers';
+import { TransactionActionMenu } from './TransactionActionMenu';
+import * as Transactions from './__fixtures__/mockData';
function Wrapper({ children }: { children?: React.ReactNode }) {
return (
diff --git a/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/mockData.ts b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__fixtures__/mockData.ts
similarity index 100%
rename from x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/mockData.ts
rename to x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__fixtures__/mockData.ts
diff --git a/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/__snapshots__/TransactionActionMenu.test.tsx.snap b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__snapshots__/TransactionActionMenu.test.tsx.snap
similarity index 100%
rename from x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/__snapshots__/TransactionActionMenu.test.tsx.snap
rename to x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__snapshots__/TransactionActionMenu.test.tsx.snap
diff --git a/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/sections.test.ts b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/sections.test.ts
similarity index 98%
rename from x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/sections.test.ts
rename to x-pack/plugins/apm/public/components/shared/TransactionActionMenu/sections.test.ts
index 048ae9474c403..f6067a34e2b90 100644
--- a/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/sections.test.ts
+++ b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/sections.test.ts
@@ -5,8 +5,8 @@
*/
import { Location } from 'history';
import { IBasePath } from 'kibana/public';
-import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
-import { getSections } from '../sections';
+import { Transaction } from '../../../../typings/es_schemas/ui/transaction';
+import { getSections } from './sections';
describe('Transaction action menu', () => {
const basePath = ({
diff --git a/x-pack/plugins/apm/public/services/__test__/SessionStorageMock.ts b/x-pack/plugins/apm/public/services/__mocks__/SessionStorageMock.ts
similarity index 100%
rename from x-pack/plugins/apm/public/services/__test__/SessionStorageMock.ts
rename to x-pack/plugins/apm/public/services/__mocks__/SessionStorageMock.ts
diff --git a/x-pack/plugins/apm/public/services/__test__/callApi.test.ts b/x-pack/plugins/apm/public/services/callApi.test.ts
similarity index 97%
rename from x-pack/plugins/apm/public/services/__test__/callApi.test.ts
rename to x-pack/plugins/apm/public/services/callApi.test.ts
index f82201bbd4de8..1e606ac4b9aa9 100644
--- a/x-pack/plugins/apm/public/services/__test__/callApi.test.ts
+++ b/x-pack/plugins/apm/public/services/callApi.test.ts
@@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { mockNow } from '../../utils/testHelpers';
-import { clearCache, callApi } from '../rest/callApi';
-import { SessionStorageMock } from './SessionStorageMock';
+import { mockNow } from '../utils/testHelpers';
+import { clearCache, callApi } from './rest/callApi';
+import { SessionStorageMock } from './__mocks__/SessionStorageMock';
import { HttpSetup } from 'kibana/public';
type HttpMock = HttpSetup & {
diff --git a/x-pack/plugins/apm/public/services/__test__/callApmApi.test.ts b/x-pack/plugins/apm/public/services/callApmApi.test.ts
similarity index 93%
rename from x-pack/plugins/apm/public/services/__test__/callApmApi.test.ts
rename to x-pack/plugins/apm/public/services/callApmApi.test.ts
index 2307ec9f06bb5..5906053cbd810 100644
--- a/x-pack/plugins/apm/public/services/__test__/callApmApi.test.ts
+++ b/x-pack/plugins/apm/public/services/callApmApi.test.ts
@@ -4,8 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import * as callApiExports from '../rest/callApi';
-import { createCallApmApi, callApmApi } from '../rest/createCallApmApi';
+import * as callApiExports from './rest/callApi';
+import { createCallApmApi, callApmApi } from './rest/createCallApmApi';
import { HttpSetup } from 'kibana/public';
const callApi = jest
diff --git a/x-pack/plugins/apm/public/utils/__test__/flattenObject.test.ts b/x-pack/plugins/apm/public/utils/flattenObject.test.ts
similarity index 96%
rename from x-pack/plugins/apm/public/utils/__test__/flattenObject.test.ts
rename to x-pack/plugins/apm/public/utils/flattenObject.test.ts
index a71ecf73bad3f..68f77573949ea 100644
--- a/x-pack/plugins/apm/public/utils/__test__/flattenObject.test.ts
+++ b/x-pack/plugins/apm/public/utils/flattenObject.test.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { flattenObject } from '../flattenObject';
+import { flattenObject } from './flattenObject';
describe('FlattenObject', () => {
it('flattens multi level item', () => {
diff --git a/x-pack/plugins/apm/server/lib/errors/distribution/__tests__/__snapshots__/get_buckets.test.ts.snap b/x-pack/plugins/apm/server/lib/errors/distribution/__snapshots__/get_buckets.test.ts.snap
similarity index 100%
rename from x-pack/plugins/apm/server/lib/errors/distribution/__tests__/__snapshots__/get_buckets.test.ts.snap
rename to x-pack/plugins/apm/server/lib/errors/distribution/__snapshots__/get_buckets.test.ts.snap
diff --git a/x-pack/plugins/apm/server/lib/errors/distribution/__tests__/get_buckets.test.ts b/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.test.ts
similarity index 92%
rename from x-pack/plugins/apm/server/lib/errors/distribution/__tests__/get_buckets.test.ts
rename to x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.test.ts
index ff7d05efc1802..e05e7d3df2828 100644
--- a/x-pack/plugins/apm/server/lib/errors/distribution/__tests__/get_buckets.test.ts
+++ b/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.test.ts
@@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { getBuckets } from '../get_buckets';
-import { APMConfig } from '../../../..';
-import { ProcessorEvent } from '../../../../../common/processor_event';
+import { getBuckets } from './get_buckets';
+import { APMConfig } from '../../..';
+import { ProcessorEvent } from '../../../../common/processor_event';
describe('get buckets', () => {
let clientSpy: jest.Mock;
diff --git a/x-pack/plugins/apm/server/lib/helpers/convert_ui_filters/__test__/get_environment_ui_filter_es.test.ts b/x-pack/plugins/apm/server/lib/helpers/convert_ui_filters/get_environment_ui_filter_es.test.ts
similarity index 80%
rename from x-pack/plugins/apm/server/lib/helpers/convert_ui_filters/__test__/get_environment_ui_filter_es.test.ts
rename to x-pack/plugins/apm/server/lib/helpers/convert_ui_filters/get_environment_ui_filter_es.test.ts
index a319bba1eabe1..711790d0c4aae 100644
--- a/x-pack/plugins/apm/server/lib/helpers/convert_ui_filters/__test__/get_environment_ui_filter_es.test.ts
+++ b/x-pack/plugins/apm/server/lib/helpers/convert_ui_filters/get_environment_ui_filter_es.test.ts
@@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { getEnvironmentUiFilterES } from '../get_environment_ui_filter_es';
-import { ENVIRONMENT_NOT_DEFINED } from '../../../../../common/environment_filter_values';
-import { SERVICE_ENVIRONMENT } from '../../../../../common/elasticsearch_fieldnames';
+import { getEnvironmentUiFilterES } from './get_environment_ui_filter_es';
+import { ENVIRONMENT_NOT_DEFINED } from '../../../../common/environment_filter_values';
+import { SERVICE_ENVIRONMENT } from '../../../../common/elasticsearch_fieldnames';
describe('getEnvironmentUiFilterES', () => {
it('should return empty array, when environment is undefined', () => {
diff --git a/x-pack/plugins/canvas/canvas_plugin_src/canvas_addons.ts b/x-pack/plugins/canvas/canvas_plugin_src/canvas_addons.ts
new file mode 100644
index 0000000000000..fe5e1d7e5f983
--- /dev/null
+++ b/x-pack/plugins/canvas/canvas_plugin_src/canvas_addons.ts
@@ -0,0 +1,16 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+// @ts-expect-error Untyped Local
+export * from './uis/datasources';
+export * from './elements';
+// @ts-expect-error Untyped Local
+export * from './uis/models';
+export * from './uis/views';
+export * from './uis/arguments';
+export * from './uis/tags';
+// @ts-expect-error Untyped Local
+export * from './uis/transforms';
diff --git a/x-pack/plugins/canvas/canvas_plugin_src/plugin.ts b/x-pack/plugins/canvas/canvas_plugin_src/plugin.ts
index 7ecebd6d0677a..e650cd5037118 100644
--- a/x-pack/plugins/canvas/canvas_plugin_src/plugin.ts
+++ b/x-pack/plugins/canvas/canvas_plugin_src/plugin.ts
@@ -14,17 +14,6 @@ import { Start as InspectorStart } from '../../../../src/plugins/inspector/publi
import { functions } from './functions/browser';
import { typeFunctions } from './expression_types';
import { renderFunctions, renderFunctionFactories } from './renderers';
-import { initializeElements } from './elements';
-// @ts-expect-error untyped local
-import { transformSpecs } from './uis/transforms';
-// @ts-expect-error untyped local
-import { datasourceSpecs } from './uis/datasources';
-// @ts-expect-error untyped local
-import { modelSpecs } from './uis/models';
-import { initializeViews } from './uis/views';
-import { initializeArgs } from './uis/arguments';
-import { tagSpecs } from './uis/tags';
-
interface SetupDeps {
canvas: CanvasSetup;
}
@@ -53,13 +42,44 @@ export class CanvasSrcPlugin implements Plugin
);
});
- plugins.canvas.addElements(initializeElements(core, plugins));
- plugins.canvas.addDatasourceUIs(datasourceSpecs);
- plugins.canvas.addModelUIs(modelSpecs);
- plugins.canvas.addViewUIs(initializeViews(core, plugins));
- plugins.canvas.addArgumentUIs(initializeArgs(core, plugins));
- plugins.canvas.addTagUIs(tagSpecs);
- plugins.canvas.addTransformUIs(transformSpecs);
+ plugins.canvas.addDatasourceUIs(async () => {
+ // @ts-expect-error
+ const { datasourceSpecs } = await import('./canvas_addons');
+ return datasourceSpecs;
+ });
+
+ plugins.canvas.addElements(async () => {
+ const { initializeElements } = await import('./canvas_addons');
+ return initializeElements(core, plugins);
+ });
+
+ plugins.canvas.addModelUIs(async () => {
+ // @ts-expect-error Untyped local
+ const { modelSpecs } = await import('./canvas_addons');
+ return modelSpecs;
+ });
+
+ plugins.canvas.addViewUIs(async () => {
+ const { initializeViews } = await import('./canvas_addons');
+
+ return initializeViews(core, plugins);
+ });
+
+ plugins.canvas.addArgumentUIs(async () => {
+ const { initializeArgs } = await import('./canvas_addons');
+ return initializeArgs(core, plugins);
+ });
+
+ plugins.canvas.addTagUIs(async () => {
+ const { tagSpecs } = await import('./canvas_addons');
+ return tagSpecs;
+ });
+
+ plugins.canvas.addTransformUIs(async () => {
+ // @ts-expect-error Untyped local
+ const { transformSpecs } = await import('./canvas_addons');
+ return transformSpecs;
+ });
}
public start(core: CoreStart, plugins: StartDeps) {}
diff --git a/x-pack/plugins/canvas/public/application.tsx b/x-pack/plugins/canvas/public/application.tsx
index 7d65a99b1dd45..fc02df3740cdb 100644
--- a/x-pack/plugins/canvas/public/application.tsx
+++ b/x-pack/plugins/canvas/public/application.tsx
@@ -103,7 +103,7 @@ export const initializeCanvas = async (
// Init Registries
initRegistries();
- populateRegistries(registries);
+ await populateRegistries(registries);
// Set Badge
coreStart.chrome.setBadge(
diff --git a/x-pack/plugins/canvas/public/components/expression/expression.js b/x-pack/plugins/canvas/public/components/expression/expression.tsx
similarity index 86%
rename from x-pack/plugins/canvas/public/components/expression/expression.js
rename to x-pack/plugins/canvas/public/components/expression/expression.tsx
index 37cf1b821d9fd..141963d479724 100644
--- a/x-pack/plugins/canvas/public/components/expression/expression.js
+++ b/x-pack/plugins/canvas/public/components/expression/expression.tsx
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import React from 'react';
+import React, { FC, MutableRefObject } from 'react';
import PropTypes from 'prop-types';
import {
EuiPanel,
@@ -16,19 +16,26 @@ import {
EuiLink,
EuiPortal,
} from '@elastic/eui';
+// @ts-expect-error
import { Shortcuts } from 'react-shortcuts';
import { ComponentStrings } from '../../../i18n';
import { ExpressionInput } from '../expression_input';
import { ToolTipShortcut } from '../tool_tip_shortcut';
+import { ExpressionFunction } from '../../../types';
+import { FormState } from './';
const { Expression: strings } = ComponentStrings;
const { useRef } = React;
-const shortcut = (ref, cmd, callback) => (
+const shortcut = (
+ ref: MutableRefObject,
+ cmd: string,
+ callback: () => void
+) => (
{
+ handler={(command: string) => {
const isInputActive = ref.current && ref.current.editor && ref.current.editor.hasTextFocus();
if (isInputActive && command === cmd) {
callback();
@@ -40,18 +47,28 @@ const shortcut = (ref, cmd, callback) => (
/>
);
-export const Expression = ({
+interface Props {
+ functionDefinitions: ExpressionFunction[];
+ formState: FormState;
+ updateValue: (expression?: string) => void;
+ setExpression: (expression: string) => void;
+ done: () => void;
+ error?: string;
+ isCompact: boolean;
+ toggleCompactView: () => void;
+}
+
+export const Expression: FC = ({
functionDefinitions,
formState,
updateValue,
setExpression,
done,
error,
- fontSize,
isCompact,
toggleCompactView,
}) => {
- const refExpressionInput = useRef(null);
+ const refExpressionInput = useRef(null);
const handleRun = () => {
setExpression(formState.expression);
@@ -78,7 +95,6 @@ export const Expression = ({
({
- pageId: getSelectedPage(state),
- element: getSelectedElement(state),
-});
-
-const mapDispatchToProps = (dispatch) => ({
- setExpression: (elementId, pageId) => (expression) => {
- // destroy the context cache
- dispatch(flushContext(elementId));
-
- // update the element's expression
- dispatch(setExpression(expression, elementId, pageId));
- },
-});
-
-const mergeProps = (stateProps, dispatchProps, ownProps) => {
- const { element, pageId } = stateProps;
- const allProps = { ...ownProps, ...stateProps, ...dispatchProps };
-
- if (!element) {
- return allProps;
- }
-
- const { expression } = element;
-
- const functions = Object.values(allProps.services.expressions.getFunctions());
-
- return {
- ...allProps,
- expression,
- functionDefinitions: functions,
- setExpression: dispatchProps.setExpression(element.id, pageId),
- };
-};
-
-const expressionLifecycle = lifecycle({
- componentDidUpdate({ expression }) {
- if (
- this.props.expression !== expression &&
- this.props.expression !== this.props.formState.expression
- ) {
- this.props.setFormState({
- expression: this.props.expression,
- dirty: false,
- });
- }
- },
-});
-
-export const Expression = compose(
- withServices,
- connect(mapStateToProps, mapDispatchToProps, mergeProps),
- withState('formState', 'setFormState', ({ expression }) => ({
- expression,
- dirty: false,
- })),
- withState('isCompact', 'setCompact', true),
- withHandlers({
- toggleCompactView: ({ isCompact, setCompact }) => () => {
- setCompact(!isCompact);
- },
- updateValue: ({ setFormState }) => (expression) => {
- setFormState({
- expression,
- dirty: true,
- });
- },
- setExpression: ({ setExpression, setFormState }) => (exp) => {
- setFormState((prev) => ({
- ...prev,
- dirty: false,
- }));
- setExpression(exp);
- },
- }),
- expressionLifecycle,
- withPropsOnChange(['formState'], ({ formState }) => ({
- error: (function () {
- try {
- // TODO: We should merge the advanced UI input and this into a single validated expression input.
- fromExpression(formState.expression);
- return null;
- } catch (e) {
- return e.message;
- }
- })(),
- })),
- branch((props) => !props.element, renderComponent(ElementNotSelected))
-)(Component);
diff --git a/x-pack/plugins/canvas/public/components/expression/index.tsx b/x-pack/plugins/canvas/public/components/expression/index.tsx
new file mode 100644
index 0000000000000..fc4f1958ecb33
--- /dev/null
+++ b/x-pack/plugins/canvas/public/components/expression/index.tsx
@@ -0,0 +1,124 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+import React, { FC, useState, useCallback, useMemo, useEffect } from 'react';
+import { useDispatch, useSelector } from 'react-redux';
+import { fromExpression } from '@kbn/interpreter/common';
+import { useServices } from '../../services';
+import { getSelectedPage, getSelectedElement } from '../../state/selectors/workpad';
+// @ts-expect-error
+import { setExpression, flushContext } from '../../state/actions/elements';
+// @ts-expect-error
+import { ElementNotSelected } from './element_not_selected';
+import { Expression as Component } from './expression';
+import { State, CanvasElement } from '../../../types';
+
+interface ExpressionProps {
+ done: () => void;
+}
+
+interface ExpressionContainerProps extends ExpressionProps {
+ element: CanvasElement;
+ pageId: string;
+}
+
+export interface FormState {
+ dirty: boolean;
+ expression: string;
+}
+
+export const Expression: FC = ({ done }) => {
+ const { element, pageId } = useSelector((state: State) => ({
+ pageId: getSelectedPage(state),
+ element: getSelectedElement(state),
+ }));
+
+ if (!element) {
+ return ;
+ }
+
+ return ;
+};
+
+const ExpressionContainer: FC = ({ done, element, pageId }) => {
+ const services = useServices();
+ const dispatch = useDispatch();
+ const [isCompact, setCompact] = useState(true);
+ const toggleCompactView = useCallback(() => {
+ setCompact(!isCompact);
+ }, [isCompact, setCompact]);
+
+ const dispatchSetExpression = useCallback(
+ (expression: string) => {
+ // destroy the context cache
+ dispatch(flushContext(element.id));
+
+ // update the element's expression
+ dispatch(setExpression(expression, element.id, pageId));
+ },
+ [dispatch, element, pageId]
+ );
+
+ const [formState, setFormState] = useState({
+ dirty: false,
+ expression: element.expression,
+ });
+
+ const updateValue = useCallback(
+ (expression: string = '') => {
+ setFormState({
+ expression,
+ dirty: true,
+ });
+ },
+ [setFormState]
+ );
+
+ const onSetExpression = useCallback(
+ (expression: string) => {
+ setFormState({
+ ...formState,
+ dirty: false,
+ });
+ dispatchSetExpression(expression);
+ },
+ [setFormState, dispatchSetExpression, formState]
+ );
+
+ const currentExpression = formState.expression;
+
+ const error = useMemo(() => {
+ try {
+ // TODO: We should merge the advanced UI input and this into a single validated expression input.
+ fromExpression(currentExpression);
+ return null;
+ } catch (e) {
+ return e.message;
+ }
+ }, [currentExpression]);
+
+ useEffect(() => {
+ if (element.expression !== formState.expression && !formState.dirty) {
+ setFormState({
+ dirty: false,
+ expression: element.expression,
+ });
+ }
+ }, [element, setFormState, formState]);
+
+ return (
+
+ );
+};
diff --git a/x-pack/plugins/canvas/public/components/expression_input/index.js b/x-pack/plugins/canvas/public/components/expression_input/index.ts
similarity index 100%
rename from x-pack/plugins/canvas/public/components/expression_input/index.js
rename to x-pack/plugins/canvas/public/components/expression_input/index.ts
diff --git a/x-pack/plugins/canvas/public/components/toolbar/toolbar.component.tsx b/x-pack/plugins/canvas/public/components/toolbar/toolbar.component.tsx
index 6905b3ed23d3f..7151e72a44780 100644
--- a/x-pack/plugins/canvas/public/components/toolbar/toolbar.component.tsx
+++ b/x-pack/plugins/canvas/public/components/toolbar/toolbar.component.tsx
@@ -21,7 +21,6 @@ import {
import { WorkpadManager } from '../workpad_manager';
import { RouterContext } from '../router';
import { PageManager } from '../page_manager';
-// @ts-expect-error untyped local
import { Expression } from '../expression';
import { Tray } from './tray';
diff --git a/x-pack/plugins/canvas/public/plugin.tsx b/x-pack/plugins/canvas/public/plugin.tsx
index d18f1b8d24489..3c6c0d68da3db 100644
--- a/x-pack/plugins/canvas/public/plugin.tsx
+++ b/x-pack/plugins/canvas/public/plugin.tsx
@@ -26,9 +26,6 @@ import { EmbeddableStart } from '../../../../src/plugins/embeddable/public';
import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/public';
import { Start as InspectorStart } from '../../../../src/plugins/inspector/public';
import { BfetchPublicSetup } from '../../../../src/plugins/bfetch/public';
-// @ts-expect-error untyped local
-import { argTypeSpecs } from './expression_types/arg_types';
-import { transitions } from './transitions';
import { getPluginApi, CanvasApi } from './plugin_api';
import { CanvasSrcPlugin } from '../canvas_plugin_src/plugin';
export { CoreStart, CoreSetup };
@@ -123,8 +120,15 @@ export class CanvasPlugin
plugins.home.featureCatalogue.register(featureCatalogueEntry);
}
- canvasApi.addArgumentUIs(argTypeSpecs);
- canvasApi.addTransitions(transitions);
+ canvasApi.addArgumentUIs(async () => {
+ // @ts-expect-error
+ const { argTypeSpecs } = await import('./expression_types/arg_types');
+ return argTypeSpecs;
+ });
+ canvasApi.addTransitions(async () => {
+ const { transitions } = await import('./transitions');
+ return transitions;
+ });
return {
...canvasApi,
diff --git a/x-pack/plugins/canvas/public/plugin_api.ts b/x-pack/plugins/canvas/public/plugin_api.ts
index 62e82df4b0d04..be267bb91a909 100644
--- a/x-pack/plugins/canvas/public/plugin_api.ts
+++ b/x-pack/plugins/canvas/public/plugin_api.ts
@@ -12,24 +12,26 @@ import {
import { ElementFactory } from '../types';
import { ExpressionsSetup } from '../../../../src/plugins/expressions/public';
-type AddToRegistry = (add: T[]) => void;
+type SpecPromiseFn = () => Promise;
+type AddToRegistry = (add: T[] | SpecPromiseFn) => void;
+type AddSpecsToRegistry = (add: T[]) => void;
export interface CanvasApi {
addArgumentUIs: AddToRegistry;
addDatasourceUIs: AddToRegistry;
addElements: AddToRegistry;
- addFunctions: AddToRegistry<() => AnyExpressionFunctionDefinition>;
+ addFunctions: AddSpecsToRegistry<() => AnyExpressionFunctionDefinition>;
addModelUIs: AddToRegistry;
- addRenderers: AddToRegistry;
+ addRenderers: AddSpecsToRegistry;
addTagUIs: AddToRegistry;
addTransformUIs: AddToRegistry;
addTransitions: AddToRegistry;
- addTypes: AddToRegistry<() => AnyExpressionTypeDefinition>;
+ addTypes: AddSpecsToRegistry<() => AnyExpressionTypeDefinition>;
addViewUIs: AddToRegistry;
}
-export interface SetupRegistries {
- elements: ElementFactory[];
+export interface SetupRegistries extends Record {
+ elements: Array>;
transformUIs: any[];
datasourceUIs: any[];
modelUIs: any[];
@@ -53,6 +55,16 @@ export function getPluginApi(
transitions: [],
};
+ const addToRegistry = (registry: Array>) => {
+ return (entries: T[] | SpecPromiseFn) => {
+ if (Array.isArray(entries)) {
+ registry.push(...entries);
+ } else {
+ registry.push(entries);
+ }
+ };
+ };
+
const api: CanvasApi = {
// Functions, types and renderers are registered directly to expression plugin
addFunctions: (fns) => {
@@ -75,14 +87,14 @@ export function getPluginApi(
},
// All these others are local to canvas, and they will only register on start
- addElements: (elements) => registries.elements.push(...elements),
- addTransformUIs: (transforms) => registries.transformUIs.push(...transforms),
- addDatasourceUIs: (datasources) => registries.datasourceUIs.push(...datasources),
- addModelUIs: (models) => registries.modelUIs.push(...models),
- addViewUIs: (views) => registries.viewUIs.push(...views),
- addArgumentUIs: (args) => registries.argumentUIs.push(...args),
- addTagUIs: (tags) => registries.tagUIs.push(...tags),
- addTransitions: (transitions) => registries.transitions.push(...transitions),
+ addElements: addToRegistry(registries.elements),
+ addTransformUIs: addToRegistry(registries.transformUIs),
+ addDatasourceUIs: addToRegistry(registries.datasourceUIs),
+ addModelUIs: addToRegistry(registries.modelUIs),
+ addViewUIs: addToRegistry(registries.viewUIs),
+ addArgumentUIs: addToRegistry(registries.argumentUIs),
+ addTagUIs: addToRegistry(registries.tagUIs),
+ addTransitions: addToRegistry(registries.transitions),
};
return { api, registries };
diff --git a/x-pack/plugins/canvas/public/registries.ts b/x-pack/plugins/canvas/public/registries.ts
index b2881fc0b7799..5f87beb207b8c 100644
--- a/x-pack/plugins/canvas/public/registries.ts
+++ b/x-pack/plugins/canvas/public/registries.ts
@@ -40,8 +40,24 @@ export function initRegistries() {
});
}
-export function populateRegistries(setupRegistries: SetupRegistries) {
- register(registries, setupRegistries);
+export async function populateRegistries(setupRegistries: SetupRegistries) {
+ // Our setup registries could contain definitions or a function that would
+ // return a promise of definitions.
+ // We need to call all the fns and then wait for all of the promises to be resolved
+ const resolvedRegistries: Record = {};
+ const promises = Object.entries(setupRegistries).map(async ([key, specs]) => {
+ const resolved = await (
+ await Promise.all(specs.map((fn) => (typeof fn === 'function' ? fn() : fn)))
+ ).flat();
+
+ resolvedRegistries[key] = resolved;
+ });
+
+ // Now, wait for all of the promise registry promises to resolve and our resolved registry will be ready
+ // and we can proceeed
+ await Promise.all(promises);
+
+ register(registries, resolvedRegistries);
}
export function destroyRegistries() {
diff --git a/x-pack/plugins/data_enhanced/common/index.ts b/x-pack/plugins/data_enhanced/common/index.ts
index f26ba0dd0b46c..e3e91ccf967c1 100644
--- a/x-pack/plugins/data_enhanced/common/index.ts
+++ b/x-pack/plugins/data_enhanced/common/index.ts
@@ -12,8 +12,8 @@ export {
EqlSearchStrategyResponse,
IAsyncSearchOptions,
pollSearch,
- BackgroundSessionSavedObjectAttributes,
- BackgroundSessionFindOptions,
- BackgroundSessionStatus,
- BackgroundSessionSearchInfo,
+ SearchSessionSavedObjectAttributes,
+ SearchSessionFindOptions,
+ SearchSessionStatus,
+ SearchSessionRequestInfo,
} from './search';
diff --git a/x-pack/plugins/data_enhanced/common/search/session/status.ts b/x-pack/plugins/data_enhanced/common/search/session/status.ts
index a83dd389e4f13..e3a5bc02cdd41 100644
--- a/x-pack/plugins/data_enhanced/common/search/session/status.ts
+++ b/x-pack/plugins/data_enhanced/common/search/session/status.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-export enum BackgroundSessionStatus {
+export enum SearchSessionStatus {
IN_PROGRESS = 'in_progress',
ERROR = 'error',
COMPLETE = 'complete',
diff --git a/x-pack/plugins/data_enhanced/common/search/session/types.ts b/x-pack/plugins/data_enhanced/common/search/session/types.ts
index 1310c05ed6854..6f75e60856362 100644
--- a/x-pack/plugins/data_enhanced/common/search/session/types.ts
+++ b/x-pack/plugins/data_enhanced/common/search/session/types.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-export interface BackgroundSessionSavedObjectAttributes {
+export interface SearchSessionSavedObjectAttributes {
/**
* User-facing session name to be displayed in session management
*/
@@ -19,15 +19,15 @@ export interface BackgroundSessionSavedObjectAttributes {
urlGeneratorId: string;
initialState: Record;
restoreState: Record;
- idMapping: Record;
+ idMapping: Record;
}
-export interface BackgroundSessionSearchInfo {
+export interface SearchSessionRequestInfo {
id: string; // ID of the async search request
strategy: string; // Search strategy used to submit the search request
}
-export interface BackgroundSessionFindOptions {
+export interface SearchSessionFindOptions {
page?: number;
perPage?: number;
sortField?: string;
diff --git a/x-pack/plugins/data_enhanced/public/plugin.ts b/x-pack/plugins/data_enhanced/public/plugin.ts
index a3b37e47287e5..c7d1c8624cb1f 100644
--- a/x-pack/plugins/data_enhanced/public/plugin.ts
+++ b/x-pack/plugins/data_enhanced/public/plugin.ts
@@ -13,7 +13,7 @@ import { setAutocompleteService } from './services';
import { setupKqlQuerySuggestionProvider, KUERY_LANGUAGE_NAME } from './autocomplete';
import { EnhancedSearchInterceptor } from './search/search_interceptor';
import { toMountPoint } from '../../../../src/plugins/kibana_react/public';
-import { createConnectedBackgroundSessionIndicator } from './search';
+import { createConnectedSearchSessionIndicator } from './search';
import { ConfigSchema } from '../config';
export interface DataEnhancedSetupDependencies {
@@ -66,7 +66,7 @@ export class DataEnhancedPlugin
core.chrome.setBreadcrumbsAppendExtension({
content: toMountPoint(
React.createElement(
- createConnectedBackgroundSessionIndicator({
+ createConnectedSearchSessionIndicator({
sessionService: plugins.data.search.session,
application: core.application,
timeFilter: plugins.data.query.timefilter.timefilter,
diff --git a/x-pack/plugins/data_enhanced/public/search/search_interceptor.test.ts b/x-pack/plugins/data_enhanced/public/search/search_interceptor.test.ts
index 20b55d9688edb..fc6c860f907f6 100644
--- a/x-pack/plugins/data_enhanced/public/search/search_interceptor.test.ts
+++ b/x-pack/plugins/data_enhanced/public/search/search_interceptor.test.ts
@@ -9,7 +9,7 @@ import { EnhancedSearchInterceptor } from './search_interceptor';
import { CoreSetup, CoreStart } from 'kibana/public';
import { UI_SETTINGS } from '../../../../../src/plugins/data/common';
import { AbortError } from '../../../../../src/plugins/kibana_utils/public';
-import { ISessionService, SearchTimeoutError, SessionState } from 'src/plugins/data/public';
+import { ISessionService, SearchTimeoutError, SearchSessionState } from 'src/plugins/data/public';
import { dataPluginMock } from '../../../../../src/plugins/data/public/mocks';
import { bfetchPluginMock } from '../../../../../src/plugins/bfetch/public/mocks';
import { BehaviorSubject } from 'rxjs';
@@ -45,12 +45,12 @@ function mockFetchImplementation(responses: any[]) {
describe('EnhancedSearchInterceptor', () => {
let mockUsageCollector: any;
let sessionService: jest.Mocked;
- let sessionState$: BehaviorSubject;
+ let sessionState$: BehaviorSubject;
beforeEach(() => {
mockCoreSetup = coreMock.createSetup();
mockCoreStart = coreMock.createStart();
- sessionState$ = new BehaviorSubject(SessionState.None);
+ sessionState$ = new BehaviorSubject(SearchSessionState.None);
const dataPluginMockStart = dataPluginMock.createStartContract();
sessionService = {
...(dataPluginMockStart.search.session as jest.Mocked),
@@ -408,7 +408,7 @@ describe('EnhancedSearchInterceptor', () => {
expect(next).toHaveBeenCalled();
expect(error).not.toHaveBeenCalled();
- sessionState$.next(SessionState.BackgroundLoading);
+ sessionState$.next(SearchSessionState.BackgroundLoading);
await timeTravel(240);
diff --git a/x-pack/plugins/data_enhanced/public/search/search_interceptor.ts b/x-pack/plugins/data_enhanced/public/search/search_interceptor.ts
index 0e87c093d2a8d..b0f194115f0b8 100644
--- a/x-pack/plugins/data_enhanced/public/search/search_interceptor.ts
+++ b/x-pack/plugins/data_enhanced/public/search/search_interceptor.ts
@@ -12,7 +12,7 @@ import {
SearchInterceptorDeps,
UI_SETTINGS,
IKibanaSearchRequest,
- SessionState,
+ SearchSessionState,
} from '../../../../../src/plugins/data/public';
import { AbortError } from '../../../../../src/plugins/kibana_utils/common';
import { ENHANCED_ES_SEARCH_STRATEGY, IAsyncSearchOptions, pollSearch } from '../../common';
@@ -77,7 +77,7 @@ export class EnhancedSearchInterceptor extends SearchInterceptor {
this.deps.session.state$
.pipe(
skip(1), // ignore any state, we are only interested in transition x -> BackgroundLoading
- filter((state) => isCurrentSession() && state === SessionState.BackgroundLoading),
+ filter((state) => isCurrentSession() && state === SearchSessionState.BackgroundLoading),
take(1)
)
.subscribe(() => {
diff --git a/x-pack/plugins/data_enhanced/public/search/ui/background_session_indicator/background_session_indicator.stories.tsx b/x-pack/plugins/data_enhanced/public/search/ui/background_session_indicator/background_session_indicator.stories.tsx
deleted file mode 100644
index 4a6a852be755b..0000000000000
--- a/x-pack/plugins/data_enhanced/public/search/ui/background_session_indicator/background_session_indicator.stories.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import React from 'react';
-import { storiesOf } from '@storybook/react';
-import { BackgroundSessionIndicator } from './background_session_indicator';
-import { SessionState } from '../../../../../../../src/plugins/data/public';
-
-storiesOf('components/BackgroundSessionIndicator', module).add('default', () => (
- <>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- >
-));
diff --git a/x-pack/plugins/data_enhanced/public/search/ui/connected_background_session_indicator/connected_background_session_indicator.test.tsx b/x-pack/plugins/data_enhanced/public/search/ui/connected_search_session_indicator/connected_search_session_indicator.test.tsx
similarity index 62%
rename from x-pack/plugins/data_enhanced/public/search/ui/connected_background_session_indicator/connected_background_session_indicator.test.tsx
rename to x-pack/plugins/data_enhanced/public/search/ui/connected_search_session_indicator/connected_search_session_indicator.test.tsx
index 6fa9abd0f1ab6..2c74f9c995a5a 100644
--- a/x-pack/plugins/data_enhanced/public/search/ui/connected_background_session_indicator/connected_background_session_indicator.test.tsx
+++ b/x-pack/plugins/data_enhanced/public/search/ui/connected_search_session_indicator/connected_search_session_indicator.test.tsx
@@ -7,12 +7,12 @@
import React from 'react';
import { render, waitFor, screen, act } from '@testing-library/react';
import { dataPluginMock } from '../../../../../../../src/plugins/data/public/mocks';
-import { createConnectedBackgroundSessionIndicator } from './connected_background_session_indicator';
+import { createConnectedSearchSessionIndicator } from './connected_search_session_indicator';
import { BehaviorSubject } from 'rxjs';
import {
ISessionService,
RefreshInterval,
- SessionState,
+ SearchSessionState,
TimefilterContract,
} from '../../../../../../../src/plugins/data/public';
import { coreMock } from '../../../../../../../src/core/public/mocks';
@@ -31,78 +31,76 @@ beforeEach(() => {
});
test("shouldn't show indicator in case no active search session", async () => {
- const BackgroundSessionIndicator = createConnectedBackgroundSessionIndicator({
+ const SearchSessionIndicator = createConnectedSearchSessionIndicator({
sessionService,
application: coreStart.application,
timeFilter,
});
- const { getByTestId, container } = render();
+ const { getByTestId, container } = render();
- // make sure `backgroundSessionIndicator` isn't appearing after some time (lazy-loading)
+ // make sure `searchSessionIndicator` isn't appearing after some time (lazy-loading)
await expect(
- waitFor(() => getByTestId('backgroundSessionIndicator'), { timeout: 100 })
+ waitFor(() => getByTestId('searchSessionIndicator'), { timeout: 100 })
).rejects.toThrow();
expect(container).toMatchInlineSnapshot(``);
});
test('should show indicator in case there is an active search session', async () => {
- const state$ = new BehaviorSubject(SessionState.Loading);
- const BackgroundSessionIndicator = createConnectedBackgroundSessionIndicator({
+ const state$ = new BehaviorSubject(SearchSessionState.Loading);
+ const SearchSessionIndicator = createConnectedSearchSessionIndicator({
sessionService: { ...sessionService, state$ },
application: coreStart.application,
timeFilter,
});
- const { getByTestId } = render();
+ const { getByTestId } = render();
- await waitFor(() => getByTestId('backgroundSessionIndicator'));
+ await waitFor(() => getByTestId('searchSessionIndicator'));
});
test('should be disabled when permissions are off', async () => {
- const state$ = new BehaviorSubject(SessionState.Loading);
+ const state$ = new BehaviorSubject(SearchSessionState.Loading);
coreStart.application.currentAppId$ = new BehaviorSubject('discover');
(coreStart.application.capabilities as any) = {
discover: {
storeSearchSession: false,
},
};
- const BackgroundSessionIndicator = createConnectedBackgroundSessionIndicator({
+ const SearchSessionIndicator = createConnectedSearchSessionIndicator({
sessionService: { ...sessionService, state$ },
application: coreStart.application,
timeFilter,
});
- render();
+ render();
- await waitFor(() => screen.getByTestId('backgroundSessionIndicator'));
+ await waitFor(() => screen.getByTestId('searchSessionIndicator'));
- expect(screen.getByTestId('backgroundSessionIndicator').querySelector('button')).toBeDisabled();
+ expect(screen.getByTestId('searchSessionIndicator').querySelector('button')).toBeDisabled();
});
test('should be disabled during auto-refresh', async () => {
- const state$ = new BehaviorSubject(SessionState.Loading);
+ const state$ = new BehaviorSubject(SearchSessionState.Loading);
coreStart.application.currentAppId$ = new BehaviorSubject('discover');
(coreStart.application.capabilities as any) = {
discover: {
storeSearchSession: true,
},
};
- const BackgroundSessionIndicator = createConnectedBackgroundSessionIndicator({
+ const SearchSessionIndicator = createConnectedSearchSessionIndicator({
sessionService: { ...sessionService, state$ },
application: coreStart.application,
timeFilter,
});
- render();
+ render();
- await waitFor(() => screen.getByTestId('backgroundSessionIndicator'));
+ await waitFor(() => screen.getByTestId('searchSessionIndicator'));
- expect(
- screen.getByTestId('backgroundSessionIndicator').querySelector('button')
- ).not.toBeDisabled();
+ expect(screen.getByTestId('searchSessionIndicator').querySelector('button')).not.toBeDisabled();
act(() => {
refreshInterval$.next({ value: 0, pause: false });
});
- expect(screen.getByTestId('backgroundSessionIndicator').querySelector('button')).toBeDisabled();
+ expect(screen.getByTestId('searchSessionIndicator').querySelector('button')).toBeDisabled();
});
diff --git a/x-pack/plugins/data_enhanced/public/search/ui/connected_background_session_indicator/connected_background_session_indicator.tsx b/x-pack/plugins/data_enhanced/public/search/ui/connected_search_session_indicator/connected_search_session_indicator.tsx
similarity index 85%
rename from x-pack/plugins/data_enhanced/public/search/ui/connected_background_session_indicator/connected_background_session_indicator.tsx
rename to x-pack/plugins/data_enhanced/public/search/ui/connected_search_session_indicator/connected_search_session_indicator.tsx
index 1469c96d7166e..5c8c01064bff4 100644
--- a/x-pack/plugins/data_enhanced/public/search/ui/connected_background_session_indicator/connected_background_session_indicator.tsx
+++ b/x-pack/plugins/data_enhanced/public/search/ui/connected_search_session_indicator/connected_search_session_indicator.tsx
@@ -8,22 +8,22 @@ import React from 'react';
import { debounceTime, distinctUntilChanged, map } from 'rxjs/operators';
import useObservable from 'react-use/lib/useObservable';
import { i18n } from '@kbn/i18n';
-import { BackgroundSessionIndicator } from '../background_session_indicator';
+import { SearchSessionIndicator } from '../search_session_indicator';
import { ISessionService, TimefilterContract } from '../../../../../../../src/plugins/data/public/';
import { RedirectAppLinks } from '../../../../../../../src/plugins/kibana_react/public';
import { ApplicationStart } from '../../../../../../../src/core/public';
-export interface BackgroundSessionIndicatorDeps {
+export interface SearchSessionIndicatorDeps {
sessionService: ISessionService;
timeFilter: TimefilterContract;
application: ApplicationStart;
}
-export const createConnectedBackgroundSessionIndicator = ({
+export const createConnectedSearchSessionIndicator = ({
sessionService,
application,
timeFilter,
-}: BackgroundSessionIndicatorDeps): React.FC => {
+}: SearchSessionIndicatorDeps): React.FC => {
const isAutoRefreshEnabled = () => !timeFilter.getRefreshInterval().pause;
const isAutoRefreshEnabled$ = timeFilter
.getRefreshIntervalUpdate$()
@@ -53,7 +53,7 @@ export const createConnectedBackgroundSessionIndicator = ({
if (getCapabilitiesByAppId(application.capabilities, appId)?.storeSearchSession !== true) {
disabled = true;
- disabledReasonText = i18n.translate('xpack.data.backgroundSessionIndicator.noCapability', {
+ disabledReasonText = i18n.translate('xpack.data.searchSessionIndicator.noCapability', {
defaultMessage: "You don't have permissions to send to background.",
});
}
@@ -61,7 +61,7 @@ export const createConnectedBackgroundSessionIndicator = ({
if (autoRefreshEnabled) {
disabled = true;
disabledReasonText = i18n.translate(
- 'xpack.data.backgroundSessionIndicator.disabledDueToAutoRefreshMessage',
+ 'xpack.data.searchSessionIndicator.disabledDueToAutoRefreshMessage',
{
defaultMessage: 'Send to background is not available when auto refresh is enabled.',
}
@@ -71,7 +71,7 @@ export const createConnectedBackgroundSessionIndicator = ({
if (!state) return null;
return (
- {
sessionService.save();
diff --git a/x-pack/plugins/data_enhanced/public/search/ui/connected_background_session_indicator/index.ts b/x-pack/plugins/data_enhanced/public/search/ui/connected_search_session_indicator/index.ts
similarity index 65%
rename from x-pack/plugins/data_enhanced/public/search/ui/connected_background_session_indicator/index.ts
rename to x-pack/plugins/data_enhanced/public/search/ui/connected_search_session_indicator/index.ts
index 223a0537129df..da6ce470e6b81 100644
--- a/x-pack/plugins/data_enhanced/public/search/ui/connected_background_session_indicator/index.ts
+++ b/x-pack/plugins/data_enhanced/public/search/ui/connected_search_session_indicator/index.ts
@@ -5,6 +5,6 @@
*/
export {
- BackgroundSessionIndicatorDeps,
- createConnectedBackgroundSessionIndicator,
-} from './connected_background_session_indicator';
+ SearchSessionIndicatorDeps,
+ createConnectedSearchSessionIndicator,
+} from './connected_search_session_indicator';
diff --git a/x-pack/plugins/data_enhanced/public/search/ui/connected_background_session_indicator/background_session_view_state.ts b/x-pack/plugins/data_enhanced/public/search/ui/connected_search_session_indicator/search_session_view_state.ts
similarity index 85%
rename from x-pack/plugins/data_enhanced/public/search/ui/connected_background_session_indicator/background_session_view_state.ts
rename to x-pack/plugins/data_enhanced/public/search/ui/connected_search_session_indicator/search_session_view_state.ts
index b75c2a536f624..7b9b182453082 100644
--- a/x-pack/plugins/data_enhanced/public/search/ui/connected_background_session_indicator/background_session_view_state.ts
+++ b/x-pack/plugins/data_enhanced/public/search/ui/connected_search_session_indicator/search_session_view_state.ts
@@ -4,14 +4,14 @@
* you may not use this file except in compliance with the Elastic License.
*/
-export enum BackgroundSessionViewState {
+export enum SearchSessionViewState {
/**
* Pending search request has not been sent to the background yet
*/
Loading = 'loading',
/**
- * No action was taken and the page completed loading without background session creation.
+ * No action was taken and the page completed loading without search session creation.
*/
Completed = 'completed',
@@ -22,7 +22,7 @@ export enum BackgroundSessionViewState {
BackgroundLoading = 'backgroundLoading',
/**
- * Page load completed with background session created.
+ * Page load completed with search session created.
*/
BackgroundCompleted = 'backgroundCompleted',
diff --git a/x-pack/plugins/data_enhanced/public/search/ui/index.ts b/x-pack/plugins/data_enhanced/public/search/ui/index.ts
index 04201325eb5db..fce8f215a4b7f 100644
--- a/x-pack/plugins/data_enhanced/public/search/ui/index.ts
+++ b/x-pack/plugins/data_enhanced/public/search/ui/index.ts
@@ -4,4 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/
-export * from './connected_background_session_indicator';
+export * from './connected_search_session_indicator';
diff --git a/x-pack/plugins/data_enhanced/public/search/ui/background_session_indicator/index.tsx b/x-pack/plugins/data_enhanced/public/search/ui/search_session_indicator/index.tsx
similarity index 57%
rename from x-pack/plugins/data_enhanced/public/search/ui/background_session_indicator/index.tsx
rename to x-pack/plugins/data_enhanced/public/search/ui/search_session_indicator/index.tsx
index 55c8c453dd5d2..16ee6b49a761f 100644
--- a/x-pack/plugins/data_enhanced/public/search/ui/background_session_indicator/index.tsx
+++ b/x-pack/plugins/data_enhanced/public/search/ui/search_session_indicator/index.tsx
@@ -6,8 +6,8 @@
import { EuiDelayRender, EuiLoadingSpinner } from '@elastic/eui';
import React from 'react';
-import type { BackgroundSessionIndicatorProps } from './background_session_indicator';
-export type { BackgroundSessionIndicatorProps };
+import type { SearchSessionIndicatorProps } from './search_session_indicator';
+export type { SearchSessionIndicatorProps };
const Fallback = () => (
@@ -15,9 +15,9 @@ const Fallback = () => (
);
-const LazyBackgroundSessionIndicator = React.lazy(() => import('./background_session_indicator'));
-export const BackgroundSessionIndicator = (props: BackgroundSessionIndicatorProps) => (
+const LazySearchSessionIndicator = React.lazy(() => import('./search_session_indicator'));
+export const SearchSessionIndicator = (props: SearchSessionIndicatorProps) => (
}>
-
+
);
diff --git a/x-pack/plugins/data_enhanced/public/search/ui/background_session_indicator/background_session_indicator.scss b/x-pack/plugins/data_enhanced/public/search/ui/search_session_indicator/search_session_indicator.scss
similarity index 69%
rename from x-pack/plugins/data_enhanced/public/search/ui/background_session_indicator/background_session_indicator.scss
rename to x-pack/plugins/data_enhanced/public/search/ui/search_session_indicator/search_session_indicator.scss
index 2d13d320ae78b..6f3ae5b5846fd 100644
--- a/x-pack/plugins/data_enhanced/public/search/ui/background_session_indicator/background_session_indicator.scss
+++ b/x-pack/plugins/data_enhanced/public/search/ui/search_session_indicator/search_session_indicator.scss
@@ -1,14 +1,14 @@
-.backgroundSessionIndicator {
+.searchSessionIndicator {
padding: 0 $euiSizeXS;
}
@include euiBreakpoint('xs', 's') {
- .backgroundSessionIndicator__popoverContainer.euiFlexGroup--responsive .euiFlexItem {
+ .searchSessionIndicator__popoverContainer.euiFlexGroup--responsive .euiFlexItem {
margin-bottom: $euiSizeXS !important;
}
}
-.backgroundSessionIndicator__verticalDivider {
+.searchSessionIndicator__verticalDivider {
@include euiBreakpoint('xs', 's') {
margin-left: $euiSizeXS;
padding-left: $euiSizeXS;
diff --git a/x-pack/plugins/data_enhanced/public/search/ui/search_session_indicator/search_session_indicator.stories.tsx b/x-pack/plugins/data_enhanced/public/search/ui/search_session_indicator/search_session_indicator.stories.tsx
new file mode 100644
index 0000000000000..f3b526a8743ea
--- /dev/null
+++ b/x-pack/plugins/data_enhanced/public/search/ui/search_session_indicator/search_session_indicator.stories.tsx
@@ -0,0 +1,39 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+import React from 'react';
+import { storiesOf } from '@storybook/react';
+import { SearchSessionIndicator } from './search_session_indicator';
+import { SearchSessionState } from '../../../../../../../src/plugins/data/public';
+
+storiesOf('components/SearchSessionIndicator', module).add('default', () => (
+ <>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+));
diff --git a/x-pack/plugins/data_enhanced/public/search/ui/background_session_indicator/background_session_indicator.test.tsx b/x-pack/plugins/data_enhanced/public/search/ui/search_session_indicator/search_session_indicator.test.tsx
similarity index 60%
rename from x-pack/plugins/data_enhanced/public/search/ui/background_session_indicator/background_session_indicator.test.tsx
rename to x-pack/plugins/data_enhanced/public/search/ui/search_session_indicator/search_session_indicator.test.tsx
index b7d342300f311..6cefa1237f357 100644
--- a/x-pack/plugins/data_enhanced/public/search/ui/background_session_indicator/background_session_indicator.test.tsx
+++ b/x-pack/plugins/data_enhanced/public/search/ui/search_session_indicator/search_session_indicator.test.tsx
@@ -7,9 +7,9 @@
import React, { ReactNode } from 'react';
import { screen, render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
-import { BackgroundSessionIndicator } from './background_session_indicator';
+import { SearchSessionIndicator } from './search_session_indicator';
import { IntlProvider } from 'react-intl';
-import { SessionState } from '../../../../../../../src/plugins/data/public';
+import { SearchSessionState } from '../../../../../../../src/plugins/data/public';
function Container({ children }: { children?: ReactNode }) {
return {children};
@@ -19,12 +19,12 @@ test('Loading state', async () => {
const onCancel = jest.fn();
render(
-
+
);
- await userEvent.click(screen.getByLabelText('Loading results'));
- await userEvent.click(screen.getByText('Cancel'));
+ await userEvent.click(screen.getByLabelText('Loading'));
+ await userEvent.click(screen.getByText('Cancel session'));
expect(onCancel).toBeCalled();
});
@@ -33,12 +33,12 @@ test('Completed state', async () => {
const onSave = jest.fn();
render(
-
+
);
- await userEvent.click(screen.getByLabelText('Results loaded'));
- await userEvent.click(screen.getByText('Save'));
+ await userEvent.click(screen.getByLabelText('Loaded'));
+ await userEvent.click(screen.getByText('Save session'));
expect(onSave).toBeCalled();
});
@@ -47,12 +47,12 @@ test('Loading in the background state', async () => {
const onCancel = jest.fn();
render(
-
+
);
await userEvent.click(screen.getByLabelText('Loading results in the background'));
- await userEvent.click(screen.getByText('Cancel'));
+ await userEvent.click(screen.getByText('Cancel session'));
expect(onCancel).toBeCalled();
});
@@ -60,15 +60,15 @@ test('Loading in the background state', async () => {
test('BackgroundCompleted state', async () => {
render(
-
);
await userEvent.click(screen.getByLabelText('Results loaded in the background'));
- expect(screen.getByRole('link', { name: 'View background sessions' }).getAttribute('href')).toBe(
+ expect(screen.getByRole('link', { name: 'View all sessions' }).getAttribute('href')).toBe(
'__link__'
);
});
@@ -77,7 +77,7 @@ test('Restored state', async () => {
const onRefresh = jest.fn();
render(
-
+
);
@@ -91,7 +91,7 @@ test('Canceled state', async () => {
const onRefresh = jest.fn();
render(
-
+
);
@@ -104,9 +104,9 @@ test('Canceled state', async () => {
test('Disabled state', async () => {
render(
-
+
);
- expect(screen.getByTestId('backgroundSessionIndicator').querySelector('button')).toBeDisabled();
+ expect(screen.getByTestId('searchSessionIndicator').querySelector('button')).toBeDisabled();
});
diff --git a/x-pack/plugins/data_enhanced/public/search/ui/background_session_indicator/background_session_indicator.tsx b/x-pack/plugins/data_enhanced/public/search/ui/search_session_indicator/search_session_indicator.tsx
similarity index 57%
rename from x-pack/plugins/data_enhanced/public/search/ui/background_session_indicator/background_session_indicator.tsx
rename to x-pack/plugins/data_enhanced/public/search/ui/search_session_indicator/search_session_indicator.tsx
index ce77686c4f3c1..ed022e18c34d7 100644
--- a/x-pack/plugins/data_enhanced/public/search/ui/background_session_indicator/background_session_indicator.tsx
+++ b/x-pack/plugins/data_enhanced/public/search/ui/search_session_indicator/search_session_indicator.tsx
@@ -20,31 +20,31 @@ import {
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
-import './background_session_indicator.scss';
-import { SessionState } from '../../../../../../../src/plugins/data/public/';
+import './search_session_indicator.scss';
+import { SearchSessionState } from '../../../../../../../src/plugins/data/public';
-export interface BackgroundSessionIndicatorProps {
- state: SessionState;
+export interface SearchSessionIndicatorProps {
+ state: SearchSessionState;
onContinueInBackground?: () => void;
onCancel?: () => void;
- viewBackgroundSessionsLink?: string;
+ viewSearchSessionsLink?: string;
onSaveResults?: () => void;
onRefresh?: () => void;
disabled?: boolean;
disabledReasonText?: string;
}
-type ActionButtonProps = BackgroundSessionIndicatorProps & { buttonProps: EuiButtonEmptyProps };
+type ActionButtonProps = SearchSessionIndicatorProps & { buttonProps: EuiButtonEmptyProps };
const CancelButton = ({ onCancel = () => {}, buttonProps = {} }: ActionButtonProps) => (
);
@@ -55,28 +55,28 @@ const ContinueInBackgroundButton = ({
}: ActionButtonProps) => (
);
-const ViewBackgroundSessionsButton = ({
- viewBackgroundSessionsLink = 'management',
+const ViewAllSearchSessionsButton = ({
+ viewSearchSessionsLink = 'management',
buttonProps = {},
}: ActionButtonProps) => (
);
@@ -84,11 +84,11 @@ const ViewBackgroundSessionsButton = ({
const RefreshButton = ({ onRefresh = () => {}, buttonProps = {} }: ActionButtonProps) => (
@@ -97,18 +97,18 @@ const RefreshButton = ({ onRefresh = () => {}, buttonProps = {} }: ActionButtonP
const SaveButton = ({ onSaveResults = () => {}, buttonProps = {} }: ActionButtonProps) => (
);
-const backgroundSessionIndicatorViewStateToProps: {
- [state in SessionState]: {
+const searchSessionIndicatorViewStateToProps: {
+ [state in SearchSessionState]: {
button: Pick & {
tooltipText: string;
};
@@ -119,162 +119,151 @@ const backgroundSessionIndicatorViewStateToProps: {
};
} | null;
} = {
- [SessionState.None]: null,
- [SessionState.Loading]: {
+ [SearchSessionState.None]: null,
+ [SearchSessionState.Loading]: {
button: {
color: 'subdued',
iconType: 'clock',
'aria-label': i18n.translate(
- 'xpack.data.backgroundSessionIndicator.loadingResultsIconAriaLabel',
- { defaultMessage: 'Loading results' }
+ 'xpack.data.searchSessionIndicator.loadingResultsIconAriaLabel',
+ { defaultMessage: 'Loading' }
),
tooltipText: i18n.translate(
- 'xpack.data.backgroundSessionIndicator.loadingResultsIconTooltipText',
- { defaultMessage: 'Loading results' }
+ 'xpack.data.searchSessionIndicator.loadingResultsIconTooltipText',
+ { defaultMessage: 'Loading' }
),
},
popover: {
- text: i18n.translate('xpack.data.backgroundSessionIndicator.loadingResultsText', {
+ text: i18n.translate('xpack.data.searchSessionIndicator.loadingResultsText', {
defaultMessage: 'Loading',
}),
primaryAction: CancelButton,
secondaryAction: ContinueInBackgroundButton,
},
},
- [SessionState.Completed]: {
+ [SearchSessionState.Completed]: {
button: {
color: 'subdued',
iconType: 'checkInCircleFilled',
- 'aria-label': i18n.translate(
- 'xpack.data.backgroundSessionIndicator.resultsLoadedIconAriaLabel',
- {
- defaultMessage: 'Results loaded',
- }
- ),
+ 'aria-label': i18n.translate('xpack.data.searchSessionIndicator.resultsLoadedIconAriaLabel', {
+ defaultMessage: 'Loaded',
+ }),
tooltipText: i18n.translate(
- 'xpack.data.backgroundSessionIndicator.resultsLoadedIconTooltipText',
+ 'xpack.data.searchSessionIndicator.resultsLoadedIconTooltipText',
{
defaultMessage: 'Results loaded',
}
),
},
popover: {
- text: i18n.translate('xpack.data.backgroundSessionIndicator.resultsLoadedText', {
- defaultMessage: 'Results loaded',
+ text: i18n.translate('xpack.data.searchSessionIndicator.resultsLoadedText', {
+ defaultMessage: 'Loaded',
}),
primaryAction: SaveButton,
- secondaryAction: ViewBackgroundSessionsButton,
+ secondaryAction: ViewAllSearchSessionsButton,
},
},
- [SessionState.BackgroundLoading]: {
+ [SearchSessionState.BackgroundLoading]: {
button: {
iconType: EuiLoadingSpinner,
'aria-label': i18n.translate(
- 'xpack.data.backgroundSessionIndicator.loadingInTheBackgroundIconAriaLabel',
+ 'xpack.data.searchSessionIndicator.loadingInTheBackgroundIconAriaLabel',
{
defaultMessage: 'Loading results in the background',
}
),
tooltipText: i18n.translate(
- 'xpack.data.backgroundSessionIndicator.loadingInTheBackgroundIconTooltipText',
+ 'xpack.data.searchSessionIndicator.loadingInTheBackgroundIconTooltipText',
{
defaultMessage: 'Loading results in the background',
}
),
},
popover: {
- text: i18n.translate('xpack.data.backgroundSessionIndicator.loadingInTheBackgroundText', {
+ text: i18n.translate('xpack.data.searchSessionIndicator.loadingInTheBackgroundText', {
defaultMessage: 'Loading in the background',
}),
primaryAction: CancelButton,
- secondaryAction: ViewBackgroundSessionsButton,
+ secondaryAction: ViewAllSearchSessionsButton,
},
},
- [SessionState.BackgroundCompleted]: {
+ [SearchSessionState.BackgroundCompleted]: {
button: {
color: 'success',
iconType: 'checkInCircleFilled',
'aria-label': i18n.translate(
- 'xpack.data.backgroundSessionIndicator.resultLoadedInTheBackgroundIconAraText',
+ 'xpack.data.searchSessionIndicator.resultLoadedInTheBackgroundIconAraText',
{
defaultMessage: 'Results loaded in the background',
}
),
tooltipText: i18n.translate(
- 'xpack.data.backgroundSessionIndicator.resultLoadedInTheBackgroundIconTooltipText',
+ 'xpack.data.searchSessionIndicator.resultLoadedInTheBackgroundIconTooltipText',
{
defaultMessage: 'Results loaded in the background',
}
),
},
popover: {
- text: i18n.translate(
- 'xpack.data.backgroundSessionIndicator.resultLoadedInTheBackgroundText',
- {
- defaultMessage: 'Results loaded',
- }
- ),
- primaryAction: ViewBackgroundSessionsButton,
+ text: i18n.translate('xpack.data.searchSessionIndicator.resultLoadedInTheBackgroundText', {
+ defaultMessage: 'Loaded',
+ }),
+ primaryAction: ViewAllSearchSessionsButton,
},
},
- [SessionState.Restored]: {
+ [SearchSessionState.Restored]: {
button: {
color: 'warning',
iconType: 'refresh',
'aria-label': i18n.translate(
- 'xpack.data.backgroundSessionIndicator.restoredResultsIconAriaLabel',
- {
- defaultMessage: 'Results no longer current',
- }
- ),
- tooltipText: i18n.translate(
- 'xpack.data.backgroundSessionIndicator.restoredResultsTooltipText',
+ 'xpack.data.searchSessionIndicator.restoredResultsIconAriaLabel',
{
defaultMessage: 'Results no longer current',
}
),
+ tooltipText: i18n.translate('xpack.data.searchSessionIndicator.restoredResultsTooltipText', {
+ defaultMessage: 'Results no longer current',
+ }),
},
popover: {
- text: i18n.translate('xpack.data.backgroundSessionIndicator.restoredText', {
+ text: i18n.translate('xpack.data.searchSessionIndicator.restoredText', {
defaultMessage: 'Results no longer current',
}),
primaryAction: RefreshButton,
- secondaryAction: ViewBackgroundSessionsButton,
+ secondaryAction: ViewAllSearchSessionsButton,
},
},
- [SessionState.Canceled]: {
+ [SearchSessionState.Canceled]: {
button: {
color: 'subdued',
iconType: 'refresh',
- 'aria-label': i18n.translate('xpack.data.backgroundSessionIndicator.canceledIconAriaLabel', {
+ 'aria-label': i18n.translate('xpack.data.searchSessionIndicator.canceledIconAriaLabel', {
defaultMessage: 'Canceled',
}),
- tooltipText: i18n.translate('xpack.data.backgroundSessionIndicator.canceledTooltipText', {
+ tooltipText: i18n.translate('xpack.data.searchSessionIndicator.canceledTooltipText', {
defaultMessage: 'Search was canceled',
}),
},
popover: {
- text: i18n.translate('xpack.data.backgroundSessionIndicator.canceledText', {
+ text: i18n.translate('xpack.data.searchSessionIndicator.canceledText', {
defaultMessage: 'Search was canceled',
}),
primaryAction: RefreshButton,
- secondaryAction: ViewBackgroundSessionsButton,
+ secondaryAction: ViewAllSearchSessionsButton,
},
},
};
-const VerticalDivider: React.FC = () => (
-
-);
+const VerticalDivider: React.FC = () => ;
-export const BackgroundSessionIndicator: React.FC = (props) => {
+export const SearchSessionIndicator: React.FC = (props) => {
const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);
const onButtonClick = () => setIsPopoverOpen((isOpen) => !isOpen);
const closePopover = () => setIsPopoverOpen(false);
- if (!backgroundSessionIndicatorViewStateToProps[props.state]) return null;
+ if (!searchSessionIndicatorViewStateToProps[props.state]) return null;
- const { button, popover } = backgroundSessionIndicatorViewStateToProps[props.state]!;
+ const { button, popover } = searchSessionIndicatorViewStateToProps[props.state]!;
return (
@@ -302,8 +291,8 @@ export const BackgroundSessionIndicator: React.FC
@@ -332,4 +321,4 @@ export const BackgroundSessionIndicator: React.FC {
private readonly logger: Logger;
- private sessionService!: BackgroundSessionService;
+ private sessionService!: SearchSessionService;
constructor(private initializerContext: PluginInitializerContext) {
this.logger = initializerContext.logger.get('data_enhanced');
@@ -38,7 +38,7 @@ export class EnhancedDataServerPlugin implements Plugin new Promise((resolve) => setImmediate(resolve));
-describe('BackgroundSessionService', () => {
+describe('SearchSessionService', () => {
let savedObjectsClient: jest.Mocked;
- let service: BackgroundSessionService;
+ let service: SearchSessionService;
const MOCK_SESSION_ID = 'session-id-mock';
const MOCK_ASYNC_ID = '123456';
@@ -93,7 +93,7 @@ describe('BackgroundSessionService', () => {
const sessionId = 'd7170a35-7e2c-48d6-8dec-9a056721b489';
const mockSavedObject: SavedObject = {
id: 'd7170a35-7e2c-48d6-8dec-9a056721b489',
- type: BACKGROUND_SESSION_TYPE,
+ type: SEARCH_SESSION_TYPE,
attributes: {
name: 'my_name',
appId: 'my_app_id',
@@ -110,7 +110,7 @@ describe('BackgroundSessionService', () => {
warn: jest.fn(),
error: jest.fn(),
};
- service = new BackgroundSessionService(mockLogger);
+ service = new SearchSessionService(mockLogger);
});
it('search throws if `name` is not provided', () => {
@@ -131,7 +131,7 @@ describe('BackgroundSessionService', () => {
const response = await service.get(sessionId, { savedObjectsClient });
expect(response).toBe(mockSavedObject);
- expect(savedObjectsClient.get).toHaveBeenCalledWith(BACKGROUND_SESSION_TYPE, sessionId);
+ expect(savedObjectsClient.get).toHaveBeenCalledWith(SEARCH_SESSION_TYPE, sessionId);
});
it('find calls saved objects client', async () => {
@@ -153,7 +153,7 @@ describe('BackgroundSessionService', () => {
expect(response).toBe(mockResponse);
expect(savedObjectsClient.find).toHaveBeenCalledWith({
...options,
- type: BACKGROUND_SESSION_TYPE,
+ type: SEARCH_SESSION_TYPE,
});
});
@@ -169,7 +169,7 @@ describe('BackgroundSessionService', () => {
expect(response).toBe(mockUpdateSavedObject);
expect(savedObjectsClient.update).toHaveBeenCalledWith(
- BACKGROUND_SESSION_TYPE,
+ SEARCH_SESSION_TYPE,
sessionId,
attributes
);
@@ -181,14 +181,14 @@ describe('BackgroundSessionService', () => {
const response = await service.delete(sessionId, { savedObjectsClient });
expect(response).toEqual({});
- expect(savedObjectsClient.delete).toHaveBeenCalledWith(BACKGROUND_SESSION_TYPE, sessionId);
+ expect(savedObjectsClient.delete).toHaveBeenCalledWith(SEARCH_SESSION_TYPE, sessionId);
});
describe('search', () => {
const mockSearch = jest.fn().mockReturnValue(of({}));
const mockStrategy = { search: mockSearch };
const mockSearchDeps = {} as SearchStrategyDependencies;
- const mockDeps = {} as BackgroundSessionDependencies;
+ const mockDeps = {} as SearchSessionDependencies;
beforeEach(() => {
mockSearch.mockClear();
@@ -300,14 +300,14 @@ describe('BackgroundSessionService', () => {
);
expect(savedObjectsClient.create).toHaveBeenCalledWith(
- BACKGROUND_SESSION_TYPE,
+ SEARCH_SESSION_TYPE,
{
name,
created,
expires,
initialState: {},
restoreState: {},
- status: BackgroundSessionStatus.IN_PROGRESS,
+ status: SearchSessionStatus.IN_PROGRESS,
idMapping: {},
appId,
urlGeneratorId,
@@ -335,7 +335,7 @@ describe('BackgroundSessionService', () => {
{ savedObjectsClient }
);
- expect(savedObjectsClient.update).toHaveBeenCalledWith(BACKGROUND_SESSION_TYPE, sessionId, {
+ expect(savedObjectsClient.update).toHaveBeenCalledWith(SEARCH_SESSION_TYPE, sessionId, {
idMapping: {
[requestHash]: {
id: searchId,
@@ -385,7 +385,7 @@ describe('BackgroundSessionService', () => {
const searchId = 'FnpFYlBpeXdCUTMyZXhCLTc1TWFKX0EbdDFDTzJzTE1Sck9PVTBIcW1iU05CZzo4MDA0';
const mockSession = {
id: 'd7170a35-7e2c-48d6-8dec-9a056721b489',
- type: BACKGROUND_SESSION_TYPE,
+ type: SEARCH_SESSION_TYPE,
attributes: {
name: 'my_name',
appId: 'my_app_id',
diff --git a/x-pack/plugins/data_enhanced/server/search/session/session_service.ts b/x-pack/plugins/data_enhanced/server/search/session/session_service.ts
index 01291919001f5..8f590e1639524 100644
--- a/x-pack/plugins/data_enhanced/server/search/session/session_service.ts
+++ b/x-pack/plugins/data_enhanced/server/search/session/session_service.ts
@@ -30,12 +30,12 @@ import {
SearchStrategyDependencies,
} from '../../../../../../src/plugins/data/server';
import {
- BackgroundSessionSavedObjectAttributes,
- BackgroundSessionFindOptions,
- BackgroundSessionSearchInfo,
- BackgroundSessionStatus,
+ SearchSessionSavedObjectAttributes,
+ SearchSessionFindOptions,
+ SearchSessionRequestInfo,
+ SearchSessionStatus,
} from '../../../common';
-import { BACKGROUND_SESSION_TYPE } from '../../saved_objects';
+import { SEARCH_SESSION_TYPE } from '../../saved_objects';
import { createRequestHash } from './utils';
import { ConfigSchema } from '../../../config';
@@ -45,17 +45,17 @@ export const INMEM_TRACKING_INTERVAL = 10 * 1000;
export const INMEM_TRACKING_TIMEOUT_SEC = 60;
export const MAX_UPDATE_RETRIES = 3;
-export interface BackgroundSessionDependencies {
+export interface SearchSessionDependencies {
savedObjectsClient: SavedObjectsClientContract;
}
export interface SessionInfo {
insertTime: Moment;
retryCount: number;
- ids: Map;
+ ids: Map;
}
-export class BackgroundSessionService implements ISessionService {
+export class SearchSessionService implements ISessionService {
/**
* Map of sessionId to { [requestHash]: searchId }
* @private
@@ -79,7 +79,7 @@ export class BackgroundSessionService implements ISessionService {
const config = await config$.pipe(first()).toPromise();
if (config.search.sendToBackground.enabled) {
this.logger.debug(`setupMonitoring | Enabling monitoring`);
- const internalRepo = core.savedObjects.createInternalRepository([BACKGROUND_SESSION_TYPE]);
+ const internalRepo = core.savedObjects.createInternalRepository([SEARCH_SESSION_TYPE]);
this.internalSavedObjectsClient = new SavedObjectsClient(internalRepo);
this.monitorMappedIds();
}
@@ -92,7 +92,7 @@ export class BackgroundSessionService implements ISessionService {
private sessionIdsAsFilters(sessionIds: string[]): KueryNode {
return nodeBuilder.or(
sessionIds.map((id) => {
- return nodeBuilder.is(`${BACKGROUND_SESSION_TYPE}.attributes.sessionId`, id);
+ return nodeBuilder.is(`${SEARCH_SESSION_TYPE}.attributes.sessionId`, id);
})
);
}
@@ -107,9 +107,9 @@ export class BackgroundSessionService implements ISessionService {
*/
private async getAllMappedSavedObjects() {
const filter = this.sessionIdsAsFilters(Array.from(this.sessionSearchMap.keys()));
- const res = await this.internalSavedObjectsClient.find({
+ const res = await this.internalSavedObjectsClient.find({
perPage: INMEM_MAX_SESSIONS, // If there are more sessions in memory, they will be synced when some items are cleared out.
- type: BACKGROUND_SESSION_TYPE,
+ type: SEARCH_SESSION_TYPE,
filter,
namespaces: ['*'],
});
@@ -175,13 +175,13 @@ export class BackgroundSessionService implements ISessionService {
}
private async updateAllSavedObjects(
- activeMappingObjects: Array>
+ activeMappingObjects: Array>
) {
if (!activeMappingObjects.length) return [];
this.logger.debug(`updateAllSavedObjects | Updating ${activeMappingObjects.length} items`);
const updatedSessions: Array<
- SavedObjectsBulkUpdateObject
+ SavedObjectsBulkUpdateObject
> = activeMappingObjects
.filter((so) => !so.error)
.map((sessionSavedObject) => {
@@ -197,7 +197,7 @@ export class BackgroundSessionService implements ISessionService {
};
});
- const updateResults = await this.internalSavedObjectsClient.bulkUpdate(
+ const updateResults = await this.internalSavedObjectsClient.bulkUpdate(
updatedSessions
);
return updateResults.saved_objects;
@@ -208,7 +208,7 @@ export class BackgroundSessionService implements ISessionService {
searchRequest: Request,
options: ISearchOptions,
searchDeps: SearchStrategyDependencies,
- deps: BackgroundSessionDependencies
+ deps: SearchSessionDependencies
): Observable {
// If this is a restored background search session, look up the ID using the provided sessionId
const getSearchRequest = async () =>
@@ -236,12 +236,12 @@ export class BackgroundSessionService implements ISessionService {
appId,
created = new Date().toISOString(),
expires = new Date(Date.now() + DEFAULT_EXPIRATION).toISOString(),
- status = BackgroundSessionStatus.IN_PROGRESS,
+ status = SearchSessionStatus.IN_PROGRESS,
urlGeneratorId,
initialState = {},
restoreState = {},
- }: Partial,
- { savedObjectsClient }: BackgroundSessionDependencies
+ }: Partial,
+ { savedObjectsClient }: SearchSessionDependencies
) => {
if (!name) throw new Error('Name is required');
if (!appId) throw new Error('AppId is required');
@@ -261,8 +261,8 @@ export class BackgroundSessionService implements ISessionService {
appId,
sessionId,
};
- const session = await savedObjectsClient.create(
- BACKGROUND_SESSION_TYPE,
+ const session = await savedObjectsClient.create(
+ SEARCH_SESSION_TYPE,
attributes,
{ id: sessionId }
);
@@ -271,42 +271,42 @@ export class BackgroundSessionService implements ISessionService {
};
// TODO: Throw an error if this session doesn't belong to this user
- public get = (sessionId: string, { savedObjectsClient }: BackgroundSessionDependencies) => {
+ public get = (sessionId: string, { savedObjectsClient }: SearchSessionDependencies) => {
this.logger.debug(`get | ${sessionId}`);
- return savedObjectsClient.get(
- BACKGROUND_SESSION_TYPE,
+ return savedObjectsClient.get(
+ SEARCH_SESSION_TYPE,
sessionId
);
};
// TODO: Throw an error if this session doesn't belong to this user
public find = (
- options: BackgroundSessionFindOptions,
- { savedObjectsClient }: BackgroundSessionDependencies
+ options: SearchSessionFindOptions,
+ { savedObjectsClient }: SearchSessionDependencies
) => {
- return savedObjectsClient.find({
+ return savedObjectsClient.find({
...options,
- type: BACKGROUND_SESSION_TYPE,
+ type: SEARCH_SESSION_TYPE,
});
};
// TODO: Throw an error if this session doesn't belong to this user
public update = (
sessionId: string,
- attributes: Partial,
- { savedObjectsClient }: BackgroundSessionDependencies
+ attributes: Partial,
+ { savedObjectsClient }: SearchSessionDependencies
) => {
this.logger.debug(`update | ${sessionId}`);
- return savedObjectsClient.update(
- BACKGROUND_SESSION_TYPE,
+ return savedObjectsClient.update(
+ SEARCH_SESSION_TYPE,
sessionId,
attributes
);
};
// TODO: Throw an error if this session doesn't belong to this user
- public delete = (sessionId: string, { savedObjectsClient }: BackgroundSessionDependencies) => {
- return savedObjectsClient.delete(BACKGROUND_SESSION_TYPE, sessionId);
+ public delete = (sessionId: string, { savedObjectsClient }: SearchSessionDependencies) => {
+ return savedObjectsClient.delete(SEARCH_SESSION_TYPE, sessionId);
};
/**
@@ -318,7 +318,7 @@ export class BackgroundSessionService implements ISessionService {
searchRequest: IKibanaSearchRequest,
searchId: string,
{ sessionId, isStored, strategy }: ISearchOptions,
- deps: BackgroundSessionDependencies
+ deps: SearchSessionDependencies
) => {
if (!sessionId || !searchId) return;
this.logger.debug(`trackId | ${sessionId} | ${searchId}`);
@@ -339,7 +339,7 @@ export class BackgroundSessionService implements ISessionService {
const map = this.sessionSearchMap.get(sessionId) ?? {
insertTime: moment(),
retryCount: 0,
- ids: new Map(),
+ ids: new Map(),
};
map.ids.set(requestHash, searchInfo);
this.sessionSearchMap.set(sessionId, map);
@@ -354,7 +354,7 @@ export class BackgroundSessionService implements ISessionService {
public getId = async (
searchRequest: IKibanaSearchRequest,
{ sessionId, isStored, isRestore }: ISearchOptions,
- deps: BackgroundSessionDependencies
+ deps: SearchSessionDependencies
) => {
if (!sessionId) {
throw new Error('Session ID is required');
@@ -376,7 +376,7 @@ export class BackgroundSessionService implements ISessionService {
public asScopedProvider = ({ savedObjects }: CoreStart) => {
return (request: KibanaRequest) => {
const savedObjectsClient = savedObjects.getScopedClient(request, {
- includedHiddenTypes: [BACKGROUND_SESSION_TYPE],
+ includedHiddenTypes: [SEARCH_SESSION_TYPE],
});
const deps = { savedObjectsClient };
return {
@@ -384,11 +384,11 @@ export class BackgroundSessionService implements ISessionService {
strategy: ISearchStrategy,
...args: Parameters['search']>
) => this.search(strategy, ...args, deps),
- save: (sessionId: string, attributes: Partial) =>
+ save: (sessionId: string, attributes: Partial) =>
this.save(sessionId, attributes, deps),
get: (sessionId: string) => this.get(sessionId, deps),
- find: (options: BackgroundSessionFindOptions) => this.find(options, deps),
- update: (sessionId: string, attributes: Partial) =>
+ find: (options: SearchSessionFindOptions) => this.find(options, deps),
+ update: (sessionId: string, attributes: Partial) =>
this.update(sessionId, attributes, deps),
delete: (sessionId: string) => this.delete(sessionId, deps),
};
diff --git a/x-pack/plugins/data_enhanced/tsconfig.json b/x-pack/plugins/data_enhanced/tsconfig.json
new file mode 100644
index 0000000000000..28969652f23df
--- /dev/null
+++ b/x-pack/plugins/data_enhanced/tsconfig.json
@@ -0,0 +1,28 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "composite": true,
+ "outDir": "./target/types",
+ "emitDeclarationOnly": true,
+ "declaration": true,
+ "declarationMap": true,
+ },
+ "include": [
+ "common/**/*",
+ "public/**/*",
+ "server/**/*",
+ "config.ts",
+ // have to declare *.json explicitly due to https://github.com/microsoft/TypeScript/issues/25636
+ "public/autocomplete/providers/kql_query_suggestion/__fixtures__/*.json"
+ ],
+ "references": [
+ { "path": "../../../src/core/tsconfig.json" },
+ { "path": "../../../src/plugins/bfetch/tsconfig.json" },
+ { "path": "../../../src/plugins/data/tsconfig.json" },
+ { "path": "../../../src/plugins/kibana_react/tsconfig.json" },
+ { "path": "../../../src/plugins/kibana_utils/tsconfig.json" },
+ { "path": "../../../src/plugins/usage_collection/tsconfig.json" },
+
+ { "path": "../features/tsconfig.json" },
+ ]
+}
diff --git a/x-pack/plugins/embeddable_enhanced/tsconfig.json b/x-pack/plugins/embeddable_enhanced/tsconfig.json
new file mode 100644
index 0000000000000..6e9eb69585cbc
--- /dev/null
+++ b/x-pack/plugins/embeddable_enhanced/tsconfig.json
@@ -0,0 +1,21 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "composite": true,
+ "outDir": "./target/types",
+ "emitDeclarationOnly": true,
+ "declaration": true,
+ "declarationMap": true
+ },
+ "include": [
+ "public/**/*",
+ ],
+ "references": [
+ { "path": "../../../src/core/tsconfig.json" },
+ { "path": "../../../src/plugins/embeddable/tsconfig.json" },
+ { "path": "../../../src/plugins/kibana_react/tsconfig.json" },
+ { "path": "../../../src/plugins/ui_actions/tsconfig.json" },
+
+ { "path": "../ui_actions_enhanced/tsconfig.json" },
+ ]
+}
diff --git a/x-pack/plugins/features/server/__snapshots__/oss_features.test.ts.snap b/x-pack/plugins/features/server/__snapshots__/oss_features.test.ts.snap
index b1d7a2d434968..8432fdac93a9a 100644
--- a/x-pack/plugins/features/server/__snapshots__/oss_features.test.ts.snap
+++ b/x-pack/plugins/features/server/__snapshots__/oss_features.test.ts.snap
@@ -73,7 +73,7 @@ Array [
"dashboard",
"query",
"url",
- "background-session",
+ "search-session",
],
"read": Array [
"index-pattern",
@@ -207,7 +207,7 @@ Array [
"query",
"index-pattern",
"url",
- "background-session",
+ "search-session",
],
"read": Array [],
},
@@ -559,7 +559,7 @@ Array [
"dashboard",
"query",
"url",
- "background-session",
+ "search-session",
],
"read": Array [
"index-pattern",
@@ -693,7 +693,7 @@ Array [
"query",
"index-pattern",
"url",
- "background-session",
+ "search-session",
],
"read": Array [],
},
diff --git a/x-pack/plugins/features/server/feature_privilege_iterator.js b/x-pack/plugins/features/server/feature_privilege_iterator.js
new file mode 100644
index 0000000000000..b36cd9745de12
--- /dev/null
+++ b/x-pack/plugins/features/server/feature_privilege_iterator.js
@@ -0,0 +1,9 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+// the file created to remove TS cicular dependency between features and security pluin
+// eslint-disable-next-line @kbn/eslint/no-restricted-paths
+export { featurePrivilegeIterator } from '../../security/server/authorization';
diff --git a/x-pack/plugins/features/server/oss_features.test.ts b/x-pack/plugins/features/server/oss_features.test.ts
index a22e95105ba05..6b2ce6fd70c97 100644
--- a/x-pack/plugins/features/server/oss_features.test.ts
+++ b/x-pack/plugins/features/server/oss_features.test.ts
@@ -5,7 +5,8 @@
*/
import { buildOSSFeatures } from './oss_features';
-import { featurePrivilegeIterator } from '../../security/server/authorization';
+// @ts-expect-error
+import { featurePrivilegeIterator } from './feature_privilege_iterator';
import { KibanaFeature } from '.';
import { LicenseType } from '../../licensing/server';
diff --git a/x-pack/plugins/features/server/oss_features.ts b/x-pack/plugins/features/server/oss_features.ts
index c38fdf8b29d12..daa5d4b5d4219 100644
--- a/x-pack/plugins/features/server/oss_features.ts
+++ b/x-pack/plugins/features/server/oss_features.ts
@@ -89,7 +89,7 @@ export const buildOSSFeatures = ({ savedObjectTypes, includeTimelion }: BuildOSS
),
includeIn: 'all',
savedObject: {
- all: ['background-session'],
+ all: ['search-session'],
read: [],
},
ui: ['storeSearchSession'],
@@ -254,7 +254,7 @@ export const buildOSSFeatures = ({ savedObjectTypes, includeTimelion }: BuildOSS
),
includeIn: 'all',
savedObject: {
- all: ['background-session'],
+ all: ['search-session'],
read: [],
},
ui: ['storeSearchSession'],
diff --git a/x-pack/plugins/features/server/plugin.ts b/x-pack/plugins/features/server/plugin.ts
index 857bba4c606d4..c3e2ad06fb85c 100644
--- a/x-pack/plugins/features/server/plugin.ts
+++ b/x-pack/plugins/features/server/plugin.ts
@@ -13,7 +13,6 @@ import {
PluginInitializerContext,
} from '../../../../src/core/server';
import { Capabilities as UICapabilities } from '../../../../src/core/server';
-import { PluginSetupContract as TimelionSetupContract } from '../../../../src/plugins/vis_type_timelion/server';
import { FeatureRegistry } from './feature_registry';
import { uiCapabilitiesForFeatures } from './ui_capabilities_for_features';
import { buildOSSFeatures } from './oss_features';
@@ -51,6 +50,10 @@ export interface PluginStartContract {
getKibanaFeatures(): KibanaFeature[];
}
+interface TimelionSetupContract {
+ uiEnabled: boolean;
+}
+
/**
* Represents Features Plugin instance that will be managed by the Kibana plugin system.
*/
diff --git a/x-pack/plugins/features/tsconfig.json b/x-pack/plugins/features/tsconfig.json
new file mode 100644
index 0000000000000..1260af55fbff6
--- /dev/null
+++ b/x-pack/plugins/features/tsconfig.json
@@ -0,0 +1,19 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "composite": true,
+ "outDir": "./target/types",
+ "emitDeclarationOnly": true,
+ "declaration": true,
+ "declarationMap": true
+ },
+ "include": [
+ "common/**/*",
+ "public/**/*",
+ "server/**/*",
+ ],
+ "references": [
+ { "path": "../../../src/core/tsconfig.json" },
+ { "path": "../licensing/tsconfig.json" },
+ ]
+}
diff --git a/x-pack/plugins/fleet/server/services/agents/unenroll.ts b/x-pack/plugins/fleet/server/services/agents/unenroll.ts
index 60533e1285141..9c2b2bdfe7f6d 100644
--- a/x-pack/plugins/fleet/server/services/agents/unenroll.ts
+++ b/x-pack/plugins/fleet/server/services/agents/unenroll.ts
@@ -3,7 +3,6 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
-import { chunk } from 'lodash';
import { SavedObjectsClientContract } from 'src/core/server';
import { AgentSOAttributes } from '../../types';
import { AGENT_SAVED_OBJECT_TYPE } from '../../constants';
@@ -76,10 +75,10 @@ export async function forceUnenrollAgent(soClient: SavedObjectsClientContract, a
await Promise.all([
agent.access_api_key_id
- ? APIKeyService.invalidateAPIKey(soClient, agent.access_api_key_id)
+ ? APIKeyService.invalidateAPIKeys(soClient, [agent.access_api_key_id])
: undefined,
agent.default_api_key_id
- ? APIKeyService.invalidateAPIKey(soClient, agent.default_api_key_id)
+ ? APIKeyService.invalidateAPIKeys(soClient, [agent.default_api_key_id])
: undefined,
]);
@@ -124,16 +123,8 @@ export async function forceUnenrollAgents(
});
// Invalidate all API keys
- // ES doesn't provide a bulk invalidate API, so this could take a long time depending on
- // number of keys to invalidate. We run these in batches to avoid overloading ES.
if (apiKeys.length) {
- const BATCH_SIZE = 500;
- const batches = chunk(apiKeys, BATCH_SIZE);
- for (const apiKeysBatch of batches) {
- await Promise.all(
- apiKeysBatch.map((apiKey) => APIKeyService.invalidateAPIKey(soClient, apiKey))
- );
- }
+ APIKeyService.invalidateAPIKeys(soClient, apiKeys);
}
// Update the necessary agents
diff --git a/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key.ts b/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key.ts
index b9d0cf883d35c..8f67753392e65 100644
--- a/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key.ts
+++ b/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key.ts
@@ -9,7 +9,7 @@ import Boom from '@hapi/boom';
import { SavedObjectsClientContract, SavedObject } from 'src/core/server';
import { EnrollmentAPIKey, EnrollmentAPIKeySOAttributes } from '../../types';
import { ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE } from '../../constants';
-import { createAPIKey, invalidateAPIKey } from './security';
+import { createAPIKey, invalidateAPIKeys } from './security';
import { agentPolicyService } from '../agent_policy';
import { appContextService } from '../app_context';
import { normalizeKuery } from '../saved_object';
@@ -66,7 +66,7 @@ export async function getEnrollmentAPIKey(soClient: SavedObjectsClientContract,
export async function deleteEnrollmentApiKey(soClient: SavedObjectsClientContract, id: string) {
const enrollmentApiKey = await getEnrollmentAPIKey(soClient, id);
- await invalidateAPIKey(soClient, enrollmentApiKey.api_key_id);
+ await invalidateAPIKeys(soClient, [enrollmentApiKey.api_key_id]);
await soClient.update(ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE, id, {
active: false,
diff --git a/x-pack/plugins/fleet/server/services/api_keys/index.ts b/x-pack/plugins/fleet/server/services/api_keys/index.ts
index d1a4a21dec106..bc756a311dc78 100644
--- a/x-pack/plugins/fleet/server/services/api_keys/index.ts
+++ b/x-pack/plugins/fleet/server/services/api_keys/index.ts
@@ -10,7 +10,7 @@ import { EnrollmentAPIKeySOAttributes, EnrollmentAPIKey } from '../../types';
import { createAPIKey } from './security';
import { escapeSearchQueryPhrase } from '../saved_object';
-export { invalidateAPIKey } from './security';
+export { invalidateAPIKeys } from './security';
export * from './enrollment_api_key';
export async function generateOutputApiKey(
diff --git a/x-pack/plugins/fleet/server/services/api_keys/security.ts b/x-pack/plugins/fleet/server/services/api_keys/security.ts
index 9a32da3cff46f..a22776435e930 100644
--- a/x-pack/plugins/fleet/server/services/api_keys/security.ts
+++ b/x-pack/plugins/fleet/server/services/api_keys/security.ts
@@ -64,7 +64,7 @@ export async function authenticate(callCluster: CallESAsCurrentUser) {
}
}
-export async function invalidateAPIKey(soClient: SavedObjectsClientContract, id: string) {
+export async function invalidateAPIKeys(soClient: SavedObjectsClientContract, ids: string[]) {
const adminUser = await outputService.getAdminUser(soClient);
if (!adminUser) {
throw new Error('No admin user configured');
@@ -88,7 +88,7 @@ export async function invalidateAPIKey(soClient: SavedObjectsClientContract, id:
try {
const res = await security.authc.apiKeys.invalidate(request, {
- id,
+ ids,
});
return res;
diff --git a/x-pack/plugins/runtime_fields/jest.config.js b/x-pack/plugins/grokdebugger/jest.config.js
similarity index 85%
rename from x-pack/plugins/runtime_fields/jest.config.js
rename to x-pack/plugins/grokdebugger/jest.config.js
index 9c4ec56593c8b..bf43870b5ba65 100644
--- a/x-pack/plugins/runtime_fields/jest.config.js
+++ b/x-pack/plugins/grokdebugger/jest.config.js
@@ -7,5 +7,5 @@
module.exports = {
preset: '@kbn/test',
rootDir: '../../..',
- roots: ['/x-pack/plugins/runtime_fields'],
+ roots: ['/x-pack/plugins/grokdebugger'],
};
diff --git a/x-pack/plugins/grokdebugger/server/models/grokdebugger_request/__tests__/grokdebugger_request.js b/x-pack/plugins/grokdebugger/server/models/grokdebugger_request/grokdebugger_request.test.js
similarity index 83%
rename from x-pack/plugins/grokdebugger/server/models/grokdebugger_request/__tests__/grokdebugger_request.js
rename to x-pack/plugins/grokdebugger/server/models/grokdebugger_request/grokdebugger_request.test.js
index 2e0be6001f8ca..0644a797da8bd 100644
--- a/x-pack/plugins/grokdebugger/server/models/grokdebugger_request/__tests__/grokdebugger_request.js
+++ b/x-pack/plugins/grokdebugger/server/models/grokdebugger_request/grokdebugger_request.test.js
@@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import expect from '@kbn/expect';
-import { GrokdebuggerRequest } from '../grokdebugger_request';
+import { GrokdebuggerRequest } from './grokdebugger_request';
// FAILING: https://github.com/elastic/kibana/issues/51372
describe.skip('grokdebugger_request', () => {
@@ -24,18 +23,18 @@ describe.skip('grokdebugger_request', () => {
describe('fromDownstreamJSON factory method', () => {
it('returns correct GrokdebuggerRequest instance from downstreamRequest', () => {
const grokdebuggerRequest = GrokdebuggerRequest.fromDownstreamJSON(downstreamRequest);
- expect(grokdebuggerRequest.rawEvent).to.eql(downstreamRequest.rawEvent);
- expect(grokdebuggerRequest.pattern).to.eql(downstreamRequest.pattern);
- expect(grokdebuggerRequest.customPatterns).to.eql({});
+ expect(grokdebuggerRequest.rawEvent).toEqual(downstreamRequest.rawEvent);
+ expect(grokdebuggerRequest.pattern).toEqual(downstreamRequest.pattern);
+ expect(grokdebuggerRequest.customPatterns).toEqual({});
});
it('returns correct GrokdebuggerRequest instance from downstreamRequest when custom patterns are specified', () => {
const grokdebuggerRequest = GrokdebuggerRequest.fromDownstreamJSON(
downstreamRequestWithCustomPatterns
);
- expect(grokdebuggerRequest.rawEvent).to.eql(downstreamRequest.rawEvent);
- expect(grokdebuggerRequest.pattern).to.eql(downstreamRequest.pattern);
- expect(grokdebuggerRequest.customPatterns).to.eql('%{FOO:bar}');
+ expect(grokdebuggerRequest.rawEvent).toEqual(downstreamRequest.rawEvent);
+ expect(grokdebuggerRequest.pattern).toEqual(downstreamRequest.pattern);
+ expect(grokdebuggerRequest.customPatterns).toEqual('%{FOO:bar}');
});
});
@@ -67,7 +66,7 @@ describe.skip('grokdebugger_request', () => {
};
const grokdebuggerRequest = GrokdebuggerRequest.fromDownstreamJSON(downstreamRequest);
const upstreamJson = grokdebuggerRequest.upstreamJSON;
- expect(upstreamJson).to.eql(expectedUpstreamJSON);
+ expect(upstreamJson).toEqual(expectedUpstreamJSON);
});
it('returns the upstream simulate JSON request when custom patterns are specified', () => {
@@ -99,7 +98,7 @@ describe.skip('grokdebugger_request', () => {
downstreamRequestWithCustomPatterns
);
const upstreamJson = grokdebuggerRequest.upstreamJSON;
- expect(upstreamJson).to.eql(expectedUpstreamJSON);
+ expect(upstreamJson).toEqual(expectedUpstreamJSON);
});
});
});
diff --git a/x-pack/plugins/grokdebugger/server/models/grokdebugger_response/__tests__/grokdebugger_response.js b/x-pack/plugins/grokdebugger/server/models/grokdebugger_response/grokdebugger_response.test.js
similarity index 85%
rename from x-pack/plugins/grokdebugger/server/models/grokdebugger_response/__tests__/grokdebugger_response.js
rename to x-pack/plugins/grokdebugger/server/models/grokdebugger_response/grokdebugger_response.test.js
index 3dde3244ed19b..de550b3f9bccd 100644
--- a/x-pack/plugins/grokdebugger/server/models/grokdebugger_response/__tests__/grokdebugger_response.js
+++ b/x-pack/plugins/grokdebugger/server/models/grokdebugger_response/grokdebugger_response.test.js
@@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import expect from '@kbn/expect';
-import { GrokdebuggerResponse } from '../grokdebugger_response';
+import { GrokdebuggerResponse } from './grokdebugger_response';
describe('grokdebugger_response', () => {
describe('GrokdebuggerResponse', () => {
@@ -37,8 +36,8 @@ describe('grokdebugger_response', () => {
client: '55.3.244.1',
};
const grokdebuggerResponse = GrokdebuggerResponse.fromUpstreamJSON(upstreamJson);
- expect(grokdebuggerResponse.structuredEvent).to.eql(expectedStructuredEvent);
- expect(grokdebuggerResponse.error).to.eql({});
+ expect(grokdebuggerResponse.structuredEvent).toEqual(expectedStructuredEvent);
+ expect(grokdebuggerResponse.error).toEqual({});
});
it('returns correct GrokdebuggerResponse instance when there are valid grok parse errors', () => {
@@ -61,8 +60,8 @@ describe('grokdebugger_response', () => {
],
};
const grokdebuggerResponse = GrokdebuggerResponse.fromUpstreamJSON(upstreamJson);
- expect(grokdebuggerResponse.structuredEvent).to.eql({});
- expect(grokdebuggerResponse.error).to.be(
+ expect(grokdebuggerResponse.structuredEvent).toEqual({});
+ expect(grokdebuggerResponse.error).toBe(
'Provided Grok patterns do not match data in the input'
);
});
diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/hot_phase/hot_phase.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/hot_phase/hot_phase.tsx
index d9976605393c7..a777f30fd2e42 100644
--- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/hot_phase/hot_phase.tsx
+++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/hot_phase/hot_phase.tsx
@@ -52,7 +52,7 @@ export const HotPhase: FunctionComponent = () => {
watch: isUsingDefaultRolloverPath,
});
const { isUsingRollover } = useConfigurationIssues();
- const isUsingDefaultRollover = get(formData, isUsingDefaultRolloverPath);
+ const isUsingDefaultRollover: boolean = get(formData, isUsingDefaultRolloverPath);
const [showEmptyRolloverFieldsError, setShowEmptyRolloverFieldsError] = useState(false);
return (
@@ -145,145 +145,145 @@ export const HotPhase: FunctionComponent = () => {
}
fullWidth
>
-