[Discover] Remove visualize dependency (#82248)
This commit is contained in:
parent
77264074ad
commit
677b373ade
|
@ -12,7 +12,6 @@
|
|||
"urlForwarding",
|
||||
"navigation",
|
||||
"uiActions",
|
||||
"visualizations",
|
||||
"savedObjects"
|
||||
],
|
||||
"optionalPlugins": ["home", "share"],
|
||||
|
|
|
@ -65,7 +65,6 @@ const {
|
|||
timefilter,
|
||||
toastNotifications,
|
||||
uiSettings: config,
|
||||
visualizations,
|
||||
} = getServices();
|
||||
|
||||
import { getRootBreadcrumbs, getSavedSearchBreadcrumbs } from '../helpers/breadcrumbs';
|
||||
|
@ -874,11 +873,11 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise
|
|||
inspectorRequest.stats(getResponseInspectorStats(resp, $scope.searchSource)).ok({ json: resp });
|
||||
|
||||
if (getTimeField()) {
|
||||
const tabifiedData = tabifyAggResponse($scope.vis.data.aggs, resp);
|
||||
const tabifiedData = tabifyAggResponse($scope.opts.chartAggConfigs, resp);
|
||||
$scope.searchSource.rawResponse = resp;
|
||||
$scope.histogramData = discoverResponseHandler(
|
||||
tabifiedData,
|
||||
getDimensions($scope.vis.data.aggs.aggs, $scope.timeRange)
|
||||
getDimensions($scope.opts.chartAggConfigs.aggs, $scope.timeRange)
|
||||
);
|
||||
$scope.updateTime();
|
||||
}
|
||||
|
@ -1045,27 +1044,19 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise
|
|||
},
|
||||
},
|
||||
];
|
||||
|
||||
$scope.vis = await visualizations.createVis('histogram', {
|
||||
title: savedSearch.title,
|
||||
params: {
|
||||
addLegend: false,
|
||||
addTimeMarker: true,
|
||||
},
|
||||
data: {
|
||||
aggs: visStateAggs,
|
||||
searchSource: $scope.searchSource.getSerializedFields(),
|
||||
},
|
||||
});
|
||||
$scope.opts.chartAggConfigs = data.search.aggs.createAggConfigs(
|
||||
$scope.indexPattern,
|
||||
visStateAggs
|
||||
);
|
||||
|
||||
$scope.searchSource.onRequestStart((searchSource, options) => {
|
||||
if (!$scope.vis) return;
|
||||
return $scope.vis.data.aggs.onSearchRequestStart(searchSource, options);
|
||||
if (!$scope.opts.chartAggConfigs) return;
|
||||
return $scope.opts.chartAggConfigs.onSearchRequestStart(searchSource, options);
|
||||
});
|
||||
|
||||
$scope.searchSource.setField('aggs', function () {
|
||||
if (!$scope.vis) return;
|
||||
return $scope.vis.data.aggs.toDsl();
|
||||
if (!$scope.opts.chartAggConfigs) return;
|
||||
return $scope.opts.chartAggConfigs.toDsl();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
top-nav-menu="topNavMenu"
|
||||
update-query="handleRefresh"
|
||||
update-saved-query-id="updateSavedQueryId"
|
||||
vis="vis"
|
||||
>
|
||||
</discover-legacy>
|
||||
</discover-app>
|
||||
|
|
|
@ -51,6 +51,5 @@ export function createDiscoverLegacyDirective(reactDirective: any) {
|
|||
['topNavMenu', { watchDepth: 'reference' }],
|
||||
['updateQuery', { watchDepth: 'reference' }],
|
||||
['updateSavedQueryId', { watchDepth: 'reference' }],
|
||||
['vis', { watchDepth: 'reference' }],
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -39,13 +39,13 @@ import {
|
|||
Query,
|
||||
IndexPatternAttributes,
|
||||
DataPublicPluginStart,
|
||||
AggConfigs,
|
||||
} from '../../../../data/public';
|
||||
import { Chart } from '../angular/helpers/point_series';
|
||||
import { AppState } from '../angular/discover_state';
|
||||
import { SavedSearch } from '../../saved_searches';
|
||||
|
||||
import { SavedObject } from '../../../../../core/types';
|
||||
import { Vis } from '../../../../visualizations/public';
|
||||
import { TopNavMenuData } from '../../../../navigation/public';
|
||||
|
||||
export interface DiscoverLegacyProps {
|
||||
|
@ -66,14 +66,15 @@ export interface DiscoverLegacyProps {
|
|||
onSkipBottomButtonClick: () => void;
|
||||
onSort: (sort: string[][]) => void;
|
||||
opts: {
|
||||
savedSearch: SavedSearch;
|
||||
chartAggConfigs?: AggConfigs;
|
||||
config: IUiSettingsClient;
|
||||
indexPatternList: Array<SavedObject<IndexPatternAttributes>>;
|
||||
timefield: string;
|
||||
sampleSize: number;
|
||||
fixedScroll: (el: HTMLElement) => void;
|
||||
setHeaderActionMenu: (menuMount: MountPoint | undefined) => void;
|
||||
data: DataPublicPluginStart;
|
||||
fixedScroll: (el: HTMLElement) => void;
|
||||
indexPatternList: Array<SavedObject<IndexPatternAttributes>>;
|
||||
sampleSize: number;
|
||||
savedSearch: SavedSearch;
|
||||
setHeaderActionMenu: (menuMount: MountPoint | undefined) => void;
|
||||
timefield: string;
|
||||
};
|
||||
resetQuery: () => void;
|
||||
resultState: string;
|
||||
|
@ -87,7 +88,6 @@ export interface DiscoverLegacyProps {
|
|||
topNavMenu: TopNavMenuData[];
|
||||
updateQuery: (payload: { dateRange: TimeRange; query?: Query }, isUpdate?: boolean) => void;
|
||||
updateSavedQueryId: (savedQueryId?: string) => void;
|
||||
vis?: Vis;
|
||||
}
|
||||
|
||||
export function DiscoverLegacy({
|
||||
|
@ -119,12 +119,11 @@ export function DiscoverLegacy({
|
|||
topNavMenu,
|
||||
updateQuery,
|
||||
updateSavedQueryId,
|
||||
vis,
|
||||
}: DiscoverLegacyProps) {
|
||||
const [isSidebarClosed, setIsSidebarClosed] = useState(false);
|
||||
const { TopNavMenu } = getServices().navigation.ui;
|
||||
const { savedSearch, indexPatternList } = opts;
|
||||
const bucketAggConfig = vis?.data?.aggs?.aggs[1];
|
||||
const bucketAggConfig = opts.chartAggConfigs?.aggs[1];
|
||||
const bucketInterval =
|
||||
bucketAggConfig && search.aggs.isDateHistogramBucketAggConfig(bucketAggConfig)
|
||||
? bucketAggConfig.buckets?.getInterval()
|
||||
|
@ -242,7 +241,7 @@ export function DiscoverLegacy({
|
|||
})}
|
||||
className="dscTimechart"
|
||||
>
|
||||
{vis && rows.length !== 0 && (
|
||||
{opts.chartAggConfigs && rows.length !== 0 && (
|
||||
<div className="dscHistogram" data-test-subj="discoverChart">
|
||||
<DiscoverHistogram
|
||||
chartData={histogramData}
|
||||
|
|
|
@ -36,7 +36,6 @@ import {
|
|||
import { Start as InspectorPublicPluginStart } from 'src/plugins/inspector/public';
|
||||
import { SharePluginStart } from 'src/plugins/share/public';
|
||||
import { ChartsPluginStart } from 'src/plugins/charts/public';
|
||||
import { VisualizationsStart } from 'src/plugins/visualizations/public';
|
||||
|
||||
import { DiscoverStartPlugins } from './plugin';
|
||||
import { createSavedSearchesLoader, SavedSearch } from './saved_searches';
|
||||
|
@ -68,7 +67,6 @@ export interface DiscoverServices {
|
|||
getSavedSearchUrlById: (id: string) => Promise<string>;
|
||||
getEmbeddableInjector: any;
|
||||
uiSettings: IUiSettingsClient;
|
||||
visualizations: VisualizationsStart;
|
||||
}
|
||||
|
||||
export async function buildServices(
|
||||
|
@ -108,6 +106,5 @@ export async function buildServices(
|
|||
timefilter: plugins.data.query.timefilter.timefilter,
|
||||
toastNotifications: core.notifications.toasts,
|
||||
uiSettings: core.uiSettings,
|
||||
visualizations: plugins.visualizations,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ import { EmbeddableStart, EmbeddableSetup } from 'src/plugins/embeddable/public'
|
|||
import { ChartsPluginStart } from 'src/plugins/charts/public';
|
||||
import { NavigationPublicPluginStart as NavigationStart } from 'src/plugins/navigation/public';
|
||||
import { SharePluginStart, SharePluginSetup, UrlGeneratorContract } from 'src/plugins/share/public';
|
||||
import { VisualizationsStart, VisualizationsSetup } from 'src/plugins/visualizations/public';
|
||||
import { KibanaLegacySetup, KibanaLegacyStart } from 'src/plugins/kibana_legacy/public';
|
||||
import { UrlForwardingSetup, UrlForwardingStart } from 'src/plugins/url_forwarding/public';
|
||||
import { HomePublicPluginSetup } from 'src/plugins/home/public';
|
||||
|
@ -123,7 +122,6 @@ export interface DiscoverSetupPlugins {
|
|||
kibanaLegacy: KibanaLegacySetup;
|
||||
urlForwarding: UrlForwardingSetup;
|
||||
home?: HomePublicPluginSetup;
|
||||
visualizations: VisualizationsSetup;
|
||||
data: DataPublicPluginSetup;
|
||||
}
|
||||
|
||||
|
@ -140,7 +138,6 @@ export interface DiscoverStartPlugins {
|
|||
kibanaLegacy: KibanaLegacyStart;
|
||||
urlForwarding: UrlForwardingStart;
|
||||
inspector: InspectorPublicPluginStart;
|
||||
visualizations: VisualizationsStart;
|
||||
savedObjects: SavedObjectsStart;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue