diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 61c5cebd77116..d0dc397e6b6ed 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -750,6 +750,9 @@ test/plugin_functional/plugins/ui_settings_plugin @elastic/kibana-core packages/kbn-ui-shared-deps-npm @elastic/kibana-operations packages/kbn-ui-shared-deps-src @elastic/kibana-operations packages/kbn-ui-theme @elastic/kibana-operations +packages/kbn-unified-doc-viewer @elastic/kibana-data-discovery +examples/unified_doc_viewer @elastic/kibana-core +src/plugins/unified_doc_viewer @elastic/kibana-data-discovery packages/kbn-unified-field-list @elastic/kibana-data-discovery examples/unified_field_list_examples @elastic/kibana-data-discovery src/plugins/unified_histogram @elastic/kibana-data-discovery diff --git a/.i18nrc.json b/.i18nrc.json index 2463d023971ed..7b2d9f423c6a2 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -122,6 +122,7 @@ "visTypeXy": "src/plugins/vis_types/xy", "visualizations": "src/plugins/visualizations", "visualizationUiComponents": "packages/kbn-visualization-ui-components", + "unifiedDocViewer": ["src/plugins/unified_doc_viewer", "packages/kbn-unified-doc-viewer"], "unifiedSearch": "src/plugins/unified_search", "unifiedFieldList": "packages/kbn-unified-field-list", "unifiedHistogram": "src/plugins/unified_histogram" diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc index e33bde623f518..c48c7c8d17b43 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -336,6 +336,10 @@ In general this plugin provides: |Registers commercially licensed generic actions like per panel time range and contains some code that supports drilldown work. +|{kib-repo}blob/{branch}/src/plugins/unified_doc_viewer/README.md[unifiedDocViewer] +|This plugin contains services reliant on the plugin lifecycle for the unified doc viewer component (see @kbn/unified-doc-viewer). + + |{kib-repo}blob/{branch}/src/plugins/unified_histogram/README.md[unifiedHistogram] |Unified Histogram is a UX Building Block including a layout with a resizable histogram and a main display. It manages its own state and data fetching, and can easily be dropped into pages with minimal setup. diff --git a/examples/unified_doc_viewer/README.md b/examples/unified_doc_viewer/README.md new file mode 100644 index 0000000000000..fea17c5e9cde8 --- /dev/null +++ b/examples/unified_doc_viewer/README.md @@ -0,0 +1,3 @@ +## Unified Doc Viewer + +An example plugin showing usage of the unified doc viewer plugin (plugins/unified_doc_viewer) and package (@kbn/unified-doc-viewer). \ No newline at end of file diff --git a/examples/unified_doc_viewer/kibana.jsonc b/examples/unified_doc_viewer/kibana.jsonc new file mode 100644 index 0000000000000..6d9c4465072c6 --- /dev/null +++ b/examples/unified_doc_viewer/kibana.jsonc @@ -0,0 +1,16 @@ +{ + "type": "plugin", + "id": "@kbn/unified-doc-viewer-examples", + "owner": "@elastic/kibana-core", + "description": "Examples showing usage of the unified doc viewer.", + "plugin": { + "id": "unifiedDocViewerExamples", + "server": false, + "browser": true, + "requiredPlugins": [ + "data", + "developerExamples", + "unifiedDocViewer" + ] + } +} diff --git a/examples/unified_doc_viewer/public/application.tsx b/examples/unified_doc_viewer/public/application.tsx new file mode 100644 index 0000000000000..11cf99e1ed2bb --- /dev/null +++ b/examples/unified_doc_viewer/public/application.tsx @@ -0,0 +1,72 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React, { useEffect, useState } from 'react'; +import ReactDOM from 'react-dom'; +import type { AppMountParameters, CoreStart } from '@kbn/core/public'; +import { buildDataTableRecord } from '@kbn/discover-utils'; +import type { DataTableRecord } from '@kbn/discover-utils/types'; +import type { DataView } from '@kbn/data-views-plugin/common'; +import { UnifiedDocViewer } from '@kbn/unified-doc-viewer-plugin/public'; +import { DataPublicPluginStart } from '@kbn/data-plugin/public'; +import type { StartDeps } from './plugin'; + +export const renderApp = ( + core: CoreStart, + { data }: StartDeps, + { element }: AppMountParameters +) => { + ReactDOM.render(, element); + + return () => { + ReactDOM.unmountComponentAtNode(element); + }; +}; + +function UnifiedDocViewerExamplesApp({ data }: { data: DataPublicPluginStart }) { + const [dataView, setDataView] = useState(); + const [hit, setHit] = useState(); + + useEffect(() => { + data.dataViews.getDefault().then((defaultDataView) => setDataView(defaultDataView)); + }, [data]); + + useEffect(() => { + const setDefaultHit = async () => { + if (!dataView?.id) return; + const response = await data.search + .search({ + params: { + index: dataView?.getIndexPattern(), + body: { + fields: ['*'], + _source: false, + }, + }, + }) + .toPromise(); + const docs = response?.rawResponse?.hits?.hits ?? []; + if (docs.length > 0) { + const record = buildDataTableRecord(docs[0], dataView); + setHit(record); + } + }; + + setDefaultHit(); + }, [data, dataView]); + + return ( + <> + {dataView?.id && hit ? ( + + ) : ( + 'Loading... (make sure you have a default data view and at least one matching document)' + )} + + ); +} diff --git a/examples/unified_doc_viewer/public/index.ts b/examples/unified_doc_viewer/public/index.ts new file mode 100644 index 0000000000000..98580e69ded6e --- /dev/null +++ b/examples/unified_doc_viewer/public/index.ts @@ -0,0 +1,12 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ +import { UnifiedDocViewerExamplesPlugin } from './plugin'; + +export function plugin() { + return new UnifiedDocViewerExamplesPlugin(); +} diff --git a/examples/unified_doc_viewer/public/plugin.tsx b/examples/unified_doc_viewer/public/plugin.tsx new file mode 100644 index 0000000000000..d12c746a06223 --- /dev/null +++ b/examples/unified_doc_viewer/public/plugin.tsx @@ -0,0 +1,49 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ +import { AppMountParameters, CoreSetup, CoreStart, Plugin } from '@kbn/core/public'; +import { DeveloperExamplesSetup } from '@kbn/developer-examples-plugin/public'; +import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; + +export interface SetupDeps { + developerExamples: DeveloperExamplesSetup; +} + +export interface StartDeps { + data: DataPublicPluginStart; +} + +export class UnifiedDocViewerExamplesPlugin implements Plugin { + public setup(core: CoreSetup, deps: SetupDeps) { + // Register an application into the side navigation menu + core.application.register({ + id: 'unifiedDocViewer', + title: 'Unified Doc Viewer Examples', + async mount(params: AppMountParameters) { + // Load application bundle + const { renderApp } = await import('./application'); + // Get start services as specified in kibana.json + const [coreStart, depsStart] = await core.getStartServices(); + // Render the application + return renderApp(coreStart, depsStart, params); + }, + }); + + // This section is only needed to get this example plugin to show up in our Developer Examples. + deps.developerExamples.register({ + appId: 'unifiedDocViewer', + title: 'Unified Doc Viewer Examples', + description: 'Examples showcasing the unified doc viewer.', + }); + } + + public start(core: CoreStart) { + return {}; + } + + public stop() {} +} diff --git a/examples/unified_doc_viewer/tsconfig.json b/examples/unified_doc_viewer/tsconfig.json new file mode 100644 index 0000000000000..74f81731edbe8 --- /dev/null +++ b/examples/unified_doc_viewer/tsconfig.json @@ -0,0 +1,24 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types" + }, + "include": [ + "index.ts", + "common/**/*.ts", + "public/**/*.ts", + "public/**/*.tsx", + "../../typings/**/*" + ], + "exclude": [ + "target/**/*", + ], + "kbn_references": [ + "@kbn/core", + "@kbn/data-plugin", + "@kbn/data-views-plugin", + "@kbn/developer-examples-plugin", + "@kbn/discover-utils", + "@kbn/unified-doc-viewer-plugin", + ] +} diff --git a/package.json b/package.json index a0d3c7270c911..233826aacce77 100644 --- a/package.json +++ b/package.json @@ -742,6 +742,9 @@ "@kbn/ui-shared-deps-npm": "link:packages/kbn-ui-shared-deps-npm", "@kbn/ui-shared-deps-src": "link:packages/kbn-ui-shared-deps-src", "@kbn/ui-theme": "link:packages/kbn-ui-theme", + "@kbn/unified-doc-viewer": "link:packages/kbn-unified-doc-viewer", + "@kbn/unified-doc-viewer-examples": "link:examples/unified_doc_viewer", + "@kbn/unified-doc-viewer-plugin": "link:src/plugins/unified_doc_viewer", "@kbn/unified-field-list": "link:packages/kbn-unified-field-list", "@kbn/unified-field-list-examples-plugin": "link:examples/unified_field_list_examples", "@kbn/unified-histogram-plugin": "link:src/plugins/unified_histogram", diff --git a/packages/kbn-discover-utils/index.ts b/packages/kbn-discover-utils/index.ts index dae9c268f80db..b94d71b5540eb 100644 --- a/packages/kbn-discover-utils/index.ts +++ b/packages/kbn-discover-utils/index.ts @@ -16,6 +16,8 @@ export { ENABLE_SQL, FIELDS_LIMIT_SETTING, HIDE_ANNOUNCEMENTS, + KNOWN_FIELD_TYPE_LIST, + KNOWN_FIELD_TYPES, MAX_DOC_FIELDS_DISPLAYED, MODIFY_COLUMNS_ON_SWITCH, ROW_HEIGHT_OPTION, @@ -34,8 +36,10 @@ export { formatFieldValue, formatHit, getDocId, + getFieldTypeName, getIgnoredReason, getShouldShowFieldHandler, + isKnownFieldType, isNestedFieldParent, usePager, } from './src'; diff --git a/packages/kbn-discover-utils/src/types.ts b/packages/kbn-discover-utils/src/types.ts index 752de1dcb9e9d..5a2f3ed9b085e 100644 --- a/packages/kbn-discover-utils/src/types.ts +++ b/packages/kbn-discover-utils/src/types.ts @@ -8,7 +8,7 @@ import type { SearchHit } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -export type { IgnoredReason, ShouldShowFieldInTableHandler } from './utils'; +export type { FieldTypeKnown, IgnoredReason, ShouldShowFieldInTableHandler } from './utils'; export interface EsHitRecord extends Omit { _source?: Record; diff --git a/packages/kbn-unified-field-list/src/utils/field_types/field_types.ts b/packages/kbn-discover-utils/src/utils/field_types.ts similarity index 87% rename from packages/kbn-unified-field-list/src/utils/field_types/field_types.ts rename to packages/kbn-discover-utils/src/utils/field_types.ts index 0851d6dc1e412..320f606dd0d8e 100644 --- a/packages/kbn-unified-field-list/src/utils/field_types/field_types.ts +++ b/packages/kbn-discover-utils/src/utils/field_types.ts @@ -6,7 +6,12 @@ * Side Public License, v 1. */ -import { FieldTypeKnown } from '../../types'; +import type { DataViewField } from '@kbn/data-views-plugin/common'; + +export type FieldTypeKnown = Exclude< + DataViewField['timeSeriesMetric'] | DataViewField['type'], + undefined +>; /** * Field types for which name and description are defined diff --git a/packages/kbn-unified-field-list/src/utils/field_types/get_field_type_name.test.ts b/packages/kbn-discover-utils/src/utils/get_field_type_name.test.ts similarity index 100% rename from packages/kbn-unified-field-list/src/utils/field_types/get_field_type_name.test.ts rename to packages/kbn-discover-utils/src/utils/get_field_type_name.test.ts diff --git a/packages/kbn-unified-field-list/src/utils/field_types/get_field_type_name.ts b/packages/kbn-discover-utils/src/utils/get_field_type_name.ts similarity index 59% rename from packages/kbn-unified-field-list/src/utils/field_types/get_field_type_name.ts rename to packages/kbn-discover-utils/src/utils/get_field_type_name.ts index 23ae35a4c2ef3..7e7bd102f3353 100644 --- a/packages/kbn-unified-field-list/src/utils/field_types/get_field_type_name.ts +++ b/packages/kbn-discover-utils/src/utils/get_field_type_name.ts @@ -14,7 +14,7 @@ import { KNOWN_FIELD_TYPES } from './field_types'; * A user-friendly name of an unknown field type */ export const UNKNOWN_FIELD_TYPE_MESSAGE = i18n.translate( - 'unifiedFieldList.fieldNameIcons.unknownFieldAriaLabel', + 'discover.fieldNameIcons.unknownFieldAriaLabel', { defaultMessage: 'Unknown field', } @@ -32,7 +32,7 @@ export function getFieldTypeName(type?: string) { if (type === 'source') { // Note that this type is currently not provided, type for _source is undefined - return i18n.translate('unifiedFieldList.fieldNameIcons.sourceFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.sourceFieldAriaLabel', { defaultMessage: 'Source field', }); } @@ -40,107 +40,107 @@ export function getFieldTypeName(type?: string) { const knownType: KNOWN_FIELD_TYPES = type as KNOWN_FIELD_TYPES; switch (knownType) { case KNOWN_FIELD_TYPES.DOCUMENT: - return i18n.translate('unifiedFieldList.fieldNameIcons.recordAriaLabel', { + return i18n.translate('discover.fieldNameIcons.recordAriaLabel', { defaultMessage: 'Records', }); case KNOWN_FIELD_TYPES.BINARY: - return i18n.translate('unifiedFieldList.fieldNameIcons.binaryAriaLabel', { + return i18n.translate('discover.fieldNameIcons.binaryAriaLabel', { defaultMessage: 'Binary', }); case KNOWN_FIELD_TYPES.BOOLEAN: - return i18n.translate('unifiedFieldList.fieldNameIcons.booleanAriaLabel', { + return i18n.translate('discover.fieldNameIcons.booleanAriaLabel', { defaultMessage: 'Boolean', }); case KNOWN_FIELD_TYPES.CONFLICT: - return i18n.translate('unifiedFieldList.fieldNameIcons.conflictFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.conflictFieldAriaLabel', { defaultMessage: 'Conflict', }); case KNOWN_FIELD_TYPES.COUNTER: - return i18n.translate('unifiedFieldList.fieldNameIcons.counterFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.counterFieldAriaLabel', { defaultMessage: 'Counter metric', }); case KNOWN_FIELD_TYPES.DATE: - return i18n.translate('unifiedFieldList.fieldNameIcons.dateFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.dateFieldAriaLabel', { defaultMessage: 'Date', }); case KNOWN_FIELD_TYPES.DATE_RANGE: - return i18n.translate('unifiedFieldList.fieldNameIcons.dateRangeFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.dateRangeFieldAriaLabel', { defaultMessage: 'Date range', }); case KNOWN_FIELD_TYPES.DENSE_VECTOR: - return i18n.translate('unifiedFieldList.fieldNameIcons.denseVectorFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.denseVectorFieldAriaLabel', { defaultMessage: 'Dense vector', }); case KNOWN_FIELD_TYPES.GAUGE: - return i18n.translate('unifiedFieldList.fieldNameIcons.gaugeFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.gaugeFieldAriaLabel', { defaultMessage: 'Gauge metric', }); case KNOWN_FIELD_TYPES.GEO_POINT: - return i18n.translate('unifiedFieldList.fieldNameIcons.geoPointFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.geoPointFieldAriaLabel', { defaultMessage: 'Geo point', }); case KNOWN_FIELD_TYPES.GEO_SHAPE: - return i18n.translate('unifiedFieldList.fieldNameIcons.geoShapeFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.geoShapeFieldAriaLabel', { defaultMessage: 'Geo shape', }); case KNOWN_FIELD_TYPES.HISTOGRAM: - return i18n.translate('unifiedFieldList.fieldNameIcons.histogramFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.histogramFieldAriaLabel', { defaultMessage: 'Histogram', }); case KNOWN_FIELD_TYPES.IP: - return i18n.translate('unifiedFieldList.fieldNameIcons.ipAddressFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.ipAddressFieldAriaLabel', { defaultMessage: 'IP address', }); case KNOWN_FIELD_TYPES.IP_RANGE: - return i18n.translate('unifiedFieldList.fieldNameIcons.ipRangeFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.ipRangeFieldAriaLabel', { defaultMessage: 'IP range', }); case KNOWN_FIELD_TYPES.FLATTENED: - return i18n.translate('unifiedFieldList.fieldNameIcons.flattenedFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.flattenedFieldAriaLabel', { defaultMessage: 'Flattened', }); case KNOWN_FIELD_TYPES.MURMUR3: - return i18n.translate('unifiedFieldList.fieldNameIcons.murmur3FieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.murmur3FieldAriaLabel', { defaultMessage: 'Murmur3', }); case KNOWN_FIELD_TYPES.NUMBER: - return i18n.translate('unifiedFieldList.fieldNameIcons.numberFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.numberFieldAriaLabel', { defaultMessage: 'Number', }); case KNOWN_FIELD_TYPES.RANK_FEATURE: - return i18n.translate('unifiedFieldList.fieldNameIcons.rankFeatureFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.rankFeatureFieldAriaLabel', { defaultMessage: 'Rank feature', }); case KNOWN_FIELD_TYPES.RANK_FEATURES: - return i18n.translate('unifiedFieldList.fieldNameIcons.rankFeaturesFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.rankFeaturesFieldAriaLabel', { defaultMessage: 'Rank features', }); case KNOWN_FIELD_TYPES.POINT: - return i18n.translate('unifiedFieldList.fieldNameIcons.pointFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.pointFieldAriaLabel', { defaultMessage: 'Point', }); case KNOWN_FIELD_TYPES.SHAPE: - return i18n.translate('unifiedFieldList.fieldNameIcons.shapeFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.shapeFieldAriaLabel', { defaultMessage: 'Shape', }); case KNOWN_FIELD_TYPES.STRING: - return i18n.translate('unifiedFieldList.fieldNameIcons.stringFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.stringFieldAriaLabel', { defaultMessage: 'String', }); case KNOWN_FIELD_TYPES.TEXT: - return i18n.translate('unifiedFieldList.fieldNameIcons.textFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.textFieldAriaLabel', { defaultMessage: 'Text', }); case KNOWN_FIELD_TYPES.KEYWORD: - return i18n.translate('unifiedFieldList.fieldNameIcons.keywordFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.keywordFieldAriaLabel', { defaultMessage: 'Keyword', }); case KNOWN_FIELD_TYPES.NESTED: - return i18n.translate('unifiedFieldList.fieldNameIcons.nestedFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.nestedFieldAriaLabel', { defaultMessage: 'Nested', }); case KNOWN_FIELD_TYPES.VERSION: - return i18n.translate('unifiedFieldList.fieldNameIcons.versionFieldAriaLabel', { + return i18n.translate('discover.fieldNameIcons.versionFieldAriaLabel', { defaultMessage: 'Version', }); default: diff --git a/packages/kbn-discover-utils/src/utils/index.ts b/packages/kbn-discover-utils/src/utils/index.ts index 4828fcf82a447..fc8288f533deb 100644 --- a/packages/kbn-discover-utils/src/utils/index.ts +++ b/packages/kbn-discover-utils/src/utils/index.ts @@ -7,9 +7,11 @@ */ export * from './build_data_record'; +export * from './field_types'; export * from './format_hit'; export * from './format_value'; export * from './get_doc_id'; +export * from './get_field_type_name'; export * from './get_ignored_reason'; export * from './get_should_show_field_handler'; export * from './nested_fields'; diff --git a/packages/kbn-discover-utils/types.ts b/packages/kbn-discover-utils/types.ts index 69ea11ea628d8..ea9c48f34c39f 100644 --- a/packages/kbn-discover-utils/types.ts +++ b/packages/kbn-discover-utils/types.ts @@ -9,6 +9,7 @@ export type { DataTableRecord, EsHitRecord, + FieldTypeKnown, IgnoredReason, ShouldShowFieldInTableHandler, } from './src/types'; diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index 21dc7806e2e98..a3bee52c09267 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -142,6 +142,7 @@ pageLoadAssetSize: triggersActionsUi: 135613 uiActions: 35121 uiActionsEnhanced: 38494 + unifiedDocViewer: 25099 unifiedHistogram: 19928 unifiedSearch: 71059 upgradeAssistant: 81241 diff --git a/packages/kbn-unified-doc-viewer/README.md b/packages/kbn-unified-doc-viewer/README.md new file mode 100644 index 0000000000000..825f6eee9f910 --- /dev/null +++ b/packages/kbn-unified-doc-viewer/README.md @@ -0,0 +1,15 @@ +# @kbn/unified-doc-viewer + +This package contains components and services for the unified doc viewer component. + +Discover (Classic view → Expanded document) + +![image](https://github.com/elastic/kibana/assets/1178348/a0a360bf-2697-4427-a32e-c728f06f5a7e) + +Discover (Document explorer → Toggle dialog with details) + +![image](https://github.com/elastic/kibana/assets/1178348/c9c11587-c53f-4bcd-8d48-aaceb64981ea) + +Discover (View single document) + +![image](https://github.com/elastic/kibana/assets/1178348/4a8ea694-d4f5-4c9c-9259-1212f0d50a18) diff --git a/src/plugins/discover/public/application/doc/types.ts b/packages/kbn-unified-doc-viewer/index.ts similarity index 78% rename from src/plugins/discover/public/application/doc/types.ts rename to packages/kbn-unified-doc-viewer/index.ts index dd82e86cdb4b6..47aae8b209ac3 100644 --- a/src/plugins/discover/public/application/doc/types.ts +++ b/packages/kbn-unified-doc-viewer/index.ts @@ -6,10 +6,4 @@ * Side Public License, v 1. */ -export enum ElasticRequestState { - Loading, - NotFound, - Found, - Error, - NotFoundDataView, -} +export { DocViewer, DocViewsRegistry, ElasticRequestState, FieldName } from './src'; diff --git a/packages/kbn-unified-doc-viewer/jest.config.js b/packages/kbn-unified-doc-viewer/jest.config.js new file mode 100644 index 0000000000000..1abe8ad8e52e9 --- /dev/null +++ b/packages/kbn-unified-doc-viewer/jest.config.js @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../..', + roots: ['/packages/kbn-unified-doc-viewer'], +}; diff --git a/packages/kbn-unified-doc-viewer/kibana.jsonc b/packages/kbn-unified-doc-viewer/kibana.jsonc new file mode 100644 index 0000000000000..272c2ec69ce82 --- /dev/null +++ b/packages/kbn-unified-doc-viewer/kibana.jsonc @@ -0,0 +1,5 @@ +{ + "type": "shared-common", + "id": "@kbn/unified-doc-viewer", + "owner": "@elastic/kibana-data-discovery" +} diff --git a/packages/kbn-unified-doc-viewer/package.json b/packages/kbn-unified-doc-viewer/package.json new file mode 100644 index 0000000000000..c301255f057bc --- /dev/null +++ b/packages/kbn-unified-doc-viewer/package.json @@ -0,0 +1,7 @@ +{ + "name": "@kbn/unified-doc-viewer", + "private": true, + "version": "1.0.0", + "license": "SSPL-1.0 OR Elastic License 2.0", + "sideEffects": false +} \ No newline at end of file diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer/__snapshots__/doc_viewer.test.tsx.snap b/packages/kbn-unified-doc-viewer/src/components/doc_viewer/__snapshots__/doc_viewer.test.tsx.snap similarity index 95% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer/__snapshots__/doc_viewer.test.tsx.snap rename to packages/kbn-unified-doc-viewer/src/components/doc_viewer/__snapshots__/doc_viewer.test.tsx.snap index ad0ee0fa4dc95..83dde56a57228 100644 --- a/src/plugins/discover/public/services/doc_views/components/doc_viewer/__snapshots__/doc_viewer.test.tsx.snap +++ b/packages/kbn-unified-doc-viewer/src/components/doc_viewer/__snapshots__/doc_viewer.test.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Render with 3 different tabs 1`] = ` +exports[` Render with 3 different tabs 1`] = `
', () => { + test('Render with 3 different tabs', () => { + const registry = new DocViewsRegistry(); + registry.addDocView({ order: 10, title: 'Render function', render: jest.fn() }); + registry.addDocView({ order: 20, title: 'React component', component: () =>
test
}); + // @ts-expect-error This should be invalid and will throw an error when rendering + registry.addDocView({ order: 30, title: 'Invalid doc view' }); + + const renderProps = { hit: {} } as DocViewRenderProps; + + const wrapper = shallow( + + ); + + expect(wrapper).toMatchSnapshot(); + }); + + test('Render with 1 tab displaying error message', () => { + function SomeComponent() { + // this is just a placeholder + return null; + } + + const registry = new DocViewsRegistry(); + registry.addDocView({ + order: 10, + title: 'React component', + component: SomeComponent, + }); + + const renderProps = { + hit: buildDataTableRecord({ _index: 't', _id: '1' }), + } as DocViewRenderProps; + const errorMsg = 'Catch me if you can!'; + + const wrapper = mount( + + ); + const error = new Error(errorMsg); + wrapper.find(SomeComponent).simulateError(error); + const errorMsgComponent = findTestSubject(wrapper, 'docViewerError'); + expect(errorMsgComponent.text()).toMatch(new RegExp(`${errorMsg}`)); + }); +}); diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer.tsx b/packages/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer.tsx similarity index 57% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer.tsx rename to packages/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer.tsx index c2532735641f9..901208f8b3988 100644 --- a/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer.tsx +++ b/packages/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer.tsx @@ -8,9 +8,12 @@ import React from 'react'; import { EuiTabbedContent } from '@elastic/eui'; -import { getDocViewsRegistry } from '../../../../kibana_services'; import { DocViewerTab } from './doc_viewer_tab'; -import { DocView, DocViewRenderProps } from '../../doc_views_types'; +import type { DocView, DocViewRenderProps } from '../../types'; + +export interface DocViewerProps extends DocViewRenderProps { + docViews: DocView[]; +} /** * Rendering tabs with different views of 1 Elasticsearch hit in Discover. @@ -18,26 +21,23 @@ import { DocView, DocViewRenderProps } from '../../doc_views_types'; * A view can contain a React `component`, or any JS framework by using * a `render` function. */ -export function DocViewer(renderProps: DocViewRenderProps) { - const docViewsRegistry = getDocViewsRegistry(); - const tabs = docViewsRegistry - .getDocViewsSorted(renderProps.hit) - .map(({ title, render, component }: DocView, idx: number) => { - return { - id: `kbn_doc_viewer_tab_${idx}`, - name: title, - content: ( - - ), - ['data-test-subj']: `docViewerTab-${idx}`, - }; - }); +export function DocViewer({ docViews, ...renderProps }: DocViewerProps) { + const tabs = docViews.map(({ title, render, component }: DocView, idx: number) => { + return { + id: `kbn_doc_viewer_tab_${idx}`, + name: title, + content: ( + + ), + ['data-test-subj']: `docViewerTab-${idx}`, + }; + }); if (!tabs.length) { // There there's a minimum of 2 tabs active in Discover. diff --git a/packages/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer_error.test.tsx b/packages/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer_error.test.tsx new file mode 100644 index 0000000000000..e21d0d772ecb5 --- /dev/null +++ b/packages/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer_error.test.tsx @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React from 'react'; +import { mount } from 'enzyme'; +import { DocViewerError } from './doc_viewer_error'; + +test('DocViewerError should wrap error in boundary', () => { + const props = { + error: new Error('my error'), + }; + + expect(() => { + const wrapper = mount(); + const html = wrapper.html(); + expect(html).toContain('euiErrorBoundary'); + expect(html).toContain('my error'); + }).not.toThrowError(); +}); diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_render_error.tsx b/packages/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer_error.tsx similarity index 100% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_render_error.tsx rename to packages/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer_error.tsx diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_render_tab.test.tsx b/packages/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer_render_tab.test.tsx similarity index 93% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_render_tab.test.tsx rename to packages/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer_render_tab.test.tsx index 5c61938a9e830..1aa7372c65fb5 100644 --- a/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_render_tab.test.tsx +++ b/packages/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer_render_tab.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { mount } from 'enzyme'; import { DocViewRenderTab } from './doc_viewer_render_tab'; -import { DocViewRenderProps } from '../../doc_views_types'; +import type { DocViewRenderProps } from '../../types'; test('Mounting and unmounting DocViewerRenderTab', () => { const unmountFn = jest.fn(); diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_render_tab.tsx b/packages/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer_render_tab.tsx similarity index 92% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_render_tab.tsx rename to packages/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer_render_tab.tsx index 257f40a9850a1..5471bb52104bc 100644 --- a/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_render_tab.tsx +++ b/packages/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer_render_tab.tsx @@ -7,7 +7,7 @@ */ import React, { useRef, useEffect } from 'react'; -import { DocViewRenderFn, DocViewRenderProps } from '../../doc_views_types'; +import type { DocViewRenderFn, DocViewRenderProps } from '../../types'; interface Props { render: DocViewRenderFn; diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_tab.test.tsx b/packages/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer_tab.test.tsx similarity index 100% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_tab.test.tsx rename to packages/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer_tab.test.tsx diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_tab.tsx b/packages/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer_tab.tsx similarity index 94% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_tab.tsx rename to packages/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer_tab.tsx index 837ee910176b9..ce88120c1d196 100644 --- a/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_tab.tsx +++ b/packages/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer_tab.tsx @@ -9,8 +9,8 @@ import React from 'react'; import { isEqual } from 'lodash'; import { DocViewRenderTab } from './doc_viewer_render_tab'; -import { DocViewerError } from './doc_viewer_render_error'; -import { DocViewRenderFn, DocViewRenderProps } from '../../doc_views_types'; +import { DocViewerError } from './doc_viewer_error'; +import type { DocViewRenderFn, DocViewRenderProps } from '../../types'; interface Props { id: number; diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer/index.ts b/packages/kbn-unified-doc-viewer/src/components/doc_viewer/index.ts similarity index 100% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer/index.ts rename to packages/kbn-unified-doc-viewer/src/components/doc_viewer/index.ts diff --git a/src/plugins/discover/public/components/field_name/__snapshots__/field_name.test.tsx.snap b/packages/kbn-unified-doc-viewer/src/components/field_name/__snapshots__/field_name.test.tsx.snap similarity index 100% rename from src/plugins/discover/public/components/field_name/__snapshots__/field_name.test.tsx.snap rename to packages/kbn-unified-doc-viewer/src/components/field_name/__snapshots__/field_name.test.tsx.snap diff --git a/src/plugins/discover/public/components/field_name/__stories__/field_name.stories.tsx b/packages/kbn-unified-doc-viewer/src/components/field_name/__stories__/field_name.stories.tsx similarity index 100% rename from src/plugins/discover/public/components/field_name/__stories__/field_name.stories.tsx rename to packages/kbn-unified-doc-viewer/src/components/field_name/__stories__/field_name.stories.tsx diff --git a/src/plugins/discover/public/components/field_name/field_name.scss b/packages/kbn-unified-doc-viewer/src/components/field_name/field_name.scss similarity index 100% rename from src/plugins/discover/public/components/field_name/field_name.scss rename to packages/kbn-unified-doc-viewer/src/components/field_name/field_name.scss diff --git a/src/plugins/discover/public/components/field_name/field_name.test.tsx b/packages/kbn-unified-doc-viewer/src/components/field_name/field_name.test.tsx similarity index 100% rename from src/plugins/discover/public/components/field_name/field_name.test.tsx rename to packages/kbn-unified-doc-viewer/src/components/field_name/field_name.test.tsx diff --git a/src/plugins/discover/public/components/field_name/field_name.tsx b/packages/kbn-unified-doc-viewer/src/components/field_name/field_name.tsx similarity index 85% rename from src/plugins/discover/public/components/field_name/field_name.tsx rename to packages/kbn-unified-doc-viewer/src/components/field_name/field_name.tsx index b651cca0b7592..824de1da96dbb 100644 --- a/src/plugins/discover/public/components/field_name/field_name.tsx +++ b/packages/kbn-unified-doc-viewer/src/components/field_name/field_name.tsx @@ -12,8 +12,9 @@ import { EuiBadge, EuiFlexGroup, EuiFlexItem, EuiToolTip, EuiHighlight } from '@ import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { FieldIcon, FieldIconProps } from '@kbn/react-field'; -import { type DataViewField, getFieldSubtypeMulti } from '@kbn/data-views-plugin/public'; -import { getFieldTypeName } from '@kbn/unified-field-list/src/utils/field_types/get_field_type_name'; +import type { DataViewField } from '@kbn/data-views-plugin/public'; +import { getDataViewFieldSubtypeMulti } from '@kbn/es-query'; +import { getFieldTypeName } from '@kbn/discover-utils'; interface Props { fieldName: string; @@ -36,7 +37,7 @@ export function FieldName({ const displayName = fieldMapping && fieldMapping.displayName ? fieldMapping.displayName : fieldName; const tooltip = displayName !== fieldName ? `${fieldName} (${displayName})` : fieldName; - const subTypeMulti = fieldMapping && getFieldSubtypeMulti(fieldMapping.spec); + const subTypeMulti = fieldMapping && getDataViewFieldSubtypeMulti(fieldMapping.spec); const isMultiField = !!subTypeMulti?.multi; return ( @@ -62,7 +63,7 @@ export function FieldName({ position="top" delay="long" content={i18n.translate( - 'discover.fieldChooser.discoverField.multiFieldTooltipContent', + 'unifiedDocViewer.fieldChooser.discoverField.multiFieldTooltipContent', { defaultMessage: 'Multi-fields can have multiple values per field', } @@ -75,7 +76,7 @@ export function FieldName({ data-test-subj={`tableDocViewRow-${fieldName}-multifieldBadge`} > diff --git a/src/plugins/discover/public/components/index.ts b/packages/kbn-unified-doc-viewer/src/components/field_name/index.ts similarity index 85% rename from src/plugins/discover/public/components/index.ts rename to packages/kbn-unified-doc-viewer/src/components/field_name/index.ts index a794b8c90a477..67a2edbe1b440 100644 --- a/src/plugins/discover/public/components/index.ts +++ b/packages/kbn-unified-doc-viewer/src/components/field_name/index.ts @@ -6,4 +6,4 @@ * Side Public License, v 1. */ -export { DeferredSpinner } from './common/deferred_spinner'; +export * from './field_name'; diff --git a/packages/kbn-unified-doc-viewer/src/components/index.ts b/packages/kbn-unified-doc-viewer/src/components/index.ts new file mode 100644 index 0000000000000..0ab434a88fd44 --- /dev/null +++ b/packages/kbn-unified-doc-viewer/src/components/index.ts @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export * from './doc_viewer'; +export * from './field_name'; diff --git a/packages/kbn-unified-doc-viewer/src/index.ts b/packages/kbn-unified-doc-viewer/src/index.ts new file mode 100644 index 0000000000000..ae2e0bc299be7 --- /dev/null +++ b/packages/kbn-unified-doc-viewer/src/index.ts @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export * from './components'; +export * from './services'; diff --git a/src/plugins/discover/public/services/doc_views/doc_views_registry.ts b/packages/kbn-unified-doc-viewer/src/services/doc_views_registry.ts similarity index 78% rename from src/plugins/discover/public/services/doc_views/doc_views_registry.ts rename to packages/kbn-unified-doc-viewer/src/services/doc_views_registry.ts index 9b6f9d2490d80..620c8bc3058de 100644 --- a/src/plugins/discover/public/services/doc_views/doc_views_registry.ts +++ b/packages/kbn-unified-doc-viewer/src/services/doc_views_registry.ts @@ -7,7 +7,15 @@ */ import type { DataTableRecord } from '@kbn/discover-utils/types'; -import { DocView, DocViewInput, DocViewInputFn } from './doc_views_types'; +import { DocView, DocViewInput, DocViewInputFn } from './types'; + +export enum ElasticRequestState { + Loading, + NotFound, + Found, + Error, + NotFoundDataView, +} export class DocViewsRegistry { private docViews: DocView[] = []; @@ -17,10 +25,10 @@ export class DocViewsRegistry { */ addDocView(docViewRaw: DocViewInput | DocViewInputFn) { const docView = typeof docViewRaw === 'function' ? docViewRaw() : docViewRaw; - if (typeof docView.shouldShow !== 'function') { - docView.shouldShow = () => true; - } - this.docViews.push(docView as DocView); + this.docViews.push({ + ...docView, + shouldShow: docView.shouldShow ?? (() => true), + }); } /** * Returns a sorted array of doc_views for rendering tabs diff --git a/packages/kbn-unified-doc-viewer/src/services/index.ts b/packages/kbn-unified-doc-viewer/src/services/index.ts new file mode 100644 index 0000000000000..c1094d0d7a348 --- /dev/null +++ b/packages/kbn-unified-doc-viewer/src/services/index.ts @@ -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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export { DocViewsRegistry, ElasticRequestState } from './doc_views_registry'; diff --git a/src/plugins/discover/public/services/doc_views/doc_views_types.ts b/packages/kbn-unified-doc-viewer/src/services/types.ts similarity index 96% rename from src/plugins/discover/public/services/doc_views/doc_views_types.ts rename to packages/kbn-unified-doc-viewer/src/services/types.ts index 4fc94580ba29a..0cce5ea3ff813 100644 --- a/src/plugins/discover/public/services/doc_views/doc_views_types.ts +++ b/packages/kbn-unified-doc-viewer/src/services/types.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { DataView, DataViewField } from '@kbn/data-views-plugin/public'; +import type { DataView, DataViewField } from '@kbn/data-views-plugin/public'; import type { AggregateQuery, Query } from '@kbn/es-query'; import type { DataTableRecord, IgnoredReason } from '@kbn/discover-utils/types'; diff --git a/packages/kbn-unified-doc-viewer/src/types.ts b/packages/kbn-unified-doc-viewer/src/types.ts new file mode 100644 index 0000000000000..569665fcc6d87 --- /dev/null +++ b/packages/kbn-unified-doc-viewer/src/types.ts @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export type { + DocView, + DocViewFilterFn, + DocViewRenderFn, + DocViewRenderProps, + FieldRecordLegacy, +} from './services/types'; diff --git a/packages/kbn-unified-doc-viewer/tsconfig.json b/packages/kbn-unified-doc-viewer/tsconfig.json new file mode 100644 index 0000000000000..856fbe93d6b0f --- /dev/null +++ b/packages/kbn-unified-doc-viewer/tsconfig.json @@ -0,0 +1,27 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + "types": [ + "jest", + "node", + "react" + ] + }, + "include": [ + "**/*.ts", + "**/*.tsx", + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [ + "@kbn/discover-utils", + "@kbn/data-views-plugin", + "@kbn/es-query", + "@kbn/data-plugin", + "@kbn/i18n-react", + "@kbn/i18n", + "@kbn/react-field", + ] +} diff --git a/packages/kbn-unified-doc-viewer/types.ts b/packages/kbn-unified-doc-viewer/types.ts new file mode 100644 index 0000000000000..d4543a112d9e1 --- /dev/null +++ b/packages/kbn-unified-doc-viewer/types.ts @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export type { ElasticRequestState } from '.'; +export type { DocViewFilterFn, DocViewRenderProps, FieldRecordLegacy } from './src/types'; diff --git a/packages/kbn-unified-field-list/index.ts b/packages/kbn-unified-field-list/index.ts index fed0bc2e736e2..ffee31c4642fc 100755 --- a/packages/kbn-unified-field-list/index.ts +++ b/packages/kbn-unified-field-list/index.ts @@ -48,7 +48,6 @@ export type { AddFieldFilterHandler, FieldListGroups, FieldsGroupDetails, - FieldTypeKnown, FieldListItem, GetCustomFieldType, RenderFieldItemParams, @@ -86,13 +85,7 @@ export { type QuerySubscriberParams, } from './src/hooks/use_query_subscriber'; -export { - getFieldTypeName, - getFieldTypeDescription, - KNOWN_FIELD_TYPES, - getFieldType, - getFieldIconType, -} from './src/utils/field_types'; +export { getFieldTypeDescription, getFieldType, getFieldIconType } from './src/utils/field_types'; export { UnifiedFieldListSidebarContainer, diff --git a/packages/kbn-unified-field-list/src/components/field_icon/field_icon.tsx b/packages/kbn-unified-field-list/src/components/field_icon/field_icon.tsx index 070716911706c..cd6fcb7588fdd 100644 --- a/packages/kbn-unified-field-list/src/components/field_icon/field_icon.tsx +++ b/packages/kbn-unified-field-list/src/components/field_icon/field_icon.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { FieldIcon as KbnFieldIcon, FieldIconProps as KbnFieldIconProps } from '@kbn/react-field'; -import { getFieldTypeName } from '../../utils/field_types'; +import { getFieldTypeName } from '@kbn/discover-utils'; export type FieldIconProps = KbnFieldIconProps; diff --git a/packages/kbn-unified-field-list/src/components/field_list_filters/field_type_filter.tsx b/packages/kbn-unified-field-list/src/components/field_list_filters/field_type_filter.tsx index 1afe4bac5f0ba..b1a6387143edd 100644 --- a/packages/kbn-unified-field-list/src/components/field_list_filters/field_type_filter.tsx +++ b/packages/kbn-unified-field-list/src/components/field_list_filters/field_type_filter.tsx @@ -32,15 +32,11 @@ import type { CoreStart } from '@kbn/core-lifecycle-browser'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { type DataViewField } from '@kbn/data-views-plugin/common'; +import type { FieldTypeKnown } from '@kbn/discover-utils/types'; +import { getFieldTypeName, isKnownFieldType, KNOWN_FIELD_TYPE_LIST } from '@kbn/discover-utils'; import { FieldIcon } from '../field_icon'; -import { - getFieldIconType, - getFieldTypeName, - getFieldTypeDescription, - isKnownFieldType, - KNOWN_FIELD_TYPE_LIST, -} from '../../utils/field_types'; -import type { FieldListItem, FieldTypeKnown, GetCustomFieldType } from '../../types'; +import { getFieldIconType, getFieldTypeDescription } from '../../utils/field_types'; +import type { FieldListItem, GetCustomFieldType } from '../../types'; const EQUAL_HEIGHT_OFFSET = 2; // to avoid changes in the header's height after "Clear all" button appears const popoverTitleStyle = css` diff --git a/packages/kbn-unified-field-list/src/hooks/use_field_filters.ts b/packages/kbn-unified-field-list/src/hooks/use_field_filters.ts index c3e08ff335602..0c04ace0911f6 100644 --- a/packages/kbn-unified-field-list/src/hooks/use_field_filters.ts +++ b/packages/kbn-unified-field-list/src/hooks/use_field_filters.ts @@ -10,8 +10,9 @@ import { useMemo, useState } from 'react'; import { htmlIdGenerator } from '@elastic/eui'; import { type DataViewField } from '@kbn/data-views-plugin/common'; import type { CoreStart } from '@kbn/core-lifecycle-browser'; +import type { FieldTypeKnown } from '@kbn/discover-utils/types'; import { type FieldListFiltersProps } from '../components/field_list_filters'; -import { type FieldListItem, type FieldTypeKnown, GetCustomFieldType } from '../types'; +import { type FieldListItem, GetCustomFieldType } from '../types'; import { getFieldIconType } from '../utils/field_types'; import { fieldNameWildcardMatcher } from '../utils/field_name_wildcard_matcher'; diff --git a/packages/kbn-unified-field-list/src/types.ts b/packages/kbn-unified-field-list/src/types.ts index ab9c2af61171a..76997c73176b3 100755 --- a/packages/kbn-unified-field-list/src/types.ts +++ b/packages/kbn-unified-field-list/src/types.ts @@ -8,6 +8,7 @@ import type { DataViewField } from '@kbn/data-views-plugin/common'; import type { EuiButtonIconProps, EuiButtonProps } from '@elastic/eui'; +import type { FieldTypeKnown } from '@kbn/discover-utils/types'; export interface BucketedAggregation { buckets: Array<{ @@ -89,11 +90,6 @@ export type FieldListGroups = { [key in FieldsGroupNames]?: FieldsGroup; }; -export type FieldTypeKnown = Exclude< - DataViewField['timeSeriesMetric'] | DataViewField['type'], - undefined ->; - export type GetCustomFieldType = (field: T) => FieldTypeKnown; export interface RenderFieldItemParams { diff --git a/packages/kbn-unified-field-list/src/utils/field_types/get_field_icon_type.ts b/packages/kbn-unified-field-list/src/utils/field_types/get_field_icon_type.ts index 13ba84121085f..b03ad8cb1389e 100644 --- a/packages/kbn-unified-field-list/src/utils/field_types/get_field_icon_type.ts +++ b/packages/kbn-unified-field-list/src/utils/field_types/get_field_icon_type.ts @@ -7,9 +7,9 @@ */ import { type DataViewField } from '@kbn/data-views-plugin/common'; +import { isKnownFieldType } from '@kbn/discover-utils'; import type { FieldListItem, GetCustomFieldType } from '../../types'; import { getFieldType } from './get_field_type'; -import { isKnownFieldType } from './field_types'; /** * Returns an icon type for a field diff --git a/packages/kbn-unified-field-list/src/utils/field_types/get_field_type.ts b/packages/kbn-unified-field-list/src/utils/field_types/get_field_type.ts index 3ff787188dd06..fc92301b8f8e3 100644 --- a/packages/kbn-unified-field-list/src/utils/field_types/get_field_type.ts +++ b/packages/kbn-unified-field-list/src/utils/field_types/get_field_type.ts @@ -7,7 +7,8 @@ */ import { type DataViewField } from '@kbn/data-views-plugin/common'; -import type { FieldListItem, FieldTypeKnown } from '../../types'; +import type { FieldTypeKnown } from '@kbn/discover-utils/types'; +import type { FieldListItem } from '../../types'; /** * Returns a field type. Time series metric type will override the original field type. diff --git a/packages/kbn-unified-field-list/src/utils/field_types/get_field_type_description.test.ts b/packages/kbn-unified-field-list/src/utils/field_types/get_field_type_description.test.ts index 26434008e34ea..8c9ed41e05287 100644 --- a/packages/kbn-unified-field-list/src/utils/field_types/get_field_type_description.test.ts +++ b/packages/kbn-unified-field-list/src/utils/field_types/get_field_type_description.test.ts @@ -7,7 +7,7 @@ */ import { getFieldTypeDescription, UNKNOWN_FIELD_TYPE_DESC } from './get_field_type_description'; -import { KNOWN_FIELD_TYPES } from './field_types'; +import { KNOWN_FIELD_TYPES } from '@kbn/discover-utils'; describe('UnifiedFieldList getFieldTypeDescription()', () => { describe('known field types should be recognized', () => { diff --git a/packages/kbn-unified-field-list/src/utils/field_types/get_field_type_description.ts b/packages/kbn-unified-field-list/src/utils/field_types/get_field_type_description.ts index cadb07e59eeb4..7f6f9b6e1d765 100644 --- a/packages/kbn-unified-field-list/src/utils/field_types/get_field_type_description.ts +++ b/packages/kbn-unified-field-list/src/utils/field_types/get_field_type_description.ts @@ -8,7 +8,7 @@ import { i18n } from '@kbn/i18n'; import { KBN_FIELD_TYPES } from '@kbn/field-types'; -import { KNOWN_FIELD_TYPES } from './field_types'; +import { KNOWN_FIELD_TYPES } from '@kbn/discover-utils'; /** * A user-friendly description of an unknown field type diff --git a/packages/kbn-unified-field-list/src/utils/field_types/index.ts b/packages/kbn-unified-field-list/src/utils/field_types/index.ts index 732d98e63f8f9..59d09efdd19d6 100644 --- a/packages/kbn-unified-field-list/src/utils/field_types/index.ts +++ b/packages/kbn-unified-field-list/src/utils/field_types/index.ts @@ -6,8 +6,6 @@ * Side Public License, v 1. */ -export { KNOWN_FIELD_TYPES, KNOWN_FIELD_TYPE_LIST, isKnownFieldType } from './field_types'; -export { getFieldTypeName } from './get_field_type_name'; export { getFieldTypeDescription } from './get_field_type_description'; export { getFieldType } from './get_field_type'; export { getFieldIconType } from './get_field_icon_type'; diff --git a/src/plugins/discover/common/field_types.ts b/src/plugins/discover/common/field_types.ts deleted file mode 100644 index bd24797ab5323..0000000000000 --- a/src/plugins/discover/common/field_types.ts +++ /dev/null @@ -1,26 +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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -export enum KNOWN_FIELD_TYPES { - BOOLEAN = 'boolean', - CONFLICT = 'conflict', - DATE = 'date', - DATE_RANGE = 'date_range', - GEO_POINT = 'geo_point', - GEO_SHAPE = 'geo_shape', - HISTOGRAM = 'histogram', - IP = 'ip', - IP_RANGE = 'ip_range', - KEYWORD = 'keyword', - MURMUR3 = 'murmur3', - NUMBER = 'number', - NESTED = 'nested', - STRING = 'string', - TEXT = 'text', - VERSION = 'version', -} diff --git a/src/plugins/discover/kibana.jsonc b/src/plugins/discover/kibana.jsonc index 3da4912dd5661..0778ebf666851 100644 --- a/src/plugins/discover/kibana.jsonc +++ b/src/plugins/discover/kibana.jsonc @@ -24,6 +24,7 @@ "dataViewFieldEditor", "dataViewEditor", "expressions", + "unifiedDocViewer", "unifiedSearch", "unifiedHistogram", "contentManagement" diff --git a/src/plugins/discover/public/application/context/context_app.tsx b/src/plugins/discover/public/application/context/context_app.tsx index 6355d6de47e80..c11a9187a937f 100644 --- a/src/plugins/discover/public/application/context/context_app.tsx +++ b/src/plugins/discover/public/application/context/context_app.tsx @@ -19,6 +19,7 @@ import { i18n } from '@kbn/i18n'; import { reportPerformanceMetricEvent } from '@kbn/ebt-tools'; import { removeInterceptedWarningDuplicates } from '@kbn/search-response-warnings'; import { DOC_TABLE_LEGACY, SEARCH_FIELDS_FROM_SOURCE } from '@kbn/discover-utils'; +import type { DocViewFilterFn } from '@kbn/unified-doc-viewer/types'; import { ContextErrorMessage } from './components/context_error_message'; import { LoadingStatus } from './services/context_query_state'; import { AppState, GlobalState, isEqualFilters } from './services/context_state'; @@ -28,7 +29,6 @@ import { useContextAppFetch } from './hooks/use_context_app_fetch'; import { popularizeField } from '../../utils/popularize_field'; import { ContextAppContent } from './context_app_content'; import { SurrDocType } from './services/context'; -import { DocViewFilterFn } from '../../services/doc_views/doc_views_types'; import { useDiscoverServices } from '../../hooks/use_discover_services'; import { setBreadcrumbs } from '../../utils/breadcrumbs'; diff --git a/src/plugins/discover/public/application/context/context_app_content.tsx b/src/plugins/discover/public/application/context/context_app_content.tsx index c72b7f366e5ce..7e07a594e53c6 100644 --- a/src/plugins/discover/public/application/context/context_app_content.tsx +++ b/src/plugins/discover/public/application/context/context_app_content.tsx @@ -19,17 +19,16 @@ import { SearchResponseWarnings, } from '@kbn/search-response-warnings'; import { CONTEXT_STEP_SETTING, DOC_HIDE_TIME_COLUMN_SETTING } from '@kbn/discover-utils'; +import type { DocViewFilterFn } from '@kbn/unified-doc-viewer/types'; import { LoadingStatus } from './services/context_query_state'; import { ActionBar } from './components/action_bar/action_bar'; import { DataLoadingState, DiscoverGrid } from '../../components/discover_grid/discover_grid'; -import { DocViewFilterFn } from '../../services/doc_views/doc_views_types'; import { AppState } from './services/context_state'; import { SurrDocType } from './services/context'; import { MAX_CONTEXT_SIZE, MIN_CONTEXT_SIZE } from './services/constants'; import { DocTableContext } from '../../components/doc_table/doc_table_context'; import { useDiscoverServices } from '../../hooks/use_discover_services'; import { DiscoverGridFlyout } from '../../components/discover_grid/discover_grid_flyout'; -import { DocViewer } from '../../services/doc_views/components/doc_viewer'; export interface ContextAppContentProps { columns: string[]; @@ -157,7 +156,6 @@ export function ContextAppContent({ sort={sort} useNewFieldsApi={useNewFieldsApi} dataTestSubj="contextDocTable" - DocViewer={DocViewer} /> )} {!isLegacy && ( diff --git a/src/plugins/discover/public/application/doc/components/doc.test.tsx b/src/plugins/discover/public/application/doc/components/doc.test.tsx index dc93a5718e1e0..56eac62b0318c 100644 --- a/src/plugins/discover/public/application/doc/components/doc.test.tsx +++ b/src/plugins/discover/public/application/doc/components/doc.test.tsx @@ -16,29 +16,11 @@ import { Doc, DocProps } from './doc'; import { SEARCH_FIELDS_FROM_SOURCE as mockSearchFieldsFromSource } from '@kbn/discover-utils'; import { dataViewMock } from '@kbn/discover-utils/src/__mocks__'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; +import { setUnifiedDocViewerServices } from '@kbn/unified-doc-viewer-plugin/public/plugin'; +import { mockUnifiedDocViewerServices } from '@kbn/unified-doc-viewer-plugin/public/__mocks__'; const mockSearchApi = jest.fn(); -jest.mock('../../../kibana_services', () => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - let registry: any[] = []; - - return { - getDocViewsRegistry: () => ({ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - addDocView(view: any) { - registry.push(view); - }, - getDocViewsSorted() { - return registry; - }, - resetRegistry: () => { - registry = []; - }, - }), - }; -}); - beforeEach(() => { jest.clearAllMocks(); }); @@ -86,6 +68,7 @@ async function mountDoc(update = false) { locator: { getUrl: jest.fn(() => Promise.resolve('mock-url')) }, chrome: { setBreadcrumbs: jest.fn() }, }; + setUnifiedDocViewerServices(mockUnifiedDocViewerServices); await act(async () => { comp = mountWithIntl( diff --git a/src/plugins/discover/public/application/doc/components/doc.tsx b/src/plugins/discover/public/application/doc/components/doc.tsx index 384d0d7a4ffac..83c2c08eafa2e 100644 --- a/src/plugins/discover/public/application/doc/components/doc.tsx +++ b/src/plugins/discover/public/application/doc/components/doc.tsx @@ -9,40 +9,18 @@ import React, { useEffect } from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; import { EuiCallOut, EuiLink, EuiLoadingSpinner, EuiPage, EuiPageBody } from '@elastic/eui'; -import type { DataView } from '@kbn/data-views-plugin/public'; import { i18n } from '@kbn/i18n'; -import type { DataTableRecord } from '@kbn/discover-utils/types'; +import { ElasticRequestState } from '@kbn/unified-doc-viewer'; +import { UnifiedDocViewer, useEsDocSearch } from '@kbn/unified-doc-viewer-plugin/public'; +import type { EsDocSearchProps } from '@kbn/unified-doc-viewer-plugin/public/types'; import { setBreadcrumbs } from '../../../utils/breadcrumbs'; -import { DocViewer } from '../../../services/doc_views/components/doc_viewer'; -import { ElasticRequestState } from '../types'; -import { useEsDocSearch } from '../../../hooks/use_es_doc_search'; import { useDiscoverServices } from '../../../hooks/use_discover_services'; -export interface DocProps { - /** - * Id of the doc in ES - */ - id: string; - /** - * Index in ES to query - */ - index: string; - /** - * DataView entity - */ - dataView: DataView; - /** - * If set, will always request source, regardless of the global `fieldsFromSource` setting - */ - requestSource?: boolean; +export interface DocProps extends EsDocSearchProps { /** * Discover main view url */ referrer?: string; - /** - * Records fetched from text based query - */ - textBasedHits?: DataTableRecord[]; } export function Doc(props: DocProps) { @@ -141,7 +119,7 @@ export function Doc(props: DocProps) { {reqState === ElasticRequestState.Found && hit !== null && dataView && (
- +
)} diff --git a/src/plugins/discover/public/application/main/components/layout/discover_documents.tsx b/src/plugins/discover/public/application/main/components/layout/discover_documents.tsx index 10c0ca87ce504..5019c3e135acc 100644 --- a/src/plugins/discover/public/application/main/components/layout/discover_documents.tsx +++ b/src/plugins/discover/public/application/main/components/layout/discover_documents.tsx @@ -28,10 +28,10 @@ import { SAMPLE_SIZE_SETTING, SEARCH_FIELDS_FROM_SOURCE, } from '@kbn/discover-utils'; +import type { DocViewFilterFn } from '@kbn/unified-doc-viewer/types'; import { useInternalStateSelector } from '../../services/discover_internal_state_container'; import { useAppStateSelector } from '../../services/discover_app_state_container'; import { useDiscoverServices } from '../../../../hooks/use_discover_services'; -import { DocViewFilterFn } from '../../../../services/doc_views/doc_views_types'; import { DataLoadingState, DiscoverGrid } from '../../../../components/discover_grid/discover_grid'; import { FetchStatus } from '../../../types'; import { useColumns } from '../../../../hooks/use_data_grid_columns'; @@ -44,7 +44,6 @@ import { DocumentExplorerUpdateCallout } from '../document_explorer_callout/docu import { DiscoverTourProvider } from '../../../../components/discover_tour'; import { getRawRecordType } from '../../utils/get_raw_record_type'; import { DiscoverGridFlyout } from '../../../../components/discover_grid/discover_grid_flyout'; -import { DocViewer } from '../../../../services/doc_views/components/doc_viewer'; import { useSavedSearchInitial } from '../../services/discover_state_provider'; import { useFetchMoreRecords } from './use_fetch_more_records'; @@ -236,7 +235,6 @@ function DiscoverDocumentsComponent({ onSort={!isTextBasedQuery ? onSort : undefined} useNewFieldsApi={useNewFieldsApi} dataTestSubj="discoverDocTable" - DocViewer={DocViewer} /> )} diff --git a/src/plugins/discover/public/application/main/components/layout/discover_layout.tsx b/src/plugins/discover/public/application/main/components/layout/discover_layout.tsx index 328153b6eeec5..550be02a6733d 100644 --- a/src/plugins/discover/public/application/main/components/layout/discover_layout.tsx +++ b/src/plugins/discover/public/application/main/components/layout/discover_layout.tsx @@ -24,6 +24,7 @@ import { generateFilters } from '@kbn/data-plugin/public'; import { useDragDropContext } from '@kbn/dom-drag-drop'; import { DataViewField, DataViewType } from '@kbn/data-views-plugin/public'; import { SEARCH_FIELDS_FROM_SOURCE, SHOW_FIELD_STATISTICS } from '@kbn/discover-utils'; +import type { DocViewFilterFn } from '@kbn/unified-doc-viewer/types'; import { useSavedSearchInitial } from '../../services/discover_state_provider'; import { DiscoverStateContainer } from '../../services/discover_state'; import { VIEW_MODE } from '../../../../../common/constants'; @@ -36,7 +37,6 @@ import { LoadingSpinner } from '../loading_spinner/loading_spinner'; import { DiscoverSidebarResponsive } from '../sidebar'; import { popularizeField } from '../../../../utils/popularize_field'; import { DiscoverTopNav } from '../top_nav/discover_topnav'; -import { DocViewFilterFn } from '../../../../services/doc_views/doc_views_types'; import { getResultState } from '../../utils/get_result_state'; import { DiscoverUninitialized } from '../uninitialized/uninitialized'; import { DataMainMsg, RecordRawType } from '../../services/discover_data_state_container'; diff --git a/src/plugins/discover/public/application/main/components/layout/discover_main_content.tsx b/src/plugins/discover/public/application/main/components/layout/discover_main_content.tsx index 655ff5cbbb04f..91fe00263c1c4 100644 --- a/src/plugins/discover/public/application/main/components/layout/discover_main_content.tsx +++ b/src/plugins/discover/public/application/main/components/layout/discover_main_content.tsx @@ -12,10 +12,10 @@ import React, { useCallback } from 'react'; import { DataView } from '@kbn/data-views-plugin/common'; import { METRIC_TYPE } from '@kbn/analytics'; import { i18n } from '@kbn/i18n'; +import type { DocViewFilterFn } from '@kbn/unified-doc-viewer/types'; import { VIEW_MODE } from '../../../../../common/constants'; import { useDiscoverServices } from '../../../../hooks/use_discover_services'; import { DocumentViewModeToggle } from '../../../../components/view_mode_toggle'; -import { DocViewFilterFn } from '../../../../services/doc_views/doc_views_types'; import { DiscoverStateContainer } from '../../services/discover_state'; import { FieldStatisticsTab } from '../field_stats_table'; import { DiscoverDocuments } from './discover_documents'; diff --git a/src/plugins/discover/public/components/common/deferred_spinner.tsx b/src/plugins/discover/public/components/common/deferred_spinner.tsx deleted file mode 100644 index 11f77281f9eb0..0000000000000 --- a/src/plugins/discover/public/components/common/deferred_spinner.tsx +++ /dev/null @@ -1,32 +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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import React, { useEffect, useRef, useState } from 'react'; - -/** - * A component that shows it children with a 300ms delay. This is good for wrapping - * loading spinners for tasks that might potentially be very fast (e.g. loading async chunks). - * That way we don't show a quick flash of the spinner before the actual content and will only - * show the spinner once loading takes a bit longer (more than 300ms). - */ -export const DeferredSpinner: React.FC = ({ children }) => { - const timeoutRef = useRef(); - const [showContent, setShowContent] = useState(false); - useEffect(() => { - timeoutRef.current = window.setTimeout(() => { - setShowContent(true); - }, 300); - return () => { - if (timeoutRef.current) { - clearTimeout(timeoutRef.current); - } - }; - }, []); - - return showContent ? {children} : null; -}; diff --git a/src/plugins/discover/public/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid.tsx index c9ef3119ae421..662c5eb670d49 100644 --- a/src/plugins/discover/public/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/components/discover_grid/discover_grid.tsx @@ -42,7 +42,7 @@ import { MAX_DOC_FIELDS_DISPLAYED, SHOW_MULTIFIELDS, } from '@kbn/discover-utils'; -import { DocViewFilterFn } from '../../services/doc_views/doc_views_types'; +import type { DocViewFilterFn } from '@kbn/unified-doc-viewer/types'; import { getSchemaDetectors } from './discover_grid_schema'; import { DiscoverGridFlyout } from './discover_grid_flyout'; import { DiscoverGridContext } from './discover_grid_context'; diff --git a/src/plugins/discover/public/components/discover_grid/discover_grid_cell_actions.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_cell_actions.tsx index 59cd130277f90..32779230e1b7f 100644 --- a/src/plugins/discover/public/components/discover_grid/discover_grid_cell_actions.tsx +++ b/src/plugins/discover/public/components/discover_grid/discover_grid_cell_actions.tsx @@ -10,7 +10,7 @@ import React, { useContext } from 'react'; import { EuiDataGridColumnCellActionProps } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { DataViewField } from '@kbn/data-views-plugin/public'; -import { DocViewFilterFn } from '../../services/doc_views/doc_views_types'; +import type { DocViewFilterFn } from '@kbn/unified-doc-viewer/types'; import { DiscoverGridContext, GridContext } from './discover_grid_context'; import { useDiscoverServices } from '../../hooks/use_discover_services'; import { copyValueToClipboard } from '../../utils/copy_value_to_clipboard'; diff --git a/src/plugins/discover/public/components/discover_grid/discover_grid_columns.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_columns.tsx index a93b8a9ff1464..8effacbf9427f 100644 --- a/src/plugins/discover/public/components/discover_grid/discover_grid_columns.tsx +++ b/src/plugins/discover/public/components/discover_grid/discover_grid_columns.tsx @@ -17,7 +17,7 @@ import { } from '@elastic/eui'; import type { DataView } from '@kbn/data-views-plugin/public'; import { ToastsStart, IUiSettingsClient } from '@kbn/core/public'; -import { DocViewFilterFn } from '../../services/doc_views/doc_views_types'; +import type { DocViewFilterFn } from '@kbn/unified-doc-viewer/types'; import { ExpandButton } from './discover_grid_expand_button'; import { DiscoverGridSettings } from './types'; import type { ValueToStringConverter } from '../../types'; diff --git a/src/plugins/discover/public/components/discover_grid/discover_grid_context.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_context.tsx index 8ec4689a00178..f2dfd540c7d05 100644 --- a/src/plugins/discover/public/components/discover_grid/discover_grid_context.tsx +++ b/src/plugins/discover/public/components/discover_grid/discover_grid_context.tsx @@ -9,7 +9,7 @@ import React from 'react'; import type { DataView } from '@kbn/data-views-plugin/public'; import type { DataTableRecord } from '@kbn/discover-utils/types'; -import type { DocViewFilterFn } from '../../services/doc_views/doc_views_types'; +import type { DocViewFilterFn } from '@kbn/unified-doc-viewer/types'; import type { ValueToStringConverter } from '../../types'; export interface GridContext { diff --git a/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.test.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.test.tsx index e42fae3eacd3b..d8691180dc727 100644 --- a/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.test.tsx +++ b/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.test.tsx @@ -14,8 +14,6 @@ import { DiscoverGridFlyout, DiscoverGridFlyoutProps } from './discover_grid_fly import { createFilterManagerMock } from '@kbn/data-plugin/public/query/filter_manager/filter_manager.mock'; import { dataViewMock, esHitsMock } from '@kbn/discover-utils/src/__mocks__'; import { DiscoverServices } from '../../build_services'; -import { DocViewsRegistry } from '../../services/doc_views/doc_views_registry'; -import { setDocViewsRegistry } from '../../kibana_services'; import { dataViewWithTimefieldMock } from '../../__mocks__/data_view_with_timefield'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; import type { DataView } from '@kbn/data-views-plugin/public'; @@ -23,6 +21,8 @@ import type { DataTableRecord, EsHitRecord } from '@kbn/discover-utils/types'; import { buildDataTableRecord } from '@kbn/discover-utils'; import { act } from 'react-dom/test-utils'; import { ReactWrapper } from 'enzyme'; +import { setUnifiedDocViewerServices } from '@kbn/unified-doc-viewer-plugin/public/plugin'; +import { mockUnifiedDocViewerServices } from '@kbn/unified-doc-viewer-plugin/public/__mocks__'; const waitNextTick = () => new Promise((resolve) => setTimeout(resolve, 0)); @@ -34,8 +34,6 @@ const waitNextUpdate = async (component: ReactWrapper) => { }; describe('Discover flyout', function () { - setDocViewsRegistry(new DocViewsRegistry()); - const mountComponent = async ({ dataView, hits, @@ -60,6 +58,7 @@ describe('Discover flyout', function () { contextLocator: { getRedirectUrl: jest.fn(() => 'mock-context-redirect-url') }, singleDocLocator: { getRedirectUrl: jest.fn(() => 'mock-doc-redirect-url') }, } as unknown as DiscoverServices; + setUnifiedDocViewerServices(mockUnifiedDocViewerServices); const hit = buildDataTableRecord( hitIndex ? esHitsMock[hitIndex] : (esHitsMock[0] as EsHitRecord), diff --git a/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.tsx index f277ad47200ff..ab25ac97fdc3c 100644 --- a/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.tsx +++ b/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.tsx @@ -27,8 +27,8 @@ import { } from '@elastic/eui'; import type { Filter, Query, AggregateQuery } from '@kbn/es-query'; import type { DataTableRecord } from '@kbn/discover-utils/types'; -import { DocViewer } from '../../services/doc_views/components/doc_viewer/doc_viewer'; -import { DocViewFilterFn } from '../../services/doc_views/doc_views_types'; +import type { DocViewFilterFn } from '@kbn/unified-doc-viewer/types'; +import { UnifiedDocViewer } from '@kbn/unified-doc-viewer-plugin/public'; import { useNavigationProps } from '../../hooks/use_navigation_props'; import { useDiscoverServices } from '../../hooks/use_discover_services'; import { isTextBasedQuery } from '../../application/main/utils/is_text_based_query'; @@ -225,7 +225,7 @@ export function DiscoverGridFlyout({ - - - - { useNewFieldsApi: true, filterManager: mockFilterManager, addBasePath: (path: string) => path, - DocViewer, } as unknown as TableRowProps; - beforeEach(() => { - setDocViewsRegistry(new DocViewsRegistry()); - }); - it('should render __document__ column', () => { const component = mountComponent({ ...defaultProps, columns: [] }); const docTableField = findTestSubject(component, 'docTableField'); diff --git a/src/plugins/discover/public/components/doc_table/components/table_row.tsx b/src/plugins/discover/public/components/doc_table/components/table_row.tsx index e1c00ec3397c0..6057cd64aa473 100644 --- a/src/plugins/discover/public/components/doc_table/components/table_row.tsx +++ b/src/plugins/discover/public/components/doc_table/components/table_row.tsx @@ -19,10 +19,10 @@ import type { } from '@kbn/discover-utils/types'; import { formatFieldValue } from '@kbn/discover-utils'; import { DOC_HIDE_TIME_COLUMN_SETTING, MAX_DOC_FIELDS_DISPLAYED } from '@kbn/discover-utils'; -import { DocViewRenderProps } from '../../../services/doc_views/doc_views_types'; +import type { DocViewFilterFn } from '@kbn/unified-doc-viewer/types'; +import { UnifiedDocViewer } from '@kbn/unified-doc-viewer-plugin/public'; import { TableCell } from './table_row/table_cell'; import { formatRow, formatTopLevelObject } from '../utils/row_formatter'; -import { DocViewFilterFn } from '../../../services/doc_views/doc_views_types'; import { TableRowDetails } from './table_row_details'; import { useDiscoverServices } from '../../../hooks/use_discover_services'; @@ -43,7 +43,6 @@ export interface TableRowProps { shouldShowFieldHandler: ShouldShowFieldInTableHandler; onAddColumn?: (column: string) => void; onRemoveColumn?: (column: string) => void; - DocViewer: React.ComponentType; } export const TableRow = ({ @@ -59,7 +58,6 @@ export const TableRow = ({ shouldShowFieldHandler, onAddColumn, onRemoveColumn, - DocViewer, }: TableRowProps) => { const { uiSettings, fieldFormats } = useDiscoverServices(); const [maxEntries, hideTimeColumn] = useMemo( @@ -223,7 +221,7 @@ export const TableRow = ({ savedSearchId={savedSearchId} isPlainRecord={isPlainRecord} > - ); diff --git a/src/plugins/discover/public/components/doc_table/doc_table_wrapper.test.tsx b/src/plugins/discover/public/components/doc_table/doc_table_wrapper.test.tsx index 2f05c0c2b357d..17925373186f3 100644 --- a/src/plugins/discover/public/components/doc_table/doc_table_wrapper.test.tsx +++ b/src/plugins/discover/public/components/doc_table/doc_table_wrapper.test.tsx @@ -15,7 +15,6 @@ import { discoverServiceMock } from '../../__mocks__/services'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; import { buildDataTableRecord } from '@kbn/discover-utils'; import type { EsHitRecord } from '@kbn/discover-utils/types'; -import { DocViewer } from '../../services/doc_views/components/doc_viewer'; describe('Doc table component', () => { const mountComponent = (customProps?: Partial) => { @@ -48,7 +47,6 @@ describe('Doc table component', () => { render: () => { return
mock
; }, - DocViewer, ...(customProps || {}), }; diff --git a/src/plugins/discover/public/components/doc_table/doc_table_wrapper.tsx b/src/plugins/discover/public/components/doc_table/doc_table_wrapper.tsx index 8e32b97956cea..a61523b6647c3 100644 --- a/src/plugins/discover/public/components/doc_table/doc_table_wrapper.tsx +++ b/src/plugins/discover/public/components/doc_table/doc_table_wrapper.tsx @@ -14,9 +14,9 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { Filter } from '@kbn/es-query'; import type { DataTableRecord } from '@kbn/discover-utils/types'; import { SHOW_MULTIFIELDS, getShouldShowFieldHandler } from '@kbn/discover-utils'; +import type { DocViewFilterFn } from '@kbn/unified-doc-viewer/types'; import { TableHeader } from './components/table_header/table_header'; import { TableRow } from './components/table_row'; -import { DocViewFilterFn, DocViewRenderProps } from '../../services/doc_views/doc_views_types'; import { useDiscoverServices } from '../../hooks/use_discover_services'; export interface DocTableProps { @@ -89,10 +89,6 @@ export interface DocTableProps { * Remove column callback */ onRemoveColumn?: (column: string) => void; - /** - * Doc viewer component - */ - DocViewer: React.ComponentType; } export interface DocTableRenderProps { @@ -133,7 +129,6 @@ export const DocTableWrapper = forwardRef( sharedItemTitle, dataTestSubj, isLoading, - DocViewer, }: DocTableWrapperProps, ref ) => { @@ -191,7 +186,6 @@ export const DocTableWrapper = forwardRef( shouldShowFieldHandler={shouldShowFieldHandler} onAddColumn={onAddColumn} onRemoveColumn={onRemoveColumn} - DocViewer={DocViewer} isPlainRecord={isPlainRecord} rows={rows} /> @@ -207,7 +201,6 @@ export const DocTableWrapper = forwardRef( shouldShowFieldHandler, onAddColumn, onRemoveColumn, - DocViewer, isPlainRecord, rows, ] diff --git a/src/plugins/discover/public/kibana_services.ts b/src/plugins/discover/public/kibana_services.ts index 8d261d73696e5..ebab3c97c0cec 100644 --- a/src/plugins/discover/public/kibana_services.ts +++ b/src/plugins/discover/public/kibana_services.ts @@ -12,7 +12,6 @@ import type { ScopedHistory, AppMountParameters } from '@kbn/core/public'; import type { UiActionsStart } from '@kbn/ui-actions-plugin/public'; import { createGetterSetter } from '@kbn/kibana-utils-plugin/public'; import { HistoryLocationState } from './build_services'; -import { DocViewsRegistry } from './services/doc_views/doc_views_registry'; let uiActions: UiActionsStart; export interface UrlTracker { @@ -29,9 +28,6 @@ export const [getHeaderActionMenuMounter, setHeaderActionMenuMounter] = export const [getUrlTracker, setUrlTracker] = createGetterSetter('urlTracker'); -export const [getDocViewsRegistry, setDocViewsRegistry] = - createGetterSetter('DocViewsRegistry'); - /** * Makes sure discover and context are using one instance of history. */ diff --git a/src/plugins/discover/public/mocks.tsx b/src/plugins/discover/public/mocks.tsx index e733e9d32dbee..ae2bc4fa547fd 100644 --- a/src/plugins/discover/public/mocks.tsx +++ b/src/plugins/discover/public/mocks.tsx @@ -15,9 +15,6 @@ export type Start = jest.Mocked; const createSetupContract = (): Setup => { const setupContract: Setup = { - docViews: { - addDocView: jest.fn(), - }, locator: sharePluginMock.createLocator(), }; return setupContract; diff --git a/src/plugins/discover/public/plugin.tsx b/src/plugins/discover/public/plugin.tsx index c3b92275d3956..e00d9d29516c7 100644 --- a/src/plugins/discover/public/plugin.tsx +++ b/src/plugins/discover/public/plugin.tsx @@ -6,7 +6,6 @@ * Side Public License, v 1. */ -import { i18n } from '@kbn/i18n'; import React, { ComponentType } from 'react'; import { BehaviorSubject, combineLatest, map } from 'rxjs'; import { @@ -26,7 +25,6 @@ import { SharePluginStart, SharePluginSetup } from '@kbn/share-plugin/public'; import { UrlForwardingSetup, UrlForwardingStart } from '@kbn/url-forwarding-plugin/public'; import { HomePublicPluginSetup } from '@kbn/home-plugin/public'; import { Start as InspectorPublicPluginStart } from '@kbn/inspector-plugin/public'; -import { EuiSkeletonText } from '@elastic/eui'; import { DataPublicPluginSetup, DataPublicPluginStart } from '@kbn/data-plugin/public'; import { SavedObjectsStart } from '@kbn/saved-objects-plugin/public'; import { DEFAULT_APP_CATEGORIES } from '@kbn/core/public'; @@ -42,16 +40,14 @@ import type { SavedObjectTaggingOssPluginStart } from '@kbn/saved-objects-taggin import type { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public'; import type { SavedSearchPublicPluginStart } from '@kbn/saved-search-plugin/public'; import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public'; +import type { UnifiedDocViewerStart } from '@kbn/unified-doc-viewer-plugin/public'; import { setStateToKbnUrl } from '@kbn/kibana-utils-plugin/public'; import type { LensPublicStart } from '@kbn/lens-plugin/public'; +import { TRUNCATE_MAX_HEIGHT } from '@kbn/discover-utils'; import type { ServerlessPluginStart } from '@kbn/serverless/public'; -import { DOC_TABLE_LEGACY, TRUNCATE_MAX_HEIGHT } from '@kbn/discover-utils'; import { NoDataPagePluginStart } from '@kbn/no-data-page-plugin/public'; import { PLUGIN_ID } from '../common'; -import { DocViewInput, DocViewInputFn } from './services/doc_views/doc_views_types'; -import { DocViewsRegistry } from './services/doc_views/doc_views_registry'; import { - setDocViewsRegistry, setHeaderActionMenuMounter, setScopedHistory, setUiActions, @@ -61,10 +57,8 @@ import { import { registerFeature } from './register_feature'; import { buildServices } from './build_services'; import { SearchEmbeddableFactory } from './embeddable'; -import { DeferredSpinner } from './components'; import { ViewSavedSearchAction } from './embeddable/view_saved_search_action'; import { injectTruncateStyles } from './utils/truncate_styles'; -import { useDiscoverServices } from './hooks/use_discover_services'; import { initializeKbnUrlTracking } from './utils/initialize_kbn_url_tracking'; import { DiscoverContextAppLocator, @@ -86,24 +80,10 @@ import { type DiscoverContainerProps, } from './components/discover_container'; -const DocViewerLegacyTable = React.lazy( - () => import('./services/doc_views/components/doc_viewer_table/legacy') -); -const DocViewerTable = React.lazy(() => import('./services/doc_views/components/doc_viewer_table')); -const SourceViewer = React.lazy(() => import('./services/doc_views/components/doc_viewer_source')); - /** * @public */ export interface DiscoverSetup { - docViews: { - /** - * Add new doc view shown along with table view and json view in the details of each document in Discover. - * @param docViewRaw - */ - addDocView(docViewRaw: DocViewInput | DocViewInputFn): void; - }; - /** * `share` plugin URL locator for Discover app. Use it to generate links into * Discover application, for example, navigate: @@ -211,6 +191,7 @@ export interface DiscoverStartPlugins { savedObjectsManagement: SavedObjectsManagementPluginStart; savedSearch: SavedSearchPublicPluginStart; unifiedSearch: UnifiedSearchPublicPluginStart; + unifiedDocViewer: UnifiedDocViewerStart; lens: LensPublicStart; contentManagement: ContentManagementPublicStart; serverless?: ServerlessPluginStart; @@ -227,7 +208,6 @@ export class DiscoverPlugin constructor(private readonly initializerContext: PluginInitializerContext) {} private appStateUpdater = new BehaviorSubject(() => ({})); - private docViewsRegistry: DocViewsRegistry | null = null; private stopUrlTracking: (() => void) | undefined = undefined; private profileRegistry = createProfileRegistry(); private locator?: DiscoverAppLocator; @@ -253,59 +233,6 @@ export class DiscoverPlugin ); } - this.docViewsRegistry = new DocViewsRegistry(); - setDocViewsRegistry(this.docViewsRegistry); - this.docViewsRegistry.addDocView({ - title: i18n.translate('discover.docViews.table.tableTitle', { - defaultMessage: 'Table', - }), - order: 10, - component: (props) => { - // eslint-disable-next-line react-hooks/rules-of-hooks - const services = useDiscoverServices(); - const DocView = services.uiSettings.get(DOC_TABLE_LEGACY) - ? DocViewerLegacyTable - : DocViewerTable; - - return ( - - - - } - > - - - ); - }, - }); - this.docViewsRegistry.addDocView({ - title: i18n.translate('discover.docViews.json.jsonTitle', { - defaultMessage: 'JSON', - }), - order: 20, - component: ({ hit, dataView, query, textBasedHits }) => { - return ( - - - - } - > - - - ); - }, - }); - const { setTrackedUrl, restorePreviousUrl, @@ -418,9 +345,6 @@ export class DiscoverPlugin this.registerEmbeddable(core, plugins); return { - docViews: { - addDocView: this.docViewsRegistry.addDocView.bind(this.docViewsRegistry), - }, locator: this.locator, }; } diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer.test.tsx b/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer.test.tsx deleted file mode 100644 index c7c659c6f84d8..0000000000000 --- a/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer.test.tsx +++ /dev/null @@ -1,89 +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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import React from 'react'; -import { mount, shallow } from 'enzyme'; -import { DocViewer } from './doc_viewer'; -import { findTestSubject } from '@elastic/eui/lib/test'; -import { getDocViewsRegistry } from '../../../../kibana_services'; -import { DocViewRenderProps } from '../../doc_views_types'; -import { buildDataTableRecord } from '@kbn/discover-utils'; - -jest.mock('../../../../kibana_services', () => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - let registry: any[] = []; - return { - getDocViewsRegistry: () => ({ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - addDocView(view: any) { - registry.push(view); - }, - getDocViewsSorted() { - return registry; - }, - resetRegistry: () => { - registry = []; - }, - }), - }; -}); - -jest.mock('../../../../hooks/use_discover_services', () => { - return { - useDiscoverServices: { - uiSettings: { - get: jest.fn(), - }, - }, - }; -}); - -beforeEach(() => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (getDocViewsRegistry() as any).resetRegistry(); - jest.clearAllMocks(); -}); - -test('Render with 3 different tabs', () => { - const registry = getDocViewsRegistry(); - registry.addDocView({ order: 10, title: 'Render function', render: jest.fn() }); - registry.addDocView({ order: 20, title: 'React component', component: () =>
test
}); - // @ts-expect-error This should be invalid and will throw an error when rendering - registry.addDocView({ order: 30, title: 'Invalid doc view' }); - - const renderProps = { hit: {} } as DocViewRenderProps; - - const wrapper = shallow(); - - expect(wrapper).toMatchSnapshot(); -}); - -test('Render with 1 tab displaying error message', () => { - function SomeComponent() { - // this is just a placeholder - return null; - } - - const registry = getDocViewsRegistry(); - registry.addDocView({ - order: 10, - title: 'React component', - component: SomeComponent, - }); - - const renderProps = { - hit: buildDataTableRecord({ _index: 't', _id: '1' }), - } as DocViewRenderProps; - const errorMsg = 'Catch me if you can!'; - - const wrapper = mount(); - const error = new Error(errorMsg); - wrapper.find(SomeComponent).simulateError(error); - const errorMsgComponent = findTestSubject(wrapper, 'docViewerError'); - expect(errorMsgComponent.text()).toMatch(new RegExp(`${errorMsg}`)); -}); diff --git a/src/plugins/discover/tsconfig.json b/src/plugins/discover/tsconfig.json index 8e93218385709..231dcc926b830 100644 --- a/src/plugins/discover/tsconfig.json +++ b/src/plugins/discover/tsconfig.json @@ -51,8 +51,6 @@ "@kbn/shared-ux-page-analytics-no-data", "@kbn/alerting-plugin", "@kbn/ui-theme", - "@kbn/react-field", - "@kbn/monaco", "@kbn/config-schema", "@kbn/storybook", "@kbn/shared-ux-router", @@ -68,6 +66,8 @@ "@kbn/field-types", "@kbn/search-response-warnings", "@kbn/content-management-plugin", + "@kbn/unified-doc-viewer", + "@kbn/unified-doc-viewer-plugin", "@kbn/serverless", "@kbn/react-kibana-mount", "@kbn/react-kibana-context-render", diff --git a/src/plugins/unified_doc_viewer/README.md b/src/plugins/unified_doc_viewer/README.md new file mode 100644 index 0000000000000..5a88d60f00444 --- /dev/null +++ b/src/plugins/unified_doc_viewer/README.md @@ -0,0 +1,3 @@ +# unifiedDocViewer + +This plugin contains services reliant on the plugin lifecycle for the unified doc viewer component (see @kbn/unified-doc-viewer). \ No newline at end of file diff --git a/src/plugins/unified_doc_viewer/jest.config.js b/src/plugins/unified_doc_viewer/jest.config.js new file mode 100644 index 0000000000000..5250be53c79a6 --- /dev/null +++ b/src/plugins/unified_doc_viewer/jest.config.js @@ -0,0 +1,18 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../..', + roots: ['/src/plugins/unified_doc_viewer'], + coverageDirectory: '/target/kibana-coverage/jest/src/plugins/unified_doc_viewer', + coverageReporters: ['text', 'html'], + collectCoverageFrom: [ + '/src/plugins/unified_doc_viewer/{common,public,server}/**/*.{ts,tsx}', + ], +}; diff --git a/src/plugins/unified_doc_viewer/kibana.jsonc b/src/plugins/unified_doc_viewer/kibana.jsonc new file mode 100644 index 0000000000000..deb19cf85c0e4 --- /dev/null +++ b/src/plugins/unified_doc_viewer/kibana.jsonc @@ -0,0 +1,13 @@ +{ + "type": "plugin", + "id": "@kbn/unified-doc-viewer-plugin", + "owner": "@elastic/kibana-data-discovery", + "description": "This plugin contains services reliant on the plugin lifecycle for the unified doc viewer component (see @kbn/unified-doc-viewer).", + "plugin": { + "id": "unifiedDocViewer", + "server": false, + "browser": true, + "requiredBundles": ["kibanaUtils", "kibanaReact"], + "requiredPlugins": ["data", "fieldFormats"], + } +} diff --git a/src/plugins/unified_doc_viewer/public/__mocks__/index.ts b/src/plugins/unified_doc_viewer/public/__mocks__/index.ts new file mode 100644 index 0000000000000..d15c62a75d256 --- /dev/null +++ b/src/plugins/unified_doc_viewer/public/__mocks__/index.ts @@ -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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export * from './services'; diff --git a/src/plugins/unified_doc_viewer/public/__mocks__/services.ts b/src/plugins/unified_doc_viewer/public/__mocks__/services.ts new file mode 100644 index 0000000000000..c43b8daa86727 --- /dev/null +++ b/src/plugins/unified_doc_viewer/public/__mocks__/services.ts @@ -0,0 +1,27 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { analyticsServiceMock } from '@kbn/core-analytics-browser-mocks'; +import { dataPluginMock } from '@kbn/data-plugin/public/mocks'; +import { fieldFormatsMock } from '@kbn/field-formats-plugin/common/mocks'; +import { uiSettingsServiceMock } from '@kbn/core-ui-settings-browser-mocks'; +import type { UnifiedDocViewerServices, UnifiedDocViewerStart } from '../types'; +import { Storage } from '@kbn/kibana-utils-plugin/public'; + +export const mockUnifiedDocViewer: jest.Mocked = { + getDocViews: jest.fn().mockReturnValue([]), +}; + +export const mockUnifiedDocViewerServices: jest.Mocked = { + analytics: analyticsServiceMock.createAnalyticsServiceStart(), + data: dataPluginMock.createStartContract(), + fieldFormats: fieldFormatsMock, + storage: new Storage(localStorage), + uiSettings: uiSettingsServiceMock.createStartContract(), + unifiedDocViewer: mockUnifiedDocViewer, +}; diff --git a/src/plugins/unified_doc_viewer/public/components/doc_viewer/doc_viewer.tsx b/src/plugins/unified_doc_viewer/public/components/doc_viewer/doc_viewer.tsx new file mode 100644 index 0000000000000..beb9a032d8c84 --- /dev/null +++ b/src/plugins/unified_doc_viewer/public/components/doc_viewer/doc_viewer.tsx @@ -0,0 +1,22 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React from 'react'; +import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; +import type { DocViewRenderProps } from '@kbn/unified-doc-viewer/types'; +import { DocViewer } from '@kbn/unified-doc-viewer'; +import { getUnifiedDocViewerServices } from '../../plugin'; + +export function UnifiedDocViewer(props: DocViewRenderProps) { + const services = getUnifiedDocViewerServices(); + return ( + + + + ); +} diff --git a/src/plugins/unified_doc_viewer/public/components/doc_viewer/index.ts b/src/plugins/unified_doc_viewer/public/components/doc_viewer/index.ts new file mode 100644 index 0000000000000..799dfb8c9289f --- /dev/null +++ b/src/plugins/unified_doc_viewer/public/components/doc_viewer/index.ts @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { UnifiedDocViewer } from './doc_viewer'; + +// Required for usage in React.lazy +// eslint-disable-next-line import/no-default-export +export default UnifiedDocViewer; diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer_source/get_height.test.tsx b/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/get_height.test.tsx similarity index 100% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer_source/get_height.test.tsx rename to src/plugins/unified_doc_viewer/public/components/doc_viewer_source/get_height.test.tsx diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer_source/get_height.tsx b/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/get_height.tsx similarity index 100% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer_source/get_height.tsx rename to src/plugins/unified_doc_viewer/public/components/doc_viewer_source/get_height.tsx diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer_source/index.ts b/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/index.ts similarity index 100% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer_source/index.ts rename to src/plugins/unified_doc_viewer/public/components/doc_viewer_source/index.ts diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer_source/source.scss b/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.scss similarity index 100% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer_source/source.scss rename to src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.scss diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer_source/source.test.tsx b/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.test.tsx similarity index 94% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer_source/source.test.tsx rename to src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.test.tsx index 03853ba6b8d9e..02f31a2e4f46c 100644 --- a/src/plugins/discover/public/services/doc_views/components/doc_viewer_source/source.test.tsx +++ b/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.test.tsx @@ -10,10 +10,10 @@ import React from 'react'; import type { DataView } from '@kbn/data-views-plugin/public'; import { mountWithIntl } from '@kbn/test-jest-helpers'; import { DocViewerSource } from './source'; -import * as hooks from '../../../../hooks/use_es_doc_search'; +import * as hooks from '../../hooks/use_es_doc_search'; import * as useUiSettingHook from '@kbn/kibana-react-plugin/public/ui_settings/use_ui_setting'; import { EuiButton, EuiEmptyPrompt, EuiLoadingSpinner } from '@elastic/eui'; -import { JsonCodeEditorCommon } from '../../../../components/json_code_editor/json_code_editor_common'; +import { JsonCodeEditorCommon } from '../json_code_editor'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; import { buildDataTableRecord } from '@kbn/discover-utils'; import { of } from 'rxjs'; @@ -53,6 +53,7 @@ describe('Source Viewer component', () => { dataView={mockDataView} width={123} hasLineNumbers={true} + onRefresh={() => {}} />
); @@ -71,6 +72,7 @@ describe('Source Viewer component', () => { dataView={mockDataView} width={123} hasLineNumbers={true} + onRefresh={() => {}} /> ); @@ -110,6 +112,7 @@ describe('Source Viewer component', () => { dataView={mockDataView} width={123} hasLineNumbers={true} + onRefresh={() => {}} /> ); diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer_source/source.tsx b/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.tsx similarity index 76% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer_source/source.tsx rename to src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.tsx index 95c3b8b34e5d9..733f9040b3b3a 100644 --- a/src/plugins/discover/public/services/doc_views/components/doc_viewer_source/source.tsx +++ b/src/plugins/unified_doc_viewer/public/components/doc_viewer_source/source.tsx @@ -12,14 +12,14 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { monaco } from '@kbn/monaco'; import { EuiButton, EuiEmptyPrompt, EuiLoadingSpinner, EuiSpacer, EuiText } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { DataView } from '@kbn/data-views-plugin/public'; +import type { DataView } from '@kbn/data-views-plugin/public'; import type { DataTableRecord } from '@kbn/discover-utils/types'; +import { ElasticRequestState } from '@kbn/unified-doc-viewer'; import { DOC_TABLE_LEGACY, SEARCH_FIELDS_FROM_SOURCE } from '@kbn/discover-utils'; -import { useDiscoverServices } from '../../../../hooks/use_discover_services'; -import { JSONCodeEditorCommonMemoized } from '../../../../components/json_code_editor/json_code_editor_common'; -import { useEsDocSearch } from '../../../../hooks/use_es_doc_search'; -import { ElasticRequestState } from '../../../../application/doc/types'; +import { useEsDocSearch } from '../../hooks'; +import { useUnifiedDocViewerServices } from '../../hooks'; import { getHeight } from './get_height'; +import { JSONCodeEditorCommonMemoized } from '../json_code_editor'; interface SourceViewerProps { id: string; @@ -28,6 +28,8 @@ interface SourceViewerProps { textBasedHits?: DataTableRecord[]; hasLineNumbers: boolean; width?: number; + requestState?: ElasticRequestState; + onRefresh: () => void; } // Ihe number of lines displayed without scrolling used for classic table, which renders the component @@ -43,14 +45,15 @@ export const DocViewerSource = ({ width, hasLineNumbers, textBasedHits, + onRefresh, }: SourceViewerProps) => { const [editor, setEditor] = useState(); const [editorHeight, setEditorHeight] = useState(); const [jsonValue, setJsonValue] = useState(''); - const { uiSettings } = useDiscoverServices(); + const { uiSettings } = useUnifiedDocViewerServices(); const useNewFieldsApi = !uiSettings.get(SEARCH_FIELDS_FROM_SOURCE); const useDocExplorer = !uiSettings.get(DOC_TABLE_LEGACY); - const [reqState, hit, requestData] = useEsDocSearch({ + const [requestState, hit] = useEsDocSearch({ id, index, dataView, @@ -59,10 +62,10 @@ export const DocViewerSource = ({ }); useEffect(() => { - if (reqState === ElasticRequestState.Found && hit) { + if (requestState === ElasticRequestState.Found && hit) { setJsonValue(JSON.stringify(hit.raw, undefined, 2)); } - }, [reqState, hit]); + }, [requestState, hit]); // setting editor height // - classic view: based on lines height and count to stretch and fit its content @@ -93,26 +96,26 @@ export const DocViewerSource = ({
- +
); const errorMessageTitle = (

- {i18n.translate('discover.sourceViewer.errorMessageTitle', { + {i18n.translate('unifiedDocViewer.sourceViewer.errorMessageTitle', { defaultMessage: 'An Error Occurred', })}

); const errorMessage = (
- {i18n.translate('discover.sourceViewer.errorMessage', { + {i18n.translate('unifiedDocViewer.sourceViewer.errorMessage', { defaultMessage: 'Could not fetch data at this time. Refresh the tab to try again.', })} - - {i18n.translate('discover.sourceViewer.refresh', { + + {i18n.translate('unifiedDocViewer.sourceViewer.refresh', { defaultMessage: 'Refresh', })} @@ -122,11 +125,11 @@ export const DocViewerSource = ({ ); - if (reqState === ElasticRequestState.Error || reqState === ElasticRequestState.NotFound) { + if (requestState === ElasticRequestState.Error || requestState === ElasticRequestState.NotFound) { return errorState; } - if (reqState === ElasticRequestState.Loading || jsonValue === '') { + if (requestState === ElasticRequestState.Loading || jsonValue === '') { return loadingState; } diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/index.ts b/src/plugins/unified_doc_viewer/public/components/doc_viewer_table/index.ts similarity index 100% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer_table/index.ts rename to src/plugins/unified_doc_viewer/public/components/doc_viewer_table/index.ts diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/index.ts b/src/plugins/unified_doc_viewer/public/components/doc_viewer_table/legacy/index.ts similarity index 100% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/index.ts rename to src/plugins/unified_doc_viewer/public/components/doc_viewer_table/legacy/index.ts diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/table.test.tsx b/src/plugins/unified_doc_viewer/public/components/doc_viewer_table/legacy/table.test.tsx similarity index 97% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/table.test.tsx rename to src/plugins/unified_doc_viewer/public/components/doc_viewer_table/legacy/table.test.tsx index d1ab0d3d8b3e5..3a614ef71ad5e 100644 --- a/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/table.test.tsx +++ b/src/plugins/unified_doc_viewer/public/components/doc_viewer_table/legacy/table.test.tsx @@ -10,11 +10,11 @@ import React from 'react'; import { mountWithIntl } from '@kbn/test-jest-helpers'; import { findTestSubject } from '@elastic/eui/lib/test'; import { DocViewerLegacyTable } from './table'; -import { DataView } from '@kbn/data-views-plugin/public'; -import { DocViewRenderProps } from '../../../doc_views_types'; +import type { DataView } from '@kbn/data-views-plugin/public'; +import type { DocViewRenderProps } from '@kbn/unified-doc-viewer/types'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; -import { DiscoverServices } from '../../../../../build_services'; import { buildDataTableRecord } from '@kbn/discover-utils'; +import type { UnifiedDocViewerServices } from '../../../hooks'; const services = { uiSettings: { @@ -73,7 +73,10 @@ dataView.fields.getByName = (name: string) => { return dataView.fields.getAll().find((field) => field.name === name); }; -const mountComponent = (props: DocViewRenderProps, overrides?: Partial) => { +const mountComponent = ( + props: DocViewRenderProps, + overrides?: Partial +) => { return mountWithIntl( {' '} @@ -419,7 +422,7 @@ describe('DocViewTable at Discover Doc with Fields API', () => { } }, }, - } as unknown as DiscoverServices; + } as unknown as UnifiedDocViewerServices; const component = mountComponent(props, overridedServices); const categoryKeywordRow = findTestSubject(component, 'tableDocViewRow-category.keyword'); diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/table.tsx b/src/plugins/unified_doc_viewer/public/components/doc_viewer_table/legacy/table.tsx similarity index 94% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/table.tsx rename to src/plugins/unified_doc_viewer/public/components/doc_viewer_table/legacy/table.tsx index 1d465978b17b1..6b2a70b868911 100644 --- a/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/table.tsx +++ b/src/plugins/unified_doc_viewer/public/components/doc_viewer_table/legacy/table.tsx @@ -17,8 +17,8 @@ import { getShouldShowFieldHandler, isNestedFieldParent, } from '@kbn/discover-utils'; -import { useDiscoverServices } from '../../../../../hooks/use_discover_services'; -import { DocViewRenderProps, FieldRecordLegacy } from '../../../doc_views_types'; +import type { DocViewRenderProps, FieldRecordLegacy } from '@kbn/unified-doc-viewer/types'; +import { useUnifiedDocViewerServices } from '../../../hooks'; import { ACTIONS_COLUMN, MAIN_COLUMNS } from './table_columns'; export const DocViewerLegacyTable = ({ @@ -29,7 +29,7 @@ export const DocViewerLegacyTable = ({ onAddColumn, onRemoveColumn, }: DocViewRenderProps) => { - const { fieldFormats, uiSettings } = useDiscoverServices(); + const { fieldFormats, uiSettings } = useUnifiedDocViewerServices(); const showMultiFields = useMemo(() => uiSettings.get(SHOW_MULTIFIELDS), [uiSettings]); const mapping = useCallback((name: string) => dataView.fields.getByName(name), [dataView.fields]); diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/table_cell_actions.tsx b/src/plugins/unified_doc_viewer/public/components/doc_viewer_table/legacy/table_cell_actions.tsx similarity index 93% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/table_cell_actions.tsx rename to src/plugins/unified_doc_viewer/public/components/doc_viewer_table/legacy/table_cell_actions.tsx index 3ce4b789bd1ff..4499a44190747 100644 --- a/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/table_cell_actions.tsx +++ b/src/plugins/unified_doc_viewer/public/components/doc_viewer_table/legacy/table_cell_actions.tsx @@ -7,12 +7,12 @@ */ import React from 'react'; -import { DataViewField } from '@kbn/data-views-plugin/public'; +import type { DataViewField } from '@kbn/data-views-plugin/public'; +import type { DocViewFilterFn } from '@kbn/unified-doc-viewer/types'; import { DocViewTableRowBtnFilterRemove } from './table_row_btn_filter_remove'; import { DocViewTableRowBtnFilterExists } from './table_row_btn_filter_exists'; import { DocViewTableRowBtnToggleColumn } from './table_row_btn_toggle_column'; import { DocViewTableRowBtnFilterAdd } from './table_row_btn_filter_add'; -import { DocViewFilterFn } from '../../../doc_views_types'; interface TableActionsProps { field: string; diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/table_columns.tsx b/src/plugins/unified_doc_viewer/public/components/doc_viewer_table/legacy/table_columns.tsx similarity index 84% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/table_columns.tsx rename to src/plugins/unified_doc_viewer/public/components/doc_viewer_table/legacy/table_columns.tsx index 121187761b2c6..4b79a84970698 100644 --- a/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/table_columns.tsx +++ b/src/plugins/unified_doc_viewer/public/components/doc_viewer_table/legacy/table_columns.tsx @@ -9,10 +9,10 @@ import { EuiBasicTableColumn, EuiText } from '@elastic/eui'; import React from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; -import { FieldName } from '../../../../../components/field_name/field_name'; +import type { FieldRecordLegacy } from '@kbn/unified-doc-viewer/types'; +import { FieldName } from '@kbn/unified-doc-viewer'; import { TableActions } from './table_cell_actions'; import { TableFieldValue } from '../table_cell_value'; -import { FieldRecordLegacy } from '../../../doc_views_types'; export const ACTIONS_COLUMN: EuiBasicTableColumn = { field: 'action', @@ -23,7 +23,7 @@ export const ACTIONS_COLUMN: EuiBasicTableColumn = { @@ -55,7 +55,10 @@ export const MAIN_COLUMNS: Array> = [ name: ( - + ), @@ -85,7 +88,10 @@ export const MAIN_COLUMNS: Array> = [ name: ( - + ), diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/table_row_btn_filter_add.tsx b/src/plugins/unified_doc_viewer/public/components/doc_viewer_table/legacy/table_row_btn_filter_add.tsx similarity index 77% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/table_row_btn_filter_add.tsx rename to src/plugins/unified_doc_viewer/public/components/doc_viewer_table/legacy/table_row_btn_filter_add.tsx index ac3768cb96ecd..180dae22cb25f 100644 --- a/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/table_row_btn_filter_add.tsx +++ b/src/plugins/unified_doc_viewer/public/components/doc_viewer_table/legacy/table_row_btn_filter_add.tsx @@ -19,12 +19,12 @@ export interface Props { export function DocViewTableRowBtnFilterAdd({ onClick, disabled = false }: Props) { const tooltipContent = disabled ? ( ) : ( ); @@ -32,9 +32,12 @@ export function DocViewTableRowBtnFilterAdd({ onClick, disabled = false }: Props return ( ) : ( ) ) : ( ); @@ -44,9 +44,12 @@ export function DocViewTableRowBtnFilterExists({ return ( ) : ( ); @@ -32,9 +32,12 @@ export function DocViewTableRowBtnFilterRemove({ onClick, disabled = false }: Pr return ( } > { const showActionsInsideTableCell = useIsWithinBreakpoints(['xl'], true); - const { storage, uiSettings, fieldFormats } = useDiscoverServices(); + const { fieldFormats, storage, uiSettings } = useUnifiedDocViewerServices(); const showMultiFields = uiSettings.get(SHOW_MULTIFIELDS); const currentDataViewId = dataView.id!; const isSingleDocView = !filter; @@ -129,7 +129,7 @@ export const DocViewerTable = ({ [flattened, dataView, showMultiFields] ); - const searchPlaceholder = i18n.translate('discover.docView.table.searchPlaceHolder', { + const searchPlaceholder = i18n.translate('unifiedDocViewer.docView.table.searchPlaceHolder', { defaultMessage: 'Search field names', }); @@ -283,7 +283,7 @@ export const DocViewerTable = ({ @@ -293,14 +293,20 @@ export const DocViewerTable = ({ - + , - + , @@ -401,7 +407,10 @@ export const DocViewerTable = ({ {rowElements.length === 0 ? (

- +

) : ( diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/table_cell_actions.tsx b/src/plugins/unified_doc_viewer/public/components/doc_viewer_table/table_cell_actions.tsx similarity index 75% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer_table/table_cell_actions.tsx rename to src/plugins/unified_doc_viewer/public/components/doc_viewer_table/table_cell_actions.tsx index 9f29f3ba7f69f..8b9a35e071310 100644 --- a/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/table_cell_actions.tsx +++ b/src/plugins/unified_doc_viewer/public/components/doc_viewer_table/table_cell_actions.tsx @@ -17,7 +17,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import type { DataViewField } from '@kbn/data-views-plugin/public'; -import { DocViewFilterFn } from '../../doc_views_types'; +import type { DocViewFilterFn } from '@kbn/unified-doc-viewer/types'; interface TableActionsProps { mode?: 'inline' | 'as_popover'; @@ -43,43 +43,49 @@ export const TableActions = ({ onTogglePinned, }: TableActionsProps) => { const [isOpen, setIsOpen] = useState(false); - const openActionsLabel = i18n.translate('discover.docView.table.actions.open', { + const openActionsLabel = i18n.translate('unifiedDocViewer.docView.table.actions.open', { defaultMessage: 'Open actions', }); - const actionsLabel = i18n.translate('discover.docView.table.actions.label', { + const actionsLabel = i18n.translate('unifiedDocViewer.docView.table.actions.label', { defaultMessage: 'Actions', }); // Filters pair const filtersPairDisabled = !fieldMapping || !fieldMapping.filterable || ignoredValue; - const filterAddLabel = i18n.translate('discover.docViews.table.filterForValueButtonTooltip', { - defaultMessage: 'Filter for value', - }); + const filterAddLabel = i18n.translate( + 'unifiedDocViewer.docViews.table.filterForValueButtonTooltip', + { + defaultMessage: 'Filter for value', + } + ); const filterAddAriaLabel = i18n.translate( - 'discover.docViews.table.filterForValueButtonAriaLabel', + 'unifiedDocViewer.docViews.table.filterForValueButtonAriaLabel', { defaultMessage: 'Filter for value' } ); - const filterOutLabel = i18n.translate('discover.docViews.table.filterOutValueButtonTooltip', { - defaultMessage: 'Filter out value', - }); + const filterOutLabel = i18n.translate( + 'unifiedDocViewer.docViews.table.filterOutValueButtonTooltip', + { + defaultMessage: 'Filter out value', + } + ); const filterOutAriaLabel = i18n.translate( - 'discover.docViews.table.filterOutValueButtonAriaLabel', + 'unifiedDocViewer.docViews.table.filterOutValueButtonAriaLabel', { defaultMessage: 'Filter out value' } ); const filtersPairToolTip = (filtersPairDisabled && - i18n.translate('discover.docViews.table.unindexedFieldsCanNotBeSearchedTooltip', { + i18n.translate('unifiedDocViewer.docViews.table.unindexedFieldsCanNotBeSearchedTooltip', { defaultMessage: 'Unindexed fields or ignored values cannot be searched', })) || undefined; // Filter exists const filterExistsLabel = i18n.translate( - 'discover.docViews.table.filterForFieldPresentButtonTooltip', + 'unifiedDocViewer.docViews.table.filterForFieldPresentButtonTooltip', { defaultMessage: 'Filter for field present' } ); const filterExistsAriaLabel = i18n.translate( - 'discover.docViews.table.filterForFieldPresentButtonAriaLabel', + 'unifiedDocViewer.docViews.table.filterForFieldPresentButtonAriaLabel', { defaultMessage: 'Filter for field present' } ); const filtersExistsDisabled = !fieldMapping || !fieldMapping.filterable; @@ -87,35 +93,44 @@ export const TableActions = ({ (filtersExistsDisabled && (fieldMapping && fieldMapping.scripted ? i18n.translate( - 'discover.docViews.table.unableToFilterForPresenceOfScriptedFieldsTooltip', + 'unifiedDocViewer.docViews.table.unableToFilterForPresenceOfScriptedFieldsTooltip', { defaultMessage: 'Unable to filter for presence of scripted fields', } ) - : i18n.translate('discover.docViews.table.unableToFilterForPresenceOfMetaFieldsTooltip', { - defaultMessage: 'Unable to filter for presence of meta fields', - }))) || + : i18n.translate( + 'unifiedDocViewer.docViews.table.unableToFilterForPresenceOfMetaFieldsTooltip', + { + defaultMessage: 'Unable to filter for presence of meta fields', + } + ))) || undefined; // Toggle columns const toggleColumnsLabel = i18n.translate( - 'discover.docViews.table.toggleColumnInTableButtonTooltip', + 'unifiedDocViewer.docViews.table.toggleColumnInTableButtonTooltip', { defaultMessage: 'Toggle column in table' } ); const toggleColumnsAriaLabel = i18n.translate( - 'discover.docViews.table.toggleColumnInTableButtonAriaLabel', + 'unifiedDocViewer.docViews.table.toggleColumnInTableButtonAriaLabel', { defaultMessage: 'Toggle column in table' } ); // Pinned const pinnedLabel = pinned - ? i18n.translate('discover.docViews.table.unpinFieldLabel', { defaultMessage: 'Unpin field' }) - : i18n.translate('discover.docViews.table.pinFieldLabel', { defaultMessage: 'Pin field' }); + ? i18n.translate('unifiedDocViewer.docViews.table.unpinFieldLabel', { + defaultMessage: 'Unpin field', + }) + : i18n.translate('unifiedDocViewer.docViews.table.pinFieldLabel', { + defaultMessage: 'Pin field', + }); const pinnedAriaLabel = pinned - ? i18n.translate('discover.docViews.table.unpinFieldAriaLabel', { + ? i18n.translate('unifiedDocViewer.docViews.table.unpinFieldAriaLabel', { defaultMessage: 'Unpin field', }) - : i18n.translate('discover.docViews.table.pinFieldAriaLabel', { defaultMessage: 'Pin field' }); + : i18n.translate('unifiedDocViewer.docViews.table.pinFieldAriaLabel', { + defaultMessage: 'Pin field', + }); const pinnedIconType = pinned ? 'pinFilled' : 'pin'; const toggleOpenPopover = useCallback(() => setIsOpen((current) => !current), []); diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/table_cell_value.tsx b/src/plugins/unified_doc_viewer/public/components/doc_viewer_table/table_cell_value.tsx similarity index 83% rename from src/plugins/discover/public/services/doc_views/components/doc_viewer_table/table_cell_value.tsx rename to src/plugins/unified_doc_viewer/public/components/doc_viewer_table/table_cell_value.tsx index d1ec9d369439f..79c79e6a45836 100644 --- a/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/table_cell_value.tsx +++ b/src/plugins/unified_doc_viewer/public/components/doc_viewer_table/table_cell_value.tsx @@ -26,26 +26,26 @@ const IgnoreWarning: React.FC = React.memo(({ rawValue, reas switch (reason) { case IgnoredReason.IGNORE_ABOVE: return multiValue - ? i18n.translate('discover.docView.table.ignored.multiAboveTooltip', { + ? i18n.translate('unifiedDocViewer.docView.table.ignored.multiAboveTooltip', { defaultMessage: `One or more values in this field are too long and can't be searched or filtered.`, }) - : i18n.translate('discover.docView.table.ignored.singleAboveTooltip', { + : i18n.translate('unifiedDocViewer.docView.table.ignored.singleAboveTooltip', { defaultMessage: `The value in this field is too long and can't be searched or filtered.`, }); case IgnoredReason.MALFORMED: return multiValue - ? i18n.translate('discover.docView.table.ignored.multiMalformedTooltip', { + ? i18n.translate('unifiedDocViewer.docView.table.ignored.multiMalformedTooltip', { defaultMessage: `This field has one or more malformed values that can't be searched or filtered.`, }) - : i18n.translate('discover.docView.table.ignored.singleMalformedTooltip', { + : i18n.translate('unifiedDocViewer.docView.table.ignored.singleMalformedTooltip', { defaultMessage: `The value in this field is malformed and can't be searched or filtered.`, }); case IgnoredReason.UNKNOWN: return multiValue - ? i18n.translate('discover.docView.table.ignored.multiUnknownTooltip', { + ? i18n.translate('unifiedDocViewer.docView.table.ignored.multiUnknownTooltip', { defaultMessage: `One or more values in this field were ignored by Elasticsearch and can't be searched or filtered.`, }) - : i18n.translate('discover.docView.table.ignored.singleUnknownTooltip', { + : i18n.translate('unifiedDocViewer.docView.table.ignored.singleUnknownTooltip', { defaultMessage: `The value in this field was ignored by Elasticsearch and can't be searched or filtered.`, }); } @@ -67,10 +67,10 @@ const IgnoreWarning: React.FC = React.memo(({ rawValue, reas {multiValue - ? i18n.translate('discover.docViews.table.ignored.multiValueLabel', { + ? i18n.translate('unifiedDocViewer.docViews.table.ignored.multiValueLabel', { defaultMessage: 'Contains ignored values', }) - : i18n.translate('discover.docViews.table.ignored.singleValueLabel', { + : i18n.translate('unifiedDocViewer.docViews.table.ignored.singleValueLabel', { defaultMessage: 'Ignored value', })} diff --git a/src/plugins/unified_doc_viewer/public/components/index.ts b/src/plugins/unified_doc_viewer/public/components/index.ts new file mode 100644 index 0000000000000..b5f3a8948d689 --- /dev/null +++ b/src/plugins/unified_doc_viewer/public/components/index.ts @@ -0,0 +1,12 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export * from './doc_viewer'; +export * from './doc_viewer_source'; +export * from './doc_viewer_table'; +export * from './json_code_editor'; diff --git a/src/plugins/discover/public/components/json_code_editor/__snapshots__/json_code_editor.test.tsx.snap b/src/plugins/unified_doc_viewer/public/components/json_code_editor/__snapshots__/json_code_editor.test.tsx.snap similarity index 100% rename from src/plugins/discover/public/components/json_code_editor/__snapshots__/json_code_editor.test.tsx.snap rename to src/plugins/unified_doc_viewer/public/components/json_code_editor/__snapshots__/json_code_editor.test.tsx.snap diff --git a/src/plugins/unified_doc_viewer/public/components/json_code_editor/index.ts b/src/plugins/unified_doc_viewer/public/components/json_code_editor/index.ts new file mode 100644 index 0000000000000..d0e3147e65ab1 --- /dev/null +++ b/src/plugins/unified_doc_viewer/public/components/json_code_editor/index.ts @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export * from './json_code_editor'; +export * from './json_code_editor_common'; diff --git a/src/plugins/discover/public/components/json_code_editor/json_code_editor.scss b/src/plugins/unified_doc_viewer/public/components/json_code_editor/json_code_editor.scss similarity index 100% rename from src/plugins/discover/public/components/json_code_editor/json_code_editor.scss rename to src/plugins/unified_doc_viewer/public/components/json_code_editor/json_code_editor.scss diff --git a/src/plugins/discover/public/components/json_code_editor/json_code_editor.test.tsx b/src/plugins/unified_doc_viewer/public/components/json_code_editor/json_code_editor.test.tsx similarity index 92% rename from src/plugins/discover/public/components/json_code_editor/json_code_editor.test.tsx rename to src/plugins/unified_doc_viewer/public/components/json_code_editor/json_code_editor.test.tsx index 9ec60410b591e..e1ec1373f8657 100644 --- a/src/plugins/discover/public/components/json_code_editor/json_code_editor.test.tsx +++ b/src/plugins/unified_doc_viewer/public/components/json_code_editor/json_code_editor.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { shallow } from 'enzyme'; -import { JsonCodeEditor } from './json_code_editor'; +import JsonCodeEditor from './json_code_editor'; it('returns the `JsonCodeEditor` component', () => { const value = { diff --git a/src/plugins/discover/public/components/json_code_editor/json_code_editor.tsx b/src/plugins/unified_doc_viewer/public/components/json_code_editor/json_code_editor.tsx similarity index 78% rename from src/plugins/discover/public/components/json_code_editor/json_code_editor.tsx rename to src/plugins/unified_doc_viewer/public/components/json_code_editor/json_code_editor.tsx index 426a180d37957..d08e35eb6d4bf 100644 --- a/src/plugins/discover/public/components/json_code_editor/json_code_editor.tsx +++ b/src/plugins/unified_doc_viewer/public/components/json_code_editor/json_code_editor.tsx @@ -11,14 +11,21 @@ import './json_code_editor.scss'; import React from 'react'; import { JsonCodeEditorCommon } from './json_code_editor_common'; -interface JsonCodeEditorProps { +export interface JsonCodeEditorProps { json: Record; width?: string | number; height?: string | number; hasLineNumbers?: boolean; } -export const JsonCodeEditor = ({ json, width, height, hasLineNumbers }: JsonCodeEditorProps) => { +// Required for usage in React.lazy +// eslint-disable-next-line import/no-default-export +export default function JsonCodeEditor({ + json, + width, + height, + hasLineNumbers, +}: JsonCodeEditorProps) { const jsonValue = JSON.stringify(json, null, 2); return ( @@ -31,4 +38,4 @@ export const JsonCodeEditor = ({ json, width, height, hasLineNumbers }: JsonCode hideCopyButton={true} /> ); -}; +} diff --git a/src/plugins/discover/public/components/json_code_editor/json_code_editor_common.tsx b/src/plugins/unified_doc_viewer/public/components/json_code_editor/json_code_editor_common.tsx similarity index 93% rename from src/plugins/discover/public/components/json_code_editor/json_code_editor_common.tsx rename to src/plugins/unified_doc_viewer/public/components/json_code_editor/json_code_editor_common.tsx index 777240fe2f5bb..fa5dbfbe616ea 100644 --- a/src/plugins/discover/public/components/json_code_editor/json_code_editor_common.tsx +++ b/src/plugins/unified_doc_viewer/public/components/json_code_editor/json_code_editor_common.tsx @@ -14,10 +14,10 @@ import { monaco, XJsonLang } from '@kbn/monaco'; import { EuiButtonEmpty, EuiCopy, EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; import { CodeEditor } from '@kbn/kibana-react-plugin/public'; -const codeEditorAriaLabel = i18n.translate('discover.json.codeEditorAriaLabel', { +const codeEditorAriaLabel = i18n.translate('unifiedDocViewer.json.codeEditorAriaLabel', { defaultMessage: 'Read only JSON view of an elasticsearch document', }); -const copyToClipboardLabel = i18n.translate('discover.json.copyToClipboardLabel', { +const copyToClipboardLabel = i18n.translate('unifiedDocViewer.json.copyToClipboardLabel', { defaultMessage: 'Copy to clipboard', }); diff --git a/src/plugins/unified_doc_viewer/public/hooks/index.ts b/src/plugins/unified_doc_viewer/public/hooks/index.ts new file mode 100644 index 0000000000000..547032ce4415e --- /dev/null +++ b/src/plugins/unified_doc_viewer/public/hooks/index.ts @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export * from './use_doc_viewer_services'; +export * from './use_es_doc_search'; diff --git a/src/plugins/unified_doc_viewer/public/hooks/use_doc_viewer_services.ts b/src/plugins/unified_doc_viewer/public/hooks/use_doc_viewer_services.ts new file mode 100644 index 0000000000000..4287e87ea6aa3 --- /dev/null +++ b/src/plugins/unified_doc_viewer/public/hooks/use_doc_viewer_services.ts @@ -0,0 +1,30 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import type { AnalyticsServiceStart } from '@kbn/core-analytics-browser'; +import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; +import type { FieldFormatsStart } from '@kbn/field-formats-plugin/public'; +import type { Storage } from '@kbn/kibana-utils-plugin/public'; +import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser'; +import { useKibana } from '@kbn/kibana-react-plugin/public'; +import type { UnifiedDocViewerStart } from '../plugin'; + +export interface UnifiedDocViewerServices { + analytics: AnalyticsServiceStart; + data: DataPublicPluginStart; + fieldFormats: FieldFormatsStart; + storage: Storage; + uiSettings: IUiSettingsClient; + unifiedDocViewer: UnifiedDocViewerStart; +} + +export function useUnifiedDocViewerServices(): UnifiedDocViewerServices { + const { services } = useKibana(); + const { analytics, data, fieldFormats, storage, uiSettings, unifiedDocViewer } = services; + return { analytics, data, fieldFormats, storage, uiSettings, unifiedDocViewer }; +} diff --git a/src/plugins/discover/public/hooks/use_es_doc_search.test.tsx b/src/plugins/unified_doc_viewer/public/hooks/use_es_doc_search.test.tsx similarity index 93% rename from src/plugins/discover/public/hooks/use_es_doc_search.test.tsx rename to src/plugins/unified_doc_viewer/public/hooks/use_es_doc_search.test.tsx index 64a998a542069..cee1cf509e138 100644 --- a/src/plugins/discover/public/hooks/use_es_doc_search.test.tsx +++ b/src/plugins/unified_doc_viewer/public/hooks/use_es_doc_search.test.tsx @@ -7,11 +7,10 @@ */ import { renderHook, act } from '@testing-library/react-hooks'; -import { buildSearchBody, useEsDocSearch } from './use_es_doc_search'; +import { type EsDocSearchProps, buildSearchBody, useEsDocSearch } from './use_es_doc_search'; import { Subject } from 'rxjs'; -import { DataView } from '@kbn/data-views-plugin/public'; -import { DocProps } from '../application/doc/components/doc'; -import { ElasticRequestState } from '../application/doc/types'; +import type { DataView } from '@kbn/data-views-plugin/public'; +import { ElasticRequestState } from '@kbn/unified-doc-viewer'; import { SEARCH_FIELDS_FROM_SOURCE as mockSearchFieldsFromSource, buildDataTableRecord, @@ -227,9 +226,9 @@ describe('Test of helper / hook', () => { id: '1', index: 'index1', dataView, - } as unknown as DocProps; + } as unknown as EsDocSearchProps; - const hook = renderHook((p: DocProps) => useEsDocSearch(p), { + const hook = renderHook((p: EsDocSearchProps) => useEsDocSearch(p), { initialProps: props, wrapper: ({ children }) => ( {children} @@ -251,9 +250,9 @@ describe('Test of helper / hook', () => { id: '1', index: 'index1', dataView, - } as unknown as DocProps; + } as unknown as EsDocSearchProps; - const hook = renderHook((p: DocProps) => useEsDocSearch(p), { + const hook = renderHook((p: EsDocSearchProps) => useEsDocSearch(p), { initialProps: props, wrapper: ({ children }) => ( {children} @@ -305,9 +304,9 @@ describe('Test of helper / hook', () => { flattened: { field1: 1, field2: 2 }, }, ], - } as unknown as DocProps; + } as unknown as EsDocSearchProps; - const hook = renderHook((p: DocProps) => useEsDocSearch(p), { + const hook = renderHook((p: EsDocSearchProps) => useEsDocSearch(p), { initialProps: props, wrapper: ({ children }) => ( {children} diff --git a/src/plugins/discover/public/hooks/use_es_doc_search.ts b/src/plugins/unified_doc_viewer/public/hooks/use_es_doc_search.ts similarity index 84% rename from src/plugins/discover/public/hooks/use_es_doc_search.ts rename to src/plugins/unified_doc_viewer/public/hooks/use_es_doc_search.ts index b430d6b4531b9..d215306d6f7ea 100644 --- a/src/plugins/discover/public/hooks/use_es_doc_search.ts +++ b/src/plugins/unified_doc_viewer/public/hooks/use_es_doc_search.ts @@ -9,16 +9,38 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { lastValueFrom } from 'rxjs'; -import { DataView } from '@kbn/data-views-plugin/public'; +import type { DataView } from '@kbn/data-views-plugin/public'; import { reportPerformanceMetricEvent } from '@kbn/ebt-tools'; import type { DataTableRecord } from '@kbn/discover-utils/types'; import { SEARCH_FIELDS_FROM_SOURCE, buildDataTableRecord } from '@kbn/discover-utils'; -import { DocProps } from '../application/doc/components/doc'; -import { ElasticRequestState } from '../application/doc/types'; -import { useDiscoverServices } from './use_discover_services'; +import { ElasticRequestState } from '@kbn/unified-doc-viewer'; +import { useUnifiedDocViewerServices } from './use_doc_viewer_services'; type RequestBody = Pick; +export interface EsDocSearchProps { + /** + * Id of the doc in ES + */ + id: string; + /** + * Index in ES to query + */ + index: string; + /** + * DataView entity + */ + dataView: DataView; + /** + * If set, will always request source, regardless of the global `fieldsFromSource` setting + */ + requestSource?: boolean; + /** + * Records fetched from text based query + */ + textBasedHits?: DataTableRecord[]; +} + /** * Custom react hook for querying a single doc in ElasticSearch */ @@ -28,10 +50,10 @@ export function useEsDocSearch({ dataView, requestSource, textBasedHits, -}: DocProps): [ElasticRequestState, DataTableRecord | null, () => void] { +}: EsDocSearchProps): [ElasticRequestState, DataTableRecord | null, () => void] { const [status, setStatus] = useState(ElasticRequestState.Loading); const [hit, setHit] = useState(null); - const { data, uiSettings, analytics } = useDiscoverServices(); + const { data, uiSettings, analytics } = useUnifiedDocViewerServices(); const useNewFieldsApi = useMemo(() => !uiSettings.get(SEARCH_FIELDS_FROM_SOURCE), [uiSettings]); const requestData = useCallback(async () => { diff --git a/src/plugins/unified_doc_viewer/public/index.tsx b/src/plugins/unified_doc_viewer/public/index.tsx new file mode 100644 index 0000000000000..d08de9dcaa0eb --- /dev/null +++ b/src/plugins/unified_doc_viewer/public/index.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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React from 'react'; +import { withSuspense } from '@kbn/shared-ux-utility'; +import { EuiDelayRender, EuiSkeletonText } from '@elastic/eui'; +import { DocViewRenderProps } from '@kbn/unified-doc-viewer/src/services/types'; +import type { JsonCodeEditorProps } from './components'; +import { UnifiedDocViewerPublicPlugin } from './plugin'; + +export type { UnifiedDocViewerSetup, UnifiedDocViewerStart } from './plugin'; + +const LazyJsonCodeEditor = React.lazy( + () => import('./components/json_code_editor/json_code_editor') +); + +export const JsonCodeEditor = withSuspense( + LazyJsonCodeEditor, + + + +); + +const LazyUnifiedDocViewer = React.lazy(() => import('./components/doc_viewer')); +export const UnifiedDocViewer = withSuspense( + LazyUnifiedDocViewer, + + + +); + +export { useEsDocSearch, useUnifiedDocViewerServices } from './hooks'; + +export const plugin = () => new UnifiedDocViewerPublicPlugin(); diff --git a/src/plugins/unified_doc_viewer/public/plugin.tsx b/src/plugins/unified_doc_viewer/public/plugin.tsx new file mode 100644 index 0000000000000..018e6ffadd312 --- /dev/null +++ b/src/plugins/unified_doc_viewer/public/plugin.tsx @@ -0,0 +1,114 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React from 'react'; +import type { CoreSetup, Plugin } from '@kbn/core/public'; +import { DOC_TABLE_LEGACY } from '@kbn/discover-utils'; +import { i18n } from '@kbn/i18n'; +import { DocViewsRegistry } from '@kbn/unified-doc-viewer'; +import { EuiDelayRender, EuiSkeletonText } from '@elastic/eui'; +import { createGetterSetter, Storage } from '@kbn/kibana-utils-plugin/public'; +import { DataPublicPluginStart } from '@kbn/data-plugin/public'; +import { FieldFormatsStart } from '@kbn/field-formats-plugin/public'; +import { CoreStart } from '@kbn/core/public'; +import { type UnifiedDocViewerServices, useUnifiedDocViewerServices } from './hooks'; + +export const [getUnifiedDocViewerServices, setUnifiedDocViewerServices] = + createGetterSetter('UnifiedDocViewerServices'); + +const DocViewerLegacyTable = React.lazy(() => import('./components/doc_viewer_table/legacy')); +const DocViewerTable = React.lazy(() => import('./components/doc_viewer_table')); +const SourceViewer = React.lazy(() => import('./components/doc_viewer_source')); + +export interface UnifiedDocViewerSetup { + addDocView: DocViewsRegistry['addDocView']; +} + +export interface UnifiedDocViewerStart { + getDocViews: DocViewsRegistry['getDocViewsSorted']; +} + +export interface UnifiedDocViewerStartDeps { + data: DataPublicPluginStart; + fieldFormats: FieldFormatsStart; +} + +export class UnifiedDocViewerPublicPlugin + implements Plugin +{ + private docViewsRegistry = new DocViewsRegistry(); + + public setup(core: CoreSetup) { + this.docViewsRegistry.addDocView({ + title: i18n.translate('unifiedDocViewer.docViews.table.tableTitle', { + defaultMessage: 'Table', + }), + order: 10, + component: (props) => { + // eslint-disable-next-line react-hooks/rules-of-hooks + const { uiSettings } = useUnifiedDocViewerServices(); + const DocView = uiSettings.get(DOC_TABLE_LEGACY) ? DocViewerLegacyTable : DocViewerTable; + + return ( + + + + } + > + + + ); + }, + }); + + this.docViewsRegistry.addDocView({ + title: i18n.translate('unifiedDocViewer.docViews.json.jsonTitle', { + defaultMessage: 'JSON', + }), + order: 20, + component: ({ hit, dataView, query, textBasedHits }) => { + return ( + + + + } + > + {}} + /> + + ); + }, + }); + + return { + addDocView: this.docViewsRegistry.addDocView.bind(this.docViewsRegistry), + }; + } + + public start(core: CoreStart, deps: UnifiedDocViewerStartDeps) { + const { analytics, uiSettings } = core; + const { data, fieldFormats } = deps; + const storage = new Storage(localStorage); + const unifiedDocViewer = { + getDocViews: this.docViewsRegistry.getDocViewsSorted.bind(this.docViewsRegistry), + }; + const services = { analytics, data, fieldFormats, storage, uiSettings, unifiedDocViewer }; + setUnifiedDocViewerServices(services); + return unifiedDocViewer; + } +} diff --git a/src/plugins/unified_doc_viewer/public/types.ts b/src/plugins/unified_doc_viewer/public/types.ts new file mode 100644 index 0000000000000..d9ec40eedfffb --- /dev/null +++ b/src/plugins/unified_doc_viewer/public/types.ts @@ -0,0 +1,11 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export type { JsonCodeEditorProps } from './components'; +export type { EsDocSearchProps, UnifiedDocViewerServices } from './hooks'; +export type { UnifiedDocViewerSetup, UnifiedDocViewerStart } from './plugin'; diff --git a/src/plugins/unified_doc_viewer/tsconfig.json b/src/plugins/unified_doc_viewer/tsconfig.json new file mode 100644 index 0000000000000..3e959ca047e40 --- /dev/null +++ b/src/plugins/unified_doc_viewer/tsconfig.json @@ -0,0 +1,31 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + }, + "include": [ "../../../typings/**/*", "common/**/*", "public/**/*", "server/**/*"], + "kbn_references": [ + "@kbn/kibana-react-plugin", + "@kbn/monaco", + "@kbn/data-views-plugin", + "@kbn/test-jest-helpers", + "@kbn/discover-utils", + "@kbn/i18n-react", + "@kbn/i18n", + "@kbn/unified-doc-viewer", + "@kbn/unified-field-list", + "@kbn/kibana-utils-plugin", + "@kbn/data-plugin", + "@kbn/core-analytics-browser", + "@kbn/field-formats-plugin", + "@kbn/core-ui-settings-browser", + "@kbn/ebt-tools", + "@kbn/core", + "@kbn/shared-ux-utility", + "@kbn/core-analytics-browser-mocks", + "@kbn/core-ui-settings-browser-mocks" + ], + "exclude": [ + "target/**/*", + ] +} diff --git a/tsconfig.base.json b/tsconfig.base.json index c916d9bc563e3..b7e3ed499f701 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1494,6 +1494,12 @@ "@kbn/ui-shared-deps-src/*": ["packages/kbn-ui-shared-deps-src/*"], "@kbn/ui-theme": ["packages/kbn-ui-theme"], "@kbn/ui-theme/*": ["packages/kbn-ui-theme/*"], + "@kbn/unified-doc-viewer": ["packages/kbn-unified-doc-viewer"], + "@kbn/unified-doc-viewer/*": ["packages/kbn-unified-doc-viewer/*"], + "@kbn/unified-doc-viewer-examples": ["examples/unified_doc_viewer"], + "@kbn/unified-doc-viewer-examples/*": ["examples/unified_doc_viewer/*"], + "@kbn/unified-doc-viewer-plugin": ["src/plugins/unified_doc_viewer"], + "@kbn/unified-doc-viewer-plugin/*": ["src/plugins/unified_doc_viewer/*"], "@kbn/unified-field-list": ["packages/kbn-unified-field-list"], "@kbn/unified-field-list/*": ["packages/kbn-unified-field-list/*"], "@kbn/unified-field-list-examples-plugin": ["examples/unified_field_list_examples"], diff --git a/x-pack/plugins/data_visualizer/public/application/common/components/field_type_icon/field_type_icon.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/field_type_icon/field_type_icon.tsx index d4b5bf3f57e27..90a17f070e1f7 100644 --- a/x-pack/plugins/data_visualizer/public/application/common/components/field_type_icon/field_type_icon.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/field_type_icon/field_type_icon.tsx @@ -9,7 +9,7 @@ import React, { FC } from 'react'; import { EuiToolTip } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FieldIcon } from '@kbn/react-field'; -import { getFieldTypeName } from '@kbn/unified-field-list/src/utils/field_types/get_field_type_name'; +import { getFieldTypeName } from '@kbn/discover-utils'; import './_index.scss'; interface FieldTypeIconProps { diff --git a/x-pack/plugins/data_visualizer/public/application/common/components/field_types_filter/field_types_filter.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/field_types_filter/field_types_filter.tsx index 401a437eb0f67..b4a09b3cb1c9d 100644 --- a/x-pack/plugins/data_visualizer/public/application/common/components/field_types_filter/field_types_filter.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/field_types_filter/field_types_filter.tsx @@ -8,7 +8,7 @@ import React, { FC, useMemo } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import { getFieldTypeName } from '@kbn/unified-field-list/src/utils/field_types/get_field_type_name'; +import { getFieldTypeName } from '@kbn/discover-utils'; import { FieldTypesHelpPopover } from './field_types_help_popover'; import { MultiSelectPicker, Option } from '../multi_select_picker'; import type { diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/search_panel/field_type_filter.tsx b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/search_panel/field_type_filter.tsx index 517400024084a..46adbecdfc814 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/search_panel/field_type_filter.tsx +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/search_panel/field_type_filter.tsx @@ -9,7 +9,7 @@ import React, { FC, useMemo } from 'react'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { css } from '@emotion/react'; -import { getFieldTypeName } from '@kbn/unified-field-list/src/utils/field_types/get_field_type_name'; +import { getFieldTypeName } from '@kbn/discover-utils'; import { useCurrentEuiTheme } from '../../../common/hooks/use_current_eui_theme'; import { FieldTypesHelpPopover } from '../../../common/components/field_types_filter/field_types_help_popover'; import { FieldTypeIcon } from '../../../common/components/field_type_icon'; diff --git a/x-pack/plugins/data_visualizer/tsconfig.json b/x-pack/plugins/data_visualizer/tsconfig.json index 75dd55b83e274..5221ef48b5efc 100644 --- a/x-pack/plugins/data_visualizer/tsconfig.json +++ b/x-pack/plugins/data_visualizer/tsconfig.json @@ -26,6 +26,7 @@ "@kbn/data-views-plugin", "@kbn/datemath", "@kbn/discover-plugin", + "@kbn/discover-utils", "@kbn/embeddable-plugin", "@kbn/embeddable-plugin", "@kbn/es-query", diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index 6047eaf8f343f..f0306e4e9da3a 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -2310,35 +2310,36 @@ "discover.docTable.tableRow.viewSurroundingDocumentsLinkText": "Afficher les documents alentour", "discover.documentsAriaLabel": "Documents", "discover.documentsErrorTitle": "Erreur lors de la recherche", - "discover.docView.table.actions.label": "Actions", - "discover.docView.table.actions.open": "Actions ouvertes", - "discover.docView.table.ignored.multiAboveTooltip": "Une ou plusieurs valeurs dans ce champ sont trop longues et ne peuvent pas être recherchées ni filtrées.", - "discover.docView.table.ignored.multiMalformedTooltip": "Ce champ comporte une ou plusieurs valeurs mal formées qui ne peuvent pas être recherchées ni filtrées.", - "discover.docView.table.ignored.multiUnknownTooltip": "Une ou plusieurs valeurs dans ce champ ont été ignorées par Elasticsearch et ne peuvent pas être recherchées ni filtrées.", - "discover.docView.table.ignored.singleAboveTooltip": "La valeur dans ce champ est trop longue et ne peut pas être recherchée ni filtrée.", - "discover.docView.table.ignored.singleMalformedTooltip": "La valeur dans ce champ est mal formée et ne peut pas être recherchée ni filtrée.", - "discover.docView.table.ignored.singleUnknownTooltip": "La valeur dans ce champ a été ignorée par Elasticsearch et ne peut pas être recherchée ni filtrée.", - "discover.docView.table.searchPlaceHolder": "Rechercher les noms de champs", - "discover.docViews.json.jsonTitle": "JSON", - "discover.docViews.table.filterForFieldPresentButtonAriaLabel": "Filtrer sur le champ", - "discover.docViews.table.filterForFieldPresentButtonTooltip": "Filtrer sur le champ", - "discover.docViews.table.filterForValueButtonAriaLabel": "Filtrer sur la valeur", - "discover.docViews.table.filterForValueButtonTooltip": "Filtrer sur la valeur", - "discover.docViews.table.filterOutValueButtonAriaLabel": "Exclure la valeur", - "discover.docViews.table.filterOutValueButtonTooltip": "Exclure la valeur", - "discover.docViews.table.ignored.multiValueLabel": "Contient des valeurs ignorées", - "discover.docViews.table.ignored.singleValueLabel": "Valeur ignorée", - "discover.docViews.table.pinFieldAriaLabel": "Épingler le champ", - "discover.docViews.table.pinFieldLabel": "Épingler le champ", + "unifiedDocViewer.docView.table.actions.label": "Actions", + "unifiedDocViewer.docView.table.actions.open": "Actions ouvertes", + "unifiedDocViewer.docView.table.ignored.multiAboveTooltip": "Une ou plusieurs valeurs dans ce champ sont trop longues et ne peuvent pas être recherchées ni filtrées.", + "unifiedDocViewer.docView.table.ignored.multiMalformedTooltip": "Ce champ comporte une ou plusieurs valeurs mal formées qui ne peuvent pas être recherchées ni filtrées.", + "unifiedDocViewer.docView.table.ignored.multiUnknownTooltip": "Une ou plusieurs valeurs dans ce champ ont été ignorées par Elasticsearch et ne peuvent pas être recherchées ni filtrées.", + "unifiedDocViewer.docView.table.ignored.singleAboveTooltip": "La valeur dans ce champ est trop longue et ne peut pas être recherchée ni filtrée.", + "unifiedDocViewer.docView.table.ignored.singleMalformedTooltip": "La valeur dans ce champ est mal formée et ne peut pas être recherchée ni filtrée.", + "unifiedDocViewer.docView.table.ignored.singleUnknownTooltip": "La valeur dans ce champ a été ignorée par Elasticsearch et ne peut pas être recherchée ni filtrée.", + "unifiedDocViewer.docView.table.searchPlaceHolder": "Rechercher les noms de champs", + "unifiedDocViewer.docViews.json.jsonTitle": "JSON", + "unifiedDocViewer.docViews.table.filterForFieldPresentButtonAriaLabel": "Filtrer sur le champ", + "unifiedDocViewer.docViews.table.filterForFieldPresentButtonTooltip": "Filtrer sur le champ", + "unifiedDocViewer.docViews.table.filterForValueButtonAriaLabel": "Filtrer sur la valeur", + "unifiedDocViewer.docViews.table.filterForValueButtonTooltip": "Filtrer sur la valeur", + "unifiedDocViewer.docViews.table.filterOutValueButtonAriaLabel": "Exclure la valeur", + "unifiedDocViewer.docViews.table.filterOutValueButtonTooltip": "Exclure la valeur", + "unifiedDocViewer.docViews.table.ignored.multiValueLabel": "Contient des valeurs ignorées", + "unifiedDocViewer.docViews.table.ignored.singleValueLabel": "Valeur ignorée", + "unifiedDocViewer.docViews.table.pinFieldAriaLabel": "Épingler le champ", + "unifiedDocViewer.docViews.table.pinFieldLabel": "Épingler le champ", "discover.docViews.table.scoreSortWarningTooltip": "Filtrez sur _score pour pouvoir récupérer les valeurs correspondantes.", - "discover.docViews.table.tableTitle": "Tableau", - "discover.docViews.table.toggleColumnInTableButtonAriaLabel": "Afficher/Masquer la colonne dans le tableau", - "discover.docViews.table.toggleColumnInTableButtonTooltip": "Afficher/Masquer la colonne dans le tableau", - "discover.docViews.table.unableToFilterForPresenceOfMetaFieldsTooltip": "Impossible de filtrer sur les champs méta", - "discover.docViews.table.unableToFilterForPresenceOfScriptedFieldsTooltip": "Impossible de filtrer sur les champs scriptés", - "discover.docViews.table.unindexedFieldsCanNotBeSearchedTooltip": "Les champs non indexés ou les valeurs ignorées ne peuvent pas être recherchés", - "discover.docViews.table.unpinFieldAriaLabel": "Désépingler le champ", - "discover.docViews.table.unpinFieldLabel": "Désépingler le champ", + "unifiedDocViewer.docViews.table.tableTitle": "Tableau", + "unifiedDocViewer.docViews.table.toggleColumnInTableButtonAriaLabel": "Afficher/Masquer la colonne dans le tableau", + "unifiedDocViewer.docViews.table.toggleColumnInTableButtonTooltip": "Afficher/Masquer la colonne dans le tableau", + "unifiedDocViewer.fieldChooser.discoverField.name": "Afficher/Masquer les détails du champ", + "unifiedDocViewer.docViews.table.unableToFilterForPresenceOfMetaFieldsTooltip": "Impossible de filtrer sur les champs méta", + "unifiedDocViewer.docViews.table.unableToFilterForPresenceOfScriptedFieldsTooltip": "Impossible de filtrer sur les champs scriptés", + "unifiedDocViewer.docViews.table.unindexedFieldsCanNotBeSearchedTooltip": "Les champs non indexés ou les valeurs ignorées ne peuvent pas être recherchés", + "unifiedDocViewer.docViews.table.unpinFieldAriaLabel": "Désépingler le champ", + "unifiedDocViewer.docViews.table.unpinFieldLabel": "Désépingler le champ", "discover.dropZoneTableLabel": "Abandonner la zone pour ajouter un champ en tant que colonne dans la table", "discover.dscTour.stepAddFields.imageAltText": "Dans la liste Champs disponibles, cliquez sur l'icône Plus pour afficher/masquer un champ dans le tableau de documents.", "discover.dscTour.stepAddFields.title": "Ajouter des champs dans le tableau", @@ -2359,13 +2360,13 @@ "discover.embeddable.search.displayName": "rechercher", "discover.errorCalloutShowErrorMessage": "Afficher les détails", "discover.fieldChooser.availableFieldsTooltip": "Champs disponibles pour l'affichage dans le tableau.", - "discover.fieldChooser.discoverField.actions": "Actions", + "unifiedDocViewer.fieldChooser.discoverField.actions": "Actions", "discover.fieldChooser.discoverField.addFieldTooltip": "Ajouter le champ en tant que colonne", - "discover.fieldChooser.discoverField.multiField": "champ multiple", - "discover.fieldChooser.discoverField.multiFieldTooltipContent": "Les champs multiples peuvent avoir plusieurs valeurs.", - "discover.fieldChooser.discoverField.name": "Champ", + "unifiedDocViewer.fieldChooser.discoverField.multiField": "champ multiple", + "unifiedDocViewer.fieldChooser.discoverField.multiFieldTooltipContent": "Les champs multiples peuvent avoir plusieurs valeurs.", + "unifiedDocViewer.fieldChooser.discoverField.name": "Champ", "discover.fieldChooser.discoverField.removeFieldTooltip": "Supprimer le champ du tableau", - "discover.fieldChooser.discoverField.value": "Valeur", + "unifiedDocViewer.fieldChooser.discoverField.value": "Valeur", "discover.goToDiscoverButtonText": "Aller à Discover", "discover.grid.closePopover": "Fermer la fenêtre contextuelle", "discover.grid.copyCellValueButton": "Copier la valeur", @@ -2395,10 +2396,10 @@ "discover.inspectorRequestDescriptionDocument": "Cette requête interroge Elasticsearch afin de récupérer les documents.", "discover.invalidFiltersWarnToast.description": "Les références d'ID de la vue de données dans certains filtres appliqués diffèrent de la vue de données actuelle.", "discover.invalidFiltersWarnToast.title": "Références d'index différentes", - "discover.json.codeEditorAriaLabel": "Affichage JSON en lecture seule d’un document Elasticsearch", - "discover.json.copyToClipboardLabel": "Copier dans le presse-papiers", + "unifiedDocViewer.json.codeEditorAriaLabel": "Affichage JSON en lecture seule d’un document Elasticsearch", + "unifiedDocViewer.json.copyToClipboardLabel": "Copier dans le presse-papiers", "discover.loadingDocuments": "Chargement des documents", - "discover.loadingJSON": "Chargement de JSON", + "unifiedDocViewer.loadingJSON": "Chargement de JSON", "discover.loadingResults": "Chargement des résultats", "discover.localMenu.alertsDescription": "Alertes", "discover.localMenu.fallbackReportTitle": "Recherche Discover sans titre", @@ -2461,9 +2462,9 @@ "discover.showSelectedDocumentsOnly": "Afficher uniquement les documents sélectionnés", "discover.singleDocRoute.errorTitle": "Une erreur s'est produite", "discover.skipToBottomButtonLabel": "Atteindre la fin du tableau", - "discover.sourceViewer.errorMessage": "Impossible de récupérer les données pour le moment. Actualisez l'onglet et réessayez.", - "discover.sourceViewer.errorMessageTitle": "Une erreur s'est produite.", - "discover.sourceViewer.refresh": "Actualiser", + "unifiedDocViewer.sourceViewer.errorMessage": "Impossible de récupérer les données pour le moment. Actualisez l'onglet et réessayez.", + "unifiedDocViewer.sourceViewer.errorMessageTitle": "Une erreur s'est produite.", + "unifiedDocViewer.sourceViewer.refresh": "Actualiser", "discover.toggleSidebarAriaLabel": "Activer/Désactiver la barre latérale", "discover.topNav.openSearchPanel.manageSearchesButtonLabel": "Gérer les recherches", "discover.topNav.openSearchPanel.noSearchesFoundDescription": "Aucune recherche correspondante trouvée.", @@ -5696,34 +5697,34 @@ "unifiedFieldList.fieldNameDescription.textField": "Texte intégral tel que le corps d'un e-mail ou la description d'un produit.", "unifiedFieldList.fieldNameDescription.unknownField": "Champ inconnu", "unifiedFieldList.fieldNameDescription.versionField": "Versions des logiciels. Prend en charge les règles de priorité de la Gestion sémantique des versions.", - "unifiedFieldList.fieldNameIcons.binaryAriaLabel": "Binaire", - "unifiedFieldList.fieldNameIcons.booleanAriaLabel": "Booléen", - "unifiedFieldList.fieldNameIcons.conflictFieldAriaLabel": "Conflit", - "unifiedFieldList.fieldNameIcons.counterFieldAriaLabel": "Indicateur de compteur", - "unifiedFieldList.fieldNameIcons.dateFieldAriaLabel": "Date", - "unifiedFieldList.fieldNameIcons.dateRangeFieldAriaLabel": "Plage de dates", - "unifiedFieldList.fieldNameIcons.denseVectorFieldAriaLabel": "Vecteur dense", - "unifiedFieldList.fieldNameIcons.flattenedFieldAriaLabel": "Lissé", - "unifiedFieldList.fieldNameIcons.gaugeFieldAriaLabel": "Indicateur de jauge", - "unifiedFieldList.fieldNameIcons.geoPointFieldAriaLabel": "Point géographique", - "unifiedFieldList.fieldNameIcons.geoShapeFieldAriaLabel": "Forme géométrique", - "unifiedFieldList.fieldNameIcons.histogramFieldAriaLabel": "Histogramme", - "unifiedFieldList.fieldNameIcons.ipAddressFieldAriaLabel": "Adresse IP", - "unifiedFieldList.fieldNameIcons.ipRangeFieldAriaLabel": "Plage d'IP", - "unifiedFieldList.fieldNameIcons.keywordFieldAriaLabel": "Mot-clé", - "unifiedFieldList.fieldNameIcons.murmur3FieldAriaLabel": "Murmur3", - "unifiedFieldList.fieldNameIcons.nestedFieldAriaLabel": "Imbriqué", - "unifiedFieldList.fieldNameIcons.numberFieldAriaLabel": "Nombre", - "unifiedFieldList.fieldNameIcons.pointFieldAriaLabel": "Point", - "unifiedFieldList.fieldNameIcons.rankFeatureFieldAriaLabel": "Fonctionnalité de rang", - "unifiedFieldList.fieldNameIcons.rankFeaturesFieldAriaLabel": "Fonctionnalités de rang", - "unifiedFieldList.fieldNameIcons.recordAriaLabel": "Enregistrements", - "unifiedFieldList.fieldNameIcons.shapeFieldAriaLabel": "Forme", - "unifiedFieldList.fieldNameIcons.sourceFieldAriaLabel": "Champ source", - "unifiedFieldList.fieldNameIcons.stringFieldAriaLabel": "Chaîne", - "unifiedFieldList.fieldNameIcons.textFieldAriaLabel": "Texte", - "unifiedFieldList.fieldNameIcons.unknownFieldAriaLabel": "Champ inconnu", - "unifiedFieldList.fieldNameIcons.versionFieldAriaLabel": "Version", + "discover.fieldNameIcons.binaryAriaLabel": "Binaire", + "discover.fieldNameIcons.booleanAriaLabel": "Booléen", + "discover.fieldNameIcons.conflictFieldAriaLabel": "Conflit", + "discover.fieldNameIcons.counterFieldAriaLabel": "Indicateur de compteur", + "discover.fieldNameIcons.dateFieldAriaLabel": "Date", + "discover.fieldNameIcons.dateRangeFieldAriaLabel": "Plage de dates", + "discover.fieldNameIcons.denseVectorFieldAriaLabel": "Vecteur dense", + "discover.fieldNameIcons.flattenedFieldAriaLabel": "Lissé", + "discover.fieldNameIcons.gaugeFieldAriaLabel": "Indicateur de jauge", + "discover.fieldNameIcons.geoPointFieldAriaLabel": "Point géographique", + "discover.fieldNameIcons.geoShapeFieldAriaLabel": "Forme géométrique", + "discover.fieldNameIcons.histogramFieldAriaLabel": "Histogramme", + "discover.fieldNameIcons.ipAddressFieldAriaLabel": "Adresse IP", + "discover.fieldNameIcons.ipRangeFieldAriaLabel": "Plage d'IP", + "discover.fieldNameIcons.keywordFieldAriaLabel": "Mot-clé", + "discover.fieldNameIcons.murmur3FieldAriaLabel": "Murmur3", + "discover.fieldNameIcons.nestedFieldAriaLabel": "Imbriqué", + "discover.fieldNameIcons.numberFieldAriaLabel": "Nombre", + "discover.fieldNameIcons.pointFieldAriaLabel": "Point", + "discover.fieldNameIcons.rankFeatureFieldAriaLabel": "Fonctionnalité de rang", + "discover.fieldNameIcons.rankFeaturesFieldAriaLabel": "Fonctionnalités de rang", + "discover.fieldNameIcons.recordAriaLabel": "Enregistrements", + "discover.fieldNameIcons.shapeFieldAriaLabel": "Forme", + "discover.fieldNameIcons.sourceFieldAriaLabel": "Champ source", + "discover.fieldNameIcons.stringFieldAriaLabel": "Chaîne", + "discover.fieldNameIcons.textFieldAriaLabel": "Texte", + "discover.fieldNameIcons.unknownFieldAriaLabel": "Champ inconnu", + "discover.fieldNameIcons.versionFieldAriaLabel": "Version", "unifiedFieldList.fieldNameSearch.filterByNameLabel": "Rechercher les noms de champs", "unifiedFieldList.fieldPopover.addExistsFilterLabel": "Filtrer sur le champ", "unifiedFieldList.fieldPopover.deleteFieldLabel": "Supprimer le champ de la vue de données", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 118a210b83eb6..ad9e79d2eaf6d 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -2325,35 +2325,36 @@ "discover.docTable.tableRow.viewSurroundingDocumentsLinkText": "周りのドキュメントを表示", "discover.documentsAriaLabel": "ドキュメント", "discover.documentsErrorTitle": "検索エラー", - "discover.docView.table.actions.label": "アクション", - "discover.docView.table.actions.open": "アクションを開く", - "discover.docView.table.ignored.multiAboveTooltip": "このフィールドの1つ以上の値が長すぎるため、検索またはフィルタリングできません。", - "discover.docView.table.ignored.multiMalformedTooltip": "このフィールドは、検索またはフィルタリングできない正しくない形式の値が1つ以上あります。", - "discover.docView.table.ignored.multiUnknownTooltip": "このフィールドの1つ以上の値がElasticsearchによって無視されたため、検索またはフィルタリングできません。", - "discover.docView.table.ignored.singleAboveTooltip": "このフィールドの値が長すぎるため、検索またはフィルタリングできません。", - "discover.docView.table.ignored.singleMalformedTooltip": "このフィールドの値の形式が正しくないため、検索またはフィルタリングできません。", - "discover.docView.table.ignored.singleUnknownTooltip": "このフィールドの値はElasticsearchによって無視されたため、検索またはフィルタリングできません。", - "discover.docView.table.searchPlaceHolder": "検索フィールド名", - "discover.docViews.json.jsonTitle": "JSON", - "discover.docViews.table.filterForFieldPresentButtonAriaLabel": "フィールド表示のフィルター", - "discover.docViews.table.filterForFieldPresentButtonTooltip": "フィールド表示のフィルター", - "discover.docViews.table.filterForValueButtonAriaLabel": "値でフィルター", - "discover.docViews.table.filterForValueButtonTooltip": "値でフィルター", - "discover.docViews.table.filterOutValueButtonAriaLabel": "値を除外", - "discover.docViews.table.filterOutValueButtonTooltip": "値を除外", - "discover.docViews.table.ignored.multiValueLabel": "無視された値を含む", - "discover.docViews.table.ignored.singleValueLabel": "無視された値", - "discover.docViews.table.pinFieldAriaLabel": "フィールドを固定", - "discover.docViews.table.pinFieldLabel": "フィールドを固定", + "unifiedDocViewer.docView.table.actions.label": "アクション", + "unifiedDocViewer.docView.table.actions.open": "アクションを開く", + "unifiedDocViewer.docView.table.ignored.multiAboveTooltip": "このフィールドの1つ以上の値が長すぎるため、検索またはフィルタリングできません。", + "unifiedDocViewer.docView.table.ignored.multiMalformedTooltip": "このフィールドは、検索またはフィルタリングできない正しくない形式の値が1つ以上あります。", + "unifiedDocViewer.docView.table.ignored.multiUnknownTooltip": "このフィールドの1つ以上の値がElasticsearchによって無視されたため、検索またはフィルタリングできません。", + "unifiedDocViewer.docView.table.ignored.singleAboveTooltip": "このフィールドの値が長すぎるため、検索またはフィルタリングできません。", + "unifiedDocViewer.docView.table.ignored.singleMalformedTooltip": "このフィールドの値の形式が正しくないため、検索またはフィルタリングできません。", + "unifiedDocViewer.docView.table.ignored.singleUnknownTooltip": "このフィールドの値はElasticsearchによって無視されたため、検索またはフィルタリングできません。", + "unifiedDocViewer.docView.table.searchPlaceHolder": "検索フィールド名", + "unifiedDocViewer.docViews.json.jsonTitle": "JSON", + "unifiedDocViewer.docViews.table.filterForFieldPresentButtonAriaLabel": "フィールド表示のフィルター", + "unifiedDocViewer.docViews.table.filterForFieldPresentButtonTooltip": "フィールド表示のフィルター", + "unifiedDocViewer.docViews.table.filterForValueButtonAriaLabel": "値でフィルター", + "unifiedDocViewer.docViews.table.filterForValueButtonTooltip": "値でフィルター", + "unifiedDocViewer.docViews.table.filterOutValueButtonAriaLabel": "値を除外", + "unifiedDocViewer.docViews.table.filterOutValueButtonTooltip": "値を除外", + "unifiedDocViewer.docViews.table.ignored.multiValueLabel": "無視された値を含む", + "unifiedDocViewer.docViews.table.ignored.singleValueLabel": "無視された値", + "unifiedDocViewer.docViews.table.pinFieldAriaLabel": "フィールドを固定", + "unifiedDocViewer.docViews.table.pinFieldLabel": "フィールドを固定", "discover.docViews.table.scoreSortWarningTooltip": "_scoreの値を取得するには、並べ替える必要があります。", - "discover.docViews.table.tableTitle": "表", - "discover.docViews.table.toggleColumnInTableButtonAriaLabel": "表の列を切り替える", - "discover.docViews.table.toggleColumnInTableButtonTooltip": "表の列を切り替える", - "discover.docViews.table.unableToFilterForPresenceOfMetaFieldsTooltip": "メタフィールドの有無でフィルタリングできません", - "discover.docViews.table.unableToFilterForPresenceOfScriptedFieldsTooltip": "スクリプトフィールドの有無でフィルタリングできません", - "discover.docViews.table.unindexedFieldsCanNotBeSearchedTooltip": "インデックスがないフィールドまたは無視された値は検索できません", - "discover.docViews.table.unpinFieldAriaLabel": "フィールドを固定解除", - "discover.docViews.table.unpinFieldLabel": "フィールドを固定解除", + "unifiedDocViewer.docViews.table.tableTitle": "表", + "unifiedDocViewer.docViews.table.toggleColumnInTableButtonAriaLabel": "表の列を切り替える", + "unifiedDocViewer.docViews.table.toggleColumnInTableButtonTooltip": "表の列を切り替える", + "unifiedDocViewer.fieldChooser.discoverField.name": "フィールド詳細を切り替える", + "unifiedDocViewer.docViews.table.unableToFilterForPresenceOfMetaFieldsTooltip": "メタフィールドの有無でフィルタリングできません", + "unifiedDocViewer.docViews.table.unableToFilterForPresenceOfScriptedFieldsTooltip": "スクリプトフィールドの有無でフィルタリングできません", + "unifiedDocViewer.docViews.table.unindexedFieldsCanNotBeSearchedTooltip": "インデックスがないフィールドまたは無視された値は検索できません", + "unifiedDocViewer.docViews.table.unpinFieldAriaLabel": "フィールドを固定解除", + "unifiedDocViewer.docViews.table.unpinFieldLabel": "フィールドを固定解除", "discover.dropZoneTableLabel": "フィールドを列として表に追加するには、ゾーンをドロップします", "discover.dscTour.stepAddFields.imageAltText": "[使用可能なフィールド]リストで、プラスアイコンをクリックし、フィールドをドキュメントテーブルに切り替えます。", "discover.dscTour.stepAddFields.title": "フィールドをテーブルに追加", @@ -2374,13 +2375,13 @@ "discover.embeddable.search.displayName": "検索", "discover.errorCalloutShowErrorMessage": "詳細を表示", "discover.fieldChooser.availableFieldsTooltip": "フィールドをテーブルに表示できます。", - "discover.fieldChooser.discoverField.actions": "アクション", + "unifiedDocViewer.fieldChooser.discoverField.actions": "アクション", "discover.fieldChooser.discoverField.addFieldTooltip": "フィールドを列として追加", - "discover.fieldChooser.discoverField.multiField": "複数フィールド", - "discover.fieldChooser.discoverField.multiFieldTooltipContent": "複数フィールドにはフィールドごとに複数の値を入力できます", - "discover.fieldChooser.discoverField.name": "フィールド", + "unifiedDocViewer.fieldChooser.discoverField.multiField": "複数フィールド", + "unifiedDocViewer.fieldChooser.discoverField.multiFieldTooltipContent": "複数フィールドにはフィールドごとに複数の値を入力できます", + "unifiedDocViewer.fieldChooser.discoverField.name": "フィールド", "discover.fieldChooser.discoverField.removeFieldTooltip": "フィールドを表から削除", - "discover.fieldChooser.discoverField.value": "値", + "unifiedDocViewer.fieldChooser.discoverField.value": "値", "discover.goToDiscoverButtonText": "Discoverに移動", "discover.grid.closePopover": "ポップオーバーを閉じる", "discover.grid.copyCellValueButton": "値をコピー", @@ -2410,10 +2411,10 @@ "discover.inspectorRequestDescriptionDocument": "このリクエストはElasticsearchにクエリをかけ、ドキュメントを取得します。", "discover.invalidFiltersWarnToast.description": "一部の適用されたフィルターのデータビューID参照は、現在のデータビューとは異なります。", "discover.invalidFiltersWarnToast.title": "別のインデックス参照", - "discover.json.codeEditorAriaLabel": "Elasticsearch ドキュメントの JSON ビューのみを読み込む", - "discover.json.copyToClipboardLabel": "クリップボードにコピー", + "unifiedDocViewer.json.codeEditorAriaLabel": "Elasticsearch ドキュメントの JSON ビューのみを読み込む", + "unifiedDocViewer.json.copyToClipboardLabel": "クリップボードにコピー", "discover.loadingDocuments": "ドキュメントを読み込み中", - "discover.loadingJSON": "JSONを読み込んでいます", + "unifiedDocViewer.loadingJSON": "JSONを読み込んでいます", "discover.loadingResults": "結果を読み込み中", "discover.localMenu.alertsDescription": "アラート", "discover.localMenu.fallbackReportTitle": "無題のDiscover検索", @@ -2476,9 +2477,9 @@ "discover.showSelectedDocumentsOnly": "選択したドキュメントのみを表示", "discover.singleDocRoute.errorTitle": "エラーが発生しました", "discover.skipToBottomButtonLabel": "テーブルの最後に移動", - "discover.sourceViewer.errorMessage": "現在データを取得できませんでした。タブを更新して、再試行してください。", - "discover.sourceViewer.errorMessageTitle": "エラーが発生しました", - "discover.sourceViewer.refresh": "更新", + "unifiedDocViewer.sourceViewer.errorMessage": "現在データを取得できませんでした。タブを更新して、再試行してください。", + "unifiedDocViewer.sourceViewer.errorMessageTitle": "エラーが発生しました", + "unifiedDocViewer.sourceViewer.refresh": "更新", "discover.toggleSidebarAriaLabel": "サイドバーを切り替える", "discover.topNav.openSearchPanel.manageSearchesButtonLabel": "検索の管理", "discover.topNav.openSearchPanel.noSearchesFoundDescription": "一致する検索が見つかりませんでした。", @@ -5712,34 +5713,34 @@ "unifiedFieldList.fieldNameDescription.textField": "電子メール本文や製品説明などの全文テキスト。", "unifiedFieldList.fieldNameDescription.unknownField": "不明なフィールド", "unifiedFieldList.fieldNameDescription.versionField": "ソフトウェアバージョン。「セマンティックバージョニング」優先度ルールをサポートします。", - "unifiedFieldList.fieldNameIcons.binaryAriaLabel": "バイナリー", - "unifiedFieldList.fieldNameIcons.booleanAriaLabel": "ブール", - "unifiedFieldList.fieldNameIcons.conflictFieldAriaLabel": "競合", - "unifiedFieldList.fieldNameIcons.counterFieldAriaLabel": "カウンターメトリック", - "unifiedFieldList.fieldNameIcons.dateFieldAriaLabel": "日付", - "unifiedFieldList.fieldNameIcons.dateRangeFieldAriaLabel": "日付範囲", - "unifiedFieldList.fieldNameIcons.denseVectorFieldAriaLabel": "密集ベクトル", - "unifiedFieldList.fieldNameIcons.flattenedFieldAriaLabel": "平坦化済み", - "unifiedFieldList.fieldNameIcons.gaugeFieldAriaLabel": "ゲージメトリック", - "unifiedFieldList.fieldNameIcons.geoPointFieldAriaLabel": "地理ポイント", - "unifiedFieldList.fieldNameIcons.geoShapeFieldAriaLabel": "地理情報図形", - "unifiedFieldList.fieldNameIcons.histogramFieldAriaLabel": "ヒストグラム", - "unifiedFieldList.fieldNameIcons.ipAddressFieldAriaLabel": "IP アドレス", - "unifiedFieldList.fieldNameIcons.ipRangeFieldAriaLabel": "IP範囲", - "unifiedFieldList.fieldNameIcons.keywordFieldAriaLabel": "キーワード", - "unifiedFieldList.fieldNameIcons.murmur3FieldAriaLabel": "Murmur3", - "unifiedFieldList.fieldNameIcons.nestedFieldAriaLabel": "ネスト済み", - "unifiedFieldList.fieldNameIcons.numberFieldAriaLabel": "数字", - "unifiedFieldList.fieldNameIcons.pointFieldAriaLabel": "点", - "unifiedFieldList.fieldNameIcons.rankFeatureFieldAriaLabel": "ランク特性", - "unifiedFieldList.fieldNameIcons.rankFeaturesFieldAriaLabel": "ランク特性", - "unifiedFieldList.fieldNameIcons.recordAriaLabel": "記録", - "unifiedFieldList.fieldNameIcons.shapeFieldAriaLabel": "形状", - "unifiedFieldList.fieldNameIcons.sourceFieldAriaLabel": "ソースフィールド", - "unifiedFieldList.fieldNameIcons.stringFieldAriaLabel": "文字列", - "unifiedFieldList.fieldNameIcons.textFieldAriaLabel": "テキスト", - "unifiedFieldList.fieldNameIcons.unknownFieldAriaLabel": "不明なフィールド", - "unifiedFieldList.fieldNameIcons.versionFieldAriaLabel": "バージョン", + "discover.fieldNameIcons.binaryAriaLabel": "バイナリー", + "discover.fieldNameIcons.booleanAriaLabel": "ブール", + "discover.fieldNameIcons.conflictFieldAriaLabel": "競合", + "discover.fieldNameIcons.counterFieldAriaLabel": "カウンターメトリック", + "discover.fieldNameIcons.dateFieldAriaLabel": "日付", + "discover.fieldNameIcons.dateRangeFieldAriaLabel": "日付範囲", + "discover.fieldNameIcons.denseVectorFieldAriaLabel": "密集ベクトル", + "discover.fieldNameIcons.flattenedFieldAriaLabel": "平坦化済み", + "discover.fieldNameIcons.gaugeFieldAriaLabel": "ゲージメトリック", + "discover.fieldNameIcons.geoPointFieldAriaLabel": "地理ポイント", + "discover.fieldNameIcons.geoShapeFieldAriaLabel": "地理情報図形", + "discover.fieldNameIcons.histogramFieldAriaLabel": "ヒストグラム", + "discover.fieldNameIcons.ipAddressFieldAriaLabel": "IP アドレス", + "discover.fieldNameIcons.ipRangeFieldAriaLabel": "IP範囲", + "discover.fieldNameIcons.keywordFieldAriaLabel": "キーワード", + "discover.fieldNameIcons.murmur3FieldAriaLabel": "Murmur3", + "discover.fieldNameIcons.nestedFieldAriaLabel": "ネスト済み", + "discover.fieldNameIcons.numberFieldAriaLabel": "数字", + "discover.fieldNameIcons.pointFieldAriaLabel": "点", + "discover.fieldNameIcons.rankFeatureFieldAriaLabel": "ランク特性", + "discover.fieldNameIcons.rankFeaturesFieldAriaLabel": "ランク特性", + "discover.fieldNameIcons.recordAriaLabel": "記録", + "discover.fieldNameIcons.shapeFieldAriaLabel": "形状", + "discover.fieldNameIcons.sourceFieldAriaLabel": "ソースフィールド", + "discover.fieldNameIcons.stringFieldAriaLabel": "文字列", + "discover.fieldNameIcons.textFieldAriaLabel": "テキスト", + "discover.fieldNameIcons.unknownFieldAriaLabel": "不明なフィールド", + "discover.fieldNameIcons.versionFieldAriaLabel": "バージョン", "unifiedFieldList.fieldNameSearch.filterByNameLabel": "検索フィールド名", "unifiedFieldList.fieldPopover.addExistsFilterLabel": "フィールド表示のフィルター", "unifiedFieldList.fieldPopover.deleteFieldLabel": "データビューフィールドを削除", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 7f4c86d8a4f58..4d0de6185e717 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -2325,35 +2325,36 @@ "discover.docTable.tableRow.viewSurroundingDocumentsLinkText": "查看周围文档", "discover.documentsAriaLabel": "文档", "discover.documentsErrorTitle": "搜索错误", - "discover.docView.table.actions.label": "操作", - "discover.docView.table.actions.open": "打开操作", - "discover.docView.table.ignored.multiAboveTooltip": "此字段中的一个或多个值过长,无法搜索或筛选。", - "discover.docView.table.ignored.multiMalformedTooltip": "此字段包含一个或多个格式错误的值,无法搜索或筛选。", - "discover.docView.table.ignored.multiUnknownTooltip": "此字段中的一个或多个值被 Elasticsearch 忽略,无法搜索或筛选。", - "discover.docView.table.ignored.singleAboveTooltip": "此字段中的值过长,无法搜索或筛选。", - "discover.docView.table.ignored.singleMalformedTooltip": "此字段中的值格式错误,无法搜索或筛选。", - "discover.docView.table.ignored.singleUnknownTooltip": "此字段中的值被 Elasticsearch 忽略,无法搜索或筛选。", - "discover.docView.table.searchPlaceHolder": "搜索字段名称", - "discover.docViews.json.jsonTitle": "JSON", - "discover.docViews.table.filterForFieldPresentButtonAriaLabel": "筛留存在的字段", - "discover.docViews.table.filterForFieldPresentButtonTooltip": "字段是否存在筛选", - "discover.docViews.table.filterForValueButtonAriaLabel": "筛留值", - "discover.docViews.table.filterForValueButtonTooltip": "筛留值", - "discover.docViews.table.filterOutValueButtonAriaLabel": "筛除值", - "discover.docViews.table.filterOutValueButtonTooltip": "筛除值", - "discover.docViews.table.ignored.multiValueLabel": "包含被忽略的值", - "discover.docViews.table.ignored.singleValueLabel": "被忽略的值", - "discover.docViews.table.pinFieldAriaLabel": "固定字段", - "discover.docViews.table.pinFieldLabel": "固定字段", + "unifiedDocViewer.docView.table.actions.label": "操作", + "unifiedDocViewer.docView.table.actions.open": "打开操作", + "unifiedDocViewer.docView.table.ignored.multiAboveTooltip": "此字段中的一个或多个值过长,无法搜索或筛选。", + "unifiedDocViewer.docView.table.ignored.multiMalformedTooltip": "此字段包含一个或多个格式错误的值,无法搜索或筛选。", + "unifiedDocViewer.docView.table.ignored.multiUnknownTooltip": "此字段中的一个或多个值被 Elasticsearch 忽略,无法搜索或筛选。", + "unifiedDocViewer.docView.table.ignored.singleAboveTooltip": "此字段中的值过长,无法搜索或筛选。", + "unifiedDocViewer.docView.table.ignored.singleMalformedTooltip": "此字段中的值格式错误,无法搜索或筛选。", + "unifiedDocViewer.docView.table.ignored.singleUnknownTooltip": "此字段中的值被 Elasticsearch 忽略,无法搜索或筛选。", + "unifiedDocViewer.docView.table.searchPlaceHolder": "搜索字段名称", + "unifiedDocViewer.docViews.json.jsonTitle": "JSON", + "unifiedDocViewer.docViews.table.filterForFieldPresentButtonAriaLabel": "筛留存在的字段", + "unifiedDocViewer.docViews.table.filterForFieldPresentButtonTooltip": "字段是否存在筛选", + "unifiedDocViewer.docViews.table.filterForValueButtonAriaLabel": "筛留值", + "unifiedDocViewer.docViews.table.filterForValueButtonTooltip": "筛留值", + "unifiedDocViewer.docViews.table.filterOutValueButtonAriaLabel": "筛除值", + "unifiedDocViewer.docViews.table.filterOutValueButtonTooltip": "筛除值", + "unifiedDocViewer.docViews.table.ignored.multiValueLabel": "包含被忽略的值", + "unifiedDocViewer.docViews.table.ignored.singleValueLabel": "被忽略的值", + "unifiedDocViewer.docViews.table.pinFieldAriaLabel": "固定字段", + "unifiedDocViewer.docViews.table.pinFieldLabel": "固定字段", "discover.docViews.table.scoreSortWarningTooltip": "要检索 _score 的值,必须按其筛选。", - "discover.docViews.table.tableTitle": "表", - "discover.docViews.table.toggleColumnInTableButtonAriaLabel": "在表中切换列", - "discover.docViews.table.toggleColumnInTableButtonTooltip": "在表中切换列", - "discover.docViews.table.unableToFilterForPresenceOfMetaFieldsTooltip": "无法筛选元数据字段是否存在", - "discover.docViews.table.unableToFilterForPresenceOfScriptedFieldsTooltip": "无法筛选脚本字段是否存在", - "discover.docViews.table.unindexedFieldsCanNotBeSearchedTooltip": "无法搜索未编入索引的字段或被忽略的值", - "discover.docViews.table.unpinFieldAriaLabel": "取消固定字段", - "discover.docViews.table.unpinFieldLabel": "取消固定字段", + "unifiedDocViewer.docViews.table.tableTitle": "表", + "unifiedDocViewer.docViews.table.toggleColumnInTableButtonAriaLabel": "在表中切换列", + "unifiedDocViewer.docViews.table.toggleColumnInTableButtonTooltip": "在表中切换列", + "unifiedDocViewer.fieldChooser.discoverField.name": "切换字段详细信息", + "unifiedDocViewer.docViews.table.unableToFilterForPresenceOfMetaFieldsTooltip": "无法筛选元数据字段是否存在", + "unifiedDocViewer.docViews.table.unableToFilterForPresenceOfScriptedFieldsTooltip": "无法筛选脚本字段是否存在", + "unifiedDocViewer.docViews.table.unindexedFieldsCanNotBeSearchedTooltip": "无法搜索未编入索引的字段或被忽略的值", + "unifiedDocViewer.docViews.table.unpinFieldAriaLabel": "取消固定字段", + "unifiedDocViewer.docViews.table.unpinFieldLabel": "取消固定字段", "discover.dropZoneTableLabel": "放置区域以将字段作为列添加到表中", "discover.dscTour.stepAddFields.imageAltText": "在可用字段列表中,单击加号图标将字段切换为文档表。", "discover.dscTour.stepAddFields.title": "将字段添加到表中", @@ -2374,13 +2375,13 @@ "discover.embeddable.search.displayName": "搜索", "discover.errorCalloutShowErrorMessage": "显示详情", "discover.fieldChooser.availableFieldsTooltip": "适用于在表中显示的字段。", - "discover.fieldChooser.discoverField.actions": "操作", + "unifiedDocViewer.fieldChooser.discoverField.actions": "操作", "discover.fieldChooser.discoverField.addFieldTooltip": "将字段添加为列", - "discover.fieldChooser.discoverField.multiField": "多字段", - "discover.fieldChooser.discoverField.multiFieldTooltipContent": "多字段的每个字段可以有多个值", - "discover.fieldChooser.discoverField.name": "字段", + "unifiedDocViewer.fieldChooser.discoverField.multiField": "多字段", + "unifiedDocViewer.fieldChooser.discoverField.multiFieldTooltipContent": "多字段的每个字段可以有多个值", + "unifiedDocViewer.fieldChooser.discoverField.name": "字段", "discover.fieldChooser.discoverField.removeFieldTooltip": "从表中移除字段", - "discover.fieldChooser.discoverField.value": "值", + "unifiedDocViewer.fieldChooser.discoverField.value": "值", "discover.goToDiscoverButtonText": "前往 Discover", "discover.grid.closePopover": "关闭弹出框", "discover.grid.copyCellValueButton": "复制值", @@ -2410,10 +2411,10 @@ "discover.inspectorRequestDescriptionDocument": "此请求将查询 Elasticsearch 以获取文档。", "discover.invalidFiltersWarnToast.description": "某些应用的筛选中的数据视图 ID 引用与当前数据视图不同。", "discover.invalidFiltersWarnToast.title": "不同的索引引用", - "discover.json.codeEditorAriaLabel": "Elasticsearch 文档的只读 JSON 视图", - "discover.json.copyToClipboardLabel": "复制到剪贴板", + "unifiedDocViewer.json.codeEditorAriaLabel": "Elasticsearch 文档的只读 JSON 视图", + "unifiedDocViewer.json.copyToClipboardLabel": "复制到剪贴板", "discover.loadingDocuments": "正在加载文档", - "discover.loadingJSON": "正在加载 JSON", + "unifiedDocViewer.loadingJSON": "正在加载 JSON", "discover.loadingResults": "正在加载结果", "discover.localMenu.alertsDescription": "告警", "discover.localMenu.fallbackReportTitle": "未命名 Discover 搜索", @@ -2476,9 +2477,9 @@ "discover.showSelectedDocumentsOnly": "仅显示选定的文档", "discover.singleDocRoute.errorTitle": "发生错误", "discover.skipToBottomButtonLabel": "转到表尾", - "discover.sourceViewer.errorMessage": "当前无法获取数据。请刷新选项卡以重试。", - "discover.sourceViewer.errorMessageTitle": "发生错误", - "discover.sourceViewer.refresh": "刷新", + "unifiedDocViewer.sourceViewer.errorMessage": "当前无法获取数据。请刷新选项卡以重试。", + "unifiedDocViewer.sourceViewer.errorMessageTitle": "发生错误", + "unifiedDocViewer.sourceViewer.refresh": "刷新", "discover.toggleSidebarAriaLabel": "切换侧边栏", "discover.topNav.openSearchPanel.manageSearchesButtonLabel": "管理搜索", "discover.topNav.openSearchPanel.noSearchesFoundDescription": "未找到匹配的搜索。", @@ -5711,34 +5712,34 @@ "unifiedFieldList.fieldNameDescription.textField": "全文本,如电子邮件正文或产品描述。", "unifiedFieldList.fieldNameDescription.unknownField": "未知字段", "unifiedFieldList.fieldNameDescription.versionField": "软件版本。支持“语义版本控制”优先规则。", - "unifiedFieldList.fieldNameIcons.binaryAriaLabel": "二进制", - "unifiedFieldList.fieldNameIcons.booleanAriaLabel": "布尔型", - "unifiedFieldList.fieldNameIcons.conflictFieldAriaLabel": "冲突", - "unifiedFieldList.fieldNameIcons.counterFieldAriaLabel": "计数器指标", - "unifiedFieldList.fieldNameIcons.dateFieldAriaLabel": "日期", - "unifiedFieldList.fieldNameIcons.dateRangeFieldAriaLabel": "日期范围", - "unifiedFieldList.fieldNameIcons.denseVectorFieldAriaLabel": "密集向量", - "unifiedFieldList.fieldNameIcons.flattenedFieldAriaLabel": "扁平", - "unifiedFieldList.fieldNameIcons.gaugeFieldAriaLabel": "仪表盘指标", - "unifiedFieldList.fieldNameIcons.geoPointFieldAriaLabel": "地理点", - "unifiedFieldList.fieldNameIcons.geoShapeFieldAriaLabel": "几何形状", - "unifiedFieldList.fieldNameIcons.histogramFieldAriaLabel": "直方图", - "unifiedFieldList.fieldNameIcons.ipAddressFieldAriaLabel": "IP 地址", - "unifiedFieldList.fieldNameIcons.ipRangeFieldAriaLabel": "IP 范围", - "unifiedFieldList.fieldNameIcons.keywordFieldAriaLabel": "关键字", - "unifiedFieldList.fieldNameIcons.murmur3FieldAriaLabel": "Murmur3", - "unifiedFieldList.fieldNameIcons.nestedFieldAriaLabel": "嵌套", - "unifiedFieldList.fieldNameIcons.numberFieldAriaLabel": "数字", - "unifiedFieldList.fieldNameIcons.pointFieldAriaLabel": "点", - "unifiedFieldList.fieldNameIcons.rankFeatureFieldAriaLabel": "排名特征", - "unifiedFieldList.fieldNameIcons.rankFeaturesFieldAriaLabel": "排名特征", - "unifiedFieldList.fieldNameIcons.recordAriaLabel": "记录", - "unifiedFieldList.fieldNameIcons.shapeFieldAriaLabel": "形状", - "unifiedFieldList.fieldNameIcons.sourceFieldAriaLabel": "源字段", - "unifiedFieldList.fieldNameIcons.stringFieldAriaLabel": "字符串", - "unifiedFieldList.fieldNameIcons.textFieldAriaLabel": "文本", - "unifiedFieldList.fieldNameIcons.unknownFieldAriaLabel": "未知字段", - "unifiedFieldList.fieldNameIcons.versionFieldAriaLabel": "版本", + "discover.fieldNameIcons.binaryAriaLabel": "二进制", + "discover.fieldNameIcons.booleanAriaLabel": "布尔型", + "discover.fieldNameIcons.conflictFieldAriaLabel": "冲突", + "discover.fieldNameIcons.counterFieldAriaLabel": "计数器指标", + "discover.fieldNameIcons.dateFieldAriaLabel": "日期", + "discover.fieldNameIcons.dateRangeFieldAriaLabel": "日期范围", + "discover.fieldNameIcons.denseVectorFieldAriaLabel": "密集向量", + "discover.fieldNameIcons.flattenedFieldAriaLabel": "扁平", + "discover.fieldNameIcons.gaugeFieldAriaLabel": "仪表盘指标", + "discover.fieldNameIcons.geoPointFieldAriaLabel": "地理点", + "discover.fieldNameIcons.geoShapeFieldAriaLabel": "几何形状", + "discover.fieldNameIcons.histogramFieldAriaLabel": "直方图", + "discover.fieldNameIcons.ipAddressFieldAriaLabel": "IP 地址", + "discover.fieldNameIcons.ipRangeFieldAriaLabel": "IP 范围", + "discover.fieldNameIcons.keywordFieldAriaLabel": "关键字", + "discover.fieldNameIcons.murmur3FieldAriaLabel": "Murmur3", + "discover.fieldNameIcons.nestedFieldAriaLabel": "嵌套", + "discover.fieldNameIcons.numberFieldAriaLabel": "数字", + "discover.fieldNameIcons.pointFieldAriaLabel": "点", + "discover.fieldNameIcons.rankFeatureFieldAriaLabel": "排名特征", + "discover.fieldNameIcons.rankFeaturesFieldAriaLabel": "排名特征", + "discover.fieldNameIcons.recordAriaLabel": "记录", + "discover.fieldNameIcons.shapeFieldAriaLabel": "形状", + "discover.fieldNameIcons.sourceFieldAriaLabel": "源字段", + "discover.fieldNameIcons.stringFieldAriaLabel": "字符串", + "discover.fieldNameIcons.textFieldAriaLabel": "文本", + "discover.fieldNameIcons.unknownFieldAriaLabel": "未知字段", + "discover.fieldNameIcons.versionFieldAriaLabel": "版本", "unifiedFieldList.fieldNameSearch.filterByNameLabel": "搜索字段名称", "unifiedFieldList.fieldPopover.addExistsFilterLabel": "筛留存在的字段", "unifiedFieldList.fieldPopover.deleteFieldLabel": "删除数据视图字段", diff --git a/yarn.lock b/yarn.lock index 14e8f72e1138c..a86858b1a6d53 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5913,6 +5913,18 @@ version "0.0.0" uid "" +"@kbn/unified-doc-viewer-examples@link:examples/unified_doc_viewer": + version "0.0.0" + uid "" + +"@kbn/unified-doc-viewer-plugin@link:src/plugins/unified_doc_viewer": + version "0.0.0" + uid "" + +"@kbn/unified-doc-viewer@link:packages/kbn-unified-doc-viewer": + version "0.0.0" + uid "" + "@kbn/unified-field-list-examples-plugin@link:examples/unified_field_list_examples": version "0.0.0" uid ""