- You can combine data views from any Kibana app into one dashboard and see everything in one place.
+ Analyze all of your Elastic data in one place by creating a dashboard and adding visualizations.
- Install some sample data
+ Add some sample data
,
}
}
@@ -146,13 +146,13 @@ exports[`after fetch initialFilter 1`] = `
iconType="plusInCircle"
onClick={[Function]}
>
- Create new dashboard
+ Create a dashboard
}
body={
- You can combine data views from any Kibana app into one dashboard and see everything in one place.
+ Analyze all of your Elastic data in one place by creating a dashboard and adding visualizations.
- Install some sample data
+ Add some sample data
,
}
}
@@ -257,13 +257,13 @@ exports[`after fetch renders all table rows 1`] = `
iconType="plusInCircle"
onClick={[Function]}
>
- Create new dashboard
+ Create a dashboard
}
body={
- You can combine data views from any Kibana app into one dashboard and see everything in one place.
+ Analyze all of your Elastic data in one place by creating a dashboard and adding visualizations.
- Install some sample data
+ Add some sample data
,
}
}
@@ -368,13 +368,13 @@ exports[`after fetch renders call to action when no dashboards exist 1`] = `
iconType="plusInCircle"
onClick={[Function]}
>
- Create new dashboard
+ Create a dashboard
}
body={
- You can combine data views from any Kibana app into one dashboard and see everything in one place.
+ Analyze all of your Elastic data in one place by creating a dashboard and adding visualizations.
- Install some sample data
+ Add some sample data
,
}
}
@@ -446,6 +446,128 @@ exports[`after fetch renders call to action when no dashboards exist 1`] = `
`;
+exports[`after fetch renders call to action with continue when no dashboards exist but one is in progress 1`] = `
+
+
+
+
+ Discard changes
+
+
+
+
+ Continue editing
+
+
+
+ }
+ body={
+
+
+ Analyze all of your Elastic data in one place by creating a dashboard and adding visualizations.
+
+
+ }
+ iconType="dashboardApp"
+ title={
+
+ Dashboard in progress
+
+ }
+ />
+ }
+ entityName="dashboard"
+ entityNamePlural="dashboards"
+ findItems={[Function]}
+ headingId="dashboardListingHeading"
+ initialFilter=""
+ initialPageSize={20}
+ listingLimit={100}
+ rowHeader="title"
+ searchFilters={Array []}
+ tableCaption="Dashboards"
+ tableColumns={
+ Array [
+ Object {
+ "field": "title",
+ "name": "Title",
+ "render": [Function],
+ "sortable": true,
+ },
+ Object {
+ "field": "description",
+ "name": "Description",
+ "render": [Function],
+ "sortable": true,
+ },
+ ]
+ }
+ tableListTitle="Dashboards"
+ toastNotifications={
+ Object {
+ "add": [MockFunction],
+ "addDanger": [MockFunction],
+ "addError": [MockFunction],
+ "addInfo": [MockFunction],
+ "addSuccess": [MockFunction],
+ "addWarning": [MockFunction],
+ "get$": [MockFunction],
+ "remove": [MockFunction],
+ }
+ }
+ />
+
+`;
+
exports[`after fetch renders warning when listingLimit is exceeded 1`] = `
- Create new dashboard
+ Create a dashboard
}
body={
- You can combine data views from any Kibana app into one dashboard and see everything in one place.
+ Analyze all of your Elastic data in one place by creating a dashboard and adding visualizations.
- Install some sample data
+ Add some sample data
,
}
}
diff --git a/src/plugins/dashboard/public/application/listing/dashboard_listing.test.tsx b/src/plugins/dashboard/public/application/listing/dashboard_listing.test.tsx
index 37ee0ec13d7c9..ff34a63bdce19 100644
--- a/src/plugins/dashboard/public/application/listing/dashboard_listing.test.tsx
+++ b/src/plugins/dashboard/public/application/listing/dashboard_listing.test.tsx
@@ -16,6 +16,7 @@ import { KibanaContextProvider } from '../../services/kibana_react';
import { createKbnUrlStateStorage } from '../../services/kibana_utils';
import { DashboardListing, DashboardListingProps } from './dashboard_listing';
import { makeDefaultServices } from '../test_helpers';
+import { DASHBOARD_PANELS_UNSAVED_ID } from '../lib/dashboard_session_storage';
function makeDefaultProps(): DashboardListingProps {
return {
@@ -72,6 +73,25 @@ describe('after fetch', () => {
expect(component).toMatchSnapshot();
});
+ test('renders call to action with continue when no dashboards exist but one is in progress', async () => {
+ const services = makeDefaultServices();
+ services.savedDashboards.find = () => {
+ return Promise.resolve({
+ total: 0,
+ hits: [],
+ });
+ };
+ services.dashboardSessionStorage.getDashboardIdsWithUnsavedChanges = () => [
+ DASHBOARD_PANELS_UNSAVED_ID,
+ ];
+ const { component } = mountWith({ services });
+ // Ensure all promises resolve
+ await new Promise((resolve) => process.nextTick(resolve));
+ // Ensure the state changes are reflected
+ component.update();
+ expect(component).toMatchSnapshot();
+ });
+
test('initialFilter', async () => {
const props = makeDefaultProps();
props.initialFilter = 'testFilter';
diff --git a/src/plugins/dashboard/public/application/listing/dashboard_listing.tsx b/src/plugins/dashboard/public/application/listing/dashboard_listing.tsx
index 827e5abf2bd6a..8b99b5c51598a 100644
--- a/src/plugins/dashboard/public/application/listing/dashboard_listing.tsx
+++ b/src/plugins/dashboard/public/application/listing/dashboard_listing.tsx
@@ -7,7 +7,15 @@
*/
import { FormattedMessage } from '@kbn/i18n/react';
-import { EuiLink, EuiButton, EuiEmptyPrompt, EuiBasicTableColumn } from '@elastic/eui';
+import {
+ EuiLink,
+ EuiButton,
+ EuiEmptyPrompt,
+ EuiBasicTableColumn,
+ EuiFlexGroup,
+ EuiFlexItem,
+ EuiButtonEmpty,
+} from '@elastic/eui';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { attemptLoadDashboardByTitle } from '../lib';
import { DashboardAppServices, DashboardRedirect } from '../../types';
@@ -15,6 +23,8 @@ import {
getDashboardBreadcrumb,
dashboardListingTable,
noItemsStrings,
+ dashboardUnsavedListingStrings,
+ getNewDashboardTitle,
} from '../../dashboard_strings';
import { ApplicationStart, SavedObjectsFindOptionsReference } from '../../../../../core/public';
import { syncQueryStateWithUrl } from '../../services/data';
@@ -22,8 +32,9 @@ import { IKbnUrlStateStorage } from '../../services/kibana_utils';
import { TableListView, useKibana } from '../../services/kibana_react';
import { SavedObjectsTaggingApi } from '../../services/saved_objects_tagging_oss';
import { DashboardUnsavedListing } from './dashboard_unsaved_listing';
-import { confirmCreateWithUnsaved } from './confirm_overlays';
+import { confirmCreateWithUnsaved, confirmDiscardUnsavedChanges } from './confirm_overlays';
import { getDashboardListItemLink } from './get_dashboard_list_item_link';
+import { DASHBOARD_PANELS_UNSAVED_ID } from '../lib/dashboard_session_storage';
export interface DashboardListingProps {
kbnUrlStateStorage: IKbnUrlStateStorage;
@@ -117,10 +128,109 @@ export const DashboardListing = ({
}
}, [dashboardSessionStorage, redirectTo, core.overlays]);
- const emptyPrompt = useMemo(
- () => getNoItemsMessage(showWriteControls, core.application, createItem),
- [createItem, core.application, showWriteControls]
- );
+ const emptyPrompt = useMemo(() => {
+ if (!showWriteControls) {
+ return (
+ {noItemsStrings.getReadonlyTitle()}}
+ body={{noItemsStrings.getReadonlyBody()}
}
+ />
+ );
+ }
+
+ const isEditingFirstDashboard = unsavedDashboardIds.length === 1;
+
+ const emptyAction = isEditingFirstDashboard ? (
+
+
+
+ confirmDiscardUnsavedChanges(core.overlays, () => {
+ dashboardSessionStorage.clearState(DASHBOARD_PANELS_UNSAVED_ID);
+ setUnsavedDashboardIds(dashboardSessionStorage.getDashboardIdsWithUnsavedChanges());
+ })
+ }
+ data-test-subj="discardDashboardPromptButton"
+ aria-label={dashboardUnsavedListingStrings.getDiscardAriaLabel(getNewDashboardTitle())}
+ >
+ {dashboardUnsavedListingStrings.getDiscardTitle()}
+
+
+
+ redirectTo({ destination: 'dashboard' })}
+ data-test-subj="createDashboardPromptButton"
+ aria-label={dashboardUnsavedListingStrings.getEditAriaLabel(getNewDashboardTitle())}
+ >
+ {dashboardUnsavedListingStrings.getEditTitle()}
+
+
+
+ ) : (
+
+ {noItemsStrings.getCreateNewDashboardText()}
+
+ );
+
+ return (
+
+ {isEditingFirstDashboard
+ ? noItemsStrings.getReadEditInProgressTitle()
+ : noItemsStrings.getReadEditTitle()}
+
+ }
+ body={
+ <>
+ {noItemsStrings.getReadEditDashboardDescription()}
+ {!isEditingFirstDashboard && (
+
+
+ core.application.navigateToApp('home', {
+ path: '#/tutorial_directory/sampleData',
+ })
+ }
+ >
+ {noItemsStrings.getSampleDataLinkText()}
+
+ ),
+ }}
+ />
+
+ )}
+ >
+ }
+ actions={emptyAction}
+ />
+ );
+ }, [
+ redirectTo,
+ createItem,
+ core.overlays,
+ core.application,
+ showWriteControls,
+ unsavedDashboardIds,
+ dashboardSessionStorage,
+ ]);
const fetchItems = useCallback(
(filter: string) => {
@@ -233,60 +343,3 @@ const getTableColumns = (
...(savedObjectsTagging ? [savedObjectsTagging.ui.getTableColumnDefinition()] : []),
] as unknown as Array>>;
};
-
-const getNoItemsMessage = (
- showWriteControls: boolean,
- application: ApplicationStart,
- createItem: () => void
-) => {
- if (!showWriteControls) {
- return (
- {noItemsStrings.getReadonlyTitle()}}
- body={{noItemsStrings.getReadonlyBody()}
}
- />
- );
- }
-
- return (
- {noItemsStrings.getReadEditTitle()}}
- body={
- <>
- {noItemsStrings.getReadEditDashboardDescription()}
-
-
- application.navigateToApp('home', {
- path: '#/tutorial_directory/sampleData',
- })
- }
- >
- {noItemsStrings.getSampleDataLinkText()}
-
- ),
- }}
- />
-
- >
- }
- actions={
-
- {noItemsStrings.getCreateNewDashboardText()}
-
- }
- />
- );
-};
diff --git a/src/plugins/dashboard/public/application/top_nav/editor_menu.tsx b/src/plugins/dashboard/public/application/top_nav/editor_menu.tsx
index 8a46a16c1bf0c..effbf8ce980d7 100644
--- a/src/plugins/dashboard/public/application/top_nav/editor_menu.tsx
+++ b/src/plugins/dashboard/public/application/top_nav/editor_menu.tsx
@@ -231,7 +231,7 @@ export const EditorMenu = ({ dashboardContainer, createNewVisType }: Props) => {
i18n.translate('dashboard.createConfirmModal.unsavedChangesSubtitle', {
- defaultMessage: 'You can continue editing or start with a blank dashboard.',
+ defaultMessage: 'Continue editing or start over with a blank dashboard.',
}),
getStartOverButtonText: () =>
i18n.translate('dashboard.createConfirmModal.confirmButtonLabel', {
@@ -420,7 +420,7 @@ export const dashboardListingTable = {
export const dashboardUnsavedListingStrings = {
getUnsavedChangesTitle: (plural = false) =>
i18n.translate('dashboard.listing.unsaved.unsavedChangesTitle', {
- defaultMessage: 'You have unsaved changes in the following {dash}.',
+ defaultMessage: 'You have unsaved changes in the following {dash}:',
values: {
dash: plural
? dashboardListingTable.getEntityNamePlural()
@@ -469,17 +469,21 @@ export const noItemsStrings = {
i18n.translate('dashboard.listing.createNewDashboard.title', {
defaultMessage: 'Create your first dashboard',
}),
+ getReadEditInProgressTitle: () =>
+ i18n.translate('dashboard.listing.createNewDashboard.inProgressTitle', {
+ defaultMessage: 'Dashboard in progress',
+ }),
getReadEditDashboardDescription: () =>
i18n.translate('dashboard.listing.createNewDashboard.combineDataViewFromKibanaAppDescription', {
defaultMessage:
- 'You can combine data views from any Kibana app into one dashboard and see everything in one place.',
+ 'Analyze all of your Elastic data in one place by creating a dashboard and adding visualizations.',
}),
getSampleDataLinkText: () =>
i18n.translate('dashboard.listing.createNewDashboard.sampleDataInstallLinkText', {
- defaultMessage: `Install some sample data`,
+ defaultMessage: `Add some sample data`,
}),
getCreateNewDashboardText: () =>
i18n.translate('dashboard.listing.createNewDashboard.createButtonLabel', {
- defaultMessage: `Create new dashboard`,
+ defaultMessage: `Create a dashboard`,
}),
};
diff --git a/src/plugins/discover/public/__mocks__/saved_search.ts b/src/plugins/discover/public/__mocks__/saved_search.ts
index a488fe7e04c50..04c880e7e1928 100644
--- a/src/plugins/discover/public/__mocks__/saved_search.ts
+++ b/src/plugins/discover/public/__mocks__/saved_search.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-import { SavedSearch } from '../saved_searches';
+import { SavedSearch } from '../services/saved_searches';
import { createSearchSourceMock } from '../../../data/public/mocks';
import { indexPatternMock } from './index_pattern';
import { indexPatternWithTimefieldMock } from './index_pattern_with_timefield';
diff --git a/src/plugins/discover/public/__mocks__/search_session.ts b/src/plugins/discover/public/__mocks__/search_session.ts
index a9037217a303a..78a7a7f90a39e 100644
--- a/src/plugins/discover/public/__mocks__/search_session.ts
+++ b/src/plugins/discover/public/__mocks__/search_session.ts
@@ -8,7 +8,7 @@
import { createMemoryHistory } from 'history';
import { dataPluginMock } from '../../../data/public/mocks';
import { DataPublicPluginStart } from '../../../data/public';
-import { DiscoverSearchSessionManager } from '../application/apps/main/services/discover_search_session';
+import { DiscoverSearchSessionManager } from '../application/main/services/discover_search_session';
export function createSearchSessionMock() {
const history = createMemoryHistory();
diff --git a/src/plugins/discover/public/application/apps/context/__mocks__/top_nav_menu.tsx b/src/plugins/discover/public/application/context/__mocks__/top_nav_menu.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/context/__mocks__/top_nav_menu.tsx
rename to src/plugins/discover/public/application/context/__mocks__/top_nav_menu.tsx
diff --git a/src/plugins/discover/public/application/apps/context/__mocks__/use_context_app_fetch.tsx b/src/plugins/discover/public/application/context/__mocks__/use_context_app_fetch.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/context/__mocks__/use_context_app_fetch.tsx
rename to src/plugins/discover/public/application/context/__mocks__/use_context_app_fetch.tsx
diff --git a/src/plugins/discover/public/application/apps/context/components/action_bar/_action_bar.scss b/src/plugins/discover/public/application/context/components/action_bar/_action_bar.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/context/components/action_bar/_action_bar.scss
rename to src/plugins/discover/public/application/context/components/action_bar/_action_bar.scss
diff --git a/src/plugins/discover/public/application/apps/context/components/action_bar/action_bar.test.tsx b/src/plugins/discover/public/application/context/components/action_bar/action_bar.test.tsx
similarity index 97%
rename from src/plugins/discover/public/application/apps/context/components/action_bar/action_bar.test.tsx
rename to src/plugins/discover/public/application/context/components/action_bar/action_bar.test.tsx
index de6d01b6a5273..cce6c7fbe6053 100644
--- a/src/plugins/discover/public/application/apps/context/components/action_bar/action_bar.test.tsx
+++ b/src/plugins/discover/public/application/context/components/action_bar/action_bar.test.tsx
@@ -10,7 +10,7 @@ import React from 'react';
import { mountWithIntl } from '@kbn/test/jest';
import { ActionBar, ActionBarProps } from './action_bar';
import { findTestSubject } from '@elastic/eui/lib/test';
-import { MAX_CONTEXT_SIZE, MIN_CONTEXT_SIZE } from '../../utils/constants';
+import { MAX_CONTEXT_SIZE, MIN_CONTEXT_SIZE } from '../../services/constants';
import { SurrDocType } from '../../services/context';
describe('Test Discover Context ActionBar for successor | predecessor records', () => {
diff --git a/src/plugins/discover/public/application/apps/context/components/action_bar/action_bar.tsx b/src/plugins/discover/public/application/context/components/action_bar/action_bar.tsx
similarity index 98%
rename from src/plugins/discover/public/application/apps/context/components/action_bar/action_bar.tsx
rename to src/plugins/discover/public/application/context/components/action_bar/action_bar.tsx
index d9d56964358f8..4c1f7857e2b42 100644
--- a/src/plugins/discover/public/application/apps/context/components/action_bar/action_bar.tsx
+++ b/src/plugins/discover/public/application/context/components/action_bar/action_bar.tsx
@@ -20,7 +20,7 @@ import {
} from '@elastic/eui';
import { ActionBarWarning } from './action_bar_warning';
import { SurrDocType } from '../../services/context';
-import { MAX_CONTEXT_SIZE, MIN_CONTEXT_SIZE } from '../../utils/constants';
+import { MAX_CONTEXT_SIZE, MIN_CONTEXT_SIZE } from '../../services/constants';
export interface ActionBarProps {
/**
diff --git a/src/plugins/discover/public/application/apps/context/components/action_bar/action_bar_warning.tsx b/src/plugins/discover/public/application/context/components/action_bar/action_bar_warning.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/context/components/action_bar/action_bar_warning.tsx
rename to src/plugins/discover/public/application/context/components/action_bar/action_bar_warning.tsx
diff --git a/src/plugins/discover/public/application/apps/context/components/context_error_message/context_error_message.test.tsx b/src/plugins/discover/public/application/context/components/context_error_message/context_error_message.test.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/context/components/context_error_message/context_error_message.test.tsx
rename to src/plugins/discover/public/application/context/components/context_error_message/context_error_message.test.tsx
diff --git a/src/plugins/discover/public/application/apps/context/components/context_error_message/context_error_message.tsx b/src/plugins/discover/public/application/context/components/context_error_message/context_error_message.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/context/components/context_error_message/context_error_message.tsx
rename to src/plugins/discover/public/application/context/components/context_error_message/context_error_message.tsx
diff --git a/src/plugins/discover/public/application/apps/context/components/context_error_message/index.ts b/src/plugins/discover/public/application/context/components/context_error_message/index.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/context/components/context_error_message/index.ts
rename to src/plugins/discover/public/application/context/components/context_error_message/index.ts
diff --git a/src/plugins/discover/public/application/apps/context/context_app.scss b/src/plugins/discover/public/application/context/context_app.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/context/context_app.scss
rename to src/plugins/discover/public/application/context/context_app.scss
diff --git a/src/plugins/discover/public/application/apps/context/context_app.test.tsx b/src/plugins/discover/public/application/context/context_app.test.tsx
similarity index 88%
rename from src/plugins/discover/public/application/apps/context/context_app.test.tsx
rename to src/plugins/discover/public/application/context/context_app.test.tsx
index d1c557f2839bc..7f78bb1c698ab 100644
--- a/src/plugins/discover/public/application/apps/context/context_app.test.tsx
+++ b/src/plugins/discover/public/application/context/context_app.test.tsx
@@ -9,16 +9,16 @@
import React from 'react';
import { waitFor } from '@testing-library/react';
import { mountWithIntl } from '@kbn/test/jest';
-import { createFilterManagerMock } from '../../../../../data/public/query/filter_manager/filter_manager.mock';
+import { createFilterManagerMock } from '../../../../data/public/query/filter_manager/filter_manager.mock';
import { mockTopNavMenu } from './__mocks__/top_nav_menu';
import { ContextAppContent } from './context_app_content';
-import { indexPatternMock } from '../../../__mocks__/index_pattern';
+import { indexPatternMock } from '../../__mocks__/index_pattern';
import { ContextApp } from './context_app';
-import { setServices } from '../../../kibana_services';
-import { DiscoverServices } from '../../../build_services';
-import { indexPatternsMock } from '../../../__mocks__/index_patterns';
+import { setServices } from '../../kibana_services';
+import { DiscoverServices } from '../../build_services';
+import { indexPatternsMock } from '../../__mocks__/index_patterns';
import { act } from 'react-dom/test-utils';
-import { uiSettingsMock } from '../../../__mocks__/ui_settings';
+import { uiSettingsMock } from '../../__mocks__/ui_settings';
const mockFilterManager = createFilterManagerMock();
const mockNavigationPlugin = { ui: { TopNavMenu: mockTopNavMenu } };
diff --git a/src/plugins/discover/public/application/apps/context/context_app.tsx b/src/plugins/discover/public/application/context/context_app.tsx
similarity index 93%
rename from src/plugins/discover/public/application/apps/context/context_app.tsx
rename to src/plugins/discover/public/application/context/context_app.tsx
index bfc13aac90e4b..293680b85c005 100644
--- a/src/plugins/discover/public/application/apps/context/context_app.tsx
+++ b/src/plugins/discover/public/application/context/context_app.tsx
@@ -12,20 +12,20 @@ import classNames from 'classnames';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiText, EuiPageContent, EuiPage, EuiSpacer } from '@elastic/eui';
import { cloneDeep } from 'lodash';
-import { esFilters } from '../../../../../data/public';
-import { DOC_TABLE_LEGACY, SEARCH_FIELDS_FROM_SOURCE } from '../../../../common';
+import { esFilters } from '../../../../data/public';
+import { DOC_TABLE_LEGACY, SEARCH_FIELDS_FROM_SOURCE } from '../../../common';
import { ContextErrorMessage } from './components/context_error_message';
-import { IndexPattern, IndexPatternField } from '../../../../../data/common';
+import { IndexPattern, IndexPatternField } from '../../../../data/common';
import { LoadingStatus } from './services/context_query_state';
-import { getServices } from '../../../kibana_services';
+import { getServices } from '../../kibana_services';
import { AppState, isEqualFilters } from './services/context_state';
-import { useColumns } from '../../helpers/use_data_grid_columns';
+import { useColumns } from '../../utils/use_data_grid_columns';
import { useContextAppState } from './utils/use_context_app_state';
import { useContextAppFetch } from './utils/use_context_app_fetch';
-import { popularizeField } from '../../helpers/popularize_field';
+import { popularizeField } from '../../utils/popularize_field';
import { ContextAppContent } from './context_app_content';
import { SurrDocType } from './services/context';
-import { DocViewFilterFn } from '../../doc_views/doc_views_types';
+import { DocViewFilterFn } from '../../services/doc_views/doc_views_types';
const ContextAppContentMemoized = memo(ContextAppContent);
diff --git a/src/plugins/discover/public/application/apps/context/context_app_content.test.tsx b/src/plugins/discover/public/application/context/context_app_content.test.tsx
similarity index 91%
rename from src/plugins/discover/public/application/apps/context/context_app_content.test.tsx
rename to src/plugins/discover/public/application/context/context_app_content.test.tsx
index 9b1c47d37203f..5ec89c8e267ea 100644
--- a/src/plugins/discover/public/application/apps/context/context_app_content.test.tsx
+++ b/src/plugins/discover/public/application/context/context_app_content.test.tsx
@@ -13,13 +13,13 @@ import { ActionBar } from './components/action_bar/action_bar';
import { AppState, GetStateReturn } from './services/context_state';
import { SortDirection } from 'src/plugins/data/common';
import { ContextAppContent, ContextAppContentProps } from './context_app_content';
-import { getServices, setServices } from '../../../kibana_services';
+import { getServices, setServices } from '../../kibana_services';
import { LoadingStatus } from './services/context_query_state';
-import { indexPatternMock } from '../../../__mocks__/index_pattern';
+import { indexPatternMock } from '../../__mocks__/index_pattern';
import { DiscoverGrid } from '../../components/discover_grid/discover_grid';
-import { discoverServiceMock } from '../../../__mocks__/services';
-import { DocTableWrapper } from '../main/components/doc_table/doc_table_wrapper';
-import { EsHitRecordList } from '../../types';
+import { discoverServiceMock } from '../../__mocks__/services';
+import { DocTableWrapper } from '../../components/doc_table/doc_table_wrapper';
+import { EsHitRecordList } from '../types';
describe('ContextAppContent test', () => {
let hit;
diff --git a/src/plugins/discover/public/application/apps/context/context_app_content.tsx b/src/plugins/discover/public/application/context/context_app_content.tsx
similarity index 91%
rename from src/plugins/discover/public/application/apps/context/context_app_content.tsx
rename to src/plugins/discover/public/application/context/context_app_content.tsx
index c8f3cfe0a568f..0d24e8129a8dd 100644
--- a/src/plugins/discover/public/application/apps/context/context_app_content.tsx
+++ b/src/plugins/discover/public/application/context/context_app_content.tsx
@@ -9,20 +9,20 @@
import React, { useState, Fragment, useMemo, useCallback } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiHorizontalRule, EuiText } from '@elastic/eui';
-import { CONTEXT_STEP_SETTING, DOC_HIDE_TIME_COLUMN_SETTING } from '../../../../common';
-import { IndexPattern } from '../../../../../data/common';
-import { SortDirection } from '../../../../../data/public';
+import { CONTEXT_STEP_SETTING, DOC_HIDE_TIME_COLUMN_SETTING } from '../../../common';
+import { IndexPattern } from '../../../../data/common';
+import { SortDirection } from '../../../../data/public';
import { LoadingStatus } from './services/context_query_state';
import { ActionBar } from './components/action_bar/action_bar';
import { DiscoverGrid } from '../../components/discover_grid/discover_grid';
-import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types';
+import { DocViewFilterFn, ElasticSearchHit } from '../../services/doc_views/doc_views_types';
import { AppState } from './services/context_state';
import { SurrDocType } from './services/context';
-import { DiscoverServices } from '../../../build_services';
-import { MAX_CONTEXT_SIZE, MIN_CONTEXT_SIZE } from './utils/constants';
-import { DocTableContext } from '../main/components/doc_table/doc_table_context';
-import { EsHitRecordList } from '../../types';
-import { SortPairArr } from '../main/components/doc_table/lib/get_sort';
+import { DiscoverServices } from '../../build_services';
+import { MAX_CONTEXT_SIZE, MIN_CONTEXT_SIZE } from './services/constants';
+import { DocTableContext } from '../../components/doc_table/doc_table_context';
+import { EsHitRecordList } from '../types';
+import { SortPairArr } from '../../components/doc_table/lib/get_sort';
export interface ContextAppContentProps {
columns: string[];
diff --git a/src/plugins/discover/public/application/apps/context/context_app_route.tsx b/src/plugins/discover/public/application/context/context_app_route.tsx
similarity index 91%
rename from src/plugins/discover/public/application/apps/context/context_app_route.tsx
rename to src/plugins/discover/public/application/context/context_app_route.tsx
index 6c4722418be14..9d47d211489b0 100644
--- a/src/plugins/discover/public/application/apps/context/context_app_route.tsx
+++ b/src/plugins/discover/public/application/context/context_app_route.tsx
@@ -10,11 +10,11 @@ import { useParams } from 'react-router-dom';
import { i18n } from '@kbn/i18n';
import { EuiEmptyPrompt } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
-import { DiscoverServices } from '../../../build_services';
+import { DiscoverServices } from '../../build_services';
import { ContextApp } from './context_app';
-import { getRootBreadcrumbs } from '../../helpers/breadcrumbs';
+import { getRootBreadcrumbs } from '../../utils/breadcrumbs';
import { LoadingIndicator } from '../../components/common/loading_indicator';
-import { useIndexPattern } from '../../helpers/use_index_pattern';
+import { useIndexPattern } from '../../utils/use_index_pattern';
export interface ContextAppProps {
/**
diff --git a/src/plugins/discover/public/application/apps/context/index.ts b/src/plugins/discover/public/application/context/index.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/context/index.ts
rename to src/plugins/discover/public/application/context/index.ts
diff --git a/src/plugins/discover/public/application/apps/context/services/__snapshots__/context.test.ts.snap b/src/plugins/discover/public/application/context/services/__snapshots__/context.test.ts.snap
similarity index 100%
rename from src/plugins/discover/public/application/apps/context/services/__snapshots__/context.test.ts.snap
rename to src/plugins/discover/public/application/context/services/__snapshots__/context.test.ts.snap
diff --git a/src/plugins/discover/public/application/apps/context/services/_stubs.ts b/src/plugins/discover/public/application/context/services/_stubs.ts
similarity index 98%
rename from src/plugins/discover/public/application/apps/context/services/_stubs.ts
rename to src/plugins/discover/public/application/context/services/_stubs.ts
index e8d09e548c07a..df53523c367ae 100644
--- a/src/plugins/discover/public/application/apps/context/services/_stubs.ts
+++ b/src/plugins/discover/public/application/context/services/_stubs.ts
@@ -9,7 +9,7 @@
import sinon from 'sinon';
import moment from 'moment';
-import { EsHitRecordList } from '../../../types';
+import { EsHitRecordList } from '../../types';
type SortHit = {
[key in string]: number; // timeField name
diff --git a/src/plugins/discover/public/application/apps/context/services/anchor.test.ts b/src/plugins/discover/public/application/context/services/anchor.test.ts
similarity index 96%
rename from src/plugins/discover/public/application/apps/context/services/anchor.test.ts
rename to src/plugins/discover/public/application/context/services/anchor.test.ts
index 8886c8ab11f64..69c962b0c857e 100644
--- a/src/plugins/discover/public/application/apps/context/services/anchor.test.ts
+++ b/src/plugins/discover/public/application/context/services/anchor.test.ts
@@ -6,12 +6,12 @@
* Side Public License, v 1.
*/
-import { IndexPattern, SortDirection } from '../../../../../../data/public';
+import { IndexPattern, SortDirection } from '../../../../../data/public';
import { createSearchSourceStub } from './_stubs';
import { fetchAnchor, updateSearchSource } from './anchor';
-import { indexPatternMock } from '../../../../__mocks__/index_pattern';
-import { savedSearchMock } from '../../../../__mocks__/saved_search';
-import { EsHitRecordList } from '../../../types';
+import { indexPatternMock } from '../../../__mocks__/index_pattern';
+import { savedSearchMock } from '../../../__mocks__/saved_search';
+import { EsHitRecordList } from '../../types';
describe('context app', function () {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
diff --git a/src/plugins/discover/public/application/apps/context/services/anchor.ts b/src/plugins/discover/public/application/context/services/anchor.ts
similarity index 96%
rename from src/plugins/discover/public/application/apps/context/services/anchor.ts
rename to src/plugins/discover/public/application/context/services/anchor.ts
index f262d440b8a28..a42c0285bc197 100644
--- a/src/plugins/discover/public/application/apps/context/services/anchor.ts
+++ b/src/plugins/discover/public/application/context/services/anchor.ts
@@ -8,8 +8,8 @@
import { i18n } from '@kbn/i18n';
-import { ISearchSource, EsQuerySortValue, IndexPattern } from '../../../../../../data/public';
-import { EsHitRecord } from '../../../types';
+import { ISearchSource, EsQuerySortValue, IndexPattern } from '../../../../../data/public';
+import { EsHitRecord } from '../../types';
export async function fetchAnchor(
anchorId: string,
diff --git a/src/plugins/discover/public/application/apps/context/utils/constants.ts b/src/plugins/discover/public/application/context/services/constants.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/context/utils/constants.ts
rename to src/plugins/discover/public/application/context/services/constants.ts
diff --git a/src/plugins/discover/public/application/apps/context/services/context.predecessors.test.ts b/src/plugins/discover/public/application/context/services/context.predecessors.test.ts
similarity index 97%
rename from src/plugins/discover/public/application/apps/context/services/context.predecessors.test.ts
rename to src/plugins/discover/public/application/context/services/context.predecessors.test.ts
index 9bcf6f9c90d2c..1d343a2765da6 100644
--- a/src/plugins/discover/public/application/apps/context/services/context.predecessors.test.ts
+++ b/src/plugins/discover/public/application/context/services/context.predecessors.test.ts
@@ -11,10 +11,10 @@ import { get, last } from 'lodash';
import { IndexPattern, SortDirection } from 'src/plugins/data/common';
import { createContextSearchSourceStub } from './_stubs';
import { fetchSurroundingDocs, SurrDocType } from './context';
-import { setServices } from '../../../../kibana_services';
-import { Query } from '../../../../../../data/public';
-import { DiscoverServices } from '../../../../build_services';
-import { EsHitRecord, EsHitRecordList } from '../../../types';
+import { setServices } from '../../../kibana_services';
+import { Query } from '../../../../../data/public';
+import { DiscoverServices } from '../../../build_services';
+import { EsHitRecord, EsHitRecordList } from '../../types';
const MS_PER_DAY = 24 * 60 * 60 * 1000;
const ANCHOR_TIMESTAMP = new Date(MS_PER_DAY).toJSON();
diff --git a/src/plugins/discover/public/application/apps/context/services/context.successors.test.ts b/src/plugins/discover/public/application/context/services/context.successors.test.ts
similarity index 97%
rename from src/plugins/discover/public/application/apps/context/services/context.successors.test.ts
rename to src/plugins/discover/public/application/context/services/context.successors.test.ts
index 169d969753645..975d951f49ef3 100644
--- a/src/plugins/discover/public/application/apps/context/services/context.successors.test.ts
+++ b/src/plugins/discover/public/application/context/services/context.successors.test.ts
@@ -10,11 +10,11 @@ import moment from 'moment';
import { get, last } from 'lodash';
import { IndexPattern, SortDirection } from 'src/plugins/data/common';
import { createContextSearchSourceStub } from './_stubs';
-import { setServices } from '../../../../kibana_services';
-import { Query } from '../../../../../../data/public';
+import { setServices } from '../../../kibana_services';
+import { Query } from '../../../../../data/public';
import { fetchSurroundingDocs, SurrDocType } from './context';
-import { DiscoverServices } from '../../../../build_services';
-import { EsHitRecord, EsHitRecordList } from '../../../types';
+import { DiscoverServices } from '../../../build_services';
+import { EsHitRecord, EsHitRecordList } from '../../types';
const MS_PER_DAY = 24 * 60 * 60 * 1000;
const ANCHOR_TIMESTAMP = new Date(MS_PER_DAY).toJSON();
diff --git a/src/plugins/discover/public/application/apps/context/services/context.test.ts b/src/plugins/discover/public/application/context/services/context.test.ts
similarity index 87%
rename from src/plugins/discover/public/application/apps/context/services/context.test.ts
rename to src/plugins/discover/public/application/context/services/context.test.ts
index 5ad9c02871dca..df5a279dfe927 100644
--- a/src/plugins/discover/public/application/apps/context/services/context.test.ts
+++ b/src/plugins/discover/public/application/context/services/context.test.ts
@@ -7,8 +7,8 @@
*/
import { updateSearchSource } from './context';
-import { indexPatternMock } from '../../../../__mocks__/index_pattern';
-import { createSearchSourceMock } from '../../../../../../data/public/mocks';
+import { indexPatternMock } from '../../../__mocks__/index_pattern';
+import { createSearchSourceMock } from '../../../../../data/public/mocks';
describe('context api', function () {
test('createSearchSource when useFieldsApi is true', () => {
diff --git a/src/plugins/discover/public/application/apps/context/services/context.ts b/src/plugins/discover/public/application/context/services/context.ts
similarity index 86%
rename from src/plugins/discover/public/application/apps/context/services/context.ts
rename to src/plugins/discover/public/application/context/services/context.ts
index 257ae2dcce834..f8af5468cbad5 100644
--- a/src/plugins/discover/public/application/apps/context/services/context.ts
+++ b/src/plugins/discover/public/application/context/services/context.ts
@@ -6,14 +6,14 @@
* Side Public License, v 1.
*/
import { Filter, IndexPattern, ISearchSource } from 'src/plugins/data/public';
-import { reverseSortDir, SortDirection } from './utils/sorting';
-import { convertIsoToMillis, extractNanos } from './utils/date_conversion';
-import { fetchHitsInInterval } from './utils/fetch_hits_in_interval';
-import { generateIntervals } from './utils/generate_intervals';
-import { getEsQuerySearchAfter } from './utils/get_es_query_search_after';
-import { getEsQuerySort } from './utils/get_es_query_sort';
-import { getServices } from '../../../../kibana_services';
-import { EsHitRecord, EsHitRecordList } from '../../../types';
+import { reverseSortDir, SortDirection } from '../utils/sorting';
+import { convertIsoToMillis, extractNanos } from '../utils/date_conversion';
+import { fetchHitsInInterval } from '../utils/fetch_hits_in_interval';
+import { generateIntervals } from '../utils/generate_intervals';
+import { getEsQuerySearchAfter } from '../utils/get_es_query_search_after';
+import { getEsQuerySort } from '../utils/get_es_query_sort';
+import { getServices } from '../../../kibana_services';
+import { EsHitRecord, EsHitRecordList } from '../../types';
export enum SurrDocType {
SUCCESSORS = 'successors',
diff --git a/src/plugins/discover/public/application/apps/context/services/context_query_state.ts b/src/plugins/discover/public/application/context/services/context_query_state.ts
similarity index 95%
rename from src/plugins/discover/public/application/apps/context/services/context_query_state.ts
rename to src/plugins/discover/public/application/context/services/context_query_state.ts
index 132b74647f66e..3a6a4c0959ea6 100644
--- a/src/plugins/discover/public/application/apps/context/services/context_query_state.ts
+++ b/src/plugins/discover/public/application/context/services/context_query_state.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-import { EsHitRecord, EsHitRecordList } from '../../../types';
+import { EsHitRecord, EsHitRecordList } from '../../types';
export interface ContextFetchState {
/**
diff --git a/src/plugins/discover/public/application/apps/context/services/context_state.test.ts b/src/plugins/discover/public/application/context/services/context_state.test.ts
similarity index 96%
rename from src/plugins/discover/public/application/apps/context/services/context_state.test.ts
rename to src/plugins/discover/public/application/context/services/context_state.test.ts
index 3df8ab710729f..8f564d56c1042 100644
--- a/src/plugins/discover/public/application/apps/context/services/context_state.test.ts
+++ b/src/plugins/discover/public/application/context/services/context_state.test.ts
@@ -9,9 +9,9 @@
import { IUiSettingsClient } from 'kibana/public';
import { getState } from './context_state';
import { createBrowserHistory, History } from 'history';
-import { FilterManager, Filter } from '../../../../../../data/public';
-import { coreMock } from '../../../../../../../core/public/mocks';
-import { SEARCH_FIELDS_FROM_SOURCE } from '../../../../../common';
+import { FilterManager, Filter } from '../../../../../data/public';
+import { coreMock } from '../../../../../../core/public/mocks';
+import { SEARCH_FIELDS_FROM_SOURCE } from '../../../../common';
const setupMock = coreMock.createSetup();
diff --git a/src/plugins/discover/public/application/apps/context/services/context_state.ts b/src/plugins/discover/public/application/context/services/context_state.ts
similarity index 98%
rename from src/plugins/discover/public/application/apps/context/services/context_state.ts
rename to src/plugins/discover/public/application/context/services/context_state.ts
index 87f7cf00bafcf..8fb79f6f011c7 100644
--- a/src/plugins/discover/public/application/apps/context/services/context_state.ts
+++ b/src/plugins/discover/public/application/context/services/context_state.ts
@@ -15,9 +15,9 @@ import {
syncStates,
withNotifyOnErrors,
ReduxLikeStateContainer,
-} from '../../../../../../kibana_utils/public';
-import { esFilters, FilterManager, Filter } from '../../../../../../data/public';
-import { handleSourceColumnState } from '../../../helpers/state_helpers';
+} from '../../../../../kibana_utils/public';
+import { esFilters, FilterManager, Filter } from '../../../../../data/public';
+import { handleSourceColumnState } from '../../../utils/state_helpers';
export interface AppState {
/**
diff --git a/src/plugins/discover/public/application/apps/context/services/utils/date_conversion.test.ts b/src/plugins/discover/public/application/context/utils/date_conversion.test.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/context/services/utils/date_conversion.test.ts
rename to src/plugins/discover/public/application/context/utils/date_conversion.test.ts
diff --git a/src/plugins/discover/public/application/apps/context/services/utils/date_conversion.ts b/src/plugins/discover/public/application/context/utils/date_conversion.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/context/services/utils/date_conversion.ts
rename to src/plugins/discover/public/application/context/utils/date_conversion.ts
diff --git a/src/plugins/discover/public/application/apps/context/services/utils/fetch_hits_in_interval.ts b/src/plugins/discover/public/application/context/utils/fetch_hits_in_interval.ts
similarity index 95%
rename from src/plugins/discover/public/application/apps/context/services/utils/fetch_hits_in_interval.ts
rename to src/plugins/discover/public/application/context/utils/fetch_hits_in_interval.ts
index 4cfbee2dc02bc..3fc2716114513 100644
--- a/src/plugins/discover/public/application/apps/context/services/utils/fetch_hits_in_interval.ts
+++ b/src/plugins/discover/public/application/context/utils/fetch_hits_in_interval.ts
@@ -6,11 +6,11 @@
* Side Public License, v 1.
*/
-import { ISearchSource, EsQuerySortValue, SortDirection } from '../../../../../../../data/public';
+import { ISearchSource, EsQuerySortValue, SortDirection } from '../../../../../data/public';
import { convertTimeValueToIso } from './date_conversion';
import { IntervalValue } from './generate_intervals';
import { EsQuerySearchAfter } from './get_es_query_search_after';
-import { EsHitRecord, EsHitRecordList } from '../../../../types';
+import { EsHitRecord, EsHitRecordList } from '../../types';
interface RangeQuery {
format: string;
diff --git a/src/plugins/discover/public/application/apps/context/services/utils/generate_intervals.ts b/src/plugins/discover/public/application/context/utils/generate_intervals.ts
similarity index 93%
rename from src/plugins/discover/public/application/apps/context/services/utils/generate_intervals.ts
rename to src/plugins/discover/public/application/context/utils/generate_intervals.ts
index 47952f4f84759..5adeb31444ee7 100644
--- a/src/plugins/discover/public/application/apps/context/services/utils/generate_intervals.ts
+++ b/src/plugins/discover/public/application/context/utils/generate_intervals.ts
@@ -6,8 +6,8 @@
* Side Public License, v 1.
*/
-import { SortDirection } from '../../../../../../../data/public';
-import { SurrDocType } from '../context';
+import { SortDirection } from '../../../../../data/public';
+import { SurrDocType } from '../services/context';
export type IntervalValue = number | null;
diff --git a/src/plugins/discover/public/application/apps/context/services/utils/get_es_query_search_after.ts b/src/plugins/discover/public/application/context/utils/get_es_query_search_after.ts
similarity index 94%
rename from src/plugins/discover/public/application/apps/context/services/utils/get_es_query_search_after.ts
rename to src/plugins/discover/public/application/context/utils/get_es_query_search_after.ts
index 721459fee08f8..85a68376fe43b 100644
--- a/src/plugins/discover/public/application/apps/context/services/utils/get_es_query_search_after.ts
+++ b/src/plugins/discover/public/application/context/utils/get_es_query_search_after.ts
@@ -6,8 +6,8 @@
* Side Public License, v 1.
*/
-import { SurrDocType } from '../context';
-import { EsHitRecord, EsHitRecordList } from '../../../../types';
+import { SurrDocType } from '../services/context';
+import { EsHitRecord, EsHitRecordList } from '../../types';
export type EsQuerySearchAfter = [string | number, string | number];
diff --git a/src/plugins/discover/public/application/apps/context/services/utils/get_es_query_sort.ts b/src/plugins/discover/public/application/context/utils/get_es_query_sort.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/context/services/utils/get_es_query_sort.ts
rename to src/plugins/discover/public/application/context/utils/get_es_query_sort.ts
diff --git a/src/plugins/discover/public/application/apps/context/services/utils/sorting.test.ts b/src/plugins/discover/public/application/context/utils/sorting.test.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/context/services/utils/sorting.test.ts
rename to src/plugins/discover/public/application/context/utils/sorting.test.ts
diff --git a/src/plugins/discover/public/application/apps/context/services/utils/sorting.ts b/src/plugins/discover/public/application/context/utils/sorting.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/context/services/utils/sorting.ts
rename to src/plugins/discover/public/application/context/utils/sorting.ts
diff --git a/src/plugins/discover/public/application/apps/context/utils/use_context_app_fetch.test.ts b/src/plugins/discover/public/application/context/utils/use_context_app_fetch.test.ts
similarity index 94%
rename from src/plugins/discover/public/application/apps/context/utils/use_context_app_fetch.test.ts
rename to src/plugins/discover/public/application/context/utils/use_context_app_fetch.test.ts
index b3626f9c06f10..cd7bcd810dc39 100644
--- a/src/plugins/discover/public/application/apps/context/utils/use_context_app_fetch.test.ts
+++ b/src/plugins/discover/public/application/context/utils/use_context_app_fetch.test.ts
@@ -7,10 +7,10 @@
*/
import { act, renderHook } from '@testing-library/react-hooks';
-import { setServices, getServices } from '../../../../kibana_services';
-import { createFilterManagerMock } from '../../../../../../data/public/query/filter_manager/filter_manager.mock';
-import { CONTEXT_TIE_BREAKER_FIELDS_SETTING } from '../../../../../common';
-import { DiscoverServices } from '../../../../build_services';
+import { setServices, getServices } from '../../../kibana_services';
+import { createFilterManagerMock } from '../../../../../data/public/query/filter_manager/filter_manager.mock';
+import { CONTEXT_TIE_BREAKER_FIELDS_SETTING } from '../../../../common';
+import { DiscoverServices } from '../../../build_services';
import { FailureReason, LoadingStatus } from '../services/context_query_state';
import { ContextAppFetchProps, useContextAppFetch } from './use_context_app_fetch';
import {
@@ -18,9 +18,9 @@ import {
mockPredecessorHits,
mockSuccessorHits,
} from '../__mocks__/use_context_app_fetch';
-import { indexPatternWithTimefieldMock } from '../../../../__mocks__/index_pattern_with_timefield';
+import { indexPatternWithTimefieldMock } from '../../../__mocks__/index_pattern_with_timefield';
import { createContextSearchSourceStub } from '../services/_stubs';
-import { IndexPattern } from '../../../../../../data_views/common';
+import { IndexPattern } from '../../../../../data_views/common';
const mockFilterManager = createFilterManagerMock();
diff --git a/src/plugins/discover/public/application/apps/context/utils/use_context_app_fetch.tsx b/src/plugins/discover/public/application/context/utils/use_context_app_fetch.tsx
similarity index 93%
rename from src/plugins/discover/public/application/apps/context/utils/use_context_app_fetch.tsx
rename to src/plugins/discover/public/application/context/utils/use_context_app_fetch.tsx
index ed3b4e8ed5b5a..acc11ccdbe8f9 100644
--- a/src/plugins/discover/public/application/apps/context/utils/use_context_app_fetch.tsx
+++ b/src/plugins/discover/public/application/context/utils/use_context_app_fetch.tsx
@@ -7,12 +7,12 @@
*/
import React, { useCallback, useMemo, useState } from 'react';
import { i18n } from '@kbn/i18n';
-import { CONTEXT_TIE_BREAKER_FIELDS_SETTING } from '../../../../../common';
-import { DiscoverServices } from '../../../../build_services';
+import { CONTEXT_TIE_BREAKER_FIELDS_SETTING } from '../../../../common';
+import { DiscoverServices } from '../../../build_services';
import { fetchAnchor } from '../services/anchor';
import { fetchSurroundingDocs, SurrDocType } from '../services/context';
-import { MarkdownSimple, toMountPoint } from '../../../../../../kibana_react/public';
-import { IndexPattern, SortDirection } from '../../../../../../data/public';
+import { MarkdownSimple, toMountPoint } from '../../../../../kibana_react/public';
+import { IndexPattern, SortDirection } from '../../../../../data/public';
import {
ContextFetchState,
FailureReason,
@@ -20,8 +20,8 @@ import {
LoadingStatus,
} from '../services/context_query_state';
import { AppState } from '../services/context_state';
-import { getFirstSortableField } from '../services/utils/sorting';
-import { EsHitRecord } from '../../../types';
+import { getFirstSortableField } from './sorting';
+import { EsHitRecord } from '../../types';
const createError = (statusKey: string, reason: FailureReason, error?: Error) => ({
[statusKey]: { value: LoadingStatus.FAILED, error, reason },
diff --git a/src/plugins/discover/public/application/apps/context/utils/use_context_app_state.ts b/src/plugins/discover/public/application/context/utils/use_context_app_state.ts
similarity index 94%
rename from src/plugins/discover/public/application/apps/context/utils/use_context_app_state.ts
rename to src/plugins/discover/public/application/context/utils/use_context_app_state.ts
index 56701f17c7a63..9accdb363af92 100644
--- a/src/plugins/discover/public/application/apps/context/utils/use_context_app_state.ts
+++ b/src/plugins/discover/public/application/context/utils/use_context_app_state.ts
@@ -8,8 +8,8 @@
import { useEffect, useMemo, useState } from 'react';
import { cloneDeep } from 'lodash';
-import { CONTEXT_DEFAULT_SIZE_SETTING } from '../../../../../common';
-import { DiscoverServices } from '../../../../build_services';
+import { CONTEXT_DEFAULT_SIZE_SETTING } from '../../../../common';
+import { DiscoverServices } from '../../../build_services';
import { AppState, getState } from '../services/context_state';
export function useContextAppState({ services }: { services: DiscoverServices }) {
diff --git a/src/plugins/discover/public/application/discover_router.test.tsx b/src/plugins/discover/public/application/discover_router.test.tsx
index 59aede76c6866..dad796bc7c5f6 100644
--- a/src/plugins/discover/public/application/discover_router.test.tsx
+++ b/src/plugins/discover/public/application/discover_router.test.tsx
@@ -11,10 +11,10 @@ import { Route, RouteProps } from 'react-router-dom';
import { createSearchSessionMock } from '../__mocks__/search_session';
import { discoverServiceMock as mockDiscoverServices } from '../__mocks__/services';
import { discoverRouter } from './discover_router';
-import { DiscoverMainRoute } from './apps/main';
-import { DiscoverMainProps } from './apps/main/discover_main_route';
-import { SingleDocRoute } from './apps/doc';
-import { ContextAppRoute } from './apps/context';
+import { DiscoverMainRoute } from './main';
+import { DiscoverMainProps } from './main/discover_main_route';
+import { SingleDocRoute } from './doc';
+import { ContextAppRoute } from './context';
const pathMap: Record = {};
let mainRouteProps: DiscoverMainProps;
diff --git a/src/plugins/discover/public/application/discover_router.tsx b/src/plugins/discover/public/application/discover_router.tsx
index b3fe36358bbd4..6f88c28b52bf9 100644
--- a/src/plugins/discover/public/application/discover_router.tsx
+++ b/src/plugins/discover/public/application/discover_router.tsx
@@ -10,12 +10,12 @@ import { Redirect, Route, Router, Switch } from 'react-router-dom';
import React from 'react';
import { History } from 'history';
import { KibanaContextProvider } from '../../../kibana_react/public';
-import { ContextAppRoute } from './apps/context';
-import { SingleDocRoute } from './apps/doc';
-import { DiscoverMainRoute } from './apps/main';
-import { NotFoundRoute } from './apps/not_found';
+import { ContextAppRoute } from './context';
+import { SingleDocRoute } from './doc';
+import { DiscoverMainRoute } from './main';
+import { NotFoundRoute } from './not_found';
import { DiscoverServices } from '../build_services';
-import { DiscoverMainProps } from './apps/main/discover_main_route';
+import { DiscoverMainProps } from './main/discover_main_route';
export const discoverRouter = (services: DiscoverServices, history: History) => {
const mainRouteProps: DiscoverMainProps = {
diff --git a/src/plugins/discover/public/application/apps/doc/components/doc.test.tsx b/src/plugins/discover/public/application/doc/components/doc.test.tsx
similarity index 95%
rename from src/plugins/discover/public/application/apps/doc/components/doc.test.tsx
rename to src/plugins/discover/public/application/doc/components/doc.test.tsx
index 68c012ddd92e9..4131a004d299b 100644
--- a/src/plugins/discover/public/application/apps/doc/components/doc.test.tsx
+++ b/src/plugins/discover/public/application/doc/components/doc.test.tsx
@@ -13,12 +13,12 @@ import { mountWithIntl } from '@kbn/test/jest';
import { ReactWrapper } from 'enzyme';
import { findTestSubject } from '@elastic/eui/lib/test';
import { Doc, DocProps } from './doc';
-import { SEARCH_FIELDS_FROM_SOURCE as mockSearchFieldsFromSource } from '../../../../../common';
-import { indexPatternMock } from '../../../../__mocks__/index_pattern';
+import { SEARCH_FIELDS_FROM_SOURCE as mockSearchFieldsFromSource } from '../../../../common';
+import { indexPatternMock } from '../../../__mocks__/index_pattern';
const mockSearchApi = jest.fn();
-jest.mock('../../../../kibana_services', () => {
+jest.mock('../../../kibana_services', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let registry: any[] = [];
diff --git a/src/plugins/discover/public/application/apps/doc/components/doc.tsx b/src/plugins/discover/public/application/doc/components/doc.tsx
similarity index 94%
rename from src/plugins/discover/public/application/apps/doc/components/doc.tsx
rename to src/plugins/discover/public/application/doc/components/doc.tsx
index 7ccf77d2a29d4..3cb416ae8ef46 100644
--- a/src/plugins/discover/public/application/apps/doc/components/doc.tsx
+++ b/src/plugins/discover/public/application/doc/components/doc.tsx
@@ -10,10 +10,10 @@ import React from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiCallOut, EuiLink, EuiLoadingSpinner, EuiPageContent, EuiPage } from '@elastic/eui';
import { IndexPattern } from 'src/plugins/data/public';
-import { getServices } from '../../../../kibana_services';
-import { DocViewer } from '../../../components/doc_viewer/doc_viewer';
+import { getServices } from '../../../kibana_services';
+import { DocViewer } from '../../../services/doc_views/components/doc_viewer';
import { ElasticRequestState } from '../types';
-import { useEsDocSearch } from '../../../services/use_es_doc_search';
+import { useEsDocSearch } from '../../../utils/use_es_doc_search';
export interface DocProps {
/**
diff --git a/src/plugins/discover/public/application/apps/doc/index.ts b/src/plugins/discover/public/application/doc/index.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/doc/index.ts
rename to src/plugins/discover/public/application/doc/index.ts
diff --git a/src/plugins/discover/public/application/apps/doc/single_doc_route.tsx b/src/plugins/discover/public/application/doc/single_doc_route.tsx
similarity index 92%
rename from src/plugins/discover/public/application/apps/doc/single_doc_route.tsx
rename to src/plugins/discover/public/application/doc/single_doc_route.tsx
index aef928d523515..b9887a6f16cdf 100644
--- a/src/plugins/discover/public/application/apps/doc/single_doc_route.tsx
+++ b/src/plugins/discover/public/application/doc/single_doc_route.tsx
@@ -9,11 +9,11 @@ import React, { useEffect } from 'react';
import { useLocation, useParams } from 'react-router-dom';
import { EuiEmptyPrompt } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
-import { DiscoverServices } from '../../../build_services';
-import { getRootBreadcrumbs } from '../../helpers/breadcrumbs';
+import { DiscoverServices } from '../../build_services';
+import { getRootBreadcrumbs } from '../../utils/breadcrumbs';
import { Doc } from './components/doc';
import { LoadingIndicator } from '../../components/common/loading_indicator';
-import { useIndexPattern } from '../../helpers/use_index_pattern';
+import { useIndexPattern } from '../../utils/use_index_pattern';
export interface SingleDocRouteProps {
/**
diff --git a/src/plugins/discover/public/application/apps/doc/types.ts b/src/plugins/discover/public/application/doc/types.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/doc/types.ts
rename to src/plugins/discover/public/application/doc/types.ts
diff --git a/src/plugins/discover/public/application/apps/main/components/chart/discover_chart.test.tsx b/src/plugins/discover/public/application/main/components/chart/discover_chart.test.tsx
similarity index 86%
rename from src/plugins/discover/public/application/apps/main/components/chart/discover_chart.test.tsx
rename to src/plugins/discover/public/application/main/components/chart/discover_chart.test.tsx
index f7a383be76b9e..cb6d96f049c51 100644
--- a/src/plugins/discover/public/application/apps/main/components/chart/discover_chart.test.tsx
+++ b/src/plugins/discover/public/application/main/components/chart/discover_chart.test.tsx
@@ -9,17 +9,17 @@
import React from 'react';
import { Subject, BehaviorSubject } from 'rxjs';
import { mountWithIntl } from '@kbn/test/jest';
-import { setHeaderActionMenuMounter } from '../../../../../kibana_services';
-import { esHits } from '../../../../../__mocks__/es_hits';
-import { savedSearchMock } from '../../../../../__mocks__/saved_search';
-import { createSearchSourceMock } from '../../../../../../../data/common/search/search_source/mocks';
+import { setHeaderActionMenuMounter } from '../../../../kibana_services';
+import { esHits } from '../../../../__mocks__/es_hits';
+import { savedSearchMock } from '../../../../__mocks__/saved_search';
+import { createSearchSourceMock } from '../../../../../../data/common/search/search_source/mocks';
import { GetStateReturn } from '../../services/discover_state';
-import { DataCharts$, DataTotalHits$ } from '../../services/use_saved_search';
-import { discoverServiceMock } from '../../../../../__mocks__/services';
-import { FetchStatus } from '../../../../types';
+import { DataCharts$, DataTotalHits$ } from '../../utils/use_saved_search';
+import { discoverServiceMock } from '../../../../__mocks__/services';
+import { FetchStatus } from '../../../types';
import { Chart } from './point_series';
import { DiscoverChart } from './discover_chart';
-import { VIEW_MODE } from '../view_mode_toggle';
+import { VIEW_MODE } from '../../../../components/view_mode_toggle';
setHeaderActionMenuMounter(jest.fn());
diff --git a/src/plugins/discover/public/application/apps/main/components/chart/discover_chart.tsx b/src/plugins/discover/public/application/main/components/chart/discover_chart.tsx
similarity index 93%
rename from src/plugins/discover/public/application/apps/main/components/chart/discover_chart.tsx
rename to src/plugins/discover/public/application/main/components/chart/discover_chart.tsx
index 1fe149f3eb17d..1c382dbdf6b5a 100644
--- a/src/plugins/discover/public/application/apps/main/components/chart/discover_chart.tsx
+++ b/src/plugins/discover/public/application/main/components/chart/discover_chart.tsx
@@ -17,14 +17,14 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { HitsCounter } from '../hits_counter';
-import { SavedSearch } from '../../../../../saved_searches';
+import { SavedSearch } from '../../../../services/saved_searches';
import { AppState, GetStateReturn } from '../../services/discover_state';
import { DiscoverHistogram } from './histogram';
-import { DataCharts$, DataTotalHits$ } from '../../services/use_saved_search';
-import { DiscoverServices } from '../../../../../build_services';
+import { DataCharts$, DataTotalHits$ } from '../../utils/use_saved_search';
+import { DiscoverServices } from '../../../../build_services';
import { useChartPanels } from './use_chart_panels';
-import { VIEW_MODE, DocumentViewModeToggle } from '../view_mode_toggle';
-import { SHOW_FIELD_STATISTICS } from '../../../../../../common';
+import { VIEW_MODE, DocumentViewModeToggle } from '../../../../components/view_mode_toggle';
+import { SHOW_FIELD_STATISTICS } from '../../../../../common';
const DiscoverHistogramMemoized = memo(DiscoverHistogram);
export const CHART_HIDDEN_KEY = 'discover:chartHidden';
diff --git a/src/plugins/discover/public/application/apps/main/components/chart/histogram.scss b/src/plugins/discover/public/application/main/components/chart/histogram.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/chart/histogram.scss
rename to src/plugins/discover/public/application/main/components/chart/histogram.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/chart/histogram.tsx b/src/plugins/discover/public/application/main/components/chart/histogram.tsx
similarity index 96%
rename from src/plugins/discover/public/application/apps/main/components/chart/histogram.tsx
rename to src/plugins/discover/public/application/main/components/chart/histogram.tsx
index 315ab7bad40f1..9bdf9dd61e703 100644
--- a/src/plugins/discover/public/application/apps/main/components/chart/histogram.tsx
+++ b/src/plugins/discover/public/application/main/components/chart/histogram.tsx
@@ -38,12 +38,12 @@ import {
Endzones,
getAdjustedInterval,
renderEndzoneTooltip,
-} from '../../../../../../../charts/public';
-import { DataCharts$, DataChartsMessage } from '../../services/use_saved_search';
-import { FetchStatus } from '../../../../types';
-import { DiscoverServices } from '../../../../../build_services';
+} from '../../../../../../charts/public';
+import { DataCharts$, DataChartsMessage } from '../../utils/use_saved_search';
+import { FetchStatus } from '../../../types';
+import { DiscoverServices } from '../../../../build_services';
import { useDataState } from '../../utils/use_data_state';
-import { LEGACY_TIME_AXIS, MULTILAYER_TIME_AXIS_STYLE } from '../../../../../../../charts/common';
+import { LEGACY_TIME_AXIS, MULTILAYER_TIME_AXIS_STYLE } from '../../../../../../charts/common';
export interface DiscoverHistogramProps {
savedSearchData$: DataCharts$;
diff --git a/src/plugins/discover/public/application/apps/main/components/chart/index.ts b/src/plugins/discover/public/application/main/components/chart/index.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/chart/index.ts
rename to src/plugins/discover/public/application/main/components/chart/index.ts
diff --git a/src/plugins/discover/public/application/apps/main/components/chart/point_series.test.ts b/src/plugins/discover/public/application/main/components/chart/point_series.test.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/chart/point_series.test.ts
rename to src/plugins/discover/public/application/main/components/chart/point_series.test.ts
diff --git a/src/plugins/discover/public/application/apps/main/components/chart/point_series.ts b/src/plugins/discover/public/application/main/components/chart/point_series.ts
similarity index 96%
rename from src/plugins/discover/public/application/apps/main/components/chart/point_series.ts
rename to src/plugins/discover/public/application/main/components/chart/point_series.ts
index ee057fcb48c6a..b8cdf75d5fd36 100644
--- a/src/plugins/discover/public/application/apps/main/components/chart/point_series.ts
+++ b/src/plugins/discover/public/application/main/components/chart/point_series.ts
@@ -9,7 +9,7 @@
import { uniq } from 'lodash';
import { Duration, Moment } from 'moment';
import { Unit } from '@elastic/datemath';
-import type { SerializedFieldFormat } from '../../../../../../../field_formats/common';
+import { SerializedFieldFormat } from '../../../../../../field_formats/common';
export interface Column {
id: string;
diff --git a/src/plugins/discover/public/application/apps/main/components/chart/use_chart_panels.test.ts b/src/plugins/discover/public/application/main/components/chart/use_chart_panels.test.ts
similarity index 94%
rename from src/plugins/discover/public/application/apps/main/components/chart/use_chart_panels.test.ts
rename to src/plugins/discover/public/application/main/components/chart/use_chart_panels.test.ts
index a1b9c30380969..20f19ec4719e9 100644
--- a/src/plugins/discover/public/application/apps/main/components/chart/use_chart_panels.test.ts
+++ b/src/plugins/discover/public/application/main/components/chart/use_chart_panels.test.ts
@@ -11,8 +11,8 @@ import { renderHook } from '@testing-library/react-hooks';
import { useChartPanels } from './use_chart_panels';
import { AppState } from '../../services/discover_state';
import { BehaviorSubject } from 'rxjs';
-import { DataCharts$ } from '../../services/use_saved_search';
-import { FetchStatus } from '../../../../types';
+import { DataCharts$ } from '../../utils/use_saved_search';
+import { FetchStatus } from '../../../types';
import { EuiContextMenuPanelDescriptor } from '@elastic/eui';
describe('test useChartPanels', () => {
diff --git a/src/plugins/discover/public/application/apps/main/components/chart/use_chart_panels.ts b/src/plugins/discover/public/application/main/components/chart/use_chart_panels.ts
similarity index 95%
rename from src/plugins/discover/public/application/apps/main/components/chart/use_chart_panels.ts
rename to src/plugins/discover/public/application/main/components/chart/use_chart_panels.ts
index 3660173ef761d..cf09506c4f552 100644
--- a/src/plugins/discover/public/application/apps/main/components/chart/use_chart_panels.ts
+++ b/src/plugins/discover/public/application/main/components/chart/use_chart_panels.ts
@@ -10,9 +10,9 @@ import type {
EuiContextMenuPanelItemDescriptor,
EuiContextMenuPanelDescriptor,
} from '@elastic/eui';
-import { search } from '../../../../../../../data/public';
+import { search } from '../../../../../../data/public';
import { AppState } from '../../services/discover_state';
-import { DataCharts$ } from '../../services/use_saved_search';
+import { DataCharts$ } from '../../utils/use_saved_search';
export function useChartPanels(
state: AppState,
diff --git a/src/plugins/discover/public/application/apps/main/components/hits_counter/hits_counter.scss b/src/plugins/discover/public/application/main/components/hits_counter/hits_counter.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/hits_counter/hits_counter.scss
rename to src/plugins/discover/public/application/main/components/hits_counter/hits_counter.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/hits_counter/hits_counter.test.tsx b/src/plugins/discover/public/application/main/components/hits_counter/hits_counter.test.tsx
similarity index 95%
rename from src/plugins/discover/public/application/apps/main/components/hits_counter/hits_counter.test.tsx
rename to src/plugins/discover/public/application/main/components/hits_counter/hits_counter.test.tsx
index 02644fbf507dd..d46600fca01f4 100644
--- a/src/plugins/discover/public/application/apps/main/components/hits_counter/hits_counter.test.tsx
+++ b/src/plugins/discover/public/application/main/components/hits_counter/hits_counter.test.tsx
@@ -12,8 +12,8 @@ import { ReactWrapper } from 'enzyme';
import { HitsCounter, HitsCounterProps } from './hits_counter';
import { findTestSubject } from '@elastic/eui/lib/test';
import { BehaviorSubject } from 'rxjs';
-import { FetchStatus } from '../../../../types';
-import { DataTotalHits$ } from '../../services/use_saved_search';
+import { FetchStatus } from '../../../types';
+import { DataTotalHits$ } from '../../utils/use_saved_search';
describe('hits counter', function () {
let props: HitsCounterProps;
diff --git a/src/plugins/discover/public/application/apps/main/components/hits_counter/hits_counter.tsx b/src/plugins/discover/public/application/main/components/hits_counter/hits_counter.tsx
similarity index 96%
rename from src/plugins/discover/public/application/apps/main/components/hits_counter/hits_counter.tsx
rename to src/plugins/discover/public/application/main/components/hits_counter/hits_counter.tsx
index ab6617cbe79de..47c50f7bd47f5 100644
--- a/src/plugins/discover/public/application/apps/main/components/hits_counter/hits_counter.tsx
+++ b/src/plugins/discover/public/application/main/components/hits_counter/hits_counter.tsx
@@ -17,8 +17,8 @@ import {
} from '@elastic/eui';
import { FormattedMessage, FormattedNumber } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
-import { DataTotalHits$, DataTotalHitsMsg } from '../../services/use_saved_search';
-import { FetchStatus } from '../../../../types';
+import { DataTotalHits$, DataTotalHitsMsg } from '../../utils/use_saved_search';
+import { FetchStatus } from '../../../types';
import { useDataState } from '../../utils/use_data_state';
export interface HitsCounterProps {
diff --git a/src/plugins/discover/public/application/apps/main/components/hits_counter/index.ts b/src/plugins/discover/public/application/main/components/hits_counter/index.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/hits_counter/index.ts
rename to src/plugins/discover/public/application/main/components/hits_counter/index.ts
diff --git a/src/plugins/discover/public/application/apps/main/components/layout/discover_documents.test.tsx b/src/plugins/discover/public/application/main/components/layout/discover_documents.test.tsx
similarity index 75%
rename from src/plugins/discover/public/application/apps/main/components/layout/discover_documents.test.tsx
rename to src/plugins/discover/public/application/main/components/layout/discover_documents.test.tsx
index 60540268dcd7f..829d88bbafd08 100644
--- a/src/plugins/discover/public/application/apps/main/components/layout/discover_documents.test.tsx
+++ b/src/plugins/discover/public/application/main/components/layout/discover_documents.test.tsx
@@ -9,20 +9,20 @@
import React from 'react';
import { BehaviorSubject } from 'rxjs';
import { mountWithIntl } from '@kbn/test/jest';
-import { setHeaderActionMenuMounter } from '../../../../../kibana_services';
-import { esHits } from '../../../../../__mocks__/es_hits';
-import { savedSearchMock } from '../../../../../__mocks__/saved_search';
+import { setHeaderActionMenuMounter } from '../../../../kibana_services';
+import { esHits } from '../../../../__mocks__/es_hits';
+import { savedSearchMock } from '../../../../__mocks__/saved_search';
import { GetStateReturn } from '../../services/discover_state';
-import { DataDocuments$ } from '../../services/use_saved_search';
-import { discoverServiceMock } from '../../../../../__mocks__/services';
-import { FetchStatus } from '../../../../types';
+import { DataDocuments$ } from '../../utils/use_saved_search';
+import { discoverServiceMock } from '../../../../__mocks__/services';
+import { FetchStatus } from '../../../types';
import { DiscoverDocuments } from './discover_documents';
-import { ElasticSearchHit } from '../../../../doc_views/doc_views_types';
-import { indexPatternMock } from '../../../../../__mocks__/index_pattern';
+import { ElasticSearchHit } from '../../../../services/doc_views/doc_views_types';
+import { indexPatternMock } from '../../../../__mocks__/index_pattern';
-jest.mock('../../../../../kibana_services', () => ({
- ...jest.requireActual('../../../../../kibana_services'),
- getServices: () => jest.requireActual('../../../../../__mocks__/services').discoverServiceMock,
+jest.mock('../../../../kibana_services', () => ({
+ ...jest.requireActual('../../../../kibana_services'),
+ getServices: () => jest.requireActual('../../../../__mocks__/services').discoverServiceMock,
}));
setHeaderActionMenuMounter(jest.fn());
diff --git a/src/plugins/discover/public/application/apps/main/components/layout/discover_documents.tsx b/src/plugins/discover/public/application/main/components/layout/discover_documents.tsx
similarity index 88%
rename from src/plugins/discover/public/application/apps/main/components/layout/discover_documents.tsx
rename to src/plugins/discover/public/application/main/components/layout/discover_documents.tsx
index 64d5e08f25d73..08582b21a90ac 100644
--- a/src/plugins/discover/public/application/apps/main/components/layout/discover_documents.tsx
+++ b/src/plugins/discover/public/application/main/components/layout/discover_documents.tsx
@@ -14,24 +14,24 @@ import {
EuiScreenReaderOnly,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
-import { DocViewFilterFn, ElasticSearchHit } from '../../../../doc_views/doc_views_types';
+import { DocViewFilterFn, ElasticSearchHit } from '../../../../services/doc_views/doc_views_types';
import { DiscoverGrid } from '../../../../components/discover_grid/discover_grid';
-import { FetchStatus } from '../../../../types';
+import { FetchStatus } from '../../../types';
import {
DOC_HIDE_TIME_COLUMN_SETTING,
DOC_TABLE_LEGACY,
SAMPLE_SIZE_SETTING,
SEARCH_FIELDS_FROM_SOURCE,
-} from '../../../../../../common';
-import { useColumns } from '../../../../helpers/use_data_grid_columns';
-import { IndexPattern } from '../../../../../../../data/common';
-import { SavedSearch } from '../../../../../saved_searches';
-import { DataDocumentsMsg, DataDocuments$ } from '../../services/use_saved_search';
-import { DiscoverServices } from '../../../../../build_services';
+} from '../../../../../common';
+import { useColumns } from '../../../../utils/use_data_grid_columns';
+import { IndexPattern } from '../../../../../../data/common';
+import { SavedSearch } from '../../../../services/saved_searches';
+import { DataDocumentsMsg, DataDocuments$ } from '../../utils/use_saved_search';
+import { DiscoverServices } from '../../../../build_services';
import { AppState, GetStateReturn } from '../../services/discover_state';
import { useDataState } from '../../utils/use_data_state';
-import { DocTableInfinite } from '../doc_table/doc_table_infinite';
-import { SortPairArr } from '../doc_table/lib/get_sort';
+import { DocTableInfinite } from '../../../../components/doc_table/doc_table_infinite';
+import { SortPairArr } from '../../../../components/doc_table/lib/get_sort';
const DocTableInfiniteMemoized = React.memo(DocTableInfinite);
const DataGridMemoized = React.memo(DiscoverGrid);
diff --git a/src/plugins/discover/public/application/apps/main/components/layout/discover_layout.scss b/src/plugins/discover/public/application/main/components/layout/discover_layout.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/layout/discover_layout.scss
rename to src/plugins/discover/public/application/main/components/layout/discover_layout.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/layout/discover_layout.test.tsx b/src/plugins/discover/public/application/main/components/layout/discover_layout.test.tsx
similarity index 85%
rename from src/plugins/discover/public/application/apps/main/components/layout/discover_layout.test.tsx
rename to src/plugins/discover/public/application/main/components/layout/discover_layout.test.tsx
index 7e3252dce1ef5..c222e4038f517 100644
--- a/src/plugins/discover/public/application/apps/main/components/layout/discover_layout.test.tsx
+++ b/src/plugins/discover/public/application/main/components/layout/discover_layout.test.tsx
@@ -9,15 +9,15 @@
import React from 'react';
import { Subject, BehaviorSubject } from 'rxjs';
import { mountWithIntl } from '@kbn/test/jest';
-import { setHeaderActionMenuMounter } from '../../../../../kibana_services';
+import { setHeaderActionMenuMounter } from '../../../../kibana_services';
import { DiscoverLayout, SIDEBAR_CLOSED_KEY } from './discover_layout';
-import { esHits } from '../../../../../__mocks__/es_hits';
-import { indexPatternMock } from '../../../../../__mocks__/index_pattern';
-import { savedSearchMock } from '../../../../../__mocks__/saved_search';
-import { createSearchSourceMock } from '../../../../../../../data/common/search/search_source/mocks';
-import { IndexPattern, IndexPatternAttributes } from '../../../../../../../data/common';
-import { SavedObject } from '../../../../../../../../core/types';
-import { indexPatternWithTimefieldMock } from '../../../../../__mocks__/index_pattern_with_timefield';
+import { esHits } from '../../../../__mocks__/es_hits';
+import { indexPatternMock } from '../../../../__mocks__/index_pattern';
+import { savedSearchMock } from '../../../../__mocks__/saved_search';
+import { createSearchSourceMock } from '../../../../../../data/common/search/search_source/mocks';
+import { IndexPattern, IndexPatternAttributes } from '../../../../../../data/common';
+import { SavedObject } from '../../../../../../../core/types';
+import { indexPatternWithTimefieldMock } from '../../../../__mocks__/index_pattern_with_timefield';
import { GetStateReturn } from '../../services/discover_state';
import { DiscoverLayoutProps } from './types';
import {
@@ -25,16 +25,16 @@ import {
DataDocuments$,
DataMain$,
DataTotalHits$,
-} from '../../services/use_saved_search';
-import { discoverServiceMock } from '../../../../../__mocks__/services';
-import { FetchStatus } from '../../../../types';
-import { ElasticSearchHit } from '../../../../doc_views/doc_views_types';
-import { RequestAdapter } from '../../../../../../../inspector';
+} from '../../utils/use_saved_search';
+import { discoverServiceMock } from '../../../../__mocks__/services';
+import { FetchStatus } from '../../../types';
+import { ElasticSearchHit } from '../../../../services/doc_views/doc_views_types';
+import { RequestAdapter } from '../../../../../../inspector';
import { Chart } from '../chart/point_series';
import { DiscoverSidebar } from '../sidebar/discover_sidebar';
-jest.mock('../../../../../kibana_services', () => ({
- ...jest.requireActual('../../../../../kibana_services'),
+jest.mock('../../../../kibana_services', () => ({
+ ...jest.requireActual('../../../../kibana_services'),
getServices: () => ({
fieldFormats: {
getDefaultInstance: jest.fn(() => ({ convert: (value: unknown) => value })),
diff --git a/src/plugins/discover/public/application/apps/main/components/layout/discover_layout.tsx b/src/plugins/discover/public/application/main/components/layout/discover_layout.tsx
similarity index 95%
rename from src/plugins/discover/public/application/apps/main/components/layout/discover_layout.tsx
rename to src/plugins/discover/public/application/main/components/layout/discover_layout.tsx
index 76ed7069b294a..115b9eb1a63bf 100644
--- a/src/plugins/discover/public/application/apps/main/components/layout/discover_layout.tsx
+++ b/src/plugins/discover/public/application/main/components/layout/discover_layout.tsx
@@ -23,28 +23,28 @@ import { METRIC_TYPE } from '@kbn/analytics';
import classNames from 'classnames';
import { DiscoverNoResults } from '../no_results';
import { LoadingSpinner } from '../loading_spinner/loading_spinner';
-import { esFilters, IndexPatternField } from '../../../../../../../data/public';
+import { esFilters, IndexPatternField } from '../../../../../../data/public';
import { DiscoverSidebarResponsive } from '../sidebar';
import { DiscoverLayoutProps } from './types';
-import { SEARCH_FIELDS_FROM_SOURCE, SHOW_FIELD_STATISTICS } from '../../../../../../common';
-import { popularizeField } from '../../../../helpers/popularize_field';
+import { SEARCH_FIELDS_FROM_SOURCE, SHOW_FIELD_STATISTICS } from '../../../../../common';
+import { popularizeField } from '../../../../utils/popularize_field';
import { DiscoverTopNav } from '../top_nav/discover_topnav';
-import { DocViewFilterFn, ElasticSearchHit } from '../../../../doc_views/doc_views_types';
+import { DocViewFilterFn, ElasticSearchHit } from '../../../../services/doc_views/doc_views_types';
import { DiscoverChart } from '../chart';
import { getResultState } from '../../utils/get_result_state';
-import { InspectorSession } from '../../../../../../../inspector/public';
+import { InspectorSession } from '../../../../../../inspector/public';
import { DiscoverUninitialized } from '../uninitialized/uninitialized';
-import { DataMainMsg } from '../../services/use_saved_search';
-import { useColumns } from '../../../../helpers/use_data_grid_columns';
+import { DataMainMsg } from '../../utils/use_saved_search';
+import { useColumns } from '../../../../utils/use_data_grid_columns';
import { DiscoverDocuments } from './discover_documents';
-import { FetchStatus } from '../../../../types';
+import { FetchStatus } from '../../../types';
import { useDataState } from '../../utils/use_data_state';
import {
SavedSearchURLConflictCallout,
useSavedSearchAliasMatchRedirect,
-} from '../../../../../saved_searches';
+} from '../../../../services/saved_searches';
import { DiscoverDataVisualizerGrid } from '../../../../components/data_visualizer_grid';
-import { VIEW_MODE } from '../view_mode_toggle';
+import { VIEW_MODE } from '../../../../components/view_mode_toggle';
/**
* Local storage key for sidebar persistence state
diff --git a/src/plugins/discover/public/application/apps/main/components/layout/index.ts b/src/plugins/discover/public/application/main/components/layout/index.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/layout/index.ts
rename to src/plugins/discover/public/application/main/components/layout/index.ts
diff --git a/src/plugins/discover/public/application/apps/main/components/layout/types.ts b/src/plugins/discover/public/application/main/components/layout/types.ts
similarity index 74%
rename from src/plugins/discover/public/application/apps/main/components/layout/types.ts
rename to src/plugins/discover/public/application/main/components/layout/types.ts
index e4a780cadceae..1ed34978416fa 100644
--- a/src/plugins/discover/public/application/apps/main/components/layout/types.ts
+++ b/src/plugins/discover/public/application/main/components/layout/types.ts
@@ -12,13 +12,13 @@ import {
Query,
SavedObject,
TimeRange,
-} from '../../../../../../../data/common';
-import { ISearchSource } from '../../../../../../../data/public';
+} from '../../../../../../data/common';
+import { ISearchSource } from '../../../../../../data/public';
import { AppState, GetStateReturn } from '../../services/discover_state';
-import { DataRefetch$, SavedSearchData } from '../../services/use_saved_search';
-import { DiscoverServices } from '../../../../../build_services';
-import { SavedSearch } from '../../../../../saved_searches';
-import { RequestAdapter } from '../../../../../../../inspector';
+import { DataRefetch$, SavedSearchData } from '../../utils/use_saved_search';
+import { DiscoverServices } from '../../../../build_services';
+import { SavedSearch } from '../../../../services/saved_searches';
+import { RequestAdapter } from '../../../../../../inspector';
export interface DiscoverLayoutProps {
indexPattern: IndexPattern;
diff --git a/src/plugins/discover/public/application/apps/main/components/loading_spinner/loading_spinner.scss b/src/plugins/discover/public/application/main/components/loading_spinner/loading_spinner.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/loading_spinner/loading_spinner.scss
rename to src/plugins/discover/public/application/main/components/loading_spinner/loading_spinner.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/loading_spinner/loading_spinner.test.tsx b/src/plugins/discover/public/application/main/components/loading_spinner/loading_spinner.test.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/loading_spinner/loading_spinner.test.tsx
rename to src/plugins/discover/public/application/main/components/loading_spinner/loading_spinner.test.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/loading_spinner/loading_spinner.tsx b/src/plugins/discover/public/application/main/components/loading_spinner/loading_spinner.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/loading_spinner/loading_spinner.tsx
rename to src/plugins/discover/public/application/main/components/loading_spinner/loading_spinner.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/no_results/_no_results.scss b/src/plugins/discover/public/application/main/components/no_results/_no_results.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/no_results/_no_results.scss
rename to src/plugins/discover/public/application/main/components/no_results/_no_results.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/no_results/assets/no_results_illustration.scss b/src/plugins/discover/public/application/main/components/no_results/assets/no_results_illustration.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/no_results/assets/no_results_illustration.scss
rename to src/plugins/discover/public/application/main/components/no_results/assets/no_results_illustration.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/no_results/assets/no_results_illustration.tsx b/src/plugins/discover/public/application/main/components/no_results/assets/no_results_illustration.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/no_results/assets/no_results_illustration.tsx
rename to src/plugins/discover/public/application/main/components/no_results/assets/no_results_illustration.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/no_results/index.ts b/src/plugins/discover/public/application/main/components/no_results/index.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/no_results/index.ts
rename to src/plugins/discover/public/application/main/components/no_results/index.ts
diff --git a/src/plugins/discover/public/application/apps/main/components/no_results/no_results.test.tsx b/src/plugins/discover/public/application/main/components/no_results/no_results.test.tsx
similarity index 98%
rename from src/plugins/discover/public/application/apps/main/components/no_results/no_results.test.tsx
rename to src/plugins/discover/public/application/main/components/no_results/no_results.test.tsx
index 3a42a22d1d2eb..1f6a2235b916f 100644
--- a/src/plugins/discover/public/application/apps/main/components/no_results/no_results.test.tsx
+++ b/src/plugins/discover/public/application/main/components/no_results/no_results.test.tsx
@@ -12,7 +12,7 @@ import { findTestSubject } from '@elastic/eui/lib/test';
import { DiscoverNoResults, DiscoverNoResultsProps } from './no_results';
-jest.mock('../../../../../kibana_services', () => {
+jest.mock('../../../../kibana_services', () => {
return {
getServices: () => ({
docLinks: {
diff --git a/src/plugins/discover/public/application/apps/main/components/no_results/no_results.tsx b/src/plugins/discover/public/application/main/components/no_results/no_results.tsx
similarity index 97%
rename from src/plugins/discover/public/application/apps/main/components/no_results/no_results.tsx
rename to src/plugins/discover/public/application/main/components/no_results/no_results.tsx
index 852c0860fd0c1..38dce654f0daa 100644
--- a/src/plugins/discover/public/application/apps/main/components/no_results/no_results.tsx
+++ b/src/plugins/discover/public/application/main/components/no_results/no_results.tsx
@@ -16,7 +16,7 @@ import {
EuiSpacer,
EuiTitle,
} from '@elastic/eui';
-import { DataPublicPluginStart } from '../../../../../../../data/public';
+import { DataPublicPluginStart } from '../../../../../../data/public';
import { AdjustSearch, getTimeFieldMessage } from './no_results_helper';
import './_no_results.scss';
import { NoResultsIllustration } from './assets/no_results_illustration';
diff --git a/src/plugins/discover/public/application/apps/main/components/no_results/no_results_helper.tsx b/src/plugins/discover/public/application/main/components/no_results/no_results_helper.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/no_results/no_results_helper.tsx
rename to src/plugins/discover/public/application/main/components/no_results/no_results_helper.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/__snapshots__/discover_index_pattern.test.tsx.snap b/src/plugins/discover/public/application/main/components/sidebar/__snapshots__/discover_index_pattern.test.tsx.snap
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/__snapshots__/discover_index_pattern.test.tsx.snap
rename to src/plugins/discover/public/application/main/components/sidebar/__snapshots__/discover_index_pattern.test.tsx.snap
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/__snapshots__/discover_index_pattern_management.test.tsx.snap b/src/plugins/discover/public/application/main/components/sidebar/__snapshots__/discover_index_pattern_management.test.tsx.snap
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/__snapshots__/discover_index_pattern_management.test.tsx.snap
rename to src/plugins/discover/public/application/main/components/sidebar/__snapshots__/discover_index_pattern_management.test.tsx.snap
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/change_indexpattern.test.tsx b/src/plugins/discover/public/application/main/components/sidebar/change_indexpattern.test.tsx
similarity index 93%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/change_indexpattern.test.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/change_indexpattern.test.tsx
index 8c32942740a76..b61683c8de14a 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/change_indexpattern.test.tsx
+++ b/src/plugins/discover/public/application/main/components/sidebar/change_indexpattern.test.tsx
@@ -11,8 +11,8 @@ import { ShallowWrapper } from 'enzyme';
import { act } from 'react-dom/test-utils';
import { shallowWithIntl } from '@kbn/test/jest';
import { ChangeIndexPattern } from './change_indexpattern';
-import { indexPatternMock } from '../../../../../__mocks__/index_pattern';
-import { indexPatternWithTimefieldMock } from '../../../../../__mocks__/index_pattern_with_timefield';
+import { indexPatternMock } from '../../../../__mocks__/index_pattern';
+import { indexPatternWithTimefieldMock } from '../../../../__mocks__/index_pattern_with_timefield';
import { IndexPatternRef } from './types';
function getProps() {
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/change_indexpattern.tsx b/src/plugins/discover/public/application/main/components/sidebar/change_indexpattern.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/change_indexpattern.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/change_indexpattern.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_field.scss b/src/plugins/discover/public/application/main/components/sidebar/discover_field.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_field.scss
rename to src/plugins/discover/public/application/main/components/sidebar/discover_field.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_field.test.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_field.test.tsx
similarity index 95%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_field.test.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/discover_field.test.tsx
index 1dfc14d6c20b9..fbbe68a43f5e5 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_field.test.tsx
+++ b/src/plugins/discover/public/application/main/components/sidebar/discover_field.test.tsx
@@ -11,10 +11,10 @@ import { findTestSubject } from '@elastic/eui/lib/test';
import { mountWithIntl } from '@kbn/test/jest';
import { DiscoverField } from './discover_field';
-import { IndexPatternField } from '../../../../../../../data/public';
-import { stubIndexPattern } from '../../../../../../../data/common/stubs';
+import { IndexPatternField } from '../../../../../../data/public';
+import { stubIndexPattern } from '../../../../../../data/common/stubs';
-jest.mock('../../../../../kibana_services', () => ({
+jest.mock('../../../../kibana_services', () => ({
getUiActions: jest.fn(() => {
return {
getTriggerCompatibleActions: jest.fn(() => []),
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_field.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_field.tsx
similarity index 99%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_field.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/discover_field.tsx
index 89e7b50187630..c254f5531a8f0 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_field.tsx
+++ b/src/plugins/discover/public/application/main/components/sidebar/discover_field.tsx
@@ -25,9 +25,9 @@ import { i18n } from '@kbn/i18n';
import { UiCounterMetricType } from '@kbn/analytics';
import classNames from 'classnames';
import { DiscoverFieldDetails } from './discover_field_details';
-import { FieldIcon, FieldButton } from '../../../../../../../kibana_react/public';
+import { FieldIcon, FieldButton } from '../../../../../../kibana_react/public';
import { FieldDetails } from './types';
-import { IndexPatternField, IndexPattern } from '../../../../../../../data/public';
+import { IndexPatternField, IndexPattern } from '../../../../../../data/public';
import { getFieldTypeName } from './lib/get_field_type_name';
import { DiscoverFieldVisualize } from './discover_field_visualize';
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_field_bucket.scss b/src/plugins/discover/public/application/main/components/sidebar/discover_field_bucket.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_field_bucket.scss
rename to src/plugins/discover/public/application/main/components/sidebar/discover_field_bucket.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_field_bucket.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_field_bucket.tsx
similarity index 98%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_field_bucket.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/discover_field_bucket.tsx
index 7dab8cecf28a9..9b0134bf19406 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_field_bucket.tsx
+++ b/src/plugins/discover/public/application/main/components/sidebar/discover_field_bucket.tsx
@@ -11,7 +11,7 @@ import { EuiText, EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@e
import { i18n } from '@kbn/i18n';
import { StringFieldProgressBar } from './string_progress_bar';
import { Bucket } from './types';
-import { IndexPatternField } from '../../../../../../../data/public';
+import { IndexPatternField } from '../../../../../../data/public';
import './discover_field_bucket.scss';
interface Props {
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_field_details.test.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_field_details.test.tsx
similarity index 91%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_field_details.test.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/discover_field_details.test.tsx
index f873cfa2151da..fb3f34b1eff26 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_field_details.test.tsx
+++ b/src/plugins/discover/public/application/main/components/sidebar/discover_field_details.test.tsx
@@ -11,8 +11,8 @@ import { findTestSubject } from '@elastic/eui/lib/test';
import { mountWithIntl } from '@kbn/test/jest';
import { DiscoverFieldDetails } from './discover_field_details';
-import { IndexPatternField } from '../../../../../../../data/public';
-import { stubIndexPattern } from '../../../../../../../data/common/stubs';
+import { IndexPatternField } from '../../../../../../data/public';
+import { stubIndexPattern } from '../../../../../../data/common/stubs';
describe('discover sidebar field details', function () {
const onAddFilter = jest.fn();
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_field_details.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_field_details.tsx
similarity index 99%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_field_details.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/discover_field_details.tsx
index e29799b720e21..af2a322d97806 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_field_details.tsx
+++ b/src/plugins/discover/public/application/main/components/sidebar/discover_field_details.tsx
@@ -11,7 +11,7 @@ import { EuiText, EuiSpacer, EuiLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { DiscoverFieldBucket } from './discover_field_bucket';
import { Bucket, FieldDetails } from './types';
-import { IndexPatternField, IndexPattern } from '../../../../../../../data/public';
+import { IndexPatternField, IndexPattern } from '../../../../../../data/public';
interface DiscoverFieldDetailsProps {
field: IndexPatternField;
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_field_search.scss b/src/plugins/discover/public/application/main/components/sidebar/discover_field_search.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_field_search.scss
rename to src/plugins/discover/public/application/main/components/sidebar/discover_field_search.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_field_search.test.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_field_search.test.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_field_search.test.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/discover_field_search.test.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_field_search.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_field_search.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_field_search.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/discover_field_search.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_field_visualize.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_field_visualize.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_field_visualize.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/discover_field_visualize.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_index_pattern.test.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_index_pattern.test.tsx
similarity index 97%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_index_pattern.test.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/discover_index_pattern.test.tsx
index 50af66511de30..4f1f26f2794a4 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_index_pattern.test.tsx
+++ b/src/plugins/discover/public/application/main/components/sidebar/discover_index_pattern.test.tsx
@@ -15,7 +15,7 @@ import { SavedObject } from 'kibana/server';
import { DiscoverIndexPattern, DiscoverIndexPatternProps } from './discover_index_pattern';
import { EuiSelectable } from '@elastic/eui';
import { IndexPattern, IndexPatternAttributes } from 'src/plugins/data/public';
-import { indexPatternsMock } from '../../../../../__mocks__/index_patterns';
+import { indexPatternsMock } from '../../../../__mocks__/index_patterns';
const indexPattern = {
id: 'the-index-pattern-id-first',
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_index_pattern.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_index_pattern.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_index_pattern.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/discover_index_pattern.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_index_pattern_management.test.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_index_pattern_management.test.tsx
similarity index 92%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_index_pattern_management.test.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/discover_index_pattern_management.test.tsx
index 4e41c457ab8eb..c5b1f4d2612d6 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_index_pattern_management.test.tsx
+++ b/src/plugins/discover/public/application/main/components/sidebar/discover_index_pattern_management.test.tsx
@@ -7,12 +7,11 @@
*/
import React from 'react';
-import { mountWithIntl } from '@kbn/test/jest';
+import { mountWithIntl, findTestSubject } from '@kbn/test/jest';
import { EuiContextMenuPanel, EuiPopover, EuiContextMenuItem } from '@elastic/eui';
-import { findTestSubject } from '@kbn/test/jest';
-import { DiscoverServices } from '../../../../../build_services';
+import { DiscoverServices } from '../../../../build_services';
import { DiscoverIndexPatternManagement } from './discover_index_pattern_management';
-import { stubLogstashIndexPattern } from '../../../../../../../data/common/stubs';
+import { stubLogstashIndexPattern } from '../../../../../../data/common/stubs';
const mockServices = {
history: () => ({
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_index_pattern_management.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_index_pattern_management.tsx
similarity index 96%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_index_pattern_management.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/discover_index_pattern_management.tsx
index 81e9f821ca6c0..9353073e7fad6 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_index_pattern_management.tsx
+++ b/src/plugins/discover/public/application/main/components/sidebar/discover_index_pattern_management.tsx
@@ -9,8 +9,8 @@
import React, { useState } from 'react';
import { EuiButtonIcon, EuiContextMenuItem, EuiContextMenuPanel, EuiPopover } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
-import { DiscoverServices } from '../../../../../build_services';
-import { IndexPattern } from '../../../../../../../data/common';
+import { DiscoverServices } from '../../../../build_services';
+import { IndexPattern } from '../../../../../../data/common';
export interface DiscoverIndexPatternManagementProps {
/**
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_sidebar.scss b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_sidebar.scss
rename to src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_sidebar.test.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.test.tsx
similarity index 88%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_sidebar.test.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.test.tsx
index 03616c136df3e..b2b5c8a056995 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_sidebar.test.tsx
+++ b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.test.tsx
@@ -10,21 +10,21 @@ import { each, cloneDeep } from 'lodash';
import { ReactWrapper } from 'enzyme';
import { findTestSubject } from '@elastic/eui/lib/test';
// @ts-expect-error
-import realHits from '../../../../../__fixtures__/real_hits.js';
+import realHits from '../../../../__fixtures__/real_hits.js';
import { mountWithIntl } from '@kbn/test/jest';
import React from 'react';
import { DiscoverSidebarProps } from './discover_sidebar';
-import { flattenHit, IndexPatternAttributes } from '../../../../../../../data/common';
-import { SavedObject } from '../../../../../../../../core/types';
+import { flattenHit, IndexPatternAttributes } from '../../../../../../data/common';
+import { SavedObject } from '../../../../../../../core/types';
import { getDefaultFieldFilter } from './lib/field_filter';
import { DiscoverSidebarComponent as DiscoverSidebar } from './discover_sidebar';
-import { ElasticSearchHit } from '../../../../doc_views/doc_views_types';
-import { discoverServiceMock as mockDiscoverServices } from '../../../../../__mocks__/services';
-import { stubLogstashIndexPattern } from '../../../../../../../data/common/stubs';
-import { VIEW_MODE } from '../view_mode_toggle';
+import { ElasticSearchHit } from '../../../../services/doc_views/doc_views_types';
+import { discoverServiceMock as mockDiscoverServices } from '../../../../__mocks__/services';
+import { stubLogstashIndexPattern } from '../../../../../../data/common/stubs';
+import { VIEW_MODE } from '../../../../components/view_mode_toggle';
-jest.mock('../../../../../kibana_services', () => ({
+jest.mock('../../../../kibana_services', () => ({
getServices: () => mockDiscoverServices,
}));
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_sidebar.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.tsx
similarity index 98%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_sidebar.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.tsx
index d13860eab0d24..fcc4d32151018 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_sidebar.tsx
+++ b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.tsx
@@ -28,19 +28,19 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { DiscoverField } from './discover_field';
import { DiscoverIndexPattern } from './discover_index_pattern';
import { DiscoverFieldSearch } from './discover_field_search';
-import { FIELDS_LIMIT_SETTING } from '../../../../../../common';
+import { FIELDS_LIMIT_SETTING } from '../../../../../common';
import { groupFields } from './lib/group_fields';
import {
IndexPatternField,
indexPatterns as indexPatternUtils,
-} from '../../../../../../../data/public';
+} from '../../../../../../data/public';
import { getDetails } from './lib/get_details';
import { FieldFilterState, getDefaultFieldFilter, setFieldFilterProp } from './lib/field_filter';
import { getIndexPatternFieldList } from './lib/get_index_pattern_field_list';
import { DiscoverSidebarResponsiveProps } from './discover_sidebar_responsive';
import { DiscoverIndexPatternManagement } from './discover_index_pattern_management';
-import { ElasticSearchHit } from '../../../../doc_views/doc_views_types';
-import { VIEW_MODE } from '../view_mode_toggle';
+import { ElasticSearchHit } from '../../../../services/doc_views/doc_views_types';
+import { VIEW_MODE } from '../../../../components/view_mode_toggle';
/**
* Default number of available fields displayed and added on scroll
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_sidebar_responsive.test.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar_responsive.test.tsx
similarity index 88%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_sidebar_responsive.test.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/discover_sidebar_responsive.test.tsx
index 4e4fed8c65bf7..b412cd69c82af 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_sidebar_responsive.test.tsx
+++ b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar_responsive.test.tsx
@@ -11,22 +11,22 @@ import { BehaviorSubject } from 'rxjs';
import { ReactWrapper } from 'enzyme';
import { findTestSubject } from '@elastic/eui/lib/test';
// @ts-expect-error
-import realHits from '../../../../../__fixtures__/real_hits.js';
+import realHits from '../../../../__fixtures__/real_hits.js';
import { act } from 'react-dom/test-utils';
import { mountWithIntl } from '@kbn/test/jest';
import React from 'react';
-import { flattenHit, IndexPatternAttributes } from '../../../../../../../data/common';
-import { SavedObject } from '../../../../../../../../core/types';
+import { flattenHit, IndexPatternAttributes } from '../../../../../../data/common';
+import { SavedObject } from '../../../../../../../core/types';
import {
DiscoverSidebarResponsive,
DiscoverSidebarResponsiveProps,
} from './discover_sidebar_responsive';
-import { DiscoverServices } from '../../../../../build_services';
-import { ElasticSearchHit } from '../../../../doc_views/doc_views_types';
-import { FetchStatus } from '../../../../types';
-import { DataDocuments$ } from '../../services/use_saved_search';
-import { stubLogstashIndexPattern } from '../../../../../../../data/common/stubs';
-import { VIEW_MODE } from '../view_mode_toggle';
+import { DiscoverServices } from '../../../../build_services';
+import { ElasticSearchHit } from '../../../../services/doc_views/doc_views_types';
+import { FetchStatus } from '../../../types';
+import { DataDocuments$ } from '../../utils/use_saved_search';
+import { stubLogstashIndexPattern } from '../../../../../../data/common/stubs';
+import { VIEW_MODE } from '../../../../components/view_mode_toggle';
const mockServices = {
history: () => ({
@@ -56,7 +56,7 @@ const mockCalcFieldCounts = jest.fn(() => {
return mockfieldCounts;
});
-jest.mock('../../../../../kibana_services', () => ({
+jest.mock('../../../../kibana_services', () => ({
getUiActions: jest.fn(() => {
return {
getTriggerCompatibleActions: jest.fn(() => []),
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_sidebar_responsive.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar_responsive.tsx
similarity index 96%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/discover_sidebar_responsive.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/discover_sidebar_responsive.tsx
index 368a2b2e92d34..1df3044b81bf8 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/discover_sidebar_responsive.tsx
+++ b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar_responsive.tsx
@@ -27,17 +27,17 @@ import {
EuiFlexItem,
} from '@elastic/eui';
import { DiscoverIndexPattern } from './discover_index_pattern';
-import { IndexPatternAttributes } from '../../../../../../../data/common';
-import { SavedObject } from '../../../../../../../../core/types';
-import { IndexPatternField, IndexPattern } from '../../../../../../../data/public';
+import { IndexPatternAttributes } from '../../../../../../data/common';
+import { SavedObject } from '../../../../../../../core/types';
+import { IndexPatternField, IndexPattern } from '../../../../../../data/public';
import { getDefaultFieldFilter } from './lib/field_filter';
import { DiscoverSidebar } from './discover_sidebar';
-import { DiscoverServices } from '../../../../../build_services';
+import { DiscoverServices } from '../../../../build_services';
import { AppState } from '../../services/discover_state';
import { DiscoverIndexPatternManagement } from './discover_index_pattern_management';
-import { DataDocuments$ } from '../../services/use_saved_search';
+import { DataDocuments$ } from '../../utils/use_saved_search';
import { calcFieldCounts } from '../../utils/calc_field_counts';
-import { VIEW_MODE } from '../view_mode_toggle';
+import { VIEW_MODE } from '../../../../components/view_mode_toggle';
export interface DiscoverSidebarResponsiveProps {
/**
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/index.ts b/src/plugins/discover/public/application/main/components/sidebar/index.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/index.ts
rename to src/plugins/discover/public/application/main/components/sidebar/index.ts
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/field_calculator.js b/src/plugins/discover/public/application/main/components/sidebar/lib/field_calculator.js
similarity index 98%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/lib/field_calculator.js
rename to src/plugins/discover/public/application/main/components/sidebar/lib/field_calculator.js
index c709f3311105d..4f282f6133ef3 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/field_calculator.js
+++ b/src/plugins/discover/public/application/main/components/sidebar/lib/field_calculator.js
@@ -8,7 +8,7 @@
import { map, sortBy, without, each, defaults, isObject } from 'lodash';
import { i18n } from '@kbn/i18n';
-import { flattenHit } from '../../../../../../../../data/common';
+import { flattenHit } from '../../../../../../../data/common';
function getFieldValues(hits, field, indexPattern) {
const name = field.name;
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/field_calculator.test.ts b/src/plugins/discover/public/application/main/components/sidebar/lib/field_calculator.test.ts
similarity index 96%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/lib/field_calculator.test.ts
rename to src/plugins/discover/public/application/main/components/sidebar/lib/field_calculator.test.ts
index d4bc41f36b2d4..519b298d70072 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/field_calculator.test.ts
+++ b/src/plugins/discover/public/application/main/components/sidebar/lib/field_calculator.test.ts
@@ -10,14 +10,14 @@
import { keys, each, cloneDeep, clone, uniq, filter, map } from 'lodash';
// @ts-expect-error
-import realHits from '../../../../../../__fixtures__/real_hits.js';
+import realHits from '../../../../../__fixtures__/real_hits.js';
-import { IndexPattern } from '../../../../../../../../data/public';
-import { flattenHit } from '../../../../../../../../data/common';
+import { IndexPattern } from '../../../../../../../data/public';
+import { flattenHit } from '../../../../../../../data/common';
// @ts-expect-error
import { fieldCalculator } from './field_calculator';
-import { stubLogstashIndexPattern as indexPattern } from '../../../../../../../../data/common/stubs';
+import { stubLogstashIndexPattern as indexPattern } from '../../../../../../../data/common/stubs';
describe('fieldCalculator', function () {
it('should have a _countMissing that counts nulls & undefineds in an array', function () {
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/field_filter.test.ts b/src/plugins/discover/public/application/main/components/sidebar/lib/field_filter.test.ts
similarity index 97%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/lib/field_filter.test.ts
rename to src/plugins/discover/public/application/main/components/sidebar/lib/field_filter.test.ts
index 8d7c543157ead..23da318b6b1dd 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/field_filter.test.ts
+++ b/src/plugins/discover/public/application/main/components/sidebar/lib/field_filter.test.ts
@@ -7,7 +7,7 @@
*/
import { getDefaultFieldFilter, setFieldFilterProp, isFieldFiltered } from './field_filter';
-import { IndexPatternField } from '../../../../../../../../data/public';
+import { IndexPatternField } from '../../../../../../../data/public';
describe('field_filter', function () {
it('getDefaultFieldFilter should return default filter state', function () {
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/field_filter.ts b/src/plugins/discover/public/application/main/components/sidebar/lib/field_filter.ts
similarity index 96%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/lib/field_filter.ts
rename to src/plugins/discover/public/application/main/components/sidebar/lib/field_filter.ts
index 25a8309d3d963..9d685652be0a6 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/field_filter.ts
+++ b/src/plugins/discover/public/application/main/components/sidebar/lib/field_filter.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-import { IndexPatternField } from '../../../../../../../../data/public';
+import { IndexPatternField } from '../../../../../../../data/public';
export interface FieldFilterState {
missing: boolean;
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/get_details.ts b/src/plugins/discover/public/application/main/components/sidebar/lib/get_details.ts
similarity index 90%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/lib/get_details.ts
rename to src/plugins/discover/public/application/main/components/sidebar/lib/get_details.ts
index cf7d9945a35e6..b5beebf6fb8d4 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/get_details.ts
+++ b/src/plugins/discover/public/application/main/components/sidebar/lib/get_details.ts
@@ -8,8 +8,8 @@
// @ts-expect-error
import { fieldCalculator } from './field_calculator';
-import { IndexPattern, IndexPatternField } from '../../../../../../../../data/public';
-import { ElasticSearchHit } from '../../../../../doc_views/doc_views_types';
+import { IndexPattern, IndexPatternField } from '../../../../../../../data/public';
+import { ElasticSearchHit } from '../../../../../services/doc_views/doc_views_types';
export function getDetails(
field: IndexPatternField,
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/get_field_type_name.ts b/src/plugins/discover/public/application/main/components/sidebar/lib/get_field_type_name.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/lib/get_field_type_name.ts
rename to src/plugins/discover/public/application/main/components/sidebar/lib/get_field_type_name.ts
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/get_index_pattern_field_list.ts b/src/plugins/discover/public/application/main/components/sidebar/lib/get_index_pattern_field_list.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/lib/get_index_pattern_field_list.ts
rename to src/plugins/discover/public/application/main/components/sidebar/lib/get_index_pattern_field_list.ts
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/group_fields.test.ts b/src/plugins/discover/public/application/main/components/sidebar/lib/group_fields.test.ts
similarity index 98%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/lib/group_fields.test.ts
rename to src/plugins/discover/public/application/main/components/sidebar/lib/group_fields.test.ts
index 4842f652eb730..7e8eabd171d64 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/group_fields.test.ts
+++ b/src/plugins/discover/public/application/main/components/sidebar/lib/group_fields.test.ts
@@ -8,7 +8,7 @@
import { groupFields } from './group_fields';
import { getDefaultFieldFilter } from './field_filter';
-import { IndexPatternField } from '../../../../../../../../data/common';
+import { IndexPatternField } from '../../../../../../../data/common';
const fields = [
{
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/group_fields.tsx b/src/plugins/discover/public/application/main/components/sidebar/lib/group_fields.tsx
similarity index 97%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/lib/group_fields.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/lib/group_fields.tsx
index 50d742d83c630..e42050dfa216a 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/group_fields.tsx
+++ b/src/plugins/discover/public/application/main/components/sidebar/lib/group_fields.tsx
@@ -8,7 +8,7 @@
import { IndexPatternField } from 'src/plugins/data/public';
import { FieldFilterState, isFieldFiltered } from './field_filter';
-import { getFieldSubtypeMulti } from '../../../../../../../../data/common';
+import { getFieldSubtypeMulti } from '../../../../../../../data/common';
interface GroupedFields {
selected: IndexPatternField[];
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/visualize_trigger_utils.test.ts b/src/plugins/discover/public/application/main/components/sidebar/lib/visualize_trigger_utils.test.ts
similarity index 98%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/lib/visualize_trigger_utils.test.ts
rename to src/plugins/discover/public/application/main/components/sidebar/lib/visualize_trigger_utils.test.ts
index 0a61bf1ea6029..3c9b1f89e3cbd 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/visualize_trigger_utils.test.ts
+++ b/src/plugins/discover/public/application/main/components/sidebar/lib/visualize_trigger_utils.test.ts
@@ -26,7 +26,7 @@ const mockGetActions = jest.fn>>, [string, { fieldN
() => Promise.resolve([])
);
-jest.mock('../../../../../../kibana_services', () => ({
+jest.mock('../../../../../kibana_services', () => ({
getUiActions: () => ({
getTriggerCompatibleActions: mockGetActions,
}),
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/visualize_trigger_utils.ts b/src/plugins/discover/public/application/main/components/sidebar/lib/visualize_trigger_utils.ts
similarity index 95%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/lib/visualize_trigger_utils.ts
rename to src/plugins/discover/public/application/main/components/sidebar/lib/visualize_trigger_utils.ts
index f00b430e5acef..8cee4650a220f 100644
--- a/src/plugins/discover/public/application/apps/main/components/sidebar/lib/visualize_trigger_utils.ts
+++ b/src/plugins/discover/public/application/main/components/sidebar/lib/visualize_trigger_utils.ts
@@ -11,9 +11,9 @@ import {
VISUALIZE_GEO_FIELD_TRIGGER,
visualizeFieldTrigger,
visualizeGeoFieldTrigger,
-} from '../../../../../../../../ui_actions/public';
-import { getUiActions } from '../../../../../../kibana_services';
-import { IndexPatternField, KBN_FIELD_TYPES } from '../../../../../../../../data/public';
+} from '../../../../../../../ui_actions/public';
+import { getUiActions } from '../../../../../kibana_services';
+import { IndexPatternField, KBN_FIELD_TYPES } from '../../../../../../../data/public';
function getTriggerConstant(type: string) {
return type === KBN_FIELD_TYPES.GEO_POINT || type === KBN_FIELD_TYPES.GEO_SHAPE
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/string_progress_bar.tsx b/src/plugins/discover/public/application/main/components/sidebar/string_progress_bar.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/string_progress_bar.tsx
rename to src/plugins/discover/public/application/main/components/sidebar/string_progress_bar.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/sidebar/types.ts b/src/plugins/discover/public/application/main/components/sidebar/types.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/sidebar/types.ts
rename to src/plugins/discover/public/application/main/components/sidebar/types.ts
diff --git a/src/plugins/discover/public/application/apps/main/components/skip_bottom_button/index.ts b/src/plugins/discover/public/application/main/components/skip_bottom_button/index.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/skip_bottom_button/index.ts
rename to src/plugins/discover/public/application/main/components/skip_bottom_button/index.ts
diff --git a/src/plugins/discover/public/application/apps/main/components/skip_bottom_button/skip_bottom_button.scss b/src/plugins/discover/public/application/main/components/skip_bottom_button/skip_bottom_button.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/skip_bottom_button/skip_bottom_button.scss
rename to src/plugins/discover/public/application/main/components/skip_bottom_button/skip_bottom_button.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/skip_bottom_button/skip_bottom_button.test.tsx b/src/plugins/discover/public/application/main/components/skip_bottom_button/skip_bottom_button.test.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/skip_bottom_button/skip_bottom_button.test.tsx
rename to src/plugins/discover/public/application/main/components/skip_bottom_button/skip_bottom_button.test.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/skip_bottom_button/skip_bottom_button.tsx b/src/plugins/discover/public/application/main/components/skip_bottom_button/skip_bottom_button.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/skip_bottom_button/skip_bottom_button.tsx
rename to src/plugins/discover/public/application/main/components/skip_bottom_button/skip_bottom_button.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/top_nav/__snapshots__/open_search_panel.test.tsx.snap b/src/plugins/discover/public/application/main/components/top_nav/__snapshots__/open_search_panel.test.tsx.snap
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/top_nav/__snapshots__/open_search_panel.test.tsx.snap
rename to src/plugins/discover/public/application/main/components/top_nav/__snapshots__/open_search_panel.test.tsx.snap
diff --git a/src/plugins/discover/public/application/apps/main/components/top_nav/discover_topnav.test.tsx b/src/plugins/discover/public/application/main/components/top_nav/discover_topnav.test.tsx
similarity index 81%
rename from src/plugins/discover/public/application/apps/main/components/top_nav/discover_topnav.test.tsx
rename to src/plugins/discover/public/application/main/components/top_nav/discover_topnav.test.tsx
index 808346b53304c..2dec7bc991198 100644
--- a/src/plugins/discover/public/application/apps/main/components/top_nav/discover_topnav.test.tsx
+++ b/src/plugins/discover/public/application/main/components/top_nav/discover_topnav.test.tsx
@@ -8,14 +8,14 @@
import React from 'react';
import { shallowWithIntl } from '@kbn/test/jest';
-import { indexPatternMock } from '../../../../../__mocks__/index_pattern';
-import { savedSearchMock } from '../../../../../__mocks__/saved_search';
+import { indexPatternMock } from '../../../../__mocks__/index_pattern';
+import { savedSearchMock } from '../../../../__mocks__/saved_search';
import { DiscoverTopNav, DiscoverTopNavProps } from './discover_topnav';
-import { TopNavMenuData } from '../../../../../../../navigation/public';
-import { ISearchSource, Query } from '../../../../../../../data/common';
+import { TopNavMenuData } from '../../../../../../navigation/public';
+import { ISearchSource, Query } from '../../../../../../data/common';
import { GetStateReturn } from '../../services/discover_state';
-import { setHeaderActionMenuMounter } from '../../../../../kibana_services';
-import { discoverServiceMock } from '../../../../../__mocks__/services';
+import { setHeaderActionMenuMounter } from '../../../../kibana_services';
+import { discoverServiceMock } from '../../../../__mocks__/services';
setHeaderActionMenuMounter(jest.fn());
diff --git a/src/plugins/discover/public/application/apps/main/components/top_nav/discover_topnav.tsx b/src/plugins/discover/public/application/main/components/top_nav/discover_topnav.tsx
similarity index 95%
rename from src/plugins/discover/public/application/apps/main/components/top_nav/discover_topnav.tsx
rename to src/plugins/discover/public/application/main/components/top_nav/discover_topnav.tsx
index 5e3e2dfd96954..6af345e25f265 100644
--- a/src/plugins/discover/public/application/apps/main/components/top_nav/discover_topnav.tsx
+++ b/src/plugins/discover/public/application/main/components/top_nav/discover_topnav.tsx
@@ -9,8 +9,8 @@ import React, { useCallback, useMemo } from 'react';
import { useHistory } from 'react-router-dom';
import { DiscoverLayoutProps } from '../layout/types';
import { getTopNavLinks } from './get_top_nav_links';
-import { Query, TimeRange } from '../../../../../../../data/common/query';
-import { getHeaderActionMenuMounter } from '../../../../../kibana_services';
+import { Query, TimeRange } from '../../../../../../data/common/query';
+import { getHeaderActionMenuMounter } from '../../../../kibana_services';
import { GetStateReturn } from '../../services/discover_state';
export type DiscoverTopNavProps = Pick<
diff --git a/src/plugins/discover/public/application/apps/main/components/top_nav/get_top_nav_links.test.ts b/src/plugins/discover/public/application/main/components/top_nav/get_top_nav_links.test.ts
similarity index 91%
rename from src/plugins/discover/public/application/apps/main/components/top_nav/get_top_nav_links.test.ts
rename to src/plugins/discover/public/application/main/components/top_nav/get_top_nav_links.test.ts
index 20c5b9bae332d..6cf37c5333597 100644
--- a/src/plugins/discover/public/application/apps/main/components/top_nav/get_top_nav_links.test.ts
+++ b/src/plugins/discover/public/application/main/components/top_nav/get_top_nav_links.test.ts
@@ -8,9 +8,9 @@
import { ISearchSource } from 'src/plugins/data/public';
import { getTopNavLinks } from './get_top_nav_links';
-import { indexPatternMock } from '../../../../../__mocks__/index_pattern';
-import { savedSearchMock } from '../../../../../__mocks__/saved_search';
-import { DiscoverServices } from '../../../../../build_services';
+import { indexPatternMock } from '../../../../__mocks__/index_pattern';
+import { savedSearchMock } from '../../../../__mocks__/saved_search';
+import { DiscoverServices } from '../../../../build_services';
import { GetStateReturn } from '../../services/discover_state';
const services = {
diff --git a/src/plugins/discover/public/application/apps/main/components/top_nav/get_top_nav_links.ts b/src/plugins/discover/public/application/main/components/top_nav/get_top_nav_links.ts
similarity index 92%
rename from src/plugins/discover/public/application/apps/main/components/top_nav/get_top_nav_links.ts
rename to src/plugins/discover/public/application/main/components/top_nav/get_top_nav_links.ts
index 653e878ad01bb..4b9d48a92e0f5 100644
--- a/src/plugins/discover/public/application/apps/main/components/top_nav/get_top_nav_links.ts
+++ b/src/plugins/discover/public/application/main/components/top_nav/get_top_nav_links.ts
@@ -9,14 +9,14 @@
import { i18n } from '@kbn/i18n';
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';
-import { DiscoverServices } from '../../../../../build_services';
-import { SavedSearch } from '../../../../../saved_searches';
+import { getSharingData, showPublicUrlSwitch } from '../../../../utils/get_sharing_data';
+import { unhashUrl } from '../../../../../../kibana_utils/public';
+import { DiscoverServices } from '../../../../build_services';
+import { SavedSearch } from '../../../../services/saved_searches';
import { onSaveSearch } from './on_save_search';
import { GetStateReturn } from '../../services/discover_state';
import { openOptionsPopover } from './open_options_popover';
-import type { TopNavMenuData } from '../../../../../../../navigation/public';
+import type { TopNavMenuData } from '../../../../../../navigation/public';
/**
* Helper function to build the top nav links
diff --git a/src/plugins/discover/public/application/apps/main/components/top_nav/on_save_search.test.tsx b/src/plugins/discover/public/application/main/components/top_nav/on_save_search.test.tsx
similarity index 68%
rename from src/plugins/discover/public/application/apps/main/components/top_nav/on_save_search.test.tsx
rename to src/plugins/discover/public/application/main/components/top_nav/on_save_search.test.tsx
index 1f0cee0b75672..c0d4a34a4e429 100644
--- a/src/plugins/discover/public/application/apps/main/components/top_nav/on_save_search.test.tsx
+++ b/src/plugins/discover/public/application/main/components/top_nav/on_save_search.test.tsx
@@ -6,15 +6,15 @@
* Side Public License, v 1.
*/
-import { showSaveModal } from '../../../../../../../saved_objects/public';
-jest.mock('../../../../../../../saved_objects/public');
+import { showSaveModal } from '../../../../../../saved_objects/public';
+jest.mock('../../../../../../saved_objects/public');
import { onSaveSearch } from './on_save_search';
-import { indexPatternMock } from '../../../../../__mocks__/index_pattern';
-import { savedSearchMock } from '../../../../../__mocks__/saved_search';
-import { DiscoverServices } from '../../../../../build_services';
+import { indexPatternMock } from '../../../../__mocks__/index_pattern';
+import { savedSearchMock } from '../../../../__mocks__/saved_search';
+import { DiscoverServices } from '../../../../build_services';
import { GetStateReturn } from '../../services/discover_state';
-import { i18nServiceMock } from '../../../../../../../../core/public/mocks';
+import { i18nServiceMock } from '../../../../../../../core/public/mocks';
test('onSaveSearch', async () => {
const serviceMock = {
diff --git a/src/plugins/discover/public/application/apps/main/components/top_nav/on_save_search.tsx b/src/plugins/discover/public/application/main/components/top_nav/on_save_search.tsx
similarity index 94%
rename from src/plugins/discover/public/application/apps/main/components/top_nav/on_save_search.tsx
rename to src/plugins/discover/public/application/main/components/top_nav/on_save_search.tsx
index 25b04e12c650a..67db4968f9a33 100644
--- a/src/plugins/discover/public/application/apps/main/components/top_nav/on_save_search.tsx
+++ b/src/plugins/discover/public/application/main/components/top_nav/on_save_search.tsx
@@ -8,12 +8,12 @@
import React from 'react';
import { i18n } from '@kbn/i18n';
-import { SavedObjectSaveModal, showSaveModal } from '../../../../../../../saved_objects/public';
-import { SavedSearch, SaveSavedSearchOptions } from '../../../../../saved_searches';
-import { IndexPattern } from '../../../../../../../data/common';
-import { DiscoverServices } from '../../../../../build_services';
+import { SavedObjectSaveModal, showSaveModal } from '../../../../../../saved_objects/public';
+import { SavedSearch, SaveSavedSearchOptions } from '../../../../services/saved_searches';
+import { IndexPattern } from '../../../../../../data/common';
+import { DiscoverServices } from '../../../../build_services';
import { GetStateReturn } from '../../services/discover_state';
-import { setBreadcrumbsTitle } from '../../../../helpers/breadcrumbs';
+import { setBreadcrumbsTitle } from '../../../../utils/breadcrumbs';
import { persistSavedSearch } from '../../utils/persist_saved_search';
async function saveDataSource({
diff --git a/src/plugins/discover/public/application/apps/main/components/top_nav/open_options_popover.scss b/src/plugins/discover/public/application/main/components/top_nav/open_options_popover.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/top_nav/open_options_popover.scss
rename to src/plugins/discover/public/application/main/components/top_nav/open_options_popover.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/top_nav/open_options_popover.test.tsx b/src/plugins/discover/public/application/main/components/top_nav/open_options_popover.test.tsx
similarity index 93%
rename from src/plugins/discover/public/application/apps/main/components/top_nav/open_options_popover.test.tsx
rename to src/plugins/discover/public/application/main/components/top_nav/open_options_popover.test.tsx
index 28e57aed7b660..c9564a3ed029d 100644
--- a/src/plugins/discover/public/application/apps/main/components/top_nav/open_options_popover.test.tsx
+++ b/src/plugins/discover/public/application/main/components/top_nav/open_options_popover.test.tsx
@@ -9,9 +9,9 @@
import React from 'react';
import { mountWithIntl } from '@kbn/test/jest';
import { findTestSubject } from '@elastic/eui/lib/test';
-import { getServices } from '../../../../../kibana_services';
+import { getServices } from '../../../../kibana_services';
-jest.mock('../../../../../kibana_services', () => {
+jest.mock('../../../../kibana_services', () => {
const mockUiSettings = new Map();
return {
getServices: () => ({
diff --git a/src/plugins/discover/public/application/apps/main/components/top_nav/open_options_popover.tsx b/src/plugins/discover/public/application/main/components/top_nav/open_options_popover.tsx
similarity index 97%
rename from src/plugins/discover/public/application/apps/main/components/top_nav/open_options_popover.tsx
rename to src/plugins/discover/public/application/main/components/top_nav/open_options_popover.tsx
index 6e90c702c2bfd..1b567813c6f7b 100644
--- a/src/plugins/discover/public/application/apps/main/components/top_nav/open_options_popover.tsx
+++ b/src/plugins/discover/public/application/main/components/top_nav/open_options_popover.tsx
@@ -22,8 +22,8 @@ import {
EuiTextAlign,
} from '@elastic/eui';
import './open_options_popover.scss';
-import { DOC_TABLE_LEGACY } from '../../../../../../common';
-import { getServices } from '../../../../../kibana_services';
+import { DOC_TABLE_LEGACY } from '../../../../../common';
+import { getServices } from '../../../../kibana_services';
const container = document.createElement('div');
let isOpen = false;
diff --git a/src/plugins/discover/public/application/apps/main/components/top_nav/open_search_panel.test.tsx b/src/plugins/discover/public/application/main/components/top_nav/open_search_panel.test.tsx
similarity index 96%
rename from src/plugins/discover/public/application/apps/main/components/top_nav/open_search_panel.test.tsx
rename to src/plugins/discover/public/application/main/components/top_nav/open_search_panel.test.tsx
index dc5d3e81744db..80c70d9b1aff5 100644
--- a/src/plugins/discover/public/application/apps/main/components/top_nav/open_search_panel.test.tsx
+++ b/src/plugins/discover/public/application/main/components/top_nav/open_search_panel.test.tsx
@@ -15,7 +15,7 @@ const mockCapabilities = jest.fn().mockReturnValue({
},
});
-jest.mock('../../../../../kibana_services', () => {
+jest.mock('../../../../kibana_services', () => {
return {
getServices: () => ({
core: { uiSettings: {}, savedObjects: {} },
diff --git a/src/plugins/discover/public/application/apps/main/components/top_nav/open_search_panel.tsx b/src/plugins/discover/public/application/main/components/top_nav/open_search_panel.tsx
similarity index 95%
rename from src/plugins/discover/public/application/apps/main/components/top_nav/open_search_panel.tsx
rename to src/plugins/discover/public/application/main/components/top_nav/open_search_panel.tsx
index 1b34e6ffa0b9a..e5a175f0511da 100644
--- a/src/plugins/discover/public/application/apps/main/components/top_nav/open_search_panel.tsx
+++ b/src/plugins/discover/public/application/main/components/top_nav/open_search_panel.tsx
@@ -20,8 +20,8 @@ import {
EuiFlyoutBody,
EuiTitle,
} from '@elastic/eui';
-import { SavedObjectFinderUi } from '../../../../../../../saved_objects/public';
-import { getServices } from '../../../../../kibana_services';
+import { SavedObjectFinderUi } from '../../../../../../saved_objects/public';
+import { getServices } from '../../../../kibana_services';
const SEARCH_OBJECT_TYPE = 'search';
diff --git a/src/plugins/discover/public/application/apps/main/components/top_nav/show_open_search_panel.tsx b/src/plugins/discover/public/application/main/components/top_nav/show_open_search_panel.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/top_nav/show_open_search_panel.tsx
rename to src/plugins/discover/public/application/main/components/top_nav/show_open_search_panel.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/total_documents/total_documents.tsx b/src/plugins/discover/public/application/main/components/total_documents/total_documents.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/total_documents/total_documents.tsx
rename to src/plugins/discover/public/application/main/components/total_documents/total_documents.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/uninitialized/uninitialized.tsx b/src/plugins/discover/public/application/main/components/uninitialized/uninitialized.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/uninitialized/uninitialized.tsx
rename to src/plugins/discover/public/application/main/components/uninitialized/uninitialized.tsx
diff --git a/src/plugins/discover/public/application/apps/main/discover_main_app.test.tsx b/src/plugins/discover/public/application/main/discover_main_app.test.tsx
similarity index 72%
rename from src/plugins/discover/public/application/apps/main/discover_main_app.test.tsx
rename to src/plugins/discover/public/application/main/discover_main_app.test.tsx
index db29da87b4641..cb2bad306f43f 100644
--- a/src/plugins/discover/public/application/apps/main/discover_main_app.test.tsx
+++ b/src/plugins/discover/public/application/main/discover_main_app.test.tsx
@@ -7,14 +7,14 @@
*/
import React from 'react';
import { mountWithIntl } from '@kbn/test/jest';
-import { indexPatternMock } from '../../../__mocks__/index_pattern';
+import { indexPatternMock } from '../../__mocks__/index_pattern';
import { DiscoverMainApp } from './discover_main_app';
-import { discoverServiceMock } from '../../../__mocks__/services';
-import { savedSearchMock } from '../../../__mocks__/saved_search';
-import { createSearchSessionMock } from '../../../__mocks__/search_session';
-import { SavedObject } from '../../../../../../core/types';
-import { IndexPatternAttributes } from '../../../../../data/common';
-import { setHeaderActionMenuMounter } from '../../../kibana_services';
+import { discoverServiceMock } from '../../__mocks__/services';
+import { savedSearchMock } from '../../__mocks__/saved_search';
+import { createSearchSessionMock } from '../../__mocks__/search_session';
+import { SavedObject } from '../../../../../core/types';
+import { IndexPatternAttributes } from '../../../../data/common';
+import { setHeaderActionMenuMounter } from '../../kibana_services';
import { findTestSubject } from '@elastic/eui/lib/test';
setHeaderActionMenuMounter(jest.fn());
diff --git a/src/plugins/discover/public/application/apps/main/discover_main_app.tsx b/src/plugins/discover/public/application/main/discover_main_app.tsx
similarity index 90%
rename from src/plugins/discover/public/application/apps/main/discover_main_app.tsx
rename to src/plugins/discover/public/application/main/discover_main_app.tsx
index c7a38032ef405..ea3f852a5290a 100644
--- a/src/plugins/discover/public/application/apps/main/discover_main_app.tsx
+++ b/src/plugins/discover/public/application/main/discover_main_app.tsx
@@ -8,13 +8,13 @@
import React, { useCallback, useEffect } from 'react';
import { History } from 'history';
import { DiscoverLayout } from './components/layout';
-import { setBreadcrumbsTitle } from '../../helpers/breadcrumbs';
+import { setBreadcrumbsTitle } from '../../utils/breadcrumbs';
import { addHelpMenuToAppChrome } from '../../components/help_menu/help_menu_util';
-import { useDiscoverState } from './services/use_discover_state';
-import { useUrl } from './services/use_url';
-import { IndexPatternAttributes, SavedObject } from '../../../../../data/common';
-import { DiscoverServices } from '../../../build_services';
-import { SavedSearch } from '../../../saved_searches';
+import { useDiscoverState } from './utils/use_discover_state';
+import { useUrl } from './utils/use_url';
+import { IndexPatternAttributes, SavedObject } from '../../../../data/common';
+import { DiscoverServices } from '../../build_services';
+import { SavedSearch } from '../../services/saved_searches';
const DiscoverLayoutMemoized = React.memo(DiscoverLayout);
diff --git a/src/plugins/discover/public/application/apps/main/discover_main_route.tsx b/src/plugins/discover/public/application/main/discover_main_route.tsx
similarity index 92%
rename from src/plugins/discover/public/application/apps/main/discover_main_route.tsx
rename to src/plugins/discover/public/application/main/discover_main_route.tsx
index b674bfd6568ac..d226e5ef9748b 100644
--- a/src/plugins/discover/public/application/apps/main/discover_main_route.tsx
+++ b/src/plugins/discover/public/application/main/discover_main_route.tsx
@@ -12,15 +12,19 @@ import { i18n } from '@kbn/i18n';
import { EuiEmptyPrompt } from '@elastic/eui';
import { IndexPatternAttributes, ISearchSource, SavedObject } from 'src/plugins/data/common';
-import { DiscoverServices } from '../../../build_services';
-import { SavedSearch, getSavedSearch, getSavedSearchFullPathUrl } from '../../../saved_searches';
+import { DiscoverServices } from '../../build_services';
+import {
+ SavedSearch,
+ getSavedSearch,
+ getSavedSearchFullPathUrl,
+} from '../../services/saved_searches';
import { getState } from './services/discover_state';
import { loadIndexPattern, resolveIndexPattern } from './utils/resolve_index_pattern';
import { DiscoverMainApp } from './discover_main_app';
-import { getRootBreadcrumbs, getSavedSearchBreadcrumbs } from '../../helpers/breadcrumbs';
-import { redirectWhenMissing } from '../../../../../kibana_utils/public';
-import { DataViewSavedObjectConflictError } from '../../../../../data_views/common';
-import { getUrlTracker } from '../../../kibana_services';
+import { getRootBreadcrumbs, getSavedSearchBreadcrumbs } from '../../utils/breadcrumbs';
+import { redirectWhenMissing } from '../../../../kibana_utils/public';
+import { DataViewSavedObjectConflictError } from '../../../../data_views/common';
+import { getUrlTracker } from '../../kibana_services';
import { LoadingIndicator } from '../../components/common/loading_indicator';
const DiscoverMainAppMemoized = memo(DiscoverMainApp);
diff --git a/src/plugins/discover/public/application/apps/main/index.ts b/src/plugins/discover/public/application/main/index.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/index.ts
rename to src/plugins/discover/public/application/main/index.ts
diff --git a/src/plugins/discover/public/application/apps/main/services/discover_search_session.test.ts b/src/plugins/discover/public/application/main/services/discover_search_session.test.ts
similarity index 97%
rename from src/plugins/discover/public/application/apps/main/services/discover_search_session.test.ts
rename to src/plugins/discover/public/application/main/services/discover_search_session.test.ts
index 97c6ada3636d5..0f854438b6749 100644
--- a/src/plugins/discover/public/application/apps/main/services/discover_search_session.test.ts
+++ b/src/plugins/discover/public/application/main/services/discover_search_session.test.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-import { createSearchSessionMock } from '../../../../__mocks__/search_session';
+import { createSearchSessionMock } from '../../../__mocks__/search_session';
describe('DiscoverSearchSessionManager', () => {
const { history, session, searchSessionManager } = createSearchSessionMock();
diff --git a/src/plugins/discover/public/application/apps/main/services/discover_search_session.ts b/src/plugins/discover/public/application/main/services/discover_search_session.ts
similarity index 93%
rename from src/plugins/discover/public/application/apps/main/services/discover_search_session.ts
rename to src/plugins/discover/public/application/main/services/discover_search_session.ts
index 81ab578229d19..41e1ad37a353c 100644
--- a/src/plugins/discover/public/application/apps/main/services/discover_search_session.ts
+++ b/src/plugins/discover/public/application/main/services/discover_search_session.ts
@@ -8,13 +8,13 @@
import { History } from 'history';
import { filter } from 'rxjs/operators';
-import { DataPublicPluginStart } from '../../../../../../data/public';
+import { DataPublicPluginStart } from '../../../../../data/public';
import {
createQueryParamObservable,
getQueryParams,
removeQueryParam,
-} from '../../../../../../kibana_utils/public';
-import { SEARCH_SESSION_ID_QUERY_PARAM } from '../../../../url_generator';
+} from '../../../../../kibana_utils/public';
+import { SEARCH_SESSION_ID_QUERY_PARAM } from '../../../url_generator';
export interface DiscoverSearchSessionManagerDeps {
history: History;
diff --git a/src/plugins/discover/public/application/apps/main/services/discover_state.test.ts b/src/plugins/discover/public/application/main/services/discover_state.test.ts
similarity index 97%
rename from src/plugins/discover/public/application/apps/main/services/discover_state.test.ts
rename to src/plugins/discover/public/application/main/services/discover_state.test.ts
index 7f875be0a42c5..5c9900c6a2d78 100644
--- a/src/plugins/discover/public/application/apps/main/services/discover_state.test.ts
+++ b/src/plugins/discover/public/application/main/services/discover_state.test.ts
@@ -13,9 +13,9 @@ import {
createSearchSessionRestorationDataProvider,
} from './discover_state';
import { createBrowserHistory, History } from 'history';
-import { dataPluginMock } from '../../../../../../data/public/mocks';
-import type { SavedSearch } from '../../../../saved_searches';
-import { SEARCH_FIELDS_FROM_SOURCE } from '../../../../../common';
+import { dataPluginMock } from '../../../../../data/public/mocks';
+import type { SavedSearch } from '../../../services/saved_searches';
+import { SEARCH_FIELDS_FROM_SOURCE } from '../../../../common';
let history: History;
let state: GetStateReturn;
diff --git a/src/plugins/discover/public/application/apps/main/services/discover_state.ts b/src/plugins/discover/public/application/main/services/discover_state.ts
similarity index 96%
rename from src/plugins/discover/public/application/apps/main/services/discover_state.ts
rename to src/plugins/discover/public/application/main/services/discover_state.ts
index 388d4f19d1c27..66e013e8f20ea 100644
--- a/src/plugins/discover/public/application/apps/main/services/discover_state.ts
+++ b/src/plugins/discover/public/application/main/services/discover_state.ts
@@ -18,7 +18,7 @@ import {
StateContainer,
syncState,
withNotifyOnErrors,
-} from '../../../../../../kibana_utils/public';
+} from '../../../../../kibana_utils/public';
import {
connectToQueryState,
DataPublicPluginStart,
@@ -29,13 +29,13 @@ import {
Query,
SearchSessionInfoProvider,
syncQueryStateWithUrl,
-} from '../../../../../../data/public';
-import { migrateLegacyQuery } from '../../../helpers/migrate_legacy_query';
+} from '../../../../../data/public';
+import { migrateLegacyQuery } from '../../../utils/migrate_legacy_query';
import { DiscoverGridSettings } from '../../../components/discover_grid/types';
-import { SavedSearch } from '../../../../saved_searches';
-import { handleSourceColumnState } from '../../../helpers/state_helpers';
-import { DISCOVER_APP_LOCATOR, DiscoverAppLocatorParams } from '../../../../locator';
-import { VIEW_MODE } from '../components/view_mode_toggle';
+import { SavedSearch } from '../../../services/saved_searches';
+import { handleSourceColumnState } from '../../../utils/state_helpers';
+import { DISCOVER_APP_LOCATOR, DiscoverAppLocatorParams } from '../../../locator';
+import { VIEW_MODE } from '../../../components/view_mode_toggle';
export interface AppState {
/**
diff --git a/src/plugins/discover/public/application/apps/main/utils/calc_field_counts.test.ts b/src/plugins/discover/public/application/main/utils/calc_field_counts.test.ts
similarity index 90%
rename from src/plugins/discover/public/application/apps/main/utils/calc_field_counts.test.ts
rename to src/plugins/discover/public/application/main/utils/calc_field_counts.test.ts
index a13fd88df7c25..9d198947e06c7 100644
--- a/src/plugins/discover/public/application/apps/main/utils/calc_field_counts.test.ts
+++ b/src/plugins/discover/public/application/main/utils/calc_field_counts.test.ts
@@ -7,8 +7,8 @@
*/
import { calcFieldCounts } from './calc_field_counts';
-import { indexPatternMock } from '../../../../__mocks__/index_pattern';
-import { ElasticSearchHit } from '../../../doc_views/doc_views_types';
+import { indexPatternMock } from '../../../__mocks__/index_pattern';
+import { ElasticSearchHit } from '../../../services/doc_views/doc_views_types';
describe('calcFieldCounts', () => {
test('returns valid field count data', async () => {
diff --git a/src/plugins/discover/public/application/apps/main/utils/calc_field_counts.ts b/src/plugins/discover/public/application/main/utils/calc_field_counts.ts
similarity index 86%
rename from src/plugins/discover/public/application/apps/main/utils/calc_field_counts.ts
rename to src/plugins/discover/public/application/main/utils/calc_field_counts.ts
index 2198d2f66b6b4..08d1a2639fa0b 100644
--- a/src/plugins/discover/public/application/apps/main/utils/calc_field_counts.ts
+++ b/src/plugins/discover/public/application/main/utils/calc_field_counts.ts
@@ -6,8 +6,8 @@
* Side Public License, v 1.
*/
-import { flattenHit, IndexPattern } from '../../../../../../data/common';
-import { ElasticSearchHit } from '../../../doc_views/doc_views_types';
+import { flattenHit, IndexPattern } from '../../../../../data/common';
+import { ElasticSearchHit } from '../../../services/doc_views/doc_views_types';
/**
* This function is recording stats of the available fields, for usage in sidebar and sharing
diff --git a/src/plugins/discover/public/application/apps/main/utils/fetch_all.test.ts b/src/plugins/discover/public/application/main/utils/fetch_all.test.ts
similarity index 85%
rename from src/plugins/discover/public/application/apps/main/utils/fetch_all.test.ts
rename to src/plugins/discover/public/application/main/utils/fetch_all.test.ts
index 88830b2946b5f..9f17054de18d4 100644
--- a/src/plugins/discover/public/application/apps/main/utils/fetch_all.test.ts
+++ b/src/plugins/discover/public/application/main/utils/fetch_all.test.ts
@@ -5,13 +5,13 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
-import { FetchStatus } from '../../../types';
+import { FetchStatus } from '../../types';
import { BehaviorSubject } from 'rxjs';
-import { RequestAdapter } from '../../../../../../inspector';
-import { savedSearchMock } from '../../../../__mocks__/saved_search';
-import { ReduxLikeStateContainer } from '../../../../../../kibana_utils/common';
+import { RequestAdapter } from '../../../../../inspector';
+import { savedSearchMock } from '../../../__mocks__/saved_search';
+import { ReduxLikeStateContainer } from '../../../../../kibana_utils/common';
import { AppState } from '../services/discover_state';
-import { discoverServiceMock } from '../../../../__mocks__/services';
+import { discoverServiceMock } from '../../../__mocks__/services';
import { fetchAll } from './fetch_all';
describe('test fetchAll', () => {
diff --git a/src/plugins/discover/public/application/apps/main/utils/fetch_all.ts b/src/plugins/discover/public/application/main/utils/fetch_all.ts
similarity index 82%
rename from src/plugins/discover/public/application/apps/main/utils/fetch_all.ts
rename to src/plugins/discover/public/application/main/utils/fetch_all.ts
index e9d9335abcda0..efaa349181fb6 100644
--- a/src/plugins/discover/public/application/apps/main/utils/fetch_all.ts
+++ b/src/plugins/discover/public/application/main/utils/fetch_all.ts
@@ -12,20 +12,20 @@ import {
sendLoadingMsg,
sendPartialMsg,
sendResetMsg,
-} from '../services/use_saved_search_messages';
+} from './use_saved_search_messages';
import { updateSearchSource } from './update_search_source';
-import type { SortOrder } from '../../../../saved_searches';
+import type { SortOrder } from '../../../services/saved_searches';
import { fetchDocuments } from './fetch_documents';
import { fetchTotalHits } from './fetch_total_hits';
import { fetchChart } from './fetch_chart';
-import { ISearchSource } from '../../../../../../data/common';
-import { Adapters } from '../../../../../../inspector';
+import { ISearchSource } from '../../../../../data/common';
+import { Adapters } from '../../../../../inspector';
import { AppState } from '../services/discover_state';
-import { FetchStatus } from '../../../types';
-import { DataPublicPluginStart } from '../../../../../../data/public';
-import { SavedSearchData } from '../services/use_saved_search';
-import { DiscoverServices } from '../../../../build_services';
-import { ReduxLikeStateContainer } from '../../../../../../kibana_utils/common';
+import { FetchStatus } from '../../types';
+import { DataPublicPluginStart } from '../../../../../data/public';
+import { SavedSearchData } from './use_saved_search';
+import { DiscoverServices } from '../../../build_services';
+import { ReduxLikeStateContainer } from '../../../../../kibana_utils/common';
export function fetchAll(
dataSubjects: SavedSearchData,
diff --git a/src/plugins/discover/public/application/apps/main/utils/fetch_chart.test.ts b/src/plugins/discover/public/application/main/utils/fetch_chart.test.ts
similarity index 93%
rename from src/plugins/discover/public/application/apps/main/utils/fetch_chart.test.ts
rename to src/plugins/discover/public/application/main/utils/fetch_chart.test.ts
index 2c9350b457779..5f57484aaa653 100644
--- a/src/plugins/discover/public/application/apps/main/utils/fetch_chart.test.ts
+++ b/src/plugins/discover/public/application/main/utils/fetch_chart.test.ts
@@ -5,15 +5,15 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
-import { FetchStatus } from '../../../types';
+import { FetchStatus } from '../../types';
import { BehaviorSubject, of, throwError as throwErrorRx } from 'rxjs';
-import { RequestAdapter } from '../../../../../../inspector';
-import { savedSearchMockWithTimeField } from '../../../../__mocks__/saved_search';
+import { RequestAdapter } from '../../../../../inspector';
+import { savedSearchMockWithTimeField } from '../../../__mocks__/saved_search';
import { fetchChart, updateSearchSource } from './fetch_chart';
-import { ReduxLikeStateContainer } from '../../../../../../kibana_utils/common';
+import { ReduxLikeStateContainer } from '../../../../../kibana_utils/common';
import { AppState } from '../services/discover_state';
-import { discoverServiceMock } from '../../../../__mocks__/services';
-import { calculateBounds, IKibanaSearchResponse } from '../../../../../../data/common';
+import { discoverServiceMock } from '../../../__mocks__/services';
+import { calculateBounds, IKibanaSearchResponse } from '../../../../../data/common';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
function getDataSubjects() {
diff --git a/src/plugins/discover/public/application/apps/main/utils/fetch_chart.ts b/src/plugins/discover/public/application/main/utils/fetch_chart.ts
similarity index 89%
rename from src/plugins/discover/public/application/apps/main/utils/fetch_chart.ts
rename to src/plugins/discover/public/application/main/utils/fetch_chart.ts
index 50f3a1b8bfea7..59377970acb12 100644
--- a/src/plugins/discover/public/application/apps/main/utils/fetch_chart.ts
+++ b/src/plugins/discover/public/application/main/utils/fetch_chart.ts
@@ -12,16 +12,16 @@ import {
isCompleteResponse,
search,
ISearchSource,
-} from '../../../../../../data/public';
-import { Adapters } from '../../../../../../inspector';
+} from '../../../../../data/public';
+import { Adapters } from '../../../../../inspector';
import { getChartAggConfigs, getDimensions } from './index';
-import { tabifyAggResponse } from '../../../../../../data/common';
+import { tabifyAggResponse } from '../../../../../data/common';
import { buildPointSeriesData } from '../components/chart/point_series';
-import { FetchStatus } from '../../../types';
-import { SavedSearchData } from '../services/use_saved_search';
+import { FetchStatus } from '../../types';
+import { SavedSearchData } from './use_saved_search';
import { AppState } from '../services/discover_state';
-import { ReduxLikeStateContainer } from '../../../../../../kibana_utils/common';
-import { sendErrorMsg, sendLoadingMsg } from '../services/use_saved_search_messages';
+import { ReduxLikeStateContainer } from '../../../../../kibana_utils/common';
+import { sendErrorMsg, sendLoadingMsg } from './use_saved_search_messages';
export function fetchChart(
data$: SavedSearchData,
diff --git a/src/plugins/discover/public/application/apps/main/utils/fetch_documents.test.ts b/src/plugins/discover/public/application/main/utils/fetch_documents.test.ts
similarity index 91%
rename from src/plugins/discover/public/application/apps/main/utils/fetch_documents.test.ts
rename to src/plugins/discover/public/application/main/utils/fetch_documents.test.ts
index 6c6c7595b166e..291da255b5068 100644
--- a/src/plugins/discover/public/application/apps/main/utils/fetch_documents.test.ts
+++ b/src/plugins/discover/public/application/main/utils/fetch_documents.test.ts
@@ -6,11 +6,11 @@
* Side Public License, v 1.
*/
import { fetchDocuments } from './fetch_documents';
-import { FetchStatus } from '../../../types';
+import { FetchStatus } from '../../types';
import { BehaviorSubject, throwError as throwErrorRx } from 'rxjs';
-import { RequestAdapter } from '../../../../../../inspector';
-import { savedSearchMock } from '../../../../__mocks__/saved_search';
-import { discoverServiceMock } from '../../../../__mocks__/services';
+import { RequestAdapter } from '../../../../../inspector';
+import { savedSearchMock } from '../../../__mocks__/saved_search';
+import { discoverServiceMock } from '../../../__mocks__/services';
function getDataSubjects() {
return {
diff --git a/src/plugins/discover/public/application/apps/main/utils/fetch_documents.ts b/src/plugins/discover/public/application/main/utils/fetch_documents.ts
similarity index 86%
rename from src/plugins/discover/public/application/apps/main/utils/fetch_documents.ts
rename to src/plugins/discover/public/application/main/utils/fetch_documents.ts
index 6c5eff7cff702..0c80aee3f909d 100644
--- a/src/plugins/discover/public/application/apps/main/utils/fetch_documents.ts
+++ b/src/plugins/discover/public/application/main/utils/fetch_documents.ts
@@ -7,13 +7,13 @@
*/
import { i18n } from '@kbn/i18n';
import { filter } from 'rxjs/operators';
-import { Adapters } from '../../../../../../inspector/common';
-import { isCompleteResponse, ISearchSource } from '../../../../../../data/common';
-import { FetchStatus } from '../../../types';
-import { SavedSearchData } from '../services/use_saved_search';
-import { sendErrorMsg, sendLoadingMsg } from '../services/use_saved_search_messages';
-import { SAMPLE_SIZE_SETTING } from '../../../../../common';
-import { DiscoverServices } from '../../../../build_services';
+import { Adapters } from '../../../../../inspector/common';
+import { isCompleteResponse, ISearchSource } from '../../../../../data/common';
+import { FetchStatus } from '../../types';
+import { SavedSearchData } from './use_saved_search';
+import { sendErrorMsg, sendLoadingMsg } from './use_saved_search_messages';
+import { SAMPLE_SIZE_SETTING } from '../../../../common';
+import { DiscoverServices } from '../../../build_services';
export const fetchDocuments = (
data$: SavedSearchData,
diff --git a/src/plugins/discover/public/application/apps/main/utils/fetch_total_hits.test.ts b/src/plugins/discover/public/application/main/utils/fetch_total_hits.test.ts
similarity index 91%
rename from src/plugins/discover/public/application/apps/main/utils/fetch_total_hits.test.ts
rename to src/plugins/discover/public/application/main/utils/fetch_total_hits.test.ts
index 82a3a2fee6912..c593c9c157422 100644
--- a/src/plugins/discover/public/application/apps/main/utils/fetch_total_hits.test.ts
+++ b/src/plugins/discover/public/application/main/utils/fetch_total_hits.test.ts
@@ -5,12 +5,12 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
-import { FetchStatus } from '../../../types';
+import { FetchStatus } from '../../types';
import { BehaviorSubject, throwError as throwErrorRx } from 'rxjs';
-import { RequestAdapter } from '../../../../../../inspector';
-import { savedSearchMock } from '../../../../__mocks__/saved_search';
+import { RequestAdapter } from '../../../../../inspector';
+import { savedSearchMock } from '../../../__mocks__/saved_search';
import { fetchTotalHits } from './fetch_total_hits';
-import { discoverServiceMock } from '../../../../__mocks__/services';
+import { discoverServiceMock } from '../../../__mocks__/services';
function getDataSubjects() {
return {
diff --git a/src/plugins/discover/public/application/apps/main/utils/fetch_total_hits.ts b/src/plugins/discover/public/application/main/utils/fetch_total_hits.ts
similarity index 89%
rename from src/plugins/discover/public/application/apps/main/utils/fetch_total_hits.ts
rename to src/plugins/discover/public/application/main/utils/fetch_total_hits.ts
index cfab0d17fcd54..b80dfa9b31e7e 100644
--- a/src/plugins/discover/public/application/apps/main/utils/fetch_total_hits.ts
+++ b/src/plugins/discover/public/application/main/utils/fetch_total_hits.ts
@@ -12,11 +12,11 @@ import {
DataPublicPluginStart,
isCompleteResponse,
ISearchSource,
-} from '../../../../../../data/public';
-import { Adapters } from '../../../../../../inspector/common';
-import { FetchStatus } from '../../../types';
-import { SavedSearchData } from '../services/use_saved_search';
-import { sendErrorMsg, sendLoadingMsg } from '../services/use_saved_search_messages';
+} from '../../../../../data/public';
+import { Adapters } from '../../../../../inspector/common';
+import { FetchStatus } from '../../types';
+import { SavedSearchData } from './use_saved_search';
+import { sendErrorMsg, sendLoadingMsg } from './use_saved_search_messages';
export function fetchTotalHits(
data$: SavedSearchData,
diff --git a/src/plugins/discover/public/application/apps/main/utils/get_chart_agg_config.test.ts b/src/plugins/discover/public/application/main/utils/get_chart_agg_config.test.ts
similarity index 87%
rename from src/plugins/discover/public/application/apps/main/utils/get_chart_agg_config.test.ts
rename to src/plugins/discover/public/application/main/utils/get_chart_agg_config.test.ts
index 515565f0062c9..9960b18181ceb 100644
--- a/src/plugins/discover/public/application/apps/main/utils/get_chart_agg_config.test.ts
+++ b/src/plugins/discover/public/application/main/utils/get_chart_agg_config.test.ts
@@ -5,9 +5,9 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
-import { indexPatternWithTimefieldMock } from '../../../../__mocks__/index_pattern_with_timefield';
-import { ISearchSource } from '../../../../../../data/public';
-import { dataPluginMock } from '../../../../../../data/public/mocks';
+import { indexPatternWithTimefieldMock } from '../../../__mocks__/index_pattern_with_timefield';
+import { ISearchSource } from '../../../../../data/public';
+import { dataPluginMock } from '../../../../../data/public/mocks';
import { getChartAggConfigs } from './get_chart_agg_configs';
describe('getChartAggConfigs', () => {
diff --git a/src/plugins/discover/public/application/apps/main/utils/get_chart_agg_configs.ts b/src/plugins/discover/public/application/main/utils/get_chart_agg_configs.ts
similarity index 88%
rename from src/plugins/discover/public/application/apps/main/utils/get_chart_agg_configs.ts
rename to src/plugins/discover/public/application/main/utils/get_chart_agg_configs.ts
index 65f98f72beec0..e33fe48302a04 100644
--- a/src/plugins/discover/public/application/apps/main/utils/get_chart_agg_configs.ts
+++ b/src/plugins/discover/public/application/main/utils/get_chart_agg_configs.ts
@@ -5,8 +5,8 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
-import { ISearchSource } from '../../../../../../data/common';
-import { DataPublicPluginStart } from '../../../../../../data/public';
+import { ISearchSource } from '../../../../../data/common';
+import { DataPublicPluginStart } from '../../../../../data/public';
/**
* Helper function to apply or remove aggregations to a given search source used for gaining data
diff --git a/src/plugins/discover/public/application/apps/main/utils/get_dimensions.test.ts b/src/plugins/discover/public/application/main/utils/get_dimensions.test.ts
similarity index 89%
rename from src/plugins/discover/public/application/apps/main/utils/get_dimensions.test.ts
rename to src/plugins/discover/public/application/main/utils/get_dimensions.test.ts
index 35a6e955fe5b2..56822a614ece7 100644
--- a/src/plugins/discover/public/application/apps/main/utils/get_dimensions.test.ts
+++ b/src/plugins/discover/public/application/main/utils/get_dimensions.test.ts
@@ -5,11 +5,11 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
-import { dataPluginMock } from '../../../../../../data/public/mocks';
+import { dataPluginMock } from '../../../../../data/public/mocks';
import { getDimensions } from './get_dimensions';
-import { indexPatternWithTimefieldMock } from '../../../../__mocks__/index_pattern_with_timefield';
-import { ISearchSource, calculateBounds } from '../../../../../../data/common';
+import { indexPatternWithTimefieldMock } from '../../../__mocks__/index_pattern_with_timefield';
+import { ISearchSource, calculateBounds } from '../../../../../data/common';
import { getChartAggConfigs } from './get_chart_agg_configs';
test('getDimensions', () => {
diff --git a/src/plugins/discover/public/application/apps/main/utils/get_dimensions.ts b/src/plugins/discover/public/application/main/utils/get_dimensions.ts
similarity index 92%
rename from src/plugins/discover/public/application/apps/main/utils/get_dimensions.ts
rename to src/plugins/discover/public/application/main/utils/get_dimensions.ts
index 40b378f1c1698..6fb9cd7865c4f 100644
--- a/src/plugins/discover/public/application/apps/main/utils/get_dimensions.ts
+++ b/src/plugins/discover/public/application/main/utils/get_dimensions.ts
@@ -7,8 +7,8 @@
*/
import moment from 'moment';
import dateMath from '@elastic/datemath';
-import { IAggConfigs } from '../../../../../../data/common';
-import { DataPublicPluginStart, search } from '../../../../../../data/public';
+import { IAggConfigs } from '../../../../../data/common';
+import { DataPublicPluginStart, search } from '../../../../../data/public';
import { Dimensions, HistogramParamsBounds } from '../components/chart/point_series';
export function getDimensions(
diff --git a/src/plugins/discover/public/application/apps/main/utils/get_fetch_observable.ts b/src/plugins/discover/public/application/main/utils/get_fetch_observable.ts
similarity index 93%
rename from src/plugins/discover/public/application/apps/main/utils/get_fetch_observable.ts
rename to src/plugins/discover/public/application/main/utils/get_fetch_observable.ts
index de79a9425f17c..8c0d614f7ac61 100644
--- a/src/plugins/discover/public/application/apps/main/utils/get_fetch_observable.ts
+++ b/src/plugins/discover/public/application/main/utils/get_fetch_observable.ts
@@ -8,13 +8,13 @@
import { merge } from 'rxjs';
import { debounceTime, filter, skip, tap } from 'rxjs/operators';
-import { FetchStatus } from '../../../types';
+import { FetchStatus } from '../../types';
import type {
AutoRefreshDoneFn,
DataPublicPluginStart,
ISearchSource,
-} from '../../../../../../data/public';
-import { DataMain$, DataRefetch$ } from '../services/use_saved_search';
+} from '../../../../../data/public';
+import { DataMain$, DataRefetch$ } from './use_saved_search';
import { DiscoverSearchSessionManager } from '../services/discover_search_session';
/**
diff --git a/src/plugins/discover/public/application/apps/main/utils/get_fetch_observeable.test.ts b/src/plugins/discover/public/application/main/utils/get_fetch_observeable.test.ts
similarity index 91%
rename from src/plugins/discover/public/application/apps/main/utils/get_fetch_observeable.test.ts
rename to src/plugins/discover/public/application/main/utils/get_fetch_observeable.test.ts
index 39873ff609d64..58fcc20396dee 100644
--- a/src/plugins/discover/public/application/apps/main/utils/get_fetch_observeable.test.ts
+++ b/src/plugins/discover/public/application/main/utils/get_fetch_observeable.test.ts
@@ -6,12 +6,12 @@
* Side Public License, v 1.
*/
import { getFetch$ } from './get_fetch_observable';
-import { FetchStatus } from '../../../types';
+import { FetchStatus } from '../../types';
import { BehaviorSubject, Subject } from 'rxjs';
-import { DataPublicPluginStart } from '../../../../../../data/public';
-import { createSearchSessionMock } from '../../../../__mocks__/search_session';
-import { DataRefetch$ } from '../services/use_saved_search';
-import { savedSearchMock, savedSearchMockWithTimeField } from '../../../../__mocks__/saved_search';
+import { DataPublicPluginStart } from '../../../../../data/public';
+import { createSearchSessionMock } from '../../../__mocks__/search_session';
+import { DataRefetch$ } from './use_saved_search';
+import { savedSearchMock, savedSearchMockWithTimeField } from '../../../__mocks__/saved_search';
function createDataMock(
queryString$: Subject,
diff --git a/src/plugins/discover/public/application/apps/main/utils/get_result_state.test.ts b/src/plugins/discover/public/application/main/utils/get_result_state.test.ts
similarity index 97%
rename from src/plugins/discover/public/application/apps/main/utils/get_result_state.test.ts
rename to src/plugins/discover/public/application/main/utils/get_result_state.test.ts
index 7066d22d6aac7..8dd98650f30a5 100644
--- a/src/plugins/discover/public/application/apps/main/utils/get_result_state.test.ts
+++ b/src/plugins/discover/public/application/main/utils/get_result_state.test.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
import { getResultState, resultStatuses } from './get_result_state';
-import { FetchStatus } from '../../../types';
+import { FetchStatus } from '../../types';
describe('getResultState', () => {
test('fetching uninitialized', () => {
diff --git a/src/plugins/discover/public/application/apps/main/utils/get_result_state.ts b/src/plugins/discover/public/application/main/utils/get_result_state.ts
similarity index 96%
rename from src/plugins/discover/public/application/apps/main/utils/get_result_state.ts
rename to src/plugins/discover/public/application/main/utils/get_result_state.ts
index 424d2feabd830..ceb6de0cc7798 100644
--- a/src/plugins/discover/public/application/apps/main/utils/get_result_state.ts
+++ b/src/plugins/discover/public/application/main/utils/get_result_state.ts
@@ -5,7 +5,7 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
-import { FetchStatus } from '../../../types';
+import { FetchStatus } from '../../types';
export const resultStatuses = {
UNINITIALIZED: 'uninitialized',
diff --git a/src/plugins/discover/public/application/apps/main/utils/get_state_defaults.test.ts b/src/plugins/discover/public/application/main/utils/get_state_defaults.test.ts
similarity index 84%
rename from src/plugins/discover/public/application/apps/main/utils/get_state_defaults.test.ts
rename to src/plugins/discover/public/application/main/utils/get_state_defaults.test.ts
index 6cf34fd8cb024..0d38b1997716b 100644
--- a/src/plugins/discover/public/application/apps/main/utils/get_state_defaults.test.ts
+++ b/src/plugins/discover/public/application/main/utils/get_state_defaults.test.ts
@@ -7,12 +7,12 @@
*/
import { getStateDefaults } from './get_state_defaults';
-import { createSearchSourceMock, dataPluginMock } from '../../../../../../data/public/mocks';
-import { uiSettingsMock } from '../../../../__mocks__/ui_settings';
-import { indexPatternWithTimefieldMock } from '../../../../__mocks__/index_pattern_with_timefield';
-import { savedSearchMock } from '../../../../__mocks__/saved_search';
-import { indexPatternMock } from '../../../../__mocks__/index_pattern';
-import { discoverServiceMock } from '../../../../__mocks__/services';
+import { createSearchSourceMock, dataPluginMock } from '../../../../../data/public/mocks';
+import { uiSettingsMock } from '../../../__mocks__/ui_settings';
+import { indexPatternWithTimefieldMock } from '../../../__mocks__/index_pattern_with_timefield';
+import { savedSearchMock } from '../../../__mocks__/saved_search';
+import { indexPatternMock } from '../../../__mocks__/index_pattern';
+import { discoverServiceMock } from '../../../__mocks__/services';
describe('getStateDefaults', () => {
const storage = discoverServiceMock.storage;
diff --git a/src/plugins/discover/public/application/apps/main/utils/get_state_defaults.ts b/src/plugins/discover/public/application/main/utils/get_state_defaults.ts
similarity index 89%
rename from src/plugins/discover/public/application/apps/main/utils/get_state_defaults.ts
rename to src/plugins/discover/public/application/main/utils/get_state_defaults.ts
index 50dab0273d461..4694bec4057b0 100644
--- a/src/plugins/discover/public/application/apps/main/utils/get_state_defaults.ts
+++ b/src/plugins/discover/public/application/main/utils/get_state_defaults.ts
@@ -12,14 +12,14 @@ import {
DEFAULT_COLUMNS_SETTING,
SEARCH_FIELDS_FROM_SOURCE,
SORT_DEFAULT_ORDER_SETTING,
-} from '../../../../../common';
-import { SavedSearch } from '../../../../saved_searches';
-import { DataPublicPluginStart } from '../../../../../../data/public';
+} from '../../../../common';
+import { SavedSearch } from '../../../services/saved_searches';
+import { DataPublicPluginStart } from '../../../../../data/public';
import { AppState } from '../services/discover_state';
-import { getDefaultSort, getSortArray } from '../components/doc_table';
+import { getDefaultSort, getSortArray } from '../../../components/doc_table';
import { CHART_HIDDEN_KEY } from '../components/chart/discover_chart';
-import { Storage } from '../../../../../../kibana_utils/public';
+import { Storage } from '../../../../../kibana_utils/public';
function getDefaultColumns(savedSearch: SavedSearch, config: IUiSettingsClient) {
if (savedSearch.columns && savedSearch.columns.length > 0) {
diff --git a/src/plugins/discover/public/application/apps/main/utils/get_switch_index_pattern_app_state.test.ts b/src/plugins/discover/public/application/main/utils/get_switch_index_pattern_app_state.test.ts
similarity index 98%
rename from src/plugins/discover/public/application/apps/main/utils/get_switch_index_pattern_app_state.test.ts
rename to src/plugins/discover/public/application/main/utils/get_switch_index_pattern_app_state.test.ts
index 83107d6c57ab8..412ad060b5565 100644
--- a/src/plugins/discover/public/application/apps/main/utils/get_switch_index_pattern_app_state.test.ts
+++ b/src/plugins/discover/public/application/main/utils/get_switch_index_pattern_app_state.test.ts
@@ -7,7 +7,7 @@
*/
import { getSwitchIndexPatternAppState } from './get_switch_index_pattern_app_state';
-import { IndexPattern } from '../../../../../../data/common';
+import { IndexPattern } from '../../../../../data/common';
/**
* Helper function returning an index pattern
diff --git a/src/plugins/discover/public/application/apps/main/utils/get_switch_index_pattern_app_state.ts b/src/plugins/discover/public/application/main/utils/get_switch_index_pattern_app_state.ts
similarity index 95%
rename from src/plugins/discover/public/application/apps/main/utils/get_switch_index_pattern_app_state.ts
rename to src/plugins/discover/public/application/main/utils/get_switch_index_pattern_app_state.ts
index ff082587172a0..b6dfe7a63f3a8 100644
--- a/src/plugins/discover/public/application/apps/main/utils/get_switch_index_pattern_app_state.ts
+++ b/src/plugins/discover/public/application/main/utils/get_switch_index_pattern_app_state.ts
@@ -7,7 +7,7 @@
*/
import type { IndexPattern } from 'src/plugins/data/common';
-import { getSortArray, SortPairArr } from '../components/doc_table/lib/get_sort';
+import { getSortArray, SortPairArr } from '../../../components/doc_table/lib/get_sort';
/**
* Helper function to remove or adapt the currently selected columns/sort to be valid with the next
diff --git a/src/plugins/discover/public/application/apps/main/utils/index.ts b/src/plugins/discover/public/application/main/utils/index.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/utils/index.ts
rename to src/plugins/discover/public/application/main/utils/index.ts
diff --git a/src/plugins/discover/public/application/apps/main/utils/nested_fields.ts b/src/plugins/discover/public/application/main/utils/nested_fields.ts
similarity index 97%
rename from src/plugins/discover/public/application/apps/main/utils/nested_fields.ts
rename to src/plugins/discover/public/application/main/utils/nested_fields.ts
index beeca801457a1..f06f3dd554b4c 100644
--- a/src/plugins/discover/public/application/apps/main/utils/nested_fields.ts
+++ b/src/plugins/discover/public/application/main/utils/nested_fields.ts
@@ -8,7 +8,7 @@
import { escapeRegExp } from 'lodash/fp';
import type { IndexPattern } from 'src/plugins/data/public';
-import { getFieldSubtypeNested } from '../../../../../../data/common';
+import { getFieldSubtypeNested } from '../../../../../data/common';
/**
* This function checks if the given field in a given index pattern is a nested field's parent.
diff --git a/src/plugins/discover/public/application/apps/main/utils/persist_saved_search.ts b/src/plugins/discover/public/application/main/utils/persist_saved_search.ts
similarity index 82%
rename from src/plugins/discover/public/application/apps/main/utils/persist_saved_search.ts
rename to src/plugins/discover/public/application/main/utils/persist_saved_search.ts
index fa566fd485942..dcc0f804c27e0 100644
--- a/src/plugins/discover/public/application/apps/main/utils/persist_saved_search.ts
+++ b/src/plugins/discover/public/application/main/utils/persist_saved_search.ts
@@ -7,13 +7,13 @@
*/
import { updateSearchSource } from './update_search_source';
-import { IndexPattern } from '../../../../../../data/public';
-import { SavedSearch } from '../../../../saved_searches';
+import { IndexPattern } from '../../../../../data/public';
+import { SavedSearch } from '../../../services/saved_searches';
import { AppState } from '../services/discover_state';
-import type { SortOrder } from '../../../../saved_searches';
-import { SavedObjectSaveOpts } from '../../../../../../saved_objects/public';
-import { DiscoverServices } from '../../../../build_services';
-import { saveSavedSearch } from '../../../../saved_searches';
+import type { SortOrder } from '../../../services/saved_searches';
+import { SavedObjectSaveOpts } from '../../../../../saved_objects/public';
+import { DiscoverServices } from '../../../build_services';
+import { saveSavedSearch } from '../../../services/saved_searches';
/**
* Helper function to update and persist the given savedSearch
diff --git a/src/plugins/discover/public/application/apps/main/utils/resolve_index_pattern.test.ts b/src/plugins/discover/public/application/main/utils/resolve_index_pattern.test.ts
similarity index 89%
rename from src/plugins/discover/public/application/apps/main/utils/resolve_index_pattern.test.ts
rename to src/plugins/discover/public/application/main/utils/resolve_index_pattern.test.ts
index 56c4f8e6cd1b6..bcf764b57d8cc 100644
--- a/src/plugins/discover/public/application/apps/main/utils/resolve_index_pattern.test.ts
+++ b/src/plugins/discover/public/application/main/utils/resolve_index_pattern.test.ts
@@ -11,9 +11,9 @@ import {
getFallbackIndexPatternId,
IndexPatternSavedObject,
} from './resolve_index_pattern';
-import { indexPatternsMock } from '../../../../__mocks__/index_patterns';
-import { indexPatternMock } from '../../../../__mocks__/index_pattern';
-import { configMock } from '../../../../__mocks__/config';
+import { indexPatternsMock } from '../../../__mocks__/index_patterns';
+import { indexPatternMock } from '../../../__mocks__/index_pattern';
+import { configMock } from '../../../__mocks__/config';
describe('Resolve index pattern tests', () => {
test('returns valid data for an existing index pattern', async () => {
diff --git a/src/plugins/discover/public/application/apps/main/utils/resolve_index_pattern.ts b/src/plugins/discover/public/application/main/utils/resolve_index_pattern.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/utils/resolve_index_pattern.ts
rename to src/plugins/discover/public/application/main/utils/resolve_index_pattern.ts
diff --git a/src/plugins/discover/public/application/apps/main/utils/update_search_source.test.ts b/src/plugins/discover/public/application/main/utils/update_search_source.test.ts
similarity index 91%
rename from src/plugins/discover/public/application/apps/main/utils/update_search_source.test.ts
rename to src/plugins/discover/public/application/main/utils/update_search_source.test.ts
index 22f3b6ad86f6c..3d36cf1cce5da 100644
--- a/src/plugins/discover/public/application/apps/main/utils/update_search_source.test.ts
+++ b/src/plugins/discover/public/application/main/utils/update_search_source.test.ts
@@ -7,10 +7,10 @@
*/
import { updateSearchSource } from './update_search_source';
-import { createSearchSourceMock } from '../../../../../../data/common/search/search_source/mocks';
-import { indexPatternMock } from '../../../../__mocks__/index_pattern';
-import type { SortOrder } from '../../../../saved_searches';
-import { discoverServiceMock } from '../../../../__mocks__/services';
+import { createSearchSourceMock } from '../../../../../data/common/search/search_source/mocks';
+import { indexPatternMock } from '../../../__mocks__/index_pattern';
+import type { SortOrder } from '../../../services/saved_searches';
+import { discoverServiceMock } from '../../../__mocks__/services';
describe('updateSearchSource', () => {
test('updates a given search source', async () => {
diff --git a/src/plugins/discover/public/application/apps/main/utils/update_search_source.ts b/src/plugins/discover/public/application/main/utils/update_search_source.ts
similarity index 85%
rename from src/plugins/discover/public/application/apps/main/utils/update_search_source.ts
rename to src/plugins/discover/public/application/main/utils/update_search_source.ts
index 6d592e176afe5..a08f180f1816c 100644
--- a/src/plugins/discover/public/application/apps/main/utils/update_search_source.ts
+++ b/src/plugins/discover/public/application/main/utils/update_search_source.ts
@@ -6,11 +6,11 @@
* Side Public License, v 1.
*/
-import { SORT_DEFAULT_ORDER_SETTING } from '../../../../../common';
-import { IndexPattern, ISearchSource } from '../../../../../../data/common';
-import type { SortOrder } from '../../../../saved_searches';
-import { DiscoverServices } from '../../../../build_services';
-import { getSortForSearchSource } from '../components/doc_table';
+import { SORT_DEFAULT_ORDER_SETTING } from '../../../../common';
+import { IndexPattern, ISearchSource } from '../../../../../data/common';
+import type { SortOrder } from '../../../services/saved_searches';
+import { DiscoverServices } from '../../../build_services';
+import { getSortForSearchSource } from '../../../components/doc_table';
/**
* Helper function to update the given searchSource before fetching/sharing/persisting
diff --git a/src/plugins/discover/public/application/apps/main/utils/use_behavior_subject.ts b/src/plugins/discover/public/application/main/utils/use_behavior_subject.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/utils/use_behavior_subject.ts
rename to src/plugins/discover/public/application/main/utils/use_behavior_subject.ts
diff --git a/src/plugins/discover/public/application/apps/main/utils/use_data_state.ts b/src/plugins/discover/public/application/main/utils/use_data_state.ts
similarity index 94%
rename from src/plugins/discover/public/application/apps/main/utils/use_data_state.ts
rename to src/plugins/discover/public/application/main/utils/use_data_state.ts
index 2fd571a0dfcb9..7bfa4205081e9 100644
--- a/src/plugins/discover/public/application/apps/main/utils/use_data_state.ts
+++ b/src/plugins/discover/public/application/main/utils/use_data_state.ts
@@ -7,7 +7,7 @@
*/
import { useState, useEffect } from 'react';
import { BehaviorSubject } from 'rxjs';
-import { DataMsg } from '../services/use_saved_search';
+import { DataMsg } from './use_saved_search';
export function useDataState(data$: BehaviorSubject) {
const [fetchState, setFetchState] = useState(data$.getValue());
diff --git a/src/plugins/discover/public/application/apps/main/services/use_discover_state.test.ts b/src/plugins/discover/public/application/main/utils/use_discover_state.test.ts
similarity index 87%
rename from src/plugins/discover/public/application/apps/main/services/use_discover_state.test.ts
rename to src/plugins/discover/public/application/main/utils/use_discover_state.test.ts
index c719f83980aa0..78f742b9f7c9b 100644
--- a/src/plugins/discover/public/application/apps/main/services/use_discover_state.test.ts
+++ b/src/plugins/discover/public/application/main/utils/use_discover_state.test.ts
@@ -7,12 +7,12 @@
*/
import { renderHook, act } from '@testing-library/react-hooks';
-import { createSearchSessionMock } from '../../../../__mocks__/search_session';
-import { discoverServiceMock } from '../../../../__mocks__/services';
-import { savedSearchMock } from '../../../../__mocks__/saved_search';
+import { createSearchSessionMock } from '../../../__mocks__/search_session';
+import { discoverServiceMock } from '../../../__mocks__/services';
+import { savedSearchMock } from '../../../__mocks__/saved_search';
import { useDiscoverState } from './use_discover_state';
-import { indexPatternMock } from '../../../../__mocks__/index_pattern';
-import { SearchSource } from '../../../../../../data/common';
+import { indexPatternMock } from '../../../__mocks__/index_pattern';
+import { SearchSource } from '../../../../../data/common';
describe('test useDiscoverState', () => {
const originalSavedObjectsClient = discoverServiceMock.core.savedObjects.client;
diff --git a/src/plugins/discover/public/application/apps/main/services/use_discover_state.ts b/src/plugins/discover/public/application/main/utils/use_discover_state.ts
similarity index 93%
rename from src/plugins/discover/public/application/apps/main/services/use_discover_state.ts
rename to src/plugins/discover/public/application/main/utils/use_discover_state.ts
index a1d58fdd6090e..b70bcded4c608 100644
--- a/src/plugins/discover/public/application/apps/main/services/use_discover_state.ts
+++ b/src/plugins/discover/public/application/main/utils/use_discover_state.ts
@@ -8,22 +8,22 @@
import { useMemo, useEffect, useState, useCallback } from 'react';
import { isEqual } from 'lodash';
import { History } from 'history';
-import { getState } from './discover_state';
-import { getStateDefaults } from '../utils/get_state_defaults';
-import { DiscoverServices } from '../../../../build_services';
-import { SavedSearch, getSavedSearch } from '../../../../saved_searches';
-import { loadIndexPattern } from '../utils/resolve_index_pattern';
+import { getState } from '../services/discover_state';
+import { getStateDefaults } from './get_state_defaults';
+import { DiscoverServices } from '../../../build_services';
+import { SavedSearch, getSavedSearch } from '../../../services/saved_searches';
+import { loadIndexPattern } from './resolve_index_pattern';
import { useSavedSearch as useSavedSearchData } from './use_saved_search';
import {
MODIFY_COLUMNS_ON_SWITCH,
SEARCH_FIELDS_FROM_SOURCE,
SEARCH_ON_PAGE_LOAD_SETTING,
SORT_DEFAULT_ORDER_SETTING,
-} from '../../../../../common';
+} from '../../../../common';
import { useSearchSession } from './use_search_session';
-import { FetchStatus } from '../../../types';
-import { getSwitchIndexPatternAppState } from '../utils/get_switch_index_pattern_app_state';
-import { SortPairArr } from '../components/doc_table/lib/get_sort';
+import { FetchStatus } from '../../types';
+import { getSwitchIndexPatternAppState } from './get_switch_index_pattern_app_state';
+import { SortPairArr } from '../../../components/doc_table/lib/get_sort';
export function useDiscoverState({
services,
diff --git a/src/plugins/discover/public/application/apps/main/services/use_saved_search.test.ts b/src/plugins/discover/public/application/main/utils/use_saved_search.test.ts
similarity index 91%
rename from src/plugins/discover/public/application/apps/main/services/use_saved_search.test.ts
rename to src/plugins/discover/public/application/main/utils/use_saved_search.test.ts
index 7f252151920fb..b3ed7ab854190 100644
--- a/src/plugins/discover/public/application/apps/main/services/use_saved_search.test.ts
+++ b/src/plugins/discover/public/application/main/utils/use_saved_search.test.ts
@@ -7,14 +7,14 @@
*/
import { Subject } from 'rxjs';
import { renderHook } from '@testing-library/react-hooks';
-import { createSearchSessionMock } from '../../../../__mocks__/search_session';
-import { discoverServiceMock } from '../../../../__mocks__/services';
-import { savedSearchMock } from '../../../../__mocks__/saved_search';
+import { createSearchSessionMock } from '../../../__mocks__/search_session';
+import { discoverServiceMock } from '../../../__mocks__/services';
+import { savedSearchMock } from '../../../__mocks__/saved_search';
import { useSavedSearch } from './use_saved_search';
-import { getState } from './discover_state';
-import { uiSettingsMock } from '../../../../__mocks__/ui_settings';
+import { getState } from '../services/discover_state';
+import { uiSettingsMock } from '../../../__mocks__/ui_settings';
import { useDiscoverState } from './use_discover_state';
-import { FetchStatus } from '../../../types';
+import { FetchStatus } from '../../types';
describe('test useSavedSearch', () => {
test('useSavedSearch return is valid', async () => {
diff --git a/src/plugins/discover/public/application/apps/main/services/use_saved_search.ts b/src/plugins/discover/public/application/main/utils/use_saved_search.ts
similarity index 88%
rename from src/plugins/discover/public/application/apps/main/services/use_saved_search.ts
rename to src/plugins/discover/public/application/main/utils/use_saved_search.ts
index 6cadfbb89acfb..bfd6f1daa4bc0 100644
--- a/src/plugins/discover/public/application/apps/main/services/use_saved_search.ts
+++ b/src/plugins/discover/public/application/main/utils/use_saved_search.ts
@@ -7,22 +7,22 @@
*/
import { useCallback, useEffect, useMemo, useRef } from 'react';
import { BehaviorSubject, Subject } from 'rxjs';
-import { DiscoverServices } from '../../../../build_services';
-import { DiscoverSearchSessionManager } from './discover_search_session';
-import { ISearchSource } from '../../../../../../data/common';
-import { GetStateReturn } from './discover_state';
-import { ElasticSearchHit } from '../../../doc_views/doc_views_types';
-import { RequestAdapter } from '../../../../../../inspector/public';
-import type { AutoRefreshDoneFn } from '../../../../../../data/public';
-import { validateTimeRange } from '../utils/validate_time_range';
+import { DiscoverServices } from '../../../build_services';
+import { DiscoverSearchSessionManager } from '../services/discover_search_session';
+import { ISearchSource } from '../../../../../data/common';
+import { GetStateReturn } from '../services/discover_state';
+import { ElasticSearchHit } from '../../../services/doc_views/doc_views_types';
+import { RequestAdapter } from '../../../../../inspector/public';
+import type { AutoRefreshDoneFn } from '../../../../../data/public';
+import { validateTimeRange } from './validate_time_range';
import { Chart } from '../components/chart/point_series';
-import { useSingleton } from '../utils/use_singleton';
-import { FetchStatus } from '../../../types';
+import { useSingleton } from './use_singleton';
+import { FetchStatus } from '../../types';
-import { fetchAll } from '../utils/fetch_all';
-import { useBehaviorSubject } from '../utils/use_behavior_subject';
+import { fetchAll } from './fetch_all';
+import { useBehaviorSubject } from './use_behavior_subject';
import { sendResetMsg } from './use_saved_search_messages';
-import { getFetch$ } from '../utils/get_fetch_observable';
+import { getFetch$ } from './get_fetch_observable';
export interface SavedSearchData {
main$: DataMain$;
diff --git a/src/plugins/discover/public/application/apps/main/services/use_saved_search_messages.test.ts b/src/plugins/discover/public/application/main/utils/use_saved_search_messages.test.ts
similarity index 98%
rename from src/plugins/discover/public/application/apps/main/services/use_saved_search_messages.test.ts
rename to src/plugins/discover/public/application/main/utils/use_saved_search_messages.test.ts
index 9810436aebd90..2fa264690329e 100644
--- a/src/plugins/discover/public/application/apps/main/services/use_saved_search_messages.test.ts
+++ b/src/plugins/discover/public/application/main/utils/use_saved_search_messages.test.ts
@@ -11,7 +11,7 @@ import {
sendLoadingMsg,
sendPartialMsg,
} from './use_saved_search_messages';
-import { FetchStatus } from '../../../types';
+import { FetchStatus } from '../../types';
import { BehaviorSubject } from 'rxjs';
import { DataMainMsg } from './use_saved_search';
diff --git a/src/plugins/discover/public/application/apps/main/services/use_saved_search_messages.ts b/src/plugins/discover/public/application/main/utils/use_saved_search_messages.ts
similarity index 98%
rename from src/plugins/discover/public/application/apps/main/services/use_saved_search_messages.ts
rename to src/plugins/discover/public/application/main/utils/use_saved_search_messages.ts
index ff72a69e65fa8..325d63eb6d21a 100644
--- a/src/plugins/discover/public/application/apps/main/services/use_saved_search_messages.ts
+++ b/src/plugins/discover/public/application/main/utils/use_saved_search_messages.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-import { FetchStatus } from '../../../types';
+import { FetchStatus } from '../../types';
import {
DataCharts$,
DataDocuments$,
diff --git a/src/plugins/discover/public/application/apps/main/services/use_search_session.test.ts b/src/plugins/discover/public/application/main/utils/use_search_session.test.ts
similarity index 77%
rename from src/plugins/discover/public/application/apps/main/services/use_search_session.test.ts
rename to src/plugins/discover/public/application/main/utils/use_search_session.test.ts
index 8aa6e0764d8ec..bc9af1001aa77 100644
--- a/src/plugins/discover/public/application/apps/main/services/use_search_session.test.ts
+++ b/src/plugins/discover/public/application/main/utils/use_search_session.test.ts
@@ -8,11 +8,11 @@
import { useSearchSession } from './use_search_session';
import { renderHook } from '@testing-library/react-hooks';
-import { createSearchSessionMock } from '../../../../__mocks__/search_session';
-import { discoverServiceMock } from '../../../../__mocks__/services';
-import { savedSearchMock } from '../../../../__mocks__/saved_search';
-import { getState } from './discover_state';
-import { uiSettingsMock } from '../../../../__mocks__/ui_settings';
+import { createSearchSessionMock } from '../../../__mocks__/search_session';
+import { discoverServiceMock } from '../../../__mocks__/services';
+import { savedSearchMock } from '../../../__mocks__/saved_search';
+import { getState } from '../services/discover_state';
+import { uiSettingsMock } from '../../../__mocks__/ui_settings';
describe('test useSearchSession', () => {
test('getting the next session id', async () => {
diff --git a/src/plugins/discover/public/application/apps/main/services/use_search_session.ts b/src/plugins/discover/public/application/main/utils/use_search_session.ts
similarity index 82%
rename from src/plugins/discover/public/application/apps/main/services/use_search_session.ts
rename to src/plugins/discover/public/application/main/utils/use_search_session.ts
index e37e8f6f33839..c18261f1ffaac 100644
--- a/src/plugins/discover/public/application/apps/main/services/use_search_session.ts
+++ b/src/plugins/discover/public/application/main/utils/use_search_session.ts
@@ -7,11 +7,14 @@
*/
import { useMemo, useEffect } from 'react';
import { History } from 'history';
-import { DiscoverSearchSessionManager } from './discover_search_session';
-import { createSearchSessionRestorationDataProvider, GetStateReturn } from './discover_state';
-import { noSearchSessionStorageCapabilityMessage } from '../../../../../../data/public';
-import { DiscoverServices } from '../../../../build_services';
-import { SavedSearch } from '../../../../saved_searches';
+import { DiscoverSearchSessionManager } from '../services/discover_search_session';
+import {
+ createSearchSessionRestorationDataProvider,
+ GetStateReturn,
+} from '../services/discover_state';
+import { noSearchSessionStorageCapabilityMessage } from '../../../../../data/public';
+import { DiscoverServices } from '../../../build_services';
+import { SavedSearch } from '../../../services/saved_searches';
export function useSearchSession({
services,
diff --git a/src/plugins/discover/public/application/apps/main/utils/use_singleton.ts b/src/plugins/discover/public/application/main/utils/use_singleton.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/utils/use_singleton.ts
rename to src/plugins/discover/public/application/main/utils/use_singleton.ts
diff --git a/src/plugins/discover/public/application/apps/main/services/use_url.test.ts b/src/plugins/discover/public/application/main/utils/use_url.test.ts
similarity index 92%
rename from src/plugins/discover/public/application/apps/main/services/use_url.test.ts
rename to src/plugins/discover/public/application/main/utils/use_url.test.ts
index 740ca2bd140d7..9d8191f3581e4 100644
--- a/src/plugins/discover/public/application/apps/main/services/use_url.test.ts
+++ b/src/plugins/discover/public/application/main/utils/use_url.test.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
import { renderHook } from '@testing-library/react-hooks';
-import { createSearchSessionMock } from '../../../../__mocks__/search_session';
+import { createSearchSessionMock } from '../../../__mocks__/search_session';
import { useUrl } from './use_url';
describe('test useUrl', () => {
diff --git a/src/plugins/discover/public/application/apps/main/services/use_url.ts b/src/plugins/discover/public/application/main/utils/use_url.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/services/use_url.ts
rename to src/plugins/discover/public/application/main/utils/use_url.ts
diff --git a/src/plugins/discover/public/application/apps/main/utils/validate_time_range.test.ts b/src/plugins/discover/public/application/main/utils/validate_time_range.test.ts
similarity index 94%
rename from src/plugins/discover/public/application/apps/main/utils/validate_time_range.test.ts
rename to src/plugins/discover/public/application/main/utils/validate_time_range.test.ts
index 8d9d9adc4e8dc..ff3a66b1edfa3 100644
--- a/src/plugins/discover/public/application/apps/main/utils/validate_time_range.test.ts
+++ b/src/plugins/discover/public/application/main/utils/validate_time_range.test.ts
@@ -7,7 +7,7 @@
*/
import { validateTimeRange } from './validate_time_range';
-import { notificationServiceMock } from '../../../../../../../core/public/mocks';
+import { notificationServiceMock } from '../../../../../../core/public/mocks';
describe('Discover validateTimeRange', () => {
test('validates given time ranges correctly', async () => {
diff --git a/src/plugins/discover/public/application/apps/main/utils/validate_time_range.ts b/src/plugins/discover/public/application/main/utils/validate_time_range.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/utils/validate_time_range.ts
rename to src/plugins/discover/public/application/main/utils/validate_time_range.ts
diff --git a/src/plugins/discover/public/application/apps/not_found/index.ts b/src/plugins/discover/public/application/not_found/index.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/not_found/index.ts
rename to src/plugins/discover/public/application/not_found/index.ts
diff --git a/src/plugins/discover/public/application/apps/not_found/not_found_route.tsx b/src/plugins/discover/public/application/not_found/not_found_route.tsx
similarity index 92%
rename from src/plugins/discover/public/application/apps/not_found/not_found_route.tsx
rename to src/plugins/discover/public/application/not_found/not_found_route.tsx
index 6b6ef584d07f1..4848248a7509d 100644
--- a/src/plugins/discover/public/application/apps/not_found/not_found_route.tsx
+++ b/src/plugins/discover/public/application/not_found/not_found_route.tsx
@@ -10,9 +10,9 @@ import { i18n } from '@kbn/i18n';
import { EuiCallOut } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { Redirect } from 'react-router-dom';
-import { toMountPoint } from '../../../../../kibana_react/public';
-import { DiscoverServices } from '../../../build_services';
-import { getUrlTracker } from '../../../kibana_services';
+import { toMountPoint } from '../../../../kibana_react/public';
+import { DiscoverServices } from '../../build_services';
+import { getUrlTracker } from '../../kibana_services';
export interface NotFoundRouteProps {
/**
diff --git a/src/plugins/discover/public/application/components/common/__snapshots__/loading_indicator.test.tsx.snap b/src/plugins/discover/public/components/common/__snapshots__/loading_indicator.test.tsx.snap
similarity index 100%
rename from src/plugins/discover/public/application/components/common/__snapshots__/loading_indicator.test.tsx.snap
rename to src/plugins/discover/public/components/common/__snapshots__/loading_indicator.test.tsx.snap
diff --git a/src/plugins/discover/public/shared/components.tsx b/src/plugins/discover/public/components/common/deferred_spinner.tsx
similarity index 100%
rename from src/plugins/discover/public/shared/components.tsx
rename to src/plugins/discover/public/components/common/deferred_spinner.tsx
diff --git a/src/plugins/discover/public/application/components/common/loading_indicator.test.tsx b/src/plugins/discover/public/components/common/loading_indicator.test.tsx
similarity index 100%
rename from src/plugins/discover/public/application/components/common/loading_indicator.test.tsx
rename to src/plugins/discover/public/components/common/loading_indicator.test.tsx
diff --git a/src/plugins/discover/public/application/components/common/loading_indicator.tsx b/src/plugins/discover/public/components/common/loading_indicator.tsx
similarity index 100%
rename from src/plugins/discover/public/application/components/common/loading_indicator.tsx
rename to src/plugins/discover/public/components/common/loading_indicator.tsx
diff --git a/src/plugins/discover/public/application/components/data_visualizer_grid/data_visualizer_grid.tsx b/src/plugins/discover/public/components/data_visualizer_grid/data_visualizer_grid.tsx
similarity index 95%
rename from src/plugins/discover/public/application/components/data_visualizer_grid/data_visualizer_grid.tsx
rename to src/plugins/discover/public/components/data_visualizer_grid/data_visualizer_grid.tsx
index 5492fac014b74..511aa90f5f4a4 100644
--- a/src/plugins/discover/public/application/components/data_visualizer_grid/data_visualizer_grid.tsx
+++ b/src/plugins/discover/public/components/data_visualizer_grid/data_visualizer_grid.tsx
@@ -8,17 +8,17 @@
import React, { useEffect, useMemo, useRef, useState } from 'react';
import { Filter } from '@kbn/es-query';
-import { IndexPatternField, IndexPattern, DataView, Query } from '../../../../../data/common';
-import { DiscoverServices } from '../../../build_services';
+import { IndexPatternField, IndexPattern, DataView, Query } from '../../../../data/common';
+import { DiscoverServices } from '../../build_services';
import {
EmbeddableInput,
EmbeddableOutput,
ErrorEmbeddable,
IEmbeddable,
isErrorEmbeddable,
-} from '../../../../../embeddable/public';
-import { SavedSearch } from '../../../saved_searches';
-import { GetStateReturn } from '../../apps/main/services/discover_state';
+} from '../../../../embeddable/public';
+import { SavedSearch } from '../../services/saved_searches';
+import { GetStateReturn } from '../../application/main/services/discover_state';
export interface DataVisualizerGridEmbeddableInput extends EmbeddableInput {
indexPattern: IndexPattern;
diff --git a/src/plugins/discover/public/application/components/data_visualizer_grid/field_stats_table_embeddable.tsx b/src/plugins/discover/public/components/data_visualizer_grid/field_stats_table_embeddable.tsx
similarity index 100%
rename from src/plugins/discover/public/application/components/data_visualizer_grid/field_stats_table_embeddable.tsx
rename to src/plugins/discover/public/components/data_visualizer_grid/field_stats_table_embeddable.tsx
diff --git a/src/plugins/discover/public/application/components/data_visualizer_grid/index.ts b/src/plugins/discover/public/components/data_visualizer_grid/index.ts
similarity index 100%
rename from src/plugins/discover/public/application/components/data_visualizer_grid/index.ts
rename to src/plugins/discover/public/components/data_visualizer_grid/index.ts
diff --git a/src/plugins/discover/public/application/components/discover_grid/constants.ts b/src/plugins/discover/public/components/discover_grid/constants.ts
similarity index 100%
rename from src/plugins/discover/public/application/components/discover_grid/constants.ts
rename to src/plugins/discover/public/components/discover_grid/constants.ts
diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss b/src/plugins/discover/public/components/discover_grid/discover_grid.scss
similarity index 100%
rename from src/plugins/discover/public/application/components/discover_grid/discover_grid.scss
rename to src/plugins/discover/public/components/discover_grid/discover_grid.scss
diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.test.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid.test.tsx
similarity index 92%
rename from src/plugins/discover/public/application/components/discover_grid/discover_grid.test.tsx
rename to src/plugins/discover/public/components/discover_grid/discover_grid.test.tsx
index 22284480afc05..4a0e472f17455 100644
--- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.test.tsx
+++ b/src/plugins/discover/public/components/discover_grid/discover_grid.test.tsx
@@ -10,18 +10,18 @@ import { ReactWrapper } from 'enzyme';
import { EuiCopy } from '@elastic/eui';
import { act } from 'react-dom/test-utils';
import { findTestSubject } from '@elastic/eui/lib/test';
-import { esHits } from '../../../__mocks__/es_hits';
-import { indexPatternMock } from '../../../__mocks__/index_pattern';
+import { esHits } from '../../__mocks__/es_hits';
+import { indexPatternMock } from '../../__mocks__/index_pattern';
import { mountWithIntl } from '@kbn/test/jest';
import { DiscoverGrid, DiscoverGridProps } from './discover_grid';
-import { uiSettingsMock } from '../../../__mocks__/ui_settings';
-import { DiscoverServices } from '../../../build_services';
-import { ElasticSearchHit } from '../../doc_views/doc_views_types';
+import { uiSettingsMock } from '../../__mocks__/ui_settings';
+import { DiscoverServices } from '../../build_services';
+import { ElasticSearchHit } from '../../services/doc_views/doc_views_types';
import { getDocId } from './discover_grid_document_selection';
-jest.mock('../../../kibana_services', () => ({
- ...jest.requireActual('../../../kibana_services'),
- getServices: () => jest.requireActual('../../../__mocks__/services').discoverServiceMock,
+jest.mock('../../kibana_services', () => ({
+ ...jest.requireActual('../../kibana_services'),
+ getServices: () => jest.requireActual('../../__mocks__/services').discoverServiceMock,
}));
function getProps() {
diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid.tsx
similarity index 96%
rename from src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx
rename to src/plugins/discover/public/components/discover_grid/discover_grid.tsx
index 6f96f21c9b8c8..9bcc0f90f9259 100644
--- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx
+++ b/src/plugins/discover/public/components/discover_grid/discover_grid.tsx
@@ -21,8 +21,8 @@ import {
EuiLoadingSpinner,
EuiIcon,
} from '@elastic/eui';
-import { flattenHit, IndexPattern } from '../../../../../data/common';
-import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types';
+import { flattenHit, IndexPattern } from '../../../../data/common';
+import { DocViewFilterFn, ElasticSearchHit } from '../../services/doc_views/doc_views_types';
import { getSchemaDetectors } from './discover_grid_schema';
import { DiscoverGridFlyout } from './discover_grid_flyout';
import { DiscoverGridContext } from './discover_grid_context';
@@ -34,16 +34,16 @@ import {
getVisibleColumns,
} from './discover_grid_columns';
import { defaultPageSize, gridStyle, pageSizeArr, toolbarVisibility } from './constants';
-import { DiscoverServices } from '../../../build_services';
-import { getDisplayedColumns } from '../../helpers/columns';
+import { DiscoverServices } from '../../build_services';
+import { getDisplayedColumns } from '../../utils/columns';
import {
DOC_HIDE_TIME_COLUMN_SETTING,
MAX_DOC_FIELDS_DISPLAYED,
SHOW_MULTIFIELDS,
-} from '../../../../common';
+} from '../../../common';
import { DiscoverGridDocumentToolbarBtn, getDocId } from './discover_grid_document_selection';
-import { SortPairArr } from '../../apps/main/components/doc_table/lib/get_sort';
-import { getFieldsToShow } from '../../helpers/get_fields_to_show';
+import { SortPairArr } from '../doc_table/lib/get_sort';
+import { getFieldsToShow } from '../../utils/get_fields_to_show';
interface SortObj {
id: string;
diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.test.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_cell_actions.test.tsx
similarity index 95%
rename from src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.test.tsx
rename to src/plugins/discover/public/components/discover_grid/discover_grid_cell_actions.test.tsx
index de3c55ad7a869..736175c04d3c2 100644
--- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.test.tsx
+++ b/src/plugins/discover/public/components/discover_grid/discover_grid_cell_actions.test.tsx
@@ -12,8 +12,8 @@ import { findTestSubject } from '@elastic/eui/lib/test';
import { FilterInBtn, FilterOutBtn, buildCellActions } from './discover_grid_cell_actions';
import { DiscoverGridContext } from './discover_grid_context';
-import { indexPatternMock } from '../../../__mocks__/index_pattern';
-import { esHits } from '../../../__mocks__/es_hits';
+import { indexPatternMock } from '../../__mocks__/index_pattern';
+import { esHits } from '../../__mocks__/es_hits';
import { EuiButton } from '@elastic/eui';
import { IndexPatternField } from 'src/plugins/data/common';
diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_cell_actions.tsx
similarity index 96%
rename from src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx
rename to src/plugins/discover/public/components/discover_grid/discover_grid_cell_actions.tsx
index a31b551821ddb..41852afe7b32c 100644
--- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx
+++ b/src/plugins/discover/public/components/discover_grid/discover_grid_cell_actions.tsx
@@ -9,7 +9,7 @@
import React, { useContext } from 'react';
import { EuiDataGridColumnCellActionProps } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
-import { flattenHit, IndexPatternField } from '../../../../../data/common';
+import { flattenHit, IndexPatternField } from '../../../../data/common';
import { DiscoverGridContext } from './discover_grid_context';
export const FilterInBtn = ({
diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.test.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_columns.test.tsx
similarity index 96%
rename from src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.test.tsx
rename to src/plugins/discover/public/components/discover_grid/discover_grid_columns.test.tsx
index e5ea657032403..ea9cd5034551e 100644
--- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.test.tsx
+++ b/src/plugins/discover/public/components/discover_grid/discover_grid_columns.test.tsx
@@ -6,9 +6,9 @@
* Side Public License, v 1.
*/
-import { indexPatternMock } from '../../../__mocks__/index_pattern';
+import { indexPatternMock } from '../../__mocks__/index_pattern';
import { getEuiGridColumns } from './discover_grid_columns';
-import { indexPatternWithTimefieldMock } from '../../../__mocks__/index_pattern_with_timefield';
+import { indexPatternWithTimefieldMock } from '../../__mocks__/index_pattern_with_timefield';
describe('Discover grid columns ', function () {
it('returns eui grid columns without time column', async () => {
diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_columns.tsx
similarity index 98%
rename from src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx
rename to src/plugins/discover/public/components/discover_grid/discover_grid_columns.tsx
index 5eb55a8e99cde..872fa3133a024 100644
--- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx
+++ b/src/plugins/discover/public/components/discover_grid/discover_grid_columns.tsx
@@ -11,7 +11,7 @@ import { i18n } from '@kbn/i18n';
import { EuiDataGridColumn, EuiIconTip, EuiScreenReaderOnly } from '@elastic/eui';
import { ExpandButton } from './discover_grid_expand_button';
import { DiscoverGridSettings } from './types';
-import type { IndexPattern } from '../../../../../data/common';
+import type { IndexPattern } from '../../../../data/common';
import { buildCellActions } from './discover_grid_cell_actions';
import { getSchemaByKbnType } from './discover_grid_schema';
import { SelectButton } from './discover_grid_document_selection';
diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_context.tsx
similarity index 90%
rename from src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx
rename to src/plugins/discover/public/components/discover_grid/discover_grid_context.tsx
index 8d0fbec9d7933..49b72ef126a76 100644
--- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx
+++ b/src/plugins/discover/public/components/discover_grid/discover_grid_context.tsx
@@ -8,7 +8,7 @@
import React from 'react';
import type { IndexPattern } from 'src/plugins/data/common';
-import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types';
+import { DocViewFilterFn, ElasticSearchHit } from '../../services/doc_views/doc_views_types';
export interface GridContext {
expanded: ElasticSearchHit | undefined;
diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_document_selection.test.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_document_selection.test.tsx
similarity index 97%
rename from src/plugins/discover/public/application/components/discover_grid/discover_grid_document_selection.test.tsx
rename to src/plugins/discover/public/components/discover_grid/discover_grid_document_selection.test.tsx
index e9b93e21553a2..d57fba241a1e7 100644
--- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_document_selection.test.tsx
+++ b/src/plugins/discover/public/components/discover_grid/discover_grid_document_selection.test.tsx
@@ -13,8 +13,8 @@ import {
getDocId,
SelectButton,
} from './discover_grid_document_selection';
-import { esHits } from '../../../__mocks__/es_hits';
-import { indexPatternMock } from '../../../__mocks__/index_pattern';
+import { esHits } from '../../__mocks__/es_hits';
+import { indexPatternMock } from '../../__mocks__/index_pattern';
import { DiscoverGridContext } from './discover_grid_context';
const baseContextMock = {
diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_document_selection.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_document_selection.tsx
similarity index 98%
rename from src/plugins/discover/public/application/components/discover_grid/discover_grid_document_selection.tsx
rename to src/plugins/discover/public/components/discover_grid/discover_grid_document_selection.tsx
index c87d425d601c5..abf63d2fe76b0 100644
--- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_document_selection.tsx
+++ b/src/plugins/discover/public/components/discover_grid/discover_grid_document_selection.tsx
@@ -19,7 +19,7 @@ import {
import { FormattedMessage } from '@kbn/i18n/react';
import themeDark from '@elastic/eui/dist/eui_theme_dark.json';
import themeLight from '@elastic/eui/dist/eui_theme_light.json';
-import { ElasticSearchHit } from '../../doc_views/doc_views_types';
+import { ElasticSearchHit } from '../../services/doc_views/doc_views_types';
import { DiscoverGridContext } from './discover_grid_context';
/**
diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.test.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_expand_button.test.tsx
similarity index 96%
rename from src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.test.tsx
rename to src/plugins/discover/public/components/discover_grid/discover_grid_expand_button.test.tsx
index 3f7cb70091cfa..de2117afe7bdb 100644
--- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.test.tsx
+++ b/src/plugins/discover/public/components/discover_grid/discover_grid_expand_button.test.tsx
@@ -11,8 +11,8 @@ import { mountWithIntl } from '@kbn/test/jest';
import { findTestSubject } from '@elastic/eui/lib/test';
import { ExpandButton } from './discover_grid_expand_button';
import { DiscoverGridContext } from './discover_grid_context';
-import { indexPatternMock } from '../../../__mocks__/index_pattern';
-import { esHits } from '../../../__mocks__/es_hits';
+import { indexPatternMock } from '../../__mocks__/index_pattern';
+import { esHits } from '../../__mocks__/es_hits';
const baseContextMock = {
expanded: undefined,
diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_expand_button.tsx
similarity index 97%
rename from src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx
rename to src/plugins/discover/public/components/discover_grid/discover_grid_expand_button.tsx
index f259d5c5c3658..1a7080b9613d0 100644
--- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx
+++ b/src/plugins/discover/public/components/discover_grid/discover_grid_expand_button.tsx
@@ -12,7 +12,7 @@ import themeDark from '@elastic/eui/dist/eui_theme_dark.json';
import themeLight from '@elastic/eui/dist/eui_theme_light.json';
import { i18n } from '@kbn/i18n';
import { DiscoverGridContext } from './discover_grid_context';
-import { EsHitRecord } from '../../types';
+import { EsHitRecord } from '../../application/types';
/**
* Button to expand a given row
*/
diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.test.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.test.tsx
similarity index 93%
rename from src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.test.tsx
rename to src/plugins/discover/public/components/discover_grid/discover_grid_flyout.test.tsx
index 83fa447a50ba0..64e97b824a2f9 100644
--- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.test.tsx
+++ b/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.test.tsx
@@ -10,13 +10,13 @@ import React from 'react';
import { findTestSubject } from '@elastic/eui/lib/test';
import { mountWithIntl } from '@kbn/test/jest';
import { DiscoverGridFlyout } from './discover_grid_flyout';
-import { esHits } from '../../../__mocks__/es_hits';
-import { createFilterManagerMock } from '../../../../../data/public/query/filter_manager/filter_manager.mock';
-import { indexPatternMock } from '../../../__mocks__/index_pattern';
-import { DiscoverServices } from '../../../build_services';
-import { DocViewsRegistry } from '../../doc_views/doc_views_registry';
-import { setDocViewsRegistry } from '../../../kibana_services';
-import { indexPatternWithTimefieldMock } from '../../../__mocks__/index_pattern_with_timefield';
+import { esHits } from '../../__mocks__/es_hits';
+import { createFilterManagerMock } from '../../../../data/public/query/filter_manager/filter_manager.mock';
+import { indexPatternMock } from '../../__mocks__/index_pattern';
+import { DiscoverServices } from '../../build_services';
+import { DocViewsRegistry } from '../../services/doc_views/doc_views_registry';
+import { setDocViewsRegistry } from '../../kibana_services';
+import { indexPatternWithTimefieldMock } from '../../__mocks__/index_pattern_with_timefield';
describe('Discover flyout', function () {
setDocViewsRegistry(new DocViewsRegistry());
diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.tsx
similarity index 95%
rename from src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx
rename to src/plugins/discover/public/components/discover_grid/discover_grid_flyout.tsx
index f6e5e25f284ca..d5b2248162b2f 100644
--- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx
+++ b/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.tsx
@@ -24,11 +24,11 @@ import {
EuiHideFor,
keys,
} from '@elastic/eui';
-import { DocViewer } from '../doc_viewer/doc_viewer';
-import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types';
-import { DiscoverServices } from '../../../build_services';
-import { getContextUrl } from '../../helpers/get_context_url';
-import { getSingleDocUrl } from '../../helpers/get_single_doc_url';
+import { DocViewer } from '../../services/doc_views/components/doc_viewer/doc_viewer';
+import { DocViewFilterFn, ElasticSearchHit } from '../../services/doc_views/doc_views_types';
+import { DiscoverServices } from '../../build_services';
+import { getContextUrl } from '../../utils/get_context_url';
+import { getSingleDocUrl } from '../../utils/get_single_doc_url';
interface Props {
columns: string[];
diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_schema.ts b/src/plugins/discover/public/components/discover_grid/discover_grid_schema.ts
similarity index 94%
rename from src/plugins/discover/public/application/components/discover_grid/discover_grid_schema.ts
rename to src/plugins/discover/public/components/discover_grid/discover_grid_schema.ts
index 0aa6dadd633e0..5cf257fb16f2c 100644
--- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_schema.ts
+++ b/src/plugins/discover/public/components/discover_grid/discover_grid_schema.ts
@@ -7,7 +7,7 @@
*/
import { kibanaJSON } from './constants';
-import { KBN_FIELD_TYPES } from '../../../../../data/common';
+import { KBN_FIELD_TYPES } from '../../../../data/common';
export function getSchemaByKbnType(kbnType: string | undefined) {
// Default DataGrid schemas: boolean, numeric, datetime, json, currency, string
diff --git a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.test.tsx b/src/plugins/discover/public/components/discover_grid/get_render_cell_value.test.tsx
similarity index 98%
rename from src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.test.tsx
rename to src/plugins/discover/public/components/discover_grid/get_render_cell_value.test.tsx
index 3fb96ba9e9daa..260cbf42c4d8e 100644
--- a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.test.tsx
+++ b/src/plugins/discover/public/components/discover_grid/get_render_cell_value.test.tsx
@@ -9,18 +9,18 @@
import React from 'react';
import { ReactWrapper, shallow } from 'enzyme';
import { getRenderCellValueFn } from './get_render_cell_value';
-import { indexPatternMock } from '../../../__mocks__/index_pattern';
-import { ElasticSearchHit } from '../../doc_views/doc_views_types';
+import { indexPatternMock } from '../../__mocks__/index_pattern';
+import { ElasticSearchHit } from '../../services/doc_views/doc_views_types';
import { flattenHit } from 'src/plugins/data/common';
-jest.mock('../../../../../kibana_react/public', () => ({
+jest.mock('../../../../kibana_react/public', () => ({
useUiSetting: () => true,
withKibana: (comp: ReactWrapper) => {
return comp;
},
}));
-jest.mock('../../../kibana_services', () => ({
+jest.mock('../../kibana_services', () => ({
getServices: () => ({
uiSettings: {
get: jest.fn(),
diff --git a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx b/src/plugins/discover/public/components/discover_grid/get_render_cell_value.tsx
similarity index 96%
rename from src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx
rename to src/plugins/discover/public/components/discover_grid/get_render_cell_value.tsx
index 4066c13f6391e..bf7aaac1a86a2 100644
--- a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx
+++ b/src/plugins/discover/public/components/discover_grid/get_render_cell_value.tsx
@@ -17,13 +17,13 @@ import {
EuiDescriptionListTitle,
EuiDescriptionListDescription,
} from '@elastic/eui';
-import { ElasticSearchHit } from '../../doc_views/doc_views_types';
+import { ElasticSearchHit } from '../../services/doc_views/doc_views_types';
import { DiscoverGridContext } from './discover_grid_context';
import { JsonCodeEditor } from '../json_code_editor/json_code_editor';
import { defaultMonacoEditorWidth } from './constants';
-import { EsHitRecord } from '../../types';
-import { formatFieldValue } from '../../helpers/format_value';
-import { formatHit } from '../../helpers/format_hit';
+import { EsHitRecord } from '../../application/types';
+import { formatFieldValue } from '../../utils/format_value';
+import { formatHit } from '../../utils/format_hit';
export const getRenderCellValueFn =
(
diff --git a/src/plugins/discover/public/application/components/discover_grid/types.ts b/src/plugins/discover/public/components/discover_grid/types.ts
similarity index 100%
rename from src/plugins/discover/public/application/components/discover_grid/types.ts
rename to src/plugins/discover/public/components/discover_grid/types.ts
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/_doc_table.scss b/src/plugins/discover/public/components/doc_table/_doc_table.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/_doc_table.scss
rename to src/plugins/discover/public/components/doc_table/_doc_table.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/actions/columns.test.ts b/src/plugins/discover/public/components/doc_table/actions/columns.test.ts
similarity index 86%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/actions/columns.test.ts
rename to src/plugins/discover/public/components/doc_table/actions/columns.test.ts
index 93b38cfc6519c..5f3c7d203122f 100644
--- a/src/plugins/discover/public/application/apps/main/components/doc_table/actions/columns.test.ts
+++ b/src/plugins/discover/public/components/doc_table/actions/columns.test.ts
@@ -7,11 +7,11 @@
*/
import { getStateColumnActions } from './columns';
-import { configMock } from '../../../../../../__mocks__/config';
-import { indexPatternMock } from '../../../../../../__mocks__/index_pattern';
-import { indexPatternsMock } from '../../../../../../__mocks__/index_patterns';
-import { Capabilities } from '../../../../../../../../../core/types';
-import { AppState } from '../../../services/discover_state';
+import { configMock } from '../../../__mocks__/config';
+import { indexPatternMock } from '../../../__mocks__/index_pattern';
+import { indexPatternsMock } from '../../../__mocks__/index_patterns';
+import { Capabilities } from '../../../../../../core/types';
+import { AppState } from '../../../application/main/services/discover_state';
function getStateColumnAction(state: {}, setAppState: (state: Partial) => void) {
return getStateColumnActions({
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/actions/columns.ts b/src/plugins/discover/public/components/doc_table/actions/columns.ts
similarity index 93%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/actions/columns.ts
rename to src/plugins/discover/public/components/doc_table/actions/columns.ts
index 2fc82e25634bd..cb771cc2c6de3 100644
--- a/src/plugins/discover/public/application/apps/main/components/doc_table/actions/columns.ts
+++ b/src/plugins/discover/public/components/doc_table/actions/columns.ts
@@ -6,17 +6,17 @@
* Side Public License, v 1.
*/
import { Capabilities, IUiSettingsClient } from 'kibana/public';
-import { SORT_DEFAULT_ORDER_SETTING } from '../../../../../../../common';
+import { SORT_DEFAULT_ORDER_SETTING } from '../../../../common';
import {
AppState as DiscoverState,
GetStateReturn as DiscoverGetStateReturn,
-} from '../../../../../../application/apps/main/services/discover_state';
+} from '../../../application/main/services/discover_state';
import {
AppState as ContextState,
GetStateReturn as ContextGetStateReturn,
-} from '../../../../context/services/context_state';
-import { IndexPattern, IndexPatternsContract } from '../../../../../../../../data/public';
-import { popularizeField } from '../../../../../helpers/popularize_field';
+} from '../../../application/context/services/context_state';
+import { IndexPattern, IndexPatternsContract } from '../../../../../data/public';
+import { popularizeField } from '../../../utils/popularize_field';
/**
* Helper function to provide a fallback to a single _source column if the given array of columns
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/_index.scss b/src/plugins/discover/public/components/doc_table/components/_index.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/_index.scss
rename to src/plugins/discover/public/components/doc_table/components/_index.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/_table_header.scss b/src/plugins/discover/public/components/doc_table/components/_table_header.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/_table_header.scss
rename to src/plugins/discover/public/components/doc_table/components/_table_header.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/pager/tool_bar_pagination.tsx b/src/plugins/discover/public/components/doc_table/components/pager/tool_bar_pagination.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/pager/tool_bar_pagination.tsx
rename to src/plugins/discover/public/components/doc_table/components/pager/tool_bar_pagination.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_header/__snapshots__/table_header.test.tsx.snap b/src/plugins/discover/public/components/doc_table/components/table_header/__snapshots__/table_header.test.tsx.snap
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/table_header/__snapshots__/table_header.test.tsx.snap
rename to src/plugins/discover/public/components/doc_table/components/table_header/__snapshots__/table_header.test.tsx.snap
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_header/helpers.tsx b/src/plugins/discover/public/components/doc_table/components/table_header/helpers.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/table_header/helpers.tsx
rename to src/plugins/discover/public/components/doc_table/components/table_header/helpers.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_header/score_sort_warning.tsx b/src/plugins/discover/public/components/doc_table/components/table_header/score_sort_warning.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/table_header/score_sort_warning.tsx
rename to src/plugins/discover/public/components/doc_table/components/table_header/score_sort_warning.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_header/table_header.test.tsx b/src/plugins/discover/public/components/doc_table/components/table_header/table_header.test.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/table_header/table_header.test.tsx
rename to src/plugins/discover/public/components/doc_table/components/table_header/table_header.test.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_header/table_header.tsx b/src/plugins/discover/public/components/doc_table/components/table_header/table_header.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/table_header/table_header.tsx
rename to src/plugins/discover/public/components/doc_table/components/table_header/table_header.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_header/table_header_column.tsx b/src/plugins/discover/public/components/doc_table/components/table_header/table_header_column.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/table_header/table_header_column.tsx
rename to src/plugins/discover/public/components/doc_table/components/table_header/table_header_column.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row.test.tsx b/src/plugins/discover/public/components/doc_table/components/table_row.test.tsx
similarity index 85%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row.test.tsx
rename to src/plugins/discover/public/components/doc_table/components/table_row.test.tsx
index 887564168ac85..7b0e4d821af65 100644
--- a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row.test.tsx
+++ b/src/plugins/discover/public/components/doc_table/components/table_row.test.tsx
@@ -9,12 +9,12 @@
import React from 'react';
import { mountWithIntl, findTestSubject } from '@kbn/test/jest';
import { TableRow, TableRowProps } from './table_row';
-import { setDocViewsRegistry, setServices } from '../../../../../../kibana_services';
-import { createFilterManagerMock } from '../../../../../../../../data/public/query/filter_manager/filter_manager.mock';
-import { DiscoverServices } from '../../../../../../build_services';
-import { indexPatternWithTimefieldMock } from '../../../../../../__mocks__/index_pattern_with_timefield';
-import { uiSettingsMock } from '../../../../../../__mocks__/ui_settings';
-import { DocViewsRegistry } from '../../../../../doc_views/doc_views_registry';
+import { setDocViewsRegistry, setServices } from '../../../kibana_services';
+import { createFilterManagerMock } from '../../../../../data/public/query/filter_manager/filter_manager.mock';
+import { DiscoverServices } from '../../../build_services';
+import { indexPatternWithTimefieldMock } from '../../../__mocks__/index_pattern_with_timefield';
+import { uiSettingsMock } from '../../../__mocks__/ui_settings';
+import { DocViewsRegistry } from '../../../services/doc_views/doc_views_registry';
jest.mock('../lib/row_formatter', () => {
const originalModule = jest.requireActual('../lib/row_formatter');
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row.tsx b/src/plugins/discover/public/components/doc_table/components/table_row.tsx
similarity index 92%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row.tsx
rename to src/plugins/discover/public/components/doc_table/components/table_row.tsx
index 515782ce23f45..8a980cc4160d8 100644
--- a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row.tsx
+++ b/src/plugins/discover/public/components/doc_table/components/table_row.tsx
@@ -10,14 +10,14 @@ import React, { Fragment, useCallback, useMemo, useState } from 'react';
import classNames from 'classnames';
import { i18n } from '@kbn/i18n';
import { EuiButtonEmpty, EuiIcon } from '@elastic/eui';
-import { formatFieldValue } from '../../../../../helpers/format_value';
-import { flattenHit } from '../../../../../../../../data/common';
-import { DocViewer } from '../../../../../components/doc_viewer/doc_viewer';
-import { FilterManager, IndexPattern } from '../../../../../../../../data/public';
+import { formatFieldValue } from '../../../utils/format_value';
+import { flattenHit } from '../../../../../data/common';
+import { DocViewer } from '../../../services/doc_views/components/doc_viewer/doc_viewer';
+import { FilterManager, IndexPattern } from '../../../../../data/public';
import { TableCell } from './table_row/table_cell';
-import { ElasticSearchHit, DocViewFilterFn } from '../../../../../doc_views/doc_views_types';
-import { getContextUrl } from '../../../../../helpers/get_context_url';
-import { getSingleDocUrl } from '../../../../../helpers/get_single_doc_url';
+import { ElasticSearchHit, DocViewFilterFn } from '../../../services/doc_views/doc_views_types';
+import { getContextUrl } from '../../../utils/get_context_url';
+import { getSingleDocUrl } from '../../../utils/get_single_doc_url';
import { TableRowDetails } from './table_row_details';
import { formatRow, formatTopLevelObject } from '../lib/row_formatter';
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row/__snapshots__/table_cell.test.tsx.snap b/src/plugins/discover/public/components/doc_table/components/table_row/__snapshots__/table_cell.test.tsx.snap
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row/__snapshots__/table_cell.test.tsx.snap
rename to src/plugins/discover/public/components/doc_table/components/table_row/__snapshots__/table_cell.test.tsx.snap
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row/_cell.scss b/src/plugins/discover/public/components/doc_table/components/table_row/_cell.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row/_cell.scss
rename to src/plugins/discover/public/components/doc_table/components/table_row/_cell.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row/_details.scss b/src/plugins/discover/public/components/doc_table/components/table_row/_details.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row/_details.scss
rename to src/plugins/discover/public/components/doc_table/components/table_row/_details.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row/_index.scss b/src/plugins/discover/public/components/doc_table/components/table_row/_index.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row/_index.scss
rename to src/plugins/discover/public/components/doc_table/components/table_row/_index.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row/_open.scss b/src/plugins/discover/public/components/doc_table/components/table_row/_open.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row/_open.scss
rename to src/plugins/discover/public/components/doc_table/components/table_row/_open.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row/table_cell.test.tsx b/src/plugins/discover/public/components/doc_table/components/table_row/table_cell.test.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row/table_cell.test.tsx
rename to src/plugins/discover/public/components/doc_table/components/table_row/table_cell.test.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row/table_cell.tsx b/src/plugins/discover/public/components/doc_table/components/table_row/table_cell.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row/table_cell.tsx
rename to src/plugins/discover/public/components/doc_table/components/table_row/table_cell.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row/table_cell_actions.tsx b/src/plugins/discover/public/components/doc_table/components/table_row/table_cell_actions.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row/table_cell_actions.tsx
rename to src/plugins/discover/public/components/doc_table/components/table_row/table_cell_actions.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row_details.tsx b/src/plugins/discover/public/components/doc_table/components/table_row_details.tsx
similarity index 99%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row_details.tsx
rename to src/plugins/discover/public/components/doc_table/components/table_row_details.tsx
index c3ff53fe2d3a8..02d0ee4f2272a 100644
--- a/src/plugins/discover/public/application/apps/main/components/doc_table/components/table_row_details.tsx
+++ b/src/plugins/discover/public/components/doc_table/components/table_row_details.tsx
@@ -9,7 +9,6 @@
import React from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiLink, EuiTitle } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
-
interface TableRowDetailsProps {
open: boolean;
colLength: number;
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/create_doc_table_embeddable.tsx b/src/plugins/discover/public/components/doc_table/create_doc_table_embeddable.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/create_doc_table_embeddable.tsx
rename to src/plugins/discover/public/components/doc_table/create_doc_table_embeddable.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/doc_table_context.tsx b/src/plugins/discover/public/components/doc_table/doc_table_context.tsx
similarity index 92%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/doc_table_context.tsx
rename to src/plugins/discover/public/components/doc_table/doc_table_context.tsx
index 8d29efec73716..976d4e3d5bdf1 100644
--- a/src/plugins/discover/public/application/apps/main/components/doc_table/doc_table_context.tsx
+++ b/src/plugins/discover/public/components/doc_table/doc_table_context.tsx
@@ -8,7 +8,7 @@
import React, { Fragment } from 'react';
import './index.scss';
-import { SkipBottomButton } from '../skip_bottom_button';
+import { SkipBottomButton } from '../../application/main/components/skip_bottom_button';
import { DocTableProps, DocTableRenderProps, DocTableWrapper } from './doc_table_wrapper';
const DocTableWrapperMemoized = React.memo(DocTableWrapper);
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/doc_table_embeddable.tsx b/src/plugins/discover/public/components/doc_table/doc_table_embeddable.tsx
similarity index 95%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/doc_table_embeddable.tsx
rename to src/plugins/discover/public/components/doc_table/doc_table_embeddable.tsx
index 84edf147dea4c..0743c5ef813e8 100644
--- a/src/plugins/discover/public/application/apps/main/components/doc_table/doc_table_embeddable.tsx
+++ b/src/plugins/discover/public/components/doc_table/doc_table_embeddable.tsx
@@ -10,12 +10,12 @@ import React, { memo, useCallback, useEffect, useMemo, useRef } from 'react';
import './index.scss';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui';
-import { SAMPLE_SIZE_SETTING } from '../../../../../../common';
+import { SAMPLE_SIZE_SETTING } from '../../../common';
import { usePager } from './lib/use_pager';
import { ToolBarPagination } from './components/pager/tool_bar_pagination';
import { DocTableProps, DocTableRenderProps, DocTableWrapper } from './doc_table_wrapper';
-import { TotalDocuments } from '../total_documents/total_documents';
-import { getServices } from '../../../../../kibana_services';
+import { TotalDocuments } from '../../application/main/components/total_documents/total_documents';
+import { getServices } from '../../kibana_services';
export interface DocTableEmbeddableProps extends DocTableProps {
totalHitCount: number;
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/doc_table_infinite.tsx b/src/plugins/discover/public/components/doc_table/doc_table_infinite.tsx
similarity index 98%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/doc_table_infinite.tsx
rename to src/plugins/discover/public/components/doc_table/doc_table_infinite.tsx
index dddfefa906962..d2e93cdae452e 100644
--- a/src/plugins/discover/public/application/apps/main/components/doc_table/doc_table_infinite.tsx
+++ b/src/plugins/discover/public/components/doc_table/doc_table_infinite.tsx
@@ -12,7 +12,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { debounce } from 'lodash';
import { EuiButtonEmpty } from '@elastic/eui';
import { DocTableProps, DocTableRenderProps, DocTableWrapper } from './doc_table_wrapper';
-import { SkipBottomButton } from '../skip_bottom_button';
+import { SkipBottomButton } from '../../application/main/components/skip_bottom_button';
import { shouldLoadNextDocPatch } from './lib/should_load_next_doc_patch';
const FOOTER_PADDING = { padding: 0 };
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/doc_table_wrapper.test.tsx b/src/plugins/discover/public/components/doc_table/doc_table_wrapper.test.tsx
similarity index 92%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/doc_table_wrapper.test.tsx
rename to src/plugins/discover/public/components/doc_table/doc_table_wrapper.test.tsx
index df5869bd61e52..a17a5c9b87d73 100644
--- a/src/plugins/discover/public/application/apps/main/components/doc_table/doc_table_wrapper.test.tsx
+++ b/src/plugins/discover/public/components/doc_table/doc_table_wrapper.test.tsx
@@ -8,11 +8,11 @@
import React from 'react';
import { findTestSubject, mountWithIntl } from '@kbn/test/jest';
-import { setServices } from '../../../../../kibana_services';
-import { indexPatternMock } from '../../../../../__mocks__/index_pattern';
+import { setServices } from '../../kibana_services';
+import { indexPatternMock } from '../../__mocks__/index_pattern';
import { DocTableWrapper, DocTableWrapperProps } from './doc_table_wrapper';
import { DocTableRow } from './components/table_row';
-import { discoverServiceMock } from '../../../../../__mocks__/services';
+import { discoverServiceMock } from '../../__mocks__/services';
const mountComponent = (props: DocTableWrapperProps) => {
return mountWithIntl();
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/doc_table_wrapper.tsx b/src/plugins/discover/public/components/doc_table/doc_table_wrapper.tsx
similarity index 95%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/doc_table_wrapper.tsx
rename to src/plugins/discover/public/components/doc_table/doc_table_wrapper.tsx
index 2fac1c828796d..139b835e2e5c4 100644
--- a/src/plugins/discover/public/application/apps/main/components/doc_table/doc_table_wrapper.tsx
+++ b/src/plugins/discover/public/components/doc_table/doc_table_wrapper.tsx
@@ -11,18 +11,18 @@ 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';
+import { FORMATS_UI_SETTINGS } from '../../../../field_formats/common';
import {
DOC_HIDE_TIME_COLUMN_SETTING,
SAMPLE_SIZE_SETTING,
SHOW_MULTIFIELDS,
SORT_DEFAULT_ORDER_SETTING,
-} from '../../../../../../common';
-import { getServices } from '../../../../../kibana_services';
+} from '../../../common';
+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';
-import { getFieldsToShow } from '../../../../helpers/get_fields_to_show';
+import { DocViewFilterFn } from '../../services/doc_views/doc_views_types';
+import { getFieldsToShow } from '../../utils/get_fields_to_show';
export interface DocTableProps {
/**
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/index.scss b/src/plugins/discover/public/components/doc_table/index.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/index.scss
rename to src/plugins/discover/public/components/doc_table/index.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/index.ts b/src/plugins/discover/public/components/doc_table/index.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/index.ts
rename to src/plugins/discover/public/components/doc_table/index.ts
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/get_default_sort.test.ts b/src/plugins/discover/public/components/doc_table/lib/get_default_sort.test.ts
similarity index 95%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/lib/get_default_sort.test.ts
rename to src/plugins/discover/public/components/doc_table/lib/get_default_sort.test.ts
index 3a62108a16bef..68e7b43eceb9e 100644
--- a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/get_default_sort.test.ts
+++ b/src/plugins/discover/public/components/doc_table/lib/get_default_sort.test.ts
@@ -10,7 +10,7 @@ import { getDefaultSort } from './get_default_sort';
import {
stubIndexPattern,
stubIndexPatternWithoutTimeField,
-} from '../../../../../../../../data/common/stubs';
+} from '../../../../../data/common/stubs';
describe('getDefaultSort function', function () {
test('should be a function', function () {
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/get_default_sort.ts b/src/plugins/discover/public/components/doc_table/lib/get_default_sort.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/lib/get_default_sort.ts
rename to src/plugins/discover/public/components/doc_table/lib/get_default_sort.ts
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/get_sort.test.ts b/src/plugins/discover/public/components/doc_table/lib/get_sort.test.ts
similarity index 98%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/lib/get_sort.test.ts
rename to src/plugins/discover/public/components/doc_table/lib/get_sort.test.ts
index 9f7204805dc6f..7deb8075ac286 100644
--- a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/get_sort.test.ts
+++ b/src/plugins/discover/public/components/doc_table/lib/get_sort.test.ts
@@ -10,7 +10,7 @@ import { getSort, getSortArray } from './get_sort';
import {
stubIndexPattern,
stubIndexPatternWithoutTimeField,
-} from '../../../../../../../../data/common/stubs';
+} from '../../../../../data/common/stubs';
describe('docTable', function () {
describe('getSort function', function () {
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/get_sort.ts b/src/plugins/discover/public/components/doc_table/lib/get_sort.ts
similarity index 97%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/lib/get_sort.ts
rename to src/plugins/discover/public/components/doc_table/lib/get_sort.ts
index 1e597f85666fc..bdbb3703ff87d 100644
--- a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/get_sort.ts
+++ b/src/plugins/discover/public/components/doc_table/lib/get_sort.ts
@@ -7,7 +7,7 @@
*/
import { isPlainObject } from 'lodash';
-import { IndexPattern } from '../../../../../../../../data/public';
+import { IndexPattern } from '../../../../../data/public';
export type SortPairObj = Record;
export type SortPairArr = [string, string];
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/get_sort_for_search_source.test.ts b/src/plugins/discover/public/components/doc_table/lib/get_sort_for_search_source.test.ts
similarity index 97%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/lib/get_sort_for_search_source.test.ts
rename to src/plugins/discover/public/components/doc_table/lib/get_sort_for_search_source.test.ts
index 061a458037100..de032c3748fcb 100644
--- a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/get_sort_for_search_source.test.ts
+++ b/src/plugins/discover/public/components/doc_table/lib/get_sort_for_search_source.test.ts
@@ -11,7 +11,7 @@ import { SortOrder } from '../components/table_header/helpers';
import {
stubIndexPattern,
stubIndexPatternWithoutTimeField,
-} from '../../../../../../../../data/common/stubs';
+} from '../../../../../data/common/stubs';
describe('getSortForSearchSource function', function () {
test('should be a function', function () {
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/get_sort_for_search_source.ts b/src/plugins/discover/public/components/doc_table/lib/get_sort_for_search_source.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/lib/get_sort_for_search_source.ts
rename to src/plugins/discover/public/components/doc_table/lib/get_sort_for_search_source.ts
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/row_formatter.scss b/src/plugins/discover/public/components/doc_table/lib/row_formatter.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/lib/row_formatter.scss
rename to src/plugins/discover/public/components/doc_table/lib/row_formatter.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/row_formatter.test.ts b/src/plugins/discover/public/components/doc_table/lib/row_formatter.test.ts
similarity index 95%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/lib/row_formatter.test.ts
rename to src/plugins/discover/public/components/doc_table/lib/row_formatter.test.ts
index 2e777a18ce906..ada9c1682a35b 100644
--- a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/row_formatter.test.ts
+++ b/src/plugins/discover/public/components/doc_table/lib/row_formatter.test.ts
@@ -8,11 +8,11 @@
import ReactDOM from 'react-dom/server';
import { formatRow, formatTopLevelObject } from './row_formatter';
-import { IndexPattern } from '../../../../../../../../data/common';
-import { fieldFormatsMock } from '../../../../../../../../field_formats/common/mocks';
-import { setServices } from '../../../../../../kibana_services';
-import { DiscoverServices } from '../../../../../../build_services';
-import { stubbedSavedObjectIndexPattern } from '../../../../../../../../data/common/stubs';
+import { IndexPattern } from '../../../../../data/common';
+import { fieldFormatsMock } from '../../../../../field_formats/common/mocks';
+import { setServices } from '../../../kibana_services';
+import { DiscoverServices } from '../../../build_services';
+import { stubbedSavedObjectIndexPattern } from '../../../../../data/common/stubs';
describe('Row formatter', () => {
const hit = {
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/row_formatter.tsx b/src/plugins/discover/public/components/doc_table/lib/row_formatter.tsx
similarity index 93%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/lib/row_formatter.tsx
rename to src/plugins/discover/public/components/doc_table/lib/row_formatter.tsx
index d5660a091f0aa..0ec611a307513 100644
--- a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/row_formatter.tsx
+++ b/src/plugins/discover/public/components/doc_table/lib/row_formatter.tsx
@@ -9,9 +9,9 @@
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import React, { Fragment } from 'react';
import type { IndexPattern } from 'src/plugins/data/common';
-import { MAX_DOC_FIELDS_DISPLAYED } from '../../../../../../../common';
-import { getServices } from '../../../../../../kibana_services';
-import { formatHit } from '../../../../../helpers/format_hit';
+import { MAX_DOC_FIELDS_DISPLAYED } from '../../../../common';
+import { getServices } from '../../../kibana_services';
+import { formatHit } from '../../../utils/format_hit';
import './row_formatter.scss';
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/should_load_next_doc_patch.test.ts b/src/plugins/discover/public/components/doc_table/lib/should_load_next_doc_patch.test.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/lib/should_load_next_doc_patch.test.ts
rename to src/plugins/discover/public/components/doc_table/lib/should_load_next_doc_patch.test.ts
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/should_load_next_doc_patch.ts b/src/plugins/discover/public/components/doc_table/lib/should_load_next_doc_patch.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/lib/should_load_next_doc_patch.ts
rename to src/plugins/discover/public/components/doc_table/lib/should_load_next_doc_patch.ts
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/use_pager.test.tsx b/src/plugins/discover/public/components/doc_table/lib/use_pager.test.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/lib/use_pager.test.tsx
rename to src/plugins/discover/public/components/doc_table/lib/use_pager.test.tsx
diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/use_pager.ts b/src/plugins/discover/public/components/doc_table/lib/use_pager.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/doc_table/lib/use_pager.ts
rename to src/plugins/discover/public/components/doc_table/lib/use_pager.ts
diff --git a/src/plugins/discover/public/application/components/field_name/__snapshots__/field_name.test.tsx.snap b/src/plugins/discover/public/components/field_name/__snapshots__/field_name.test.tsx.snap
similarity index 100%
rename from src/plugins/discover/public/application/components/field_name/__snapshots__/field_name.test.tsx.snap
rename to src/plugins/discover/public/components/field_name/__snapshots__/field_name.test.tsx.snap
diff --git a/src/plugins/discover/public/application/components/field_name/field_name.scss b/src/plugins/discover/public/components/field_name/field_name.scss
similarity index 100%
rename from src/plugins/discover/public/application/components/field_name/field_name.scss
rename to src/plugins/discover/public/components/field_name/field_name.scss
diff --git a/src/plugins/discover/public/application/components/field_name/field_name.test.tsx b/src/plugins/discover/public/components/field_name/field_name.test.tsx
similarity index 100%
rename from src/plugins/discover/public/application/components/field_name/field_name.test.tsx
rename to src/plugins/discover/public/components/field_name/field_name.test.tsx
diff --git a/src/plugins/discover/public/application/components/field_name/field_name.tsx b/src/plugins/discover/public/components/field_name/field_name.tsx
similarity index 92%
rename from src/plugins/discover/public/application/components/field_name/field_name.tsx
rename to src/plugins/discover/public/components/field_name/field_name.tsx
index 0e8ca31f6379a..b7a87875c64e3 100644
--- a/src/plugins/discover/public/application/components/field_name/field_name.tsx
+++ b/src/plugins/discover/public/components/field_name/field_name.tsx
@@ -11,10 +11,10 @@ import './field_name.scss';
import { EuiBadge, EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
-import { FieldIcon, FieldIconProps } from '../../../../../kibana_react/public';
+import { FieldIcon, FieldIconProps } from '../../../../kibana_react/public';
import { getFieldTypeName } from './field_type_name';
-import { IndexPatternField } from '../../../../../data/public';
-import { getFieldSubtypeMulti } from '../../../../../data/common';
+import { IndexPatternField } from '../../../../data/public';
+import { getFieldSubtypeMulti } from '../../../../data/common';
interface Props {
fieldName: string;
diff --git a/src/plugins/discover/public/application/components/field_name/field_type_name.ts b/src/plugins/discover/public/components/field_name/field_type_name.ts
similarity index 100%
rename from src/plugins/discover/public/application/components/field_name/field_type_name.ts
rename to src/plugins/discover/public/components/field_name/field_type_name.ts
diff --git a/src/plugins/discover/public/application/components/help_menu/help_menu_util.ts b/src/plugins/discover/public/components/help_menu/help_menu_util.ts
similarity index 100%
rename from src/plugins/discover/public/application/components/help_menu/help_menu_util.ts
rename to src/plugins/discover/public/components/help_menu/help_menu_util.ts
diff --git a/src/plugins/discover/public/components/index.ts b/src/plugins/discover/public/components/index.ts
new file mode 100644
index 0000000000000..a794b8c90a477
--- /dev/null
+++ b/src/plugins/discover/public/components/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 { DeferredSpinner } from './common/deferred_spinner';
diff --git a/src/plugins/discover/public/application/components/json_code_editor/__snapshots__/json_code_editor.test.tsx.snap b/src/plugins/discover/public/components/json_code_editor/__snapshots__/json_code_editor.test.tsx.snap
similarity index 100%
rename from src/plugins/discover/public/application/components/json_code_editor/__snapshots__/json_code_editor.test.tsx.snap
rename to src/plugins/discover/public/components/json_code_editor/__snapshots__/json_code_editor.test.tsx.snap
diff --git a/src/plugins/discover/public/application/components/json_code_editor/json_code_editor.scss b/src/plugins/discover/public/components/json_code_editor/json_code_editor.scss
similarity index 100%
rename from src/plugins/discover/public/application/components/json_code_editor/json_code_editor.scss
rename to src/plugins/discover/public/components/json_code_editor/json_code_editor.scss
diff --git a/src/plugins/discover/public/application/components/json_code_editor/json_code_editor.test.tsx b/src/plugins/discover/public/components/json_code_editor/json_code_editor.test.tsx
similarity index 100%
rename from src/plugins/discover/public/application/components/json_code_editor/json_code_editor.test.tsx
rename to src/plugins/discover/public/components/json_code_editor/json_code_editor.test.tsx
diff --git a/src/plugins/discover/public/application/components/json_code_editor/json_code_editor.tsx b/src/plugins/discover/public/components/json_code_editor/json_code_editor.tsx
similarity index 100%
rename from src/plugins/discover/public/application/components/json_code_editor/json_code_editor.tsx
rename to src/plugins/discover/public/components/json_code_editor/json_code_editor.tsx
diff --git a/src/plugins/discover/public/application/components/json_code_editor/json_code_editor_common.tsx b/src/plugins/discover/public/components/json_code_editor/json_code_editor_common.tsx
similarity index 97%
rename from src/plugins/discover/public/application/components/json_code_editor/json_code_editor_common.tsx
rename to src/plugins/discover/public/components/json_code_editor/json_code_editor_common.tsx
index cab4eae41afb8..07d3ec2e759a3 100644
--- a/src/plugins/discover/public/application/components/json_code_editor/json_code_editor_common.tsx
+++ b/src/plugins/discover/public/components/json_code_editor/json_code_editor_common.tsx
@@ -12,7 +12,7 @@ import React from 'react';
import { i18n } from '@kbn/i18n';
import { monaco, XJsonLang } from '@kbn/monaco';
import { EuiButtonEmpty, EuiCopy, EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui';
-import { CodeEditor } from '../../../../../kibana_react/public';
+import { CodeEditor } from '../../../../kibana_react/public';
const codeEditorAriaLabel = i18n.translate('discover.json.codeEditorAriaLabel', {
defaultMessage: 'Read only JSON view of an elasticsearch document',
diff --git a/src/plugins/discover/public/application/apps/main/components/view_mode_toggle/_index.scss b/src/plugins/discover/public/components/view_mode_toggle/_index.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/view_mode_toggle/_index.scss
rename to src/plugins/discover/public/components/view_mode_toggle/_index.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/view_mode_toggle/_view_mode_toggle.scss b/src/plugins/discover/public/components/view_mode_toggle/_view_mode_toggle.scss
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/view_mode_toggle/_view_mode_toggle.scss
rename to src/plugins/discover/public/components/view_mode_toggle/_view_mode_toggle.scss
diff --git a/src/plugins/discover/public/application/apps/main/components/view_mode_toggle/constants.ts b/src/plugins/discover/public/components/view_mode_toggle/constants.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/view_mode_toggle/constants.ts
rename to src/plugins/discover/public/components/view_mode_toggle/constants.ts
diff --git a/src/plugins/discover/public/application/apps/main/components/view_mode_toggle/index.ts b/src/plugins/discover/public/components/view_mode_toggle/index.ts
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/view_mode_toggle/index.ts
rename to src/plugins/discover/public/components/view_mode_toggle/index.ts
diff --git a/src/plugins/discover/public/application/apps/main/components/view_mode_toggle/view_mode_toggle.tsx b/src/plugins/discover/public/components/view_mode_toggle/view_mode_toggle.tsx
similarity index 100%
rename from src/plugins/discover/public/application/apps/main/components/view_mode_toggle/view_mode_toggle.tsx
rename to src/plugins/discover/public/components/view_mode_toggle/view_mode_toggle.tsx
diff --git a/src/plugins/discover/public/application/embeddable/constants.ts b/src/plugins/discover/public/embeddable/constants.ts
similarity index 84%
rename from src/plugins/discover/public/application/embeddable/constants.ts
rename to src/plugins/discover/public/embeddable/constants.ts
index 57ff91049cd0d..6c9de47a0f710 100644
--- a/src/plugins/discover/public/application/embeddable/constants.ts
+++ b/src/plugins/discover/public/embeddable/constants.ts
@@ -6,4 +6,4 @@
* Side Public License, v 1.
*/
-export { SEARCH_EMBEDDABLE_TYPE } from '../../../common/index';
+export { SEARCH_EMBEDDABLE_TYPE } from '../../common';
diff --git a/src/plugins/discover/public/application/embeddable/index.ts b/src/plugins/discover/public/embeddable/index.ts
similarity index 100%
rename from src/plugins/discover/public/application/embeddable/index.ts
rename to src/plugins/discover/public/embeddable/index.ts
diff --git a/src/plugins/discover/public/application/embeddable/saved_search_embeddable.tsx b/src/plugins/discover/public/embeddable/saved_search_embeddable.tsx
similarity index 92%
rename from src/plugins/discover/public/application/embeddable/saved_search_embeddable.tsx
rename to src/plugins/discover/public/embeddable/saved_search_embeddable.tsx
index 808962dc8319d..914b9f25d29ae 100644
--- a/src/plugins/discover/public/application/embeddable/saved_search_embeddable.tsx
+++ b/src/plugins/discover/public/embeddable/saved_search_embeddable.tsx
@@ -11,13 +11,13 @@ import React from 'react';
import ReactDOM from 'react-dom';
import { i18n } from '@kbn/i18n';
import { isEqual } from 'lodash';
-import { Container, Embeddable } from '../../../../embeddable/public';
+import { Container, Embeddable } from '../../../embeddable/public';
import { ISearchEmbeddable, SearchInput, SearchOutput } from './types';
-import { SavedSearch } from '../../saved_searches';
-import { Adapters, RequestAdapter } from '../../../../inspector/common';
+import { SavedSearch } from '../services/saved_searches';
+import { Adapters, RequestAdapter } from '../../../inspector/common';
import { SEARCH_EMBEDDABLE_TYPE } from './constants';
-import { APPLY_FILTER_TRIGGER, esFilters, FilterManager } from '../../../../data/public';
-import { DiscoverServices } from '../../build_services';
+import { APPLY_FILTER_TRIGGER, esFilters, FilterManager } from '../../../data/public';
+import { DiscoverServices } from '../build_services';
import {
Filter,
IndexPattern,
@@ -25,11 +25,11 @@ import {
ISearchSource,
Query,
TimeRange,
-} from '../../../../data/common';
-import { ElasticSearchHit } from '../doc_views/doc_views_types';
+} from '../../../data/common';
+import { ElasticSearchHit } from '../services/doc_views/doc_views_types';
import { SavedSearchEmbeddableComponent } from './saved_search_embeddable_component';
-import { UiActionsStart } from '../../../../ui_actions/public';
-import { getServices } from '../../kibana_services';
+import { UiActionsStart } from '../../../ui_actions/public';
+import { getServices } from '../kibana_services';
import {
DOC_HIDE_TIME_COLUMN_SETTING,
DOC_TABLE_LEGACY,
@@ -37,16 +37,16 @@ import {
SEARCH_FIELDS_FROM_SOURCE,
SHOW_FIELD_STATISTICS,
SORT_DEFAULT_ORDER_SETTING,
-} from '../../../common';
-import * as columnActions from '../apps/main/components/doc_table/actions/columns';
-import { handleSourceColumnState } from '../helpers/state_helpers';
+} from '../../common';
+import * as columnActions from '../components/doc_table/actions/columns';
+import { handleSourceColumnState } from '../utils/state_helpers';
import { DiscoverGridProps } from '../components/discover_grid/discover_grid';
import { DiscoverGridSettings } from '../components/discover_grid/types';
-import { DocTableProps } from '../apps/main/components/doc_table/doc_table_wrapper';
-import { getDefaultSort } from '../apps/main/components/doc_table';
-import { SortOrder } from '../apps/main/components/doc_table/components/table_header/helpers';
-import { updateSearchSource } from './helpers/update_search_source';
-import { VIEW_MODE } from '../apps/main/components/view_mode_toggle';
+import { DocTableProps } from '../components/doc_table/doc_table_wrapper';
+import { getDefaultSort } from '../components/doc_table';
+import { SortOrder } from '../components/doc_table/components/table_header/helpers';
+import { updateSearchSource } from './utils/update_search_source';
+import { VIEW_MODE } from '../components/view_mode_toggle';
import { FieldStatsTableEmbeddable } from '../components/data_visualizer_grid/field_stats_table_embeddable';
export type SearchProps = Partial &
diff --git a/src/plugins/discover/public/application/embeddable/saved_search_embeddable_component.tsx b/src/plugins/discover/public/embeddable/saved_search_embeddable_component.tsx
similarity index 86%
rename from src/plugins/discover/public/application/embeddable/saved_search_embeddable_component.tsx
rename to src/plugins/discover/public/embeddable/saved_search_embeddable_component.tsx
index 058794fa59a18..5d7907d3cf791 100644
--- a/src/plugins/discover/public/application/embeddable/saved_search_embeddable_component.tsx
+++ b/src/plugins/discover/public/embeddable/saved_search_embeddable_component.tsx
@@ -9,8 +9,8 @@
import React from 'react';
import { DiscoverGridEmbeddable, DiscoverGridEmbeddableProps } from './saved_search_grid';
-import { DiscoverDocTableEmbeddable } from '../apps/main/components/doc_table/create_doc_table_embeddable';
-import { DocTableEmbeddableProps } from '../apps/main/components/doc_table/doc_table_embeddable';
+import { DiscoverDocTableEmbeddable } from '../components/doc_table/create_doc_table_embeddable';
+import { DocTableEmbeddableProps } from '../components/doc_table/doc_table_embeddable';
import { SearchProps } from './saved_search_embeddable';
interface SavedSearchEmbeddableComponentProps {
diff --git a/src/plugins/discover/public/application/embeddable/saved_search_grid.tsx b/src/plugins/discover/public/embeddable/saved_search_grid.tsx
similarity index 88%
rename from src/plugins/discover/public/application/embeddable/saved_search_grid.tsx
rename to src/plugins/discover/public/embeddable/saved_search_grid.tsx
index 0dce6d2b3abe8..e4d4bf64a74f1 100644
--- a/src/plugins/discover/public/application/embeddable/saved_search_grid.tsx
+++ b/src/plugins/discover/public/embeddable/saved_search_grid.tsx
@@ -9,9 +9,9 @@ import React, { useState } from 'react';
import { I18nProvider } from '@kbn/i18n/react';
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { DiscoverGrid, DiscoverGridProps } from '../components/discover_grid/discover_grid';
-import { getServices } from '../../kibana_services';
-import { ElasticSearchHit } from '../doc_views/doc_views_types';
-import { TotalDocuments } from '../apps/main/components/total_documents/total_documents';
+import { getServices } from '../kibana_services';
+import { ElasticSearchHit } from '../services/doc_views/doc_views_types';
+import { TotalDocuments } from '../application/main/components/total_documents/total_documents';
export interface DiscoverGridEmbeddableProps extends DiscoverGridProps {
totalHitCount: number;
diff --git a/src/plugins/discover/public/application/embeddable/search_embeddable.scss b/src/plugins/discover/public/embeddable/search_embeddable.scss
similarity index 100%
rename from src/plugins/discover/public/application/embeddable/search_embeddable.scss
rename to src/plugins/discover/public/embeddable/search_embeddable.scss
diff --git a/src/plugins/discover/public/application/embeddable/search_embeddable_factory.ts b/src/plugins/discover/public/embeddable/search_embeddable_factory.ts
similarity index 94%
rename from src/plugins/discover/public/application/embeddable/search_embeddable_factory.ts
rename to src/plugins/discover/public/embeddable/search_embeddable_factory.ts
index a8b492d368768..8fbedf3979663 100644
--- a/src/plugins/discover/public/application/embeddable/search_embeddable_factory.ts
+++ b/src/plugins/discover/public/embeddable/search_embeddable_factory.ts
@@ -8,14 +8,14 @@
import { i18n } from '@kbn/i18n';
import { UiActionsStart } from 'src/plugins/ui_actions/public';
-import { getServices } from '../../kibana_services';
+import { getServices } from '../kibana_services';
import {
EmbeddableFactoryDefinition,
Container,
ErrorEmbeddable,
-} from '../../../../embeddable/public';
+} from '../../../embeddable/public';
-import { TimeRange } from '../../../../data/public';
+import { TimeRange } from '../../../data/public';
import { SearchInput, SearchOutput } from './types';
import { SEARCH_EMBEDDABLE_TYPE } from './constants';
@@ -24,7 +24,7 @@ import {
getSavedSearch,
getSavedSearchUrl,
throwErrorOnSavedSearchUrlConflict,
-} from '../../saved_searches';
+} from '../services/saved_searches';
interface StartServices {
executeTriggerActions: UiActionsStart['executeTriggerActions'];
diff --git a/src/plugins/discover/public/application/embeddable/types.ts b/src/plugins/discover/public/embeddable/types.ts
similarity index 86%
rename from src/plugins/discover/public/application/embeddable/types.ts
rename to src/plugins/discover/public/embeddable/types.ts
index de109e3fa7879..bf9cc6e4954fe 100644
--- a/src/plugins/discover/public/application/embeddable/types.ts
+++ b/src/plugins/discover/public/embeddable/types.ts
@@ -12,9 +12,9 @@ import {
EmbeddableOutput,
IEmbeddable,
} from 'src/plugins/embeddable/public';
-import { Filter, IndexPattern, TimeRange, Query } from '../../../../data/public';
-import { SavedSearch } from '../../saved_searches';
-import { SortOrder } from '../apps/main/components/doc_table/components/table_header/helpers';
+import { Filter, IndexPattern, TimeRange, Query } from '../../../data/public';
+import { SavedSearch } from '../services/saved_searches';
+import { SortOrder } from '../components/doc_table/components/table_header/helpers';
export interface SearchInput extends EmbeddableInput {
timeRange: TimeRange;
diff --git a/src/plugins/discover/public/application/embeddable/helpers/update_search_source.test.ts b/src/plugins/discover/public/embeddable/utils/update_search_source.test.ts
similarity index 85%
rename from src/plugins/discover/public/application/embeddable/helpers/update_search_source.test.ts
rename to src/plugins/discover/public/embeddable/utils/update_search_source.test.ts
index f09131cb5c926..cd2f6cf88cfa3 100644
--- a/src/plugins/discover/public/application/embeddable/helpers/update_search_source.test.ts
+++ b/src/plugins/discover/public/embeddable/utils/update_search_source.test.ts
@@ -5,10 +5,10 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
-import { createSearchSourceMock } from '../../../../../data/common/search/search_source/mocks';
+import { createSearchSourceMock } from '../../../../data/common/search/search_source/mocks';
import { updateSearchSource } from './update_search_source';
-import { indexPatternMock } from '../../../__mocks__/index_pattern';
-import type { SortOrder } from '../../../saved_searches';
+import { indexPatternMock } from '../../__mocks__/index_pattern';
+import type { SortOrder } from '../../services/saved_searches';
describe('updateSearchSource', () => {
const defaults = {
diff --git a/src/plugins/discover/public/application/embeddable/helpers/update_search_source.ts b/src/plugins/discover/public/embeddable/utils/update_search_source.ts
similarity index 81%
rename from src/plugins/discover/public/application/embeddable/helpers/update_search_source.ts
rename to src/plugins/discover/public/embeddable/utils/update_search_source.ts
index 1d6c29d65ca85..7e24f96d503e8 100644
--- a/src/plugins/discover/public/application/embeddable/helpers/update_search_source.ts
+++ b/src/plugins/discover/public/embeddable/utils/update_search_source.ts
@@ -6,9 +6,9 @@
* Side Public License, v 1.
*/
-import { IndexPattern, ISearchSource } from '../../../../../data/common';
-import { getSortForSearchSource } from '../../apps/main/components/doc_table';
-import { SortPairArr } from '../../apps/main/components/doc_table/lib/get_sort';
+import { IndexPattern, ISearchSource } from '../../../../data/common';
+import { getSortForSearchSource } from '../../components/doc_table';
+import { SortPairArr } from '../../components/doc_table/lib/get_sort';
export const updateSearchSource = (
searchSource: ISearchSource,
diff --git a/src/plugins/discover/public/application/embeddable/view_saved_search_action.test.ts b/src/plugins/discover/public/embeddable/view_saved_search_action.test.ts
similarity index 89%
rename from src/plugins/discover/public/application/embeddable/view_saved_search_action.test.ts
rename to src/plugins/discover/public/embeddable/view_saved_search_action.test.ts
index 990be8927766a..f0dbc0d1d7a57 100644
--- a/src/plugins/discover/public/application/embeddable/view_saved_search_action.test.ts
+++ b/src/plugins/discover/public/embeddable/view_saved_search_action.test.ts
@@ -10,15 +10,15 @@ import { ContactCardEmbeddable } from 'src/plugins/embeddable/public/lib/test_sa
import { ViewSavedSearchAction } from './view_saved_search_action';
import { SavedSearchEmbeddable } from './saved_search_embeddable';
-import { createStartContractMock } from '../../__mocks__/start_contract';
-import { uiSettingsServiceMock } from '../../../../../core/public/mocks';
-import { savedSearchMock } from '../../__mocks__/saved_search';
-import { discoverServiceMock } from '../../__mocks__/services';
+import { createStartContractMock } from '../__mocks__/start_contract';
+import { uiSettingsServiceMock } from '../../../../core/public/mocks';
+import { savedSearchMock } from '../__mocks__/saved_search';
+import { discoverServiceMock } from '../__mocks__/services';
import { IndexPattern } from 'src/plugins/data/common';
import { createFilterManagerMock } from 'src/plugins/data/public/query/filter_manager/filter_manager.mock';
import { ViewMode } from 'src/plugins/embeddable/public';
-import { setServices } from '../../kibana_services';
-import type { DiscoverServices } from '../../build_services';
+import { setServices } from '../kibana_services';
+import type { DiscoverServices } from '../build_services';
const applicationMock = createStartContractMock();
const savedSearch = savedSearchMock;
diff --git a/src/plugins/discover/public/application/embeddable/view_saved_search_action.ts b/src/plugins/discover/public/embeddable/view_saved_search_action.ts
similarity index 89%
rename from src/plugins/discover/public/application/embeddable/view_saved_search_action.ts
rename to src/plugins/discover/public/embeddable/view_saved_search_action.ts
index e4b97d011ff64..b9bbc21cfef2c 100644
--- a/src/plugins/discover/public/application/embeddable/view_saved_search_action.ts
+++ b/src/plugins/discover/public/embeddable/view_saved_search_action.ts
@@ -8,11 +8,11 @@
import { ActionExecutionContext } from 'src/plugins/ui_actions/public';
import { ApplicationStart } from 'kibana/public';
import { i18n } from '@kbn/i18n';
-import { IEmbeddable, ViewMode } from '../../../../embeddable/public';
-import { Action } from '../../../../ui_actions/public';
+import { IEmbeddable, ViewMode } from '../../../embeddable/public';
+import { Action } from '../../../ui_actions/public';
import { SavedSearchEmbeddable } from './saved_search_embeddable';
-import { SEARCH_EMBEDDABLE_TYPE } from '../../../common';
-import { getSavedSearchUrl } from '../../saved_searches';
+import { SEARCH_EMBEDDABLE_TYPE } from '../../common';
+import { getSavedSearchUrl } from '../services/saved_searches';
export const ACTION_VIEW_SAVED_SEARCH = 'ACTION_VIEW_SAVED_SEARCH';
diff --git a/src/plugins/discover/public/index.ts b/src/plugins/discover/public/index.ts
index cb7b29afe3f9a..e7abbdfc328ab 100644
--- a/src/plugins/discover/public/index.ts
+++ b/src/plugins/discover/public/index.ts
@@ -9,23 +9,23 @@
import { PluginInitializerContext } from 'kibana/public';
import { DiscoverPlugin } from './plugin';
-export type { SavedSearch } from './saved_searches';
+export type { SavedSearch } from './services/saved_searches';
export {
getSavedSearch,
getSavedSearchFullPathUrl,
getSavedSearchUrl,
getSavedSearchUrlConflictMessage,
throwErrorOnSavedSearchUrlConflict,
-} from './saved_searches';
+} from './services/saved_searches';
export type { DiscoverSetup, DiscoverStart } from './plugin';
export function plugin(initializerContext: PluginInitializerContext) {
return new DiscoverPlugin(initializerContext);
}
-export type { ISearchEmbeddable, SearchInput } from './application/embeddable';
-export { SEARCH_EMBEDDABLE_TYPE } from './application/embeddable';
-export { loadSharingDataHelpers } from './shared';
+export type { ISearchEmbeddable, SearchInput } from './embeddable';
+export { SEARCH_EMBEDDABLE_TYPE } from './embeddable';
+export { loadSharingDataHelpers } from './utils';
export type { DiscoverUrlGeneratorState } from './url_generator';
export { DISCOVER_APP_URL_GENERATOR } from './url_generator';
diff --git a/src/plugins/discover/public/kibana_services.ts b/src/plugins/discover/public/kibana_services.ts
index c68d6fbf479a1..12b0a77a7865d 100644
--- a/src/plugins/discover/public/kibana_services.ts
+++ b/src/plugins/discover/public/kibana_services.ts
@@ -12,7 +12,7 @@ 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 { DocViewsRegistry } from './application/doc_views/doc_views_registry';
+import { DocViewsRegistry } from './services/doc_views/doc_views_registry';
let services: DiscoverServices | null = null;
let uiActions: UiActionsStart;
diff --git a/src/plugins/discover/public/plugin.tsx b/src/plugins/discover/public/plugin.tsx
index 62a5a7972a278..766b2827c7cbd 100644
--- a/src/plugins/discover/public/plugin.tsx
+++ b/src/plugins/discover/public/plugin.tsx
@@ -33,8 +33,8 @@ import { SavedObjectsStart } from '../../saved_objects/public';
import { createKbnUrlTracker } from '../../kibana_utils/public';
import { DEFAULT_APP_CATEGORIES } from '../../../core/public';
import { UrlGeneratorState } from '../../share/public';
-import { DocViewInput, DocViewInputFn } from './application/doc_views/doc_views_types';
-import { DocViewsRegistry } from './application/doc_views/doc_views_registry';
+import { DocViewInput, DocViewInputFn } from './services/doc_views/doc_views_types';
+import { DocViewsRegistry } from './services/doc_views/doc_views_registry';
import {
setDocViewsRegistry,
setUrlTracker,
@@ -54,15 +54,15 @@ import {
SEARCH_SESSION_ID_QUERY_PARAM,
} from './url_generator';
import { DiscoverAppLocatorDefinition, DiscoverAppLocator } from './locator';
-import { SearchEmbeddableFactory } from './application/embeddable';
+import { SearchEmbeddableFactory } from './embeddable';
import { UsageCollectionSetup } from '../../usage_collection/public';
import { replaceUrlHashQuery } from '../../kibana_utils/public/';
import { IndexPatternFieldEditorStart } from '../../../plugins/index_pattern_field_editor/public';
-import { DeferredSpinner } from './shared';
-import { ViewSavedSearchAction } from './application/embeddable/view_saved_search_action';
+import { DeferredSpinner } from './components';
+import { ViewSavedSearchAction } from './embeddable/view_saved_search_action';
import type { SpacesPluginStart } from '../../../../x-pack/plugins/spaces/public';
import { FieldFormatsStart } from '../../field_formats/public';
-import { injectTruncateStyles } from './application/helpers/truncate_styles';
+import { injectTruncateStyles } from './utils/truncate_styles';
import { TRUNCATE_MAX_HEIGHT } from '../common';
declare module '../../share/public' {
@@ -71,11 +71,8 @@ declare module '../../share/public' {
}
}
-const DocViewerTable = React.lazy(() => import('./application/components/table/table'));
-
-const SourceViewer = React.lazy(
- () => import('./application/components/source_viewer/source_viewer')
-);
+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
@@ -350,11 +347,9 @@ export class DiscoverPlugin
await depsStart.data.indexPatterns.clearCache();
const { renderApp } = await import('./application');
-
// FIXME: Temporarily hide overflow-y in Discover app when Field Stats table is shown
// due to EUI bug https://github.com/elastic/eui/pull/5152
params.element.classList.add('dscAppWrapper');
-
const unmount = renderApp(params.element);
return () => {
unlistenParentHistory();
diff --git a/src/plugins/discover/public/application/components/doc_viewer/__snapshots__/doc_viewer.test.tsx.snap b/src/plugins/discover/public/services/doc_views/components/doc_viewer/__snapshots__/doc_viewer.test.tsx.snap
similarity index 100%
rename from src/plugins/discover/public/application/components/doc_viewer/__snapshots__/doc_viewer.test.tsx.snap
rename to src/plugins/discover/public/services/doc_views/components/doc_viewer/__snapshots__/doc_viewer.test.tsx.snap
diff --git a/src/plugins/discover/public/application/components/doc_viewer/__snapshots__/doc_viewer_render_tab.test.tsx.snap b/src/plugins/discover/public/services/doc_views/components/doc_viewer/__snapshots__/doc_viewer_render_tab.test.tsx.snap
similarity index 100%
rename from src/plugins/discover/public/application/components/doc_viewer/__snapshots__/doc_viewer_render_tab.test.tsx.snap
rename to src/plugins/discover/public/services/doc_views/components/doc_viewer/__snapshots__/doc_viewer_render_tab.test.tsx.snap
diff --git a/src/plugins/discover/public/application/components/doc_viewer/doc_viewer.scss b/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer.scss
similarity index 100%
rename from src/plugins/discover/public/application/components/doc_viewer/doc_viewer.scss
rename to src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer.scss
diff --git a/src/plugins/discover/public/application/components/doc_viewer/doc_viewer.test.tsx b/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer.test.tsx
similarity index 93%
rename from src/plugins/discover/public/application/components/doc_viewer/doc_viewer.test.tsx
rename to src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer.test.tsx
index de0353a020a67..bedf1047bc4ec 100644
--- a/src/plugins/discover/public/application/components/doc_viewer/doc_viewer.test.tsx
+++ b/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer.test.tsx
@@ -10,10 +10,10 @@ 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/doc_views_types';
+import { getDocViewsRegistry } from '../../../../kibana_services';
+import { DocViewRenderProps } from '../../doc_views_types';
-jest.mock('../../../kibana_services', () => {
+jest.mock('../../../../kibana_services', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let registry: any[] = [];
return {
diff --git a/src/plugins/discover/public/application/components/doc_viewer/doc_viewer.tsx b/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer.tsx
similarity index 91%
rename from src/plugins/discover/public/application/components/doc_viewer/doc_viewer.tsx
rename to src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer.tsx
index d0476d4c38b48..9b627b1569275 100644
--- a/src/plugins/discover/public/application/components/doc_viewer/doc_viewer.tsx
+++ b/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer.tsx
@@ -9,9 +9,9 @@
import './doc_viewer.scss';
import React from 'react';
import { EuiTabbedContent } from '@elastic/eui';
-import { getDocViewsRegistry } from '../../../kibana_services';
+import { getDocViewsRegistry } from '../../../../kibana_services';
import { DocViewerTab } from './doc_viewer_tab';
-import { DocView, DocViewRenderProps } from '../../doc_views/doc_views_types';
+import { DocView, DocViewRenderProps } from '../../doc_views_types';
/**
* Rendering tabs with different views of 1 Elasticsearch hit in Discover.
diff --git a/src/plugins/discover/public/application/components/doc_viewer/doc_viewer_render_error.tsx b/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_render_error.tsx
similarity index 100%
rename from src/plugins/discover/public/application/components/doc_viewer/doc_viewer_render_error.tsx
rename to src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_render_error.tsx
diff --git a/src/plugins/discover/public/application/components/doc_viewer/doc_viewer_render_tab.test.tsx b/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_render_tab.test.tsx
similarity index 92%
rename from src/plugins/discover/public/application/components/doc_viewer/doc_viewer_render_tab.test.tsx
rename to src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_render_tab.test.tsx
index de76074357f63..5c61938a9e830 100644
--- a/src/plugins/discover/public/application/components/doc_viewer/doc_viewer_render_tab.test.tsx
+++ b/src/plugins/discover/public/services/doc_views/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/doc_views_types';
+import { DocViewRenderProps } from '../../doc_views_types';
test('Mounting and unmounting DocViewerRenderTab', () => {
const unmountFn = jest.fn();
diff --git a/src/plugins/discover/public/application/components/doc_viewer/doc_viewer_render_tab.tsx b/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_render_tab.tsx
similarity index 97%
rename from src/plugins/discover/public/application/components/doc_viewer/doc_viewer_render_tab.tsx
rename to src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_render_tab.tsx
index a6967cac8cdcc..257f40a9850a1 100644
--- a/src/plugins/discover/public/application/components/doc_viewer/doc_viewer_render_tab.tsx
+++ b/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_render_tab.tsx
@@ -7,7 +7,7 @@
*/
import React, { useRef, useEffect } from 'react';
-import { DocViewRenderFn, DocViewRenderProps } from '../../doc_views/doc_views_types';
+import { DocViewRenderFn, DocViewRenderProps } from '../../doc_views_types';
interface Props {
render: DocViewRenderFn;
diff --git a/src/plugins/discover/public/application/components/doc_viewer/doc_viewer_tab.test.tsx b/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_tab.test.tsx
similarity index 90%
rename from src/plugins/discover/public/application/components/doc_viewer/doc_viewer_tab.test.tsx
rename to src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_tab.test.tsx
index 188deba755445..3537699e4fe20 100644
--- a/src/plugins/discover/public/application/components/doc_viewer/doc_viewer_tab.test.tsx
+++ b/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_tab.test.tsx
@@ -9,8 +9,8 @@
import React from 'react';
import { shallow } from 'enzyme';
import { DocViewerTab } from './doc_viewer_tab';
-import { ElasticSearchHit } from '../../doc_views/doc_views_types';
-import { indexPatternMock } from '../../../__mocks__/index_pattern';
+import { ElasticSearchHit } from '../../doc_views_types';
+import { indexPatternMock } from '../../../../__mocks__/index_pattern';
describe('DocViewerTab', () => {
test('changing columns triggers an update', () => {
diff --git a/src/plugins/discover/public/application/components/doc_viewer/doc_viewer_tab.tsx b/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_tab.tsx
similarity index 94%
rename from src/plugins/discover/public/application/components/doc_viewer/doc_viewer_tab.tsx
rename to src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_tab.tsx
index 75ec5a62e9299..f43e445737820 100644
--- a/src/plugins/discover/public/application/components/doc_viewer/doc_viewer_tab.tsx
+++ b/src/plugins/discover/public/services/doc_views/components/doc_viewer/doc_viewer_tab.tsx
@@ -10,9 +10,9 @@ 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/doc_views_types';
-import { getServices } from '../../../kibana_services';
-import { KibanaContextProvider } from '../../../../../kibana_react/public';
+import { DocViewRenderFn, DocViewRenderProps } from '../../doc_views_types';
+import { getServices } from '../../../../kibana_services';
+import { KibanaContextProvider } from '../../../../../../kibana_react/public';
interface Props {
id: number;
diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer/index.ts b/src/plugins/discover/public/services/doc_views/components/doc_viewer/index.ts
new file mode 100644
index 0000000000000..3801c9b2de669
--- /dev/null
+++ b/src/plugins/discover/public/services/doc_views/components/doc_viewer/index.ts
@@ -0,0 +1,8 @@
+/*
+ * 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 { DocViewer } from './doc_viewer';
diff --git a/src/plugins/discover/public/application/components/source_viewer/__snapshots__/source_viewer.test.tsx.snap b/src/plugins/discover/public/services/doc_views/components/doc_viewer_source/__snapshots__/source.test.tsx.snap
similarity index 99%
rename from src/plugins/discover/public/application/components/source_viewer/__snapshots__/source_viewer.test.tsx.snap
rename to src/plugins/discover/public/services/doc_views/components/doc_viewer_source/__snapshots__/source.test.tsx.snap
index 761263ee861b9..352006ba1c83b 100644
--- a/src/plugins/discover/public/application/components/source_viewer/__snapshots__/source_viewer.test.tsx.snap
+++ b/src/plugins/discover/public/services/doc_views/components/doc_viewer_source/__snapshots__/source.test.tsx.snap
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Source Viewer component renders error state 1`] = `
-