mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Discover] Cleanup legacy code fragments (#110646)
This commit is contained in:
parent
99ee803459
commit
284bc6663c
39 changed files with 423 additions and 510 deletions
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 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 { renderApp as renderReactApp } from './index';
|
||||
|
||||
/**
|
||||
* Here's where Discover is mounted and rendered
|
||||
*/
|
||||
export async function renderApp(moduleName: string, element: HTMLElement) {
|
||||
const app = mountDiscoverApp(moduleName, element);
|
||||
return () => {
|
||||
app();
|
||||
};
|
||||
}
|
||||
|
||||
function buildDiscoverElement(mountpoint: HTMLElement) {
|
||||
// due to legacy angular tags, we need some manual DOM intervention here
|
||||
const appWrapper = document.createElement('div');
|
||||
const discoverApp = document.createElement('discover-app');
|
||||
const discover = document.createElement('discover');
|
||||
appWrapper.appendChild(discoverApp);
|
||||
discoverApp.append(discover);
|
||||
mountpoint.appendChild(appWrapper);
|
||||
return discover;
|
||||
}
|
||||
|
||||
function mountDiscoverApp(moduleName: string, element: HTMLElement) {
|
||||
const mountpoint = document.createElement('div');
|
||||
const discoverElement = buildDiscoverElement(mountpoint);
|
||||
// @ts-expect-error
|
||||
const app = renderReactApp({ element: discoverElement });
|
||||
element.appendChild(mountpoint);
|
||||
return app;
|
||||
}
|
|
@ -9,7 +9,7 @@
|
|||
import './_action_bar.scss';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage, I18nProvider } from '@kbn/i18n/react';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import {
|
||||
EuiButtonEmpty,
|
||||
EuiFieldNumber,
|
||||
|
@ -84,84 +84,78 @@ export function ActionBar({
|
|||
}
|
||||
}, [docCount, newDocCount]);
|
||||
return (
|
||||
<I18nProvider>
|
||||
<form onSubmit={onSubmit}>
|
||||
{isSuccessor && <EuiSpacer size="s" />}
|
||||
{isSuccessor && showWarning && (
|
||||
<ActionBarWarning docCount={docCountAvailable} type={type} />
|
||||
)}
|
||||
{isSuccessor && showWarning && <EuiSpacer size="s" />}
|
||||
<EuiFlexGroup direction="row" gutterSize="s" responsive={false}>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiButtonEmpty
|
||||
data-test-subj={`${type}LoadMoreButton`}
|
||||
iconType={isSuccessor ? 'arrowDown' : 'arrowUp'}
|
||||
isDisabled={isDisabled}
|
||||
isLoading={isLoading}
|
||||
onClick={() => {
|
||||
const value = newDocCount + defaultStepSize;
|
||||
if (isValid(value)) {
|
||||
setNewDocCount(value);
|
||||
onChangeCount(type, value);
|
||||
<form onSubmit={onSubmit}>
|
||||
{isSuccessor && <EuiSpacer size="s" />}
|
||||
{isSuccessor && showWarning && <ActionBarWarning docCount={docCountAvailable} type={type} />}
|
||||
{isSuccessor && showWarning && <EuiSpacer size="s" />}
|
||||
<EuiFlexGroup direction="row" gutterSize="s" responsive={false}>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiButtonEmpty
|
||||
data-test-subj={`${type}LoadMoreButton`}
|
||||
iconType={isSuccessor ? 'arrowDown' : 'arrowUp'}
|
||||
isDisabled={isDisabled}
|
||||
isLoading={isLoading}
|
||||
onClick={() => {
|
||||
const value = newDocCount + defaultStepSize;
|
||||
if (isValid(value)) {
|
||||
setNewDocCount(value);
|
||||
onChangeCount(type, value);
|
||||
}
|
||||
}}
|
||||
flush="right"
|
||||
>
|
||||
<FormattedMessage id="discover.context.loadButtonLabel" defaultMessage="Load" />
|
||||
</EuiButtonEmpty>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiFormRow display="center">
|
||||
<EuiFieldNumber
|
||||
aria-label={
|
||||
isSuccessor
|
||||
? i18n.translate('discover.context.olderDocumentsAriaLabel', {
|
||||
defaultMessage: 'Number of older documents',
|
||||
})
|
||||
: i18n.translate('discover.context.newerDocumentsAriaLabel', {
|
||||
defaultMessage: 'Number of newer documents',
|
||||
})
|
||||
}
|
||||
compressed
|
||||
className="cxtSizePicker"
|
||||
data-test-subj={`${type}CountPicker`}
|
||||
disabled={isDisabled}
|
||||
min={MIN_CONTEXT_SIZE}
|
||||
max={MAX_CONTEXT_SIZE}
|
||||
onChange={(ev) => {
|
||||
setNewDocCount(ev.target.valueAsNumber);
|
||||
}}
|
||||
onBlur={() => {
|
||||
if (newDocCount !== docCount && isValid(newDocCount)) {
|
||||
onChangeCount(type, newDocCount);
|
||||
}
|
||||
}}
|
||||
flush="right"
|
||||
>
|
||||
<FormattedMessage id="discover.context.loadButtonLabel" defaultMessage="Load" />
|
||||
</EuiButtonEmpty>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiFormRow display="center">
|
||||
<EuiFieldNumber
|
||||
aria-label={
|
||||
isSuccessor
|
||||
? i18n.translate('discover.context.olderDocumentsAriaLabel', {
|
||||
defaultMessage: 'Number of older documents',
|
||||
})
|
||||
: i18n.translate('discover.context.newerDocumentsAriaLabel', {
|
||||
defaultMessage: 'Number of newer documents',
|
||||
})
|
||||
}
|
||||
compressed
|
||||
className="cxtSizePicker"
|
||||
data-test-subj={`${type}CountPicker`}
|
||||
disabled={isDisabled}
|
||||
min={MIN_CONTEXT_SIZE}
|
||||
max={MAX_CONTEXT_SIZE}
|
||||
onChange={(ev) => {
|
||||
setNewDocCount(ev.target.valueAsNumber);
|
||||
}}
|
||||
onBlur={() => {
|
||||
if (newDocCount !== docCount && isValid(newDocCount)) {
|
||||
onChangeCount(type, newDocCount);
|
||||
}
|
||||
}}
|
||||
type="number"
|
||||
value={newDocCount >= 0 ? newDocCount : ''}
|
||||
type="number"
|
||||
value={newDocCount >= 0 ? newDocCount : ''}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem>
|
||||
<EuiFormRow display="center">
|
||||
{isSuccessor ? (
|
||||
<FormattedMessage
|
||||
id="discover.context.olderDocumentsDescription"
|
||||
defaultMessage="older documents"
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem>
|
||||
<EuiFormRow display="center">
|
||||
{isSuccessor ? (
|
||||
<FormattedMessage
|
||||
id="discover.context.olderDocumentsDescription"
|
||||
defaultMessage="older documents"
|
||||
/>
|
||||
) : (
|
||||
<FormattedMessage
|
||||
id="discover.context.newerDocumentsDescription"
|
||||
defaultMessage="newer documents"
|
||||
/>
|
||||
)}
|
||||
</EuiFormRow>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
{!isSuccessor && showWarning && (
|
||||
<ActionBarWarning docCount={docCountAvailable} type={type} />
|
||||
)}
|
||||
{!isSuccessor && <EuiSpacer size="s" />}
|
||||
</form>
|
||||
</I18nProvider>
|
||||
) : (
|
||||
<FormattedMessage
|
||||
id="discover.context.newerDocumentsDescription"
|
||||
defaultMessage="newer documents"
|
||||
/>
|
||||
)}
|
||||
</EuiFormRow>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
{!isSuccessor && showWarning && <ActionBarWarning docCount={docCountAvailable} type={type} />}
|
||||
{!isSuccessor && <EuiSpacer size="s" />}
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { EuiCallOut, EuiText } from '@elastic/eui';
|
||||
import { FormattedMessage, I18nProvider } from '@kbn/i18n/react';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import {
|
||||
FailureReason,
|
||||
LoadingStatus,
|
||||
|
@ -27,27 +27,25 @@ export function ContextErrorMessage({ status }: ContextErrorMessageProps) {
|
|||
return null;
|
||||
}
|
||||
return (
|
||||
<I18nProvider>
|
||||
<EuiCallOut
|
||||
title={
|
||||
<EuiCallOut
|
||||
title={
|
||||
<FormattedMessage
|
||||
id="discover.context.failedToLoadAnchorDocumentDescription"
|
||||
defaultMessage="Failed to load the anchor document"
|
||||
/>
|
||||
}
|
||||
color="danger"
|
||||
iconType="alert"
|
||||
data-test-subj="contextErrorMessageTitle"
|
||||
>
|
||||
<EuiText data-test-subj="contextErrorMessageBody">
|
||||
{status.reason === FailureReason.UNKNOWN && (
|
||||
<FormattedMessage
|
||||
id="discover.context.failedToLoadAnchorDocumentDescription"
|
||||
defaultMessage="Failed to load the anchor document"
|
||||
id="discover.context.reloadPageDescription.reloadOrVisitTextMessage"
|
||||
defaultMessage="Please reload or go back to the document list to select a valid anchor document."
|
||||
/>
|
||||
}
|
||||
color="danger"
|
||||
iconType="alert"
|
||||
data-test-subj="contextErrorMessageTitle"
|
||||
>
|
||||
<EuiText data-test-subj="contextErrorMessageBody">
|
||||
{status.reason === FailureReason.UNKNOWN && (
|
||||
<FormattedMessage
|
||||
id="discover.context.reloadPageDescription.reloadOrVisitTextMessage"
|
||||
defaultMessage="Please reload or go back to the document list to select a valid anchor document."
|
||||
/>
|
||||
)}
|
||||
</EuiText>
|
||||
</EuiCallOut>
|
||||
</I18nProvider>
|
||||
)}
|
||||
</EuiText>
|
||||
</EuiCallOut>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import React, { Fragment, memo, useEffect, useRef, useMemo, useCallback } from 'react';
|
||||
import './context_app.scss';
|
||||
import classNames from 'classnames';
|
||||
import { FormattedMessage, I18nProvider } from '@kbn/i18n/react';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { EuiText, EuiPageContent, EuiPage, EuiSpacer } from '@elastic/eui';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { esFilters, SortDirection } from '../../../../../data/public';
|
||||
|
@ -138,7 +138,7 @@ export const ContextApp = ({ indexPattern, indexPatternId, anchorId }: ContextAp
|
|||
};
|
||||
|
||||
return (
|
||||
<I18nProvider>
|
||||
<Fragment>
|
||||
{fetchedState.anchorStatus.value === LoadingStatus.FAILED ? (
|
||||
<ContextErrorMessage status={fetchedState.anchorStatus} />
|
||||
) : (
|
||||
|
@ -182,6 +182,6 @@ export const ContextApp = ({ indexPattern, indexPatternId, anchorId }: ContextAp
|
|||
</EuiPage>
|
||||
</Fragment>
|
||||
)}
|
||||
</I18nProvider>
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
|
||||
import moment from 'moment';
|
||||
import { get, last } from 'lodash';
|
||||
import { SortDirection } from 'src/plugins/data/common';
|
||||
import { createIndexPatternsStub, createContextSearchSourceStub } from './_stubs';
|
||||
import { fetchContextProvider, SurrDocType } from './context';
|
||||
import { setServices, SortDirection } from '../../../../kibana_services';
|
||||
import { setServices } from '../../../../kibana_services';
|
||||
import { Query } from '../../../../../../data/public';
|
||||
import { DiscoverServices } from '../../../../build_services';
|
||||
import { EsHitRecord, EsHitRecordList } from '../../../types';
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
import moment from 'moment';
|
||||
import { get, last } from 'lodash';
|
||||
|
||||
import { SortDirection } from 'src/plugins/data/common';
|
||||
import { createIndexPatternsStub, createContextSearchSourceStub } from './_stubs';
|
||||
import { setServices, SortDirection } from '../../../../kibana_services';
|
||||
import { setServices } from '../../../../kibana_services';
|
||||
import { Query } from '../../../../../../data/public';
|
||||
import { fetchContextProvider, SurrDocType } from './context';
|
||||
import { DiscoverServices } from '../../../../build_services';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { EsQuerySortValue, SortDirection } from '../../../../../kibana_services';
|
||||
import type { EsQuerySortValue, SortDirection } from 'src/plugins/data/common';
|
||||
|
||||
/**
|
||||
* Returns `EsQuerySort` which is used to sort records in the ES query
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IndexPattern } from '../../../../../kibana_services';
|
||||
import type { IndexPattern } from 'src/plugins/data/common';
|
||||
|
||||
export enum SortDirection {
|
||||
asc = 'asc',
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { FormattedMessage, I18nProvider } from '@kbn/i18n/react';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { EuiCallOut, EuiLink, EuiLoadingSpinner, EuiPageContent, EuiPage } from '@elastic/eui';
|
||||
import { IndexPatternsContract } from 'src/plugins/data/public';
|
||||
import { getServices } from '../../../../kibana_services';
|
||||
|
@ -43,82 +43,80 @@ export function Doc(props: DocProps) {
|
|||
const [reqState, hit, indexPattern] = useEsDocSearch(props);
|
||||
const indexExistsLink = getServices().docLinks.links.apis.indexExists;
|
||||
return (
|
||||
<I18nProvider>
|
||||
<EuiPage>
|
||||
<EuiPageContent>
|
||||
{reqState === ElasticRequestState.NotFoundIndexPattern && (
|
||||
<EuiCallOut
|
||||
color="danger"
|
||||
data-test-subj={`doc-msg-notFoundIndexPattern`}
|
||||
iconType="alert"
|
||||
title={
|
||||
<FormattedMessage
|
||||
id="discover.doc.failedToLocateIndexPattern"
|
||||
defaultMessage="No index pattern matches ID {indexPatternId}."
|
||||
values={{ indexPatternId: props.indexPatternId }}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{reqState === ElasticRequestState.NotFound && (
|
||||
<EuiCallOut
|
||||
color="danger"
|
||||
data-test-subj={`doc-msg-notFound`}
|
||||
iconType="alert"
|
||||
title={
|
||||
<FormattedMessage
|
||||
id="discover.doc.failedToLocateDocumentDescription"
|
||||
defaultMessage="Cannot find document"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<EuiPage>
|
||||
<EuiPageContent>
|
||||
{reqState === ElasticRequestState.NotFoundIndexPattern && (
|
||||
<EuiCallOut
|
||||
color="danger"
|
||||
data-test-subj={`doc-msg-notFoundIndexPattern`}
|
||||
iconType="alert"
|
||||
title={
|
||||
<FormattedMessage
|
||||
id="discover.doc.couldNotFindDocumentsDescription"
|
||||
defaultMessage="No documents match that ID."
|
||||
id="discover.doc.failedToLocateIndexPattern"
|
||||
defaultMessage="No index pattern matches ID {indexPatternId}."
|
||||
values={{ indexPatternId: props.indexPatternId }}
|
||||
/>
|
||||
</EuiCallOut>
|
||||
)}
|
||||
|
||||
{reqState === ElasticRequestState.Error && (
|
||||
<EuiCallOut
|
||||
color="danger"
|
||||
data-test-subj={`doc-msg-error`}
|
||||
iconType="alert"
|
||||
title={
|
||||
<FormattedMessage
|
||||
id="discover.doc.failedToExecuteQueryDescription"
|
||||
defaultMessage="Cannot run search"
|
||||
/>
|
||||
}
|
||||
>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{reqState === ElasticRequestState.NotFound && (
|
||||
<EuiCallOut
|
||||
color="danger"
|
||||
data-test-subj={`doc-msg-notFound`}
|
||||
iconType="alert"
|
||||
title={
|
||||
<FormattedMessage
|
||||
id="discover.doc.somethingWentWrongDescription"
|
||||
defaultMessage="{indexName} is missing."
|
||||
values={{ indexName: props.index }}
|
||||
/>{' '}
|
||||
<EuiLink href={indexExistsLink} target="_blank">
|
||||
<FormattedMessage
|
||||
id="discover.doc.somethingWentWrongDescriptionAddon"
|
||||
defaultMessage="Please ensure the index exists."
|
||||
/>
|
||||
</EuiLink>
|
||||
</EuiCallOut>
|
||||
)}
|
||||
id="discover.doc.failedToLocateDocumentDescription"
|
||||
defaultMessage="Cannot find document"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<FormattedMessage
|
||||
id="discover.doc.couldNotFindDocumentsDescription"
|
||||
defaultMessage="No documents match that ID."
|
||||
/>
|
||||
</EuiCallOut>
|
||||
)}
|
||||
|
||||
{reqState === ElasticRequestState.Loading && (
|
||||
<EuiCallOut data-test-subj={`doc-msg-loading`}>
|
||||
<EuiLoadingSpinner size="m" />{' '}
|
||||
<FormattedMessage id="discover.doc.loadingDescription" defaultMessage="Loading…" />
|
||||
</EuiCallOut>
|
||||
)}
|
||||
{reqState === ElasticRequestState.Error && (
|
||||
<EuiCallOut
|
||||
color="danger"
|
||||
data-test-subj={`doc-msg-error`}
|
||||
iconType="alert"
|
||||
title={
|
||||
<FormattedMessage
|
||||
id="discover.doc.failedToExecuteQueryDescription"
|
||||
defaultMessage="Cannot run search"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<FormattedMessage
|
||||
id="discover.doc.somethingWentWrongDescription"
|
||||
defaultMessage="{indexName} is missing."
|
||||
values={{ indexName: props.index }}
|
||||
/>{' '}
|
||||
<EuiLink href={indexExistsLink} target="_blank">
|
||||
<FormattedMessage
|
||||
id="discover.doc.somethingWentWrongDescriptionAddon"
|
||||
defaultMessage="Please ensure the index exists."
|
||||
/>
|
||||
</EuiLink>
|
||||
</EuiCallOut>
|
||||
)}
|
||||
|
||||
{reqState === ElasticRequestState.Found && hit !== null && indexPattern && (
|
||||
<div data-test-subj="doc-hit">
|
||||
<DocViewer hit={hit} indexPattern={indexPattern} />
|
||||
</div>
|
||||
)}
|
||||
</EuiPageContent>
|
||||
</EuiPage>
|
||||
</I18nProvider>
|
||||
{reqState === ElasticRequestState.Loading && (
|
||||
<EuiCallOut data-test-subj={`doc-msg-loading`}>
|
||||
<EuiLoadingSpinner size="m" />{' '}
|
||||
<FormattedMessage id="discover.doc.loadingDescription" defaultMessage="Loading…" />
|
||||
</EuiCallOut>
|
||||
)}
|
||||
|
||||
{reqState === ElasticRequestState.Found && hit !== null && indexPattern && (
|
||||
<div data-test-subj="doc-hit">
|
||||
<DocViewer hit={hit} indexPattern={indexPattern} />
|
||||
</div>
|
||||
)}
|
||||
</EuiPageContent>
|
||||
</EuiPage>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { IndexPattern } from '../../../../../../../kibana_services';
|
||||
import type { IndexPattern } from 'src/plugins/data/common';
|
||||
|
||||
export type SortOrder = [string, string];
|
||||
export interface ColumnProps {
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
import React from 'react';
|
||||
import { mountWithIntl } from '@kbn/test/jest';
|
||||
import type { IndexPattern, IndexPatternField } from 'src/plugins/data/common';
|
||||
import { TableHeader } from './table_header';
|
||||
import { findTestSubject } from '@elastic/eui/lib/test';
|
||||
import { SortOrder } from './helpers';
|
||||
import { IndexPattern, IndexPatternField } from '../../../../../../../kibana_services';
|
||||
|
||||
function getMockIndexPattern() {
|
||||
return ({
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { IndexPattern } from '../../../../../../../kibana_services';
|
||||
import type { IndexPattern } from 'src/plugins/data/common';
|
||||
import { TableHeaderColumn } from './table_header_column';
|
||||
import { SortOrder, getDisplayedColumns } from './helpers';
|
||||
import { getDefaultSort } from '../../lib/get_default_sort';
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
import React, { useCallback, useMemo, useState } from 'react';
|
||||
import { EuiIcon, EuiSpacer, EuiText } from '@elastic/eui';
|
||||
import type { IndexPattern, IndexPatternField } from 'src/plugins/data/common';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { TableHeader } from './components/table_header/table_header';
|
||||
import { FORMATS_UI_SETTINGS } from '../../../../../../../field_formats/common';
|
||||
|
@ -17,7 +18,7 @@ import {
|
|||
SHOW_MULTIFIELDS,
|
||||
SORT_DEFAULT_ORDER_SETTING,
|
||||
} from '../../../../../../common';
|
||||
import { getServices, IndexPattern, IndexPatternField } from '../../../../../kibana_services';
|
||||
import { getServices } from '../../../../../kibana_services';
|
||||
import { SortOrder } from './components/table_header/helpers';
|
||||
import { DocTableRow, TableRow } from './components/table_row';
|
||||
import { DocViewFilterFn } from '../../../../doc_views/doc_views_types';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IndexPattern } from '../../../../../../kibana_services';
|
||||
import type { IndexPattern } from 'src/plugins/data/common';
|
||||
import { isSortable } from './get_sort';
|
||||
import { SortOrder } from '../components/table_header/helpers';
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
import { isPlainObject } from 'lodash';
|
||||
import { IndexPattern } from '../../../../../../../../data/public';
|
||||
|
||||
export type SortPairObj = Record<string, string>;
|
||||
|
@ -30,7 +30,7 @@ function createSortObject(
|
|||
) {
|
||||
const [field, direction] = sortPair as SortPairArr;
|
||||
return { [field]: direction };
|
||||
} else if (_.isPlainObject(sortPair) && isSortable(Object.keys(sortPair)[0], indexPattern)) {
|
||||
} else if (isPlainObject(sortPair) && isSortable(Object.keys(sortPair)[0], indexPattern)) {
|
||||
return sortPair as SortPairObj;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { EsQuerySortValue, IndexPattern } from '../../../../../../kibana_services';
|
||||
import type { EsQuerySortValue, IndexPattern } from 'src/plugins/data/common';
|
||||
import { SortOrder } from '../components/table_header/helpers';
|
||||
import { getSort } from './get_sort';
|
||||
|
||||
|
|
|
@ -7,8 +7,9 @@
|
|||
*/
|
||||
|
||||
import React, { Fragment } from 'react';
|
||||
import type { IndexPattern } from 'src/plugins/data/common';
|
||||
import { MAX_DOC_FIELDS_DISPLAYED } from '../../../../../../../common';
|
||||
import { getServices, IndexPattern } from '../../../../../../kibana_services';
|
||||
import { getServices } from '../../../../../../kibana_services';
|
||||
|
||||
interface Props {
|
||||
defPairs: Array<[string, unknown]>;
|
||||
|
|
|
@ -20,7 +20,6 @@ import {
|
|||
} from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { METRIC_TYPE } from '@kbn/analytics';
|
||||
import { I18nProvider } from '@kbn/i18n/react';
|
||||
import classNames from 'classnames';
|
||||
import { DiscoverNoResults } from '../no_results';
|
||||
import { LoadingSpinner } from '../loading_spinner/loading_spinner';
|
||||
|
@ -152,131 +151,129 @@ export function DiscoverLayout({
|
|||
const contentCentered = resultState === 'uninitialized' || resultState === 'none';
|
||||
|
||||
return (
|
||||
<I18nProvider>
|
||||
<EuiPage className="dscPage" data-fetch-counter={fetchCounter.current}>
|
||||
<TopNavMemoized
|
||||
indexPattern={indexPattern}
|
||||
onOpenInspector={onOpenInspector}
|
||||
query={state.query}
|
||||
navigateTo={navigateTo}
|
||||
savedQuery={state.savedQuery}
|
||||
savedSearch={savedSearch}
|
||||
searchSource={searchSource}
|
||||
services={services}
|
||||
stateContainer={stateContainer}
|
||||
updateQuery={onUpdateQuery}
|
||||
resetSavedSearch={resetSavedSearch}
|
||||
/>
|
||||
<EuiPageBody className="dscPageBody" aria-describedby="savedSearchTitle">
|
||||
<h1 id="savedSearchTitle" className="euiScreenReaderOnly">
|
||||
{savedSearch.title}
|
||||
</h1>
|
||||
<EuiFlexGroup className="dscPageBody__contents" gutterSize="none">
|
||||
<EuiPage className="dscPage" data-fetch-counter={fetchCounter.current}>
|
||||
<TopNavMemoized
|
||||
indexPattern={indexPattern}
|
||||
onOpenInspector={onOpenInspector}
|
||||
query={state.query}
|
||||
navigateTo={navigateTo}
|
||||
savedQuery={state.savedQuery}
|
||||
savedSearch={savedSearch}
|
||||
searchSource={searchSource}
|
||||
services={services}
|
||||
stateContainer={stateContainer}
|
||||
updateQuery={onUpdateQuery}
|
||||
resetSavedSearch={resetSavedSearch}
|
||||
/>
|
||||
<EuiPageBody className="dscPageBody" aria-describedby="savedSearchTitle">
|
||||
<h1 id="savedSearchTitle" className="euiScreenReaderOnly">
|
||||
{savedSearch.title}
|
||||
</h1>
|
||||
<EuiFlexGroup className="dscPageBody__contents" gutterSize="none">
|
||||
<EuiFlexItem grow={false}>
|
||||
<SidebarMemoized
|
||||
columns={columns}
|
||||
documents$={savedSearchData$.documents$}
|
||||
indexPatternList={indexPatternList}
|
||||
onAddField={onAddColumn}
|
||||
onAddFilter={onAddFilter}
|
||||
onRemoveField={onRemoveColumn}
|
||||
onChangeIndexPattern={onChangeIndexPattern}
|
||||
selectedIndexPattern={indexPattern}
|
||||
services={services}
|
||||
state={state}
|
||||
isClosed={isSidebarClosed}
|
||||
trackUiMetric={trackUiMetric}
|
||||
useNewFieldsApi={useNewFieldsApi}
|
||||
onEditRuntimeField={onEditRuntimeField}
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
<EuiHideFor sizes={['xs', 's']}>
|
||||
<EuiFlexItem grow={false}>
|
||||
<SidebarMemoized
|
||||
columns={columns}
|
||||
documents$={savedSearchData$.documents$}
|
||||
indexPatternList={indexPatternList}
|
||||
onAddField={onAddColumn}
|
||||
onAddFilter={onAddFilter}
|
||||
onRemoveField={onRemoveColumn}
|
||||
onChangeIndexPattern={onChangeIndexPattern}
|
||||
selectedIndexPattern={indexPattern}
|
||||
services={services}
|
||||
state={state}
|
||||
isClosed={isSidebarClosed}
|
||||
trackUiMetric={trackUiMetric}
|
||||
useNewFieldsApi={useNewFieldsApi}
|
||||
onEditRuntimeField={onEditRuntimeField}
|
||||
/>
|
||||
<div>
|
||||
<EuiSpacer size="s" />
|
||||
<EuiButtonIcon
|
||||
iconType={isSidebarClosed ? 'menuRight' : 'menuLeft'}
|
||||
iconSize="m"
|
||||
size="xs"
|
||||
onClick={() => setIsSidebarClosed(!isSidebarClosed)}
|
||||
data-test-subj="collapseSideBarButton"
|
||||
aria-controls="discover-sidebar"
|
||||
aria-expanded={isSidebarClosed ? 'false' : 'true'}
|
||||
aria-label={i18n.translate('discover.toggleSidebarAriaLabel', {
|
||||
defaultMessage: 'Toggle sidebar',
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
</EuiFlexItem>
|
||||
<EuiHideFor sizes={['xs', 's']}>
|
||||
<EuiFlexItem grow={false}>
|
||||
<div>
|
||||
<EuiSpacer size="s" />
|
||||
<EuiButtonIcon
|
||||
iconType={isSidebarClosed ? 'menuRight' : 'menuLeft'}
|
||||
iconSize="m"
|
||||
size="xs"
|
||||
onClick={() => setIsSidebarClosed(!isSidebarClosed)}
|
||||
data-test-subj="collapseSideBarButton"
|
||||
aria-controls="discover-sidebar"
|
||||
aria-expanded={isSidebarClosed ? 'false' : 'true'}
|
||||
aria-label={i18n.translate('discover.toggleSidebarAriaLabel', {
|
||||
defaultMessage: 'Toggle sidebar',
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
</EuiFlexItem>
|
||||
</EuiHideFor>
|
||||
<EuiFlexItem className="dscPageContent__wrapper">
|
||||
<EuiPageContent
|
||||
verticalPosition={contentCentered ? 'center' : undefined}
|
||||
horizontalPosition={contentCentered ? 'center' : undefined}
|
||||
paddingSize="none"
|
||||
hasShadow={false}
|
||||
className={classNames('dscPageContent', {
|
||||
'dscPageContent--centered': contentCentered,
|
||||
'dscPageContent--emptyPrompt': resultState === 'none',
|
||||
})}
|
||||
>
|
||||
{resultState === 'none' && (
|
||||
<DiscoverNoResults
|
||||
timeFieldName={timeField}
|
||||
data={data}
|
||||
error={dataState.error}
|
||||
hasQuery={!!state.query?.query}
|
||||
hasFilters={
|
||||
state.filters && state.filters.filter((f) => !f.meta.disabled).length > 0
|
||||
}
|
||||
onDisableFilters={onDisableFilters}
|
||||
/>
|
||||
)}
|
||||
{resultState === 'uninitialized' && (
|
||||
<DiscoverUninitialized onRefresh={() => savedSearchRefetch$.next()} />
|
||||
)}
|
||||
{resultState === 'loading' && <LoadingSpinner />}
|
||||
{resultState === 'ready' && (
|
||||
<EuiFlexGroup
|
||||
className="dscPageContent__inner"
|
||||
direction="column"
|
||||
alignItems="stretch"
|
||||
gutterSize="none"
|
||||
responsive={false}
|
||||
>
|
||||
<EuiFlexItem grow={false}>
|
||||
<DiscoverChartMemoized
|
||||
state={state}
|
||||
resetSavedSearch={resetSavedSearch}
|
||||
savedSearch={savedSearch}
|
||||
savedSearchDataChart$={charts$}
|
||||
savedSearchDataTotalHits$={totalHits$}
|
||||
services={services}
|
||||
stateContainer={stateContainer}
|
||||
timefield={timeField}
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
<EuiHorizontalRule margin="none" />
|
||||
|
||||
<DiscoverDocuments
|
||||
documents$={savedSearchData$.documents$}
|
||||
expandedDoc={expandedDoc}
|
||||
indexPattern={indexPattern}
|
||||
navigateTo={navigateTo}
|
||||
onAddFilter={onAddFilter as DocViewFilterFn}
|
||||
savedSearch={savedSearch}
|
||||
services={services}
|
||||
setExpandedDoc={setExpandedDoc}
|
||||
</EuiHideFor>
|
||||
<EuiFlexItem className="dscPageContent__wrapper">
|
||||
<EuiPageContent
|
||||
verticalPosition={contentCentered ? 'center' : undefined}
|
||||
horizontalPosition={contentCentered ? 'center' : undefined}
|
||||
paddingSize="none"
|
||||
hasShadow={false}
|
||||
className={classNames('dscPageContent', {
|
||||
'dscPageContent--centered': contentCentered,
|
||||
'dscPageContent--emptyPrompt': resultState === 'none',
|
||||
})}
|
||||
>
|
||||
{resultState === 'none' && (
|
||||
<DiscoverNoResults
|
||||
timeFieldName={timeField}
|
||||
data={data}
|
||||
error={dataState.error}
|
||||
hasQuery={!!state.query?.query}
|
||||
hasFilters={
|
||||
state.filters && state.filters.filter((f) => !f.meta.disabled).length > 0
|
||||
}
|
||||
onDisableFilters={onDisableFilters}
|
||||
/>
|
||||
)}
|
||||
{resultState === 'uninitialized' && (
|
||||
<DiscoverUninitialized onRefresh={() => savedSearchRefetch$.next()} />
|
||||
)}
|
||||
{resultState === 'loading' && <LoadingSpinner />}
|
||||
{resultState === 'ready' && (
|
||||
<EuiFlexGroup
|
||||
className="dscPageContent__inner"
|
||||
direction="column"
|
||||
alignItems="stretch"
|
||||
gutterSize="none"
|
||||
responsive={false}
|
||||
>
|
||||
<EuiFlexItem grow={false}>
|
||||
<DiscoverChartMemoized
|
||||
state={state}
|
||||
resetSavedSearch={resetSavedSearch}
|
||||
savedSearch={savedSearch}
|
||||
savedSearchDataChart$={charts$}
|
||||
savedSearchDataTotalHits$={totalHits$}
|
||||
services={services}
|
||||
stateContainer={stateContainer}
|
||||
timefield={timeField}
|
||||
/>
|
||||
</EuiFlexGroup>
|
||||
)}
|
||||
</EuiPageContent>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
</EuiPageBody>
|
||||
</EuiPage>
|
||||
</I18nProvider>
|
||||
</EuiFlexItem>
|
||||
<EuiHorizontalRule margin="none" />
|
||||
|
||||
<DiscoverDocuments
|
||||
documents$={savedSearchData$.documents$}
|
||||
expandedDoc={expandedDoc}
|
||||
indexPattern={indexPattern}
|
||||
navigateTo={navigateTo}
|
||||
onAddFilter={onAddFilter as DocViewFilterFn}
|
||||
savedSearch={savedSearch}
|
||||
services={services}
|
||||
setExpandedDoc={setExpandedDoc}
|
||||
state={state}
|
||||
stateContainer={stateContainer}
|
||||
/>
|
||||
</EuiFlexGroup>
|
||||
)}
|
||||
</EuiPageContent>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
</EuiPageBody>
|
||||
</EuiPage>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -7,12 +7,11 @@
|
|||
*/
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { I18nProvider } from '@kbn/i18n/react';
|
||||
import { SavedObject } from 'kibana/public';
|
||||
import { IndexPattern, IndexPatternAttributes } from 'src/plugins/data/public';
|
||||
|
||||
import { IndexPatternRef } from './types';
|
||||
import { ChangeIndexPattern } from './change_indexpattern';
|
||||
|
||||
export interface DiscoverIndexPatternProps {
|
||||
/**
|
||||
* list of available index patterns, if length > 1, component offers a "change" link
|
||||
|
@ -55,23 +54,21 @@ export function DiscoverIndexPattern({
|
|||
}
|
||||
|
||||
return (
|
||||
<I18nProvider>
|
||||
<ChangeIndexPattern
|
||||
trigger={{
|
||||
label: selected.title,
|
||||
title: selected.title,
|
||||
'data-test-subj': 'indexPattern-switch-link',
|
||||
}}
|
||||
indexPatternId={selected.id}
|
||||
indexPatternRefs={options}
|
||||
onChangeIndexPattern={(id) => {
|
||||
const indexPattern = options.find((pattern) => pattern.id === id);
|
||||
if (indexPattern) {
|
||||
onChangeIndexPattern(id);
|
||||
setSelected(indexPattern);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</I18nProvider>
|
||||
<ChangeIndexPattern
|
||||
trigger={{
|
||||
label: selected.title,
|
||||
title: selected.title,
|
||||
'data-test-subj': 'indexPattern-switch-link',
|
||||
}}
|
||||
indexPatternId={selected.id}
|
||||
indexPatternRefs={options}
|
||||
onChangeIndexPattern={(id) => {
|
||||
const indexPattern = options.find((pattern) => pattern.id === id);
|
||||
if (indexPattern) {
|
||||
onChangeIndexPattern(id);
|
||||
setSelected(indexPattern);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -6,19 +6,19 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
import { map, sortBy, without, each, defaults, isObject } from 'lodash';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
function getFieldValues(hits, field, indexPattern) {
|
||||
const name = field.name;
|
||||
const flattenHit = indexPattern.flattenHit;
|
||||
return _.map(hits, function (hit) {
|
||||
return map(hits, function (hit) {
|
||||
return flattenHit(hit)[name];
|
||||
});
|
||||
}
|
||||
|
||||
function getFieldValueCounts(params) {
|
||||
params = _.defaults(params, {
|
||||
params = defaults(params, {
|
||||
count: 5,
|
||||
grouped: false,
|
||||
});
|
||||
|
@ -44,7 +44,7 @@ function getFieldValueCounts(params) {
|
|||
|
||||
try {
|
||||
const groups = _groupValues(allValues, params);
|
||||
counts = _.map(_.sortBy(groups, 'count').reverse().slice(0, params.count), function (bucket) {
|
||||
counts = map(sortBy(groups, 'count').reverse().slice(0, params.count), function (bucket) {
|
||||
return {
|
||||
value: bucket.value,
|
||||
count: bucket.count,
|
||||
|
@ -80,7 +80,7 @@ function getFieldValueCounts(params) {
|
|||
|
||||
// returns a count of fields in the array that are undefined or null
|
||||
function _countMissing(array) {
|
||||
return array.length - _.without(array, undefined, null).length;
|
||||
return array.length - without(array, undefined, null).length;
|
||||
}
|
||||
|
||||
function _groupValues(allValues, params) {
|
||||
|
@ -88,7 +88,7 @@ function _groupValues(allValues, params) {
|
|||
let k;
|
||||
|
||||
allValues.forEach(function (value) {
|
||||
if (_.isObject(value) && !Array.isArray(value)) {
|
||||
if (isObject(value) && !Array.isArray(value)) {
|
||||
throw new Error(
|
||||
i18n.translate(
|
||||
'discover.fieldChooser.fieldCalculator.analysisIsNotAvailableForObjectFieldsErrorMessage',
|
||||
|
@ -105,7 +105,7 @@ function _groupValues(allValues, params) {
|
|||
k = value == null ? undefined : [value];
|
||||
}
|
||||
|
||||
_.each(k, function (key) {
|
||||
each(k, function (key) {
|
||||
if (groups.hasOwnProperty(key)) {
|
||||
groups[key].count++;
|
||||
} else {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
|
||||
import _ from 'lodash';
|
||||
import { keys, each, cloneDeep, clone, uniq, filter, map } from 'lodash';
|
||||
// @ts-expect-error
|
||||
import realHits from '../../../../../../__fixtures__/real_hits.js';
|
||||
|
||||
|
@ -80,7 +80,7 @@ describe('fieldCalculator', function () {
|
|||
});
|
||||
|
||||
it('should have a a key for value in the array when not grouping array terms', function () {
|
||||
expect(_.keys(groups).length).toBe(3);
|
||||
expect(keys(groups).length).toBe(3);
|
||||
expect(groups.foo).toBeInstanceOf(Object);
|
||||
expect(groups.bar).toBeInstanceOf(Object);
|
||||
expect(groups.baz).toBeInstanceOf(Object);
|
||||
|
@ -100,7 +100,7 @@ describe('fieldCalculator', function () {
|
|||
});
|
||||
|
||||
it('should group array terms when passed params.grouped', function () {
|
||||
expect(_.keys(groups).length).toBe(4);
|
||||
expect(keys(groups).length).toBe(4);
|
||||
expect(groups['foo,bar']).toBeInstanceOf(Object);
|
||||
});
|
||||
|
||||
|
@ -120,7 +120,7 @@ describe('fieldCalculator', function () {
|
|||
let hits: any;
|
||||
|
||||
beforeEach(function () {
|
||||
hits = _.each(_.cloneDeep(realHits), (hit) => indexPattern.flattenHit(hit));
|
||||
hits = each(cloneDeep(realHits), (hit) => indexPattern.flattenHit(hit));
|
||||
});
|
||||
|
||||
it('Should return an array of values for _source fields', function () {
|
||||
|
@ -131,11 +131,11 @@ describe('fieldCalculator', function () {
|
|||
);
|
||||
expect(extensions).toBeInstanceOf(Array);
|
||||
expect(
|
||||
_.filter(extensions, function (v) {
|
||||
filter(extensions, function (v) {
|
||||
return v === 'html';
|
||||
}).length
|
||||
).toBe(8);
|
||||
expect(_.uniq(_.clone(extensions)).sort()).toEqual(['gif', 'html', 'php', 'png']);
|
||||
expect(uniq(clone(extensions)).sort()).toEqual(['gif', 'html', 'php', 'png']);
|
||||
});
|
||||
|
||||
it('Should return an array of values for core meta fields', function () {
|
||||
|
@ -146,11 +146,11 @@ describe('fieldCalculator', function () {
|
|||
);
|
||||
expect(types).toBeInstanceOf(Array);
|
||||
expect(
|
||||
_.filter(types, function (v) {
|
||||
filter(types, function (v) {
|
||||
return v === 'apache';
|
||||
}).length
|
||||
).toBe(18);
|
||||
expect(_.uniq(_.clone(types)).sort()).toEqual(['apache', 'nginx']);
|
||||
expect(uniq(clone(types)).sort()).toEqual(['apache', 'nginx']);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -158,7 +158,7 @@ describe('fieldCalculator', function () {
|
|||
let params: { hits: any; field: any; count: number; indexPattern: IndexPattern };
|
||||
beforeEach(function () {
|
||||
params = {
|
||||
hits: _.cloneDeep(realHits),
|
||||
hits: cloneDeep(realHits),
|
||||
field: indexPattern.fields.getByName('extension'),
|
||||
count: 3,
|
||||
indexPattern,
|
||||
|
@ -170,7 +170,7 @@ describe('fieldCalculator', function () {
|
|||
expect(extensions).toBeInstanceOf(Object);
|
||||
expect(extensions.buckets).toBeInstanceOf(Array);
|
||||
expect(extensions.buckets.length).toBe(3);
|
||||
expect(_.map(extensions.buckets, 'value')).toEqual(['html', 'php', 'gif']);
|
||||
expect(map(extensions.buckets, 'value')).toEqual(['html', 'php', 'gif']);
|
||||
expect(extensions.error).toBe(undefined);
|
||||
});
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import moment from 'moment';
|
||||
import type { IndexPattern, ISearchSource } from 'src/plugins/data/common';
|
||||
import { showOpenSearchPanel } from './show_open_search_panel';
|
||||
import { getSharingData, showPublicUrlSwitch } from '../../utils/get_sharing_data';
|
||||
import { unhashUrl } from '../../../../../../../kibana_utils/public';
|
||||
|
@ -15,7 +16,6 @@ import { DiscoverServices } from '../../../../../build_services';
|
|||
import { SavedSearch } from '../../../../../saved_searches';
|
||||
import { onSaveSearch } from './on_save_search';
|
||||
import { GetStateReturn } from '../../services/discover_state';
|
||||
import { IndexPattern, ISearchSource } from '../../../../../kibana_services';
|
||||
import { openOptionsPopover } from './open_options_popover';
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { FormattedMessage, I18nProvider } from '@kbn/i18n/react';
|
||||
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { EuiButton, EuiEmptyPrompt } from '@elastic/eui';
|
||||
|
||||
interface Props {
|
||||
|
@ -17,31 +16,29 @@ interface Props {
|
|||
|
||||
export const DiscoverUninitialized = ({ onRefresh }: Props) => {
|
||||
return (
|
||||
<I18nProvider>
|
||||
<EuiEmptyPrompt
|
||||
iconType="discoverApp"
|
||||
title={
|
||||
<h2>
|
||||
<FormattedMessage id="discover.uninitializedTitle" defaultMessage="Start searching" />
|
||||
</h2>
|
||||
}
|
||||
body={
|
||||
<p>
|
||||
<FormattedMessage
|
||||
id="discover.uninitializedText"
|
||||
defaultMessage="Write a query, add some filters, or simply hit Refresh to retrieve results for the current query."
|
||||
/>
|
||||
</p>
|
||||
}
|
||||
actions={
|
||||
<EuiButton color="primary" fill onClick={onRefresh}>
|
||||
<FormattedMessage
|
||||
id="discover.uninitializedRefreshButtonText"
|
||||
defaultMessage="Refresh data"
|
||||
/>
|
||||
</EuiButton>
|
||||
}
|
||||
/>
|
||||
</I18nProvider>
|
||||
<EuiEmptyPrompt
|
||||
iconType="discoverApp"
|
||||
title={
|
||||
<h2>
|
||||
<FormattedMessage id="discover.uninitializedTitle" defaultMessage="Start searching" />
|
||||
</h2>
|
||||
}
|
||||
body={
|
||||
<p>
|
||||
<FormattedMessage
|
||||
id="discover.uninitializedText"
|
||||
defaultMessage="Write a query, add some filters, or simply hit Refresh to retrieve results for the current query."
|
||||
/>
|
||||
</p>
|
||||
}
|
||||
actions={
|
||||
<EuiButton color="primary" fill onClick={onRefresh}>
|
||||
<FormattedMessage
|
||||
id="discover.uninitializedRefreshButtonText"
|
||||
defaultMessage="Refresh data"
|
||||
/>
|
||||
</EuiButton>
|
||||
}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IndexPattern } from '../../../../kibana_services';
|
||||
import type { IndexPattern } from 'src/plugins/data/common';
|
||||
import { ElasticSearchHit } from '../../../doc_views/doc_views_types';
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IndexPattern } from '../../../../kibana_services';
|
||||
import type { IndexPattern } from 'src/plugins/data/common';
|
||||
import { getSortArray, SortPairArr } from '../components/doc_table/lib/get_sort';
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,10 +7,8 @@
|
|||
*/
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { IUiSettingsClient, SavedObject, ToastsStart } from 'kibana/public';
|
||||
import { IndexPattern } from '../../../../kibana_services';
|
||||
import { IndexPatternsContract, SearchSource } from '../../../../../../data/common';
|
||||
|
||||
import type { IndexPattern, IndexPatternsContract, SearchSource } from 'src/plugins/data/common';
|
||||
import type { IUiSettingsClient, SavedObject, ToastsStart } from 'kibana/public';
|
||||
export type IndexPatternSavedObject = SavedObject & { title: string };
|
||||
|
||||
interface IndexPatternData {
|
||||
|
|
|
@ -21,7 +21,7 @@ import {
|
|||
EuiLoadingSpinner,
|
||||
EuiIcon,
|
||||
} from '@elastic/eui';
|
||||
import { IndexPattern } from '../../../kibana_services';
|
||||
import type { IndexPattern } from 'src/plugins/data/common';
|
||||
import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types';
|
||||
import { getSchemaDetectors } from './discover_grid_schema';
|
||||
import { DiscoverGridFlyout } from './discover_grid_flyout';
|
||||
|
@ -36,7 +36,6 @@ import {
|
|||
import { defaultPageSize, gridStyle, pageSizeArr, toolbarVisibility } from './constants';
|
||||
import { DiscoverServices } from '../../../build_services';
|
||||
import { getDisplayedColumns } from '../../helpers/columns';
|
||||
import { KibanaContextProvider } from '../../../../../kibana_react/public';
|
||||
import { MAX_DOC_FIELDS_DISPLAYED, SHOW_MULTIFIELDS } from '../../../../common';
|
||||
import { DiscoverGridDocumentToolbarBtn, getDocId } from './discover_grid_document_selection';
|
||||
import { SortPairArr } from '../../apps/main/components/doc_table/lib/get_sort';
|
||||
|
@ -385,41 +384,39 @@ export const DiscoverGrid = ({
|
|||
data-document-number={displayedRows.length}
|
||||
className={className}
|
||||
>
|
||||
<KibanaContextProvider services={{ uiSettings: services.uiSettings }}>
|
||||
<EuiDataGridMemoized
|
||||
aria-describedby={randomId}
|
||||
aria-labelledby={ariaLabelledBy}
|
||||
columns={euiGridColumns}
|
||||
columnVisibility={columnsVisibility}
|
||||
data-test-subj="docTable"
|
||||
gridStyle={gridStyle as EuiDataGridStyle}
|
||||
leadingControlColumns={lead}
|
||||
onColumnResize={(col: { columnId: string; width: number }) => {
|
||||
if (onResize) {
|
||||
onResize(col);
|
||||
}
|
||||
}}
|
||||
pagination={paginationObj}
|
||||
renderCellValue={renderCellValue}
|
||||
rowCount={rowCount}
|
||||
schemaDetectors={schemaDetectors}
|
||||
sorting={sorting as EuiDataGridSorting}
|
||||
toolbarVisibility={
|
||||
defaultColumns
|
||||
? {
|
||||
...toolbarVisibility,
|
||||
showColumnSelector: false,
|
||||
showSortSelector: isSortEnabled,
|
||||
additionalControls,
|
||||
}
|
||||
: {
|
||||
...toolbarVisibility,
|
||||
showSortSelector: isSortEnabled,
|
||||
additionalControls,
|
||||
}
|
||||
<EuiDataGridMemoized
|
||||
aria-describedby={randomId}
|
||||
aria-labelledby={ariaLabelledBy}
|
||||
columns={euiGridColumns}
|
||||
columnVisibility={columnsVisibility}
|
||||
data-test-subj="docTable"
|
||||
gridStyle={gridStyle as EuiDataGridStyle}
|
||||
leadingControlColumns={lead}
|
||||
onColumnResize={(col: { columnId: string; width: number }) => {
|
||||
if (onResize) {
|
||||
onResize(col);
|
||||
}
|
||||
/>
|
||||
</KibanaContextProvider>
|
||||
}}
|
||||
pagination={paginationObj}
|
||||
renderCellValue={renderCellValue}
|
||||
rowCount={rowCount}
|
||||
schemaDetectors={schemaDetectors}
|
||||
sorting={sorting as EuiDataGridSorting}
|
||||
toolbarVisibility={
|
||||
defaultColumns
|
||||
? {
|
||||
...toolbarVisibility,
|
||||
showColumnSelector: false,
|
||||
showSortSelector: isSortEnabled,
|
||||
additionalControls,
|
||||
}
|
||||
: {
|
||||
...toolbarVisibility,
|
||||
showSortSelector: isSortEnabled,
|
||||
additionalControls,
|
||||
}
|
||||
}
|
||||
/>
|
||||
|
||||
{showDisclaimer && (
|
||||
<p className="dscDiscoverGrid__footer">
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import type { IndexPattern } from 'src/plugins/data/common';
|
||||
import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types';
|
||||
import { IndexPattern } from '../../../kibana_services';
|
||||
|
||||
export interface GridContext {
|
||||
expanded: ElasticSearchHit | undefined;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
import React, { useMemo, useCallback } from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import type { IndexPattern } from 'src/plugins/data/common';
|
||||
import {
|
||||
EuiFlexGroup,
|
||||
EuiFlexItem,
|
||||
|
@ -24,7 +25,6 @@ import {
|
|||
keys,
|
||||
} from '@elastic/eui';
|
||||
import { DocViewer } from '../doc_viewer/doc_viewer';
|
||||
import { IndexPattern } from '../../../kibana_services';
|
||||
import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types';
|
||||
import { DiscoverServices } from '../../../build_services';
|
||||
import { getContextUrl } from '../../helpers/get_context_url';
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
import React, { Fragment, useContext, useEffect } from 'react';
|
||||
import themeLight from '@elastic/eui/dist/eui_theme_light.json';
|
||||
import themeDark from '@elastic/eui/dist/eui_theme_dark.json';
|
||||
import type { IndexPattern } from 'src/plugins/data/common';
|
||||
|
||||
import {
|
||||
EuiDataGridCellValueElementProps,
|
||||
|
@ -16,7 +17,6 @@ import {
|
|||
EuiDescriptionListTitle,
|
||||
EuiDescriptionListDescription,
|
||||
} from '@elastic/eui';
|
||||
import { IndexPattern } from '../../../kibana_services';
|
||||
import { ElasticSearchHit } from '../../doc_views/doc_views_types';
|
||||
import { DiscoverGridContext } from './discover_grid_context';
|
||||
import { JsonCodeEditor } from '../json_code_editor/json_code_editor';
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
import React from 'react';
|
||||
import { isEqual } from 'lodash';
|
||||
import { I18nProvider } from '@kbn/i18n/react';
|
||||
import { DocViewRenderTab } from './doc_viewer_render_tab';
|
||||
import { DocViewerError } from './doc_viewer_render_error';
|
||||
import { DocViewRenderFn, DocViewRenderProps } from '../../doc_views/doc_views_types';
|
||||
|
@ -68,11 +67,9 @@ export class DocViewerTab extends React.Component<Props, State> {
|
|||
// doc view is provided by a react component
|
||||
if (Component) {
|
||||
return (
|
||||
<I18nProvider>
|
||||
<KibanaContextProvider services={{ uiSettings: getServices().uiSettings }}>
|
||||
<Component {...renderProps} />
|
||||
</KibanaContextProvider>
|
||||
</I18nProvider>
|
||||
<KibanaContextProvider services={{ uiSettings: getServices().uiSettings }}>
|
||||
<Component {...renderProps} />
|
||||
</KibanaContextProvider>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import type { IndexPattern } from 'src/plugins/data/common';
|
||||
import { mountWithIntl } from '@kbn/test/jest';
|
||||
import { SourceViewer } from './source_viewer';
|
||||
import * as hooks from '../../services/use_es_doc_search';
|
||||
|
@ -18,7 +19,7 @@ jest.mock('../../../kibana_services', () => ({
|
|||
getServices: jest.fn(),
|
||||
}));
|
||||
|
||||
import { getServices, IndexPattern } from '../../../kibana_services';
|
||||
import { getServices } from '../../../kibana_services';
|
||||
|
||||
const mockIndexPattern = {
|
||||
getComputedFields: () => [],
|
||||
|
|
|
@ -7,9 +7,8 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import { mountWithIntl } from '@kbn/test/jest';
|
||||
import { findTestSubject } from '@elastic/eui/lib/test';
|
||||
import { I18nProvider } from '@kbn/i18n/react';
|
||||
import { DocViewerTable, DocViewerTableProps } from './table';
|
||||
import { indexPatterns, IndexPattern } from '../../../../../data/public';
|
||||
import { ElasticSearchHit } from '../../doc_views/doc_views_types';
|
||||
|
@ -77,11 +76,7 @@ indexPattern.fields.getByName = (name: string) => {
|
|||
indexPattern.flattenHit = indexPatterns.flattenHitWrapper(indexPattern, indexPattern.metaFields);
|
||||
|
||||
const mountComponent = (props: DocViewerTableProps) => {
|
||||
return mount(
|
||||
<I18nProvider>
|
||||
<DocViewerTable {...props} />
|
||||
</I18nProvider>
|
||||
);
|
||||
return mountWithIntl(<DocViewerTable {...props} />);
|
||||
};
|
||||
|
||||
describe('DocViewTable at Discover', () => {
|
||||
|
|
|
@ -23,8 +23,8 @@ export const discoverRouter = (services: DiscoverServices, history: History) =>
|
|||
history,
|
||||
};
|
||||
return (
|
||||
<Router history={history} data-test-subj="discover-react-router">
|
||||
<KibanaContextProvider services={services}>
|
||||
<KibanaContextProvider services={services}>
|
||||
<Router history={history} data-test-subj="discover-react-router">
|
||||
<Switch>
|
||||
<Route
|
||||
path="/context/:indexPatternId/:id"
|
||||
|
@ -46,7 +46,7 @@ export const discoverRouter = (services: DiscoverServices, history: History) =>
|
|||
<Route path="/" exact children={<DiscoverMainRoute {...mainRouteProps} />} />
|
||||
<NotFoundRoute services={services} />
|
||||
</Switch>
|
||||
</KibanaContextProvider>
|
||||
</Router>
|
||||
</Router>
|
||||
</KibanaContextProvider>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
*/
|
||||
|
||||
import { useMemo } from 'react';
|
||||
import type { IndexPattern, IndexPatternsContract } from 'src/plugins/data/common';
|
||||
|
||||
import { Capabilities, IUiSettingsClient } from 'kibana/public';
|
||||
import { IndexPattern, IndexPatternsContract } from '../../kibana_services';
|
||||
import {
|
||||
AppState as DiscoverState,
|
||||
GetStateReturn as DiscoverGetStateReturn,
|
||||
|
|
|
@ -5,14 +5,12 @@
|
|||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
import { AppMountParameters } from 'kibana/public';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { getServices } from '../kibana_services';
|
||||
import { discoverRouter } from './discover_router';
|
||||
import { toMountPoint } from '../../../kibana_react/public';
|
||||
|
||||
export const renderApp = ({ element }: AppMountParameters) => {
|
||||
export const renderApp = (element: HTMLElement) => {
|
||||
const services = getServices();
|
||||
const { history: getHistory, capabilities, chrome, data } = services;
|
||||
|
||||
|
@ -28,11 +26,10 @@ export const renderApp = ({ element }: AppMountParameters) => {
|
|||
iconType: 'glasses',
|
||||
});
|
||||
}
|
||||
const app = discoverRouter(services, history);
|
||||
ReactDOM.render(app, element);
|
||||
const unmount = toMountPoint(discoverRouter(services, history))(element);
|
||||
|
||||
return () => {
|
||||
unmount();
|
||||
data.search.session.clear();
|
||||
ReactDOM.unmountComponentAtNode(element);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -6,13 +6,12 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
import { once } from 'lodash';
|
||||
import { createHashHistory } from 'history';
|
||||
import { ScopedHistory, AppMountParameters } from 'kibana/public';
|
||||
import { UiActionsStart } from 'src/plugins/ui_actions/public';
|
||||
import type { ScopedHistory, AppMountParameters } from 'kibana/public';
|
||||
import type { UiActionsStart } from 'src/plugins/ui_actions/public';
|
||||
import { DiscoverServices } from './build_services';
|
||||
import { createGetterSetter } from '../../kibana_utils/public';
|
||||
import { search } from '../../data/public';
|
||||
import { DocViewsRegistry } from './application/doc_views/doc_views_registry';
|
||||
|
||||
let services: DiscoverServices | null = null;
|
||||
|
@ -48,7 +47,7 @@ export const [getDocViewsRegistry, setDocViewsRegistry] = createGetterSetter<Doc
|
|||
/**
|
||||
* Makes sure discover and context are using one instance of history.
|
||||
*/
|
||||
export const getHistory = _.once(() => {
|
||||
export const getHistory = once(() => {
|
||||
const history = createHashHistory();
|
||||
history.listen(() => {
|
||||
// keep at least one listener so that `history.location` always in sync
|
||||
|
@ -72,18 +71,3 @@ export const syncHistoryLocations = () => {
|
|||
export const [getScopedHistory, setScopedHistory] = createGetterSetter<ScopedHistory>(
|
||||
'scopedHistory'
|
||||
);
|
||||
|
||||
export const { tabifyAggResponse } = search;
|
||||
export { unhashUrl, redirectWhenMissing } from '../../kibana_utils/public';
|
||||
export { formatMsg, formatStack, subscribeWithScope } from '../../kibana_legacy/public';
|
||||
|
||||
// EXPORT types
|
||||
export {
|
||||
IndexPatternsContract,
|
||||
IndexPattern,
|
||||
indexPatterns,
|
||||
IndexPatternField,
|
||||
ISearchSource,
|
||||
EsQuerySortValue,
|
||||
SortDirection,
|
||||
} from '../../data/public';
|
||||
|
|
|
@ -320,10 +320,9 @@ export class DiscoverPlugin
|
|||
// make sure the index pattern list is up to date
|
||||
await depsStart.data.indexPatterns.clearCache();
|
||||
|
||||
const { renderApp } = await import('./application/application');
|
||||
const unmount = await renderApp('discover', params.element);
|
||||
const { renderApp } = await import('./application');
|
||||
const unmount = renderApp(params.element);
|
||||
return () => {
|
||||
params.element.classList.remove('dscAppWrapper');
|
||||
unlistenParentHistory();
|
||||
unmount();
|
||||
appUnMounted();
|
||||
|
|
|
@ -479,7 +479,7 @@ export class DiscoverPageObject extends FtrService {
|
|||
* Check if Discover app is currently rendered on the screen.
|
||||
*/
|
||||
public async isDiscoverAppOnScreen(): Promise<boolean> {
|
||||
const result = await this.find.allByCssSelector('discover-app');
|
||||
const result = await this.find.allByCssSelector('.dscPage');
|
||||
return result.length === 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue