Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/platform/plugins/shared/dashboard/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type {
export { DASHBOARD_API_TYPE } from './dashboard_api/types';
export type { DashboardRendererProps } from './dashboard_renderer/dashboard_renderer';
export { LazyDashboardRenderer as DashboardRenderer } from './dashboard_renderer/lazy_dashboard_renderer';
export type { DashboardSetup, DashboardStart, DashboardFeatureFlagConfig } from './plugin';
export type { DashboardStart } from './plugin';

export { DashboardListingTable } from './dashboard_listing';
export { DashboardTopNav } from './dashboard_top_nav';
Expand Down
47 changes: 9 additions & 38 deletions src/platform/plugins/shared/dashboard/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ import type {
} from '@kbn/usage-collection-plugin/public';

import { CONTENT_ID, LATEST_VERSION } from '../common/content_management';
import {
DashboardAppLocatorDefinition,
type DashboardAppLocator,
} from './dashboard_app/locator/locator';
import { DashboardAppLocatorDefinition } from './dashboard_app/locator/locator';
import { DashboardMountContextProps } from './dashboard_app/types';
import {
DASHBOARD_APP_ID,
Expand All @@ -80,10 +77,7 @@ import type { FindDashboardsService } from './services/dashboard_content_managem
import { setKibanaServices, untilPluginStartServicesReady } from './services/kibana_services';
import { setLogger } from './services/logger';
import { registerActions } from './dashboard_actions/register_actions';

export interface DashboardFeatureFlagConfig {
allowByValueEmbeddables: boolean;
}
import type { ConfigSchema } from '../server/config';

export interface DashboardSetupDependencies {
data: DataPublicPluginSetup;
Expand Down Expand Up @@ -125,32 +119,17 @@ export interface DashboardStartDependencies {
observabilityAIAssistant?: ObservabilityAIAssistantPublicStart;
}

export interface DashboardSetup {
/**
* @deprecated
*
* Use `shareStartService.url.locators.get(DASHBOARD_APP_LOCATOR)` instead.
*/
locator?: DashboardAppLocator;
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface DashboardSetup {}

export interface DashboardStart {
/**
* @deprecated
*
* Use `shareStartService.url.locators.get(DASHBOARD_APP_LOCATOR)` instead.
*/
locator?: DashboardAppLocator;
dashboardFeatureFlagConfig: DashboardFeatureFlagConfig;
findDashboardsService: () => Promise<FindDashboardsService>;
registerDashboardPanelPlacementSetting: <SerializedState extends object = object>(
embeddableType: string,
getPanelPlacementSettings: GetPanelPlacementSettings<SerializedState>
) => void;
}

export let resolveServicesReady: () => void;

export class DashboardPlugin
implements
Plugin<DashboardSetup, DashboardStart, DashboardSetupDependencies, DashboardStartDependencies>
Expand All @@ -162,23 +141,18 @@ export class DashboardPlugin
private appStateUpdater = new BehaviorSubject<AppUpdater>(() => ({}));
private stopUrlTracking: (() => void) | undefined = undefined;
private currentHistory: ScopedHistory | undefined = undefined;
private dashboardFeatureFlagConfig?: DashboardFeatureFlagConfig;
private locator?: DashboardAppLocator;

public setup(
core: CoreSetup<DashboardStartDependencies, DashboardStart>,
{ share, embeddable, home, urlForwarding, data, contentManagement }: DashboardSetupDependencies
): DashboardSetup {
this.dashboardFeatureFlagConfig =
this.initializerContext.config.get<DashboardFeatureFlagConfig>();

) {
core.analytics.registerEventType({
eventType: 'dashboard_loaded_with_data',
schema: {},
});

if (share) {
this.locator = share.url.locators.create(
share.url.locators.create(
new DashboardAppLocatorDefinition({
useHashedUrl: core.uiSettings.get('state:storeInSessionStorage'),
getDashboardFilterFields: async (dashboardId: string) => {
Expand Down Expand Up @@ -329,9 +303,7 @@ export class DashboardPlugin
name: dashboardAppTitle,
});

return {
locator: this.locator,
};
return {};
}

public start(core: CoreStart, plugins: DashboardStartDependencies): DashboardStart {
Expand All @@ -340,13 +312,12 @@ export class DashboardPlugin
untilPluginStartServicesReady().then(() => {
registerActions({
plugins,
allowByValueEmbeddables: this.dashboardFeatureFlagConfig?.allowByValueEmbeddables,
allowByValueEmbeddables:
this.initializerContext.config.get<ConfigSchema>()?.allowByValueEmbeddables ?? true,
});
});

return {
locator: this.locator,
dashboardFeatureFlagConfig: this.dashboardFeatureFlagConfig!,
registerDashboardPanelPlacementSetting,
findDashboardsService: async () => {
const { getDashboardContentManagementService } = await import(
Expand Down
2 changes: 1 addition & 1 deletion x-pack/examples/ui_actions_enhanced_examples/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"uiActionsEnhanced",
"data",
"discover",
"dashboard",
"dashboardEnhanced",
"developerExamples",
"unifiedSearch",
"embeddable",
"share"
],
"requiredBundles": [
"dashboardEnhanced",
Expand Down
5 changes: 2 additions & 3 deletions x-pack/examples/ui_actions_enhanced_examples/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import {
} from '@kbn/ui-actions-enhanced-plugin/public';
import { createStartServicesGetter } from '@kbn/kibana-utils-plugin/public';
import { DiscoverSetup, DiscoverStart } from '@kbn/discover-plugin/public';
import { DashboardSetup, DashboardStart } from '@kbn/dashboard-plugin/public';
import { DeveloperExamplesSetup } from '@kbn/developer-examples-plugin/public';
import {
UiActionsEnhancedMemoryActionStorage,
UiActionsEnhancedDynamicActionManager,
} from '@kbn/ui-actions-enhanced-plugin/public';
import { EmbeddableSetup } from '@kbn/embeddable-plugin/public';
import { SharePluginStart } from '@kbn/share-plugin/public';
import { DashboardHelloWorldDrilldown } from './drilldowns/dashboard_hello_world_drilldown';
import { DashboardToDiscoverDrilldown } from './drilldowns/dashboard_to_discover_drilldown';
import { App1ToDashboardDrilldown } from './drilldowns/app1_to_dashboard_drilldown';
Expand All @@ -39,7 +39,6 @@ import { App2ToDashboardDrilldown } from './drilldowns/app2_to_dashboard_drilldo
import { registerButtonEmbeddable } from './embeddables/register_button_embeddable';

export interface SetupDependencies {
dashboard: DashboardSetup;
data: DataPublicPluginSetup;
developerExamples: DeveloperExamplesSetup;
discover: DiscoverSetup;
Expand All @@ -48,9 +47,9 @@ export interface SetupDependencies {
}

export interface StartDependencies {
dashboard: DashboardStart;
data: DataPublicPluginStart;
discover: DiscoverStart;
share: SharePluginStart;
uiActionsEnhanced: AdvancedUiActionsStart;
}

Expand Down
1 change: 0 additions & 1 deletion x-pack/examples/ui_actions_enhanced_examples/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"@kbn/kibana-utils-plugin",
"@kbn/share-plugin",
"@kbn/discover-plugin",
"@kbn/dashboard-plugin",
"@kbn/embeddable-plugin",
"@kbn/ui-actions-enhanced-plugin",
"@kbn/developer-examples-plugin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { FormattedMessage } from '@kbn/i18n-react';
import { i18n } from '@kbn/i18n';
import { EuiCallOut, EuiConfirmModal, EuiSpacer } from '@elastic/eui';
import { KibanaSavedObjectType } from '@kbn/fleet-plugin/public';
import { DASHBOARD_APP_LOCATOR } from '@kbn/deeplinks-analytics';
import { MonitoringStartServices } from '../../../types';

const INGEST_PIPELINE_DASHBOARD_ID = 'elasticsearch-metrics-ingest-pipelines';
Expand All @@ -35,7 +36,7 @@ export const ingestPipelineTabOnClick = async (services: MonitoringStartServices
response.data.items.some((item) => item.id === INGEST_PIPELINE_DASHBOARD_ID);

const navigateToDashboard = () =>
services.dashboard!.locator!.navigate({
services.share.url.locators.get(DASHBOARD_APP_LOCATOR)?.navigate({
dashboardId: INGEST_PIPELINE_DASHBOARD_ID,
});

Expand Down
1 change: 1 addition & 0 deletions x-pack/platform/plugins/private/monitoring/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"@kbn/response-ops-rule-form",
"@kbn/charts-plugin",
"@kbn/fields-metadata-plugin",
"@kbn/deeplinks-analytics"
],
"exclude": [
"target/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
"dashboardEnhanced"
],
"requiredPlugins": [
"dashboard",
"data",
"embeddable",
"share",
"uiActionsEnhanced",
"unifiedSearch"
],
"requiredBundles": [
"dashboard",
"embeddable",
"embeddableEnhanced",
"kibanaUtils",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
AdvancedUiActionsSetup,
AdvancedUiActionsStart,
} from '@kbn/ui-actions-enhanced-plugin/public';
import { DashboardStart } from '@kbn/dashboard-plugin/public';
import { DashboardDrilldownsService } from './services';

export interface SetupDependencies {
Expand All @@ -27,7 +26,6 @@ export interface StartDependencies {
data: DataPublicPluginStart;
embeddable: EmbeddableStart;
share: SharePluginStart;
dashboard: DashboardStart;
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
* 2.0.
*/

import type { KibanaLocation } from '@kbn/share-plugin/public';
import type { KibanaLocation, SharePluginStart } from '@kbn/share-plugin/public';
import React from 'react';
import { DataPublicPluginStart } from '@kbn/data-plugin/public';
import { DashboardStart } from '@kbn/dashboard-plugin/public';
import {
AdvancedUiActionsStart,
UiActionsEnhancedBaseActionFactoryContext as BaseActionFactoryContext,
UiActionsEnhancedDrilldownDefinition as Drilldown,
} from '@kbn/ui-actions-enhanced-plugin/public';
import { CollectConfigProps, StartServicesGetter } from '@kbn/kibana-utils-plugin/public';
import { DEFAULT_DASHBOARD_DRILLDOWN_OPTIONS } from '@kbn/presentation-util-plugin/public';
import { DASHBOARD_APP_LOCATOR } from '@kbn/deeplinks-analytics';

import { CollectConfigContainer } from './components';
import { txtGoToDashboard } from './i18n';
Expand All @@ -24,7 +24,7 @@ export interface Params {
start: StartServicesGetter<{
uiActionsEnhanced: AdvancedUiActionsStart;
data: DataPublicPluginStart;
dashboard: DashboardStart;
share: SharePluginStart;
}>;
}

Expand Down Expand Up @@ -87,7 +87,7 @@ export abstract class AbstractDashboardDrilldown<Context extends object = object
};

protected get locator() {
const locator = this.params.start().plugins.dashboard.locator;
const locator = this.params.start().plugins.share.url.locators.get(DASHBOARD_APP_LOCATOR);
if (!locator) throw new Error('Dashboard locator is required for dashboard drilldown.');
return locator;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,21 @@ describe('.execute() & getHref', () => {
},
plugins: {
uiActionsEnhanced: {},
dashboard: {
locator: {
getLocation: async (params: DashboardLocatorParams) => {
return await definition.getLocation(params);
share: {
url: {
locators: {
get: () => ({
getLocation: async (params: DashboardLocatorParams) => {
return await definition.getLocation(params);
},
}),
},
},
},
},
self: {},
})) as unknown as StartServicesGetter<
Pick<StartDependencies, 'data' | 'uiActionsEnhanced' | 'dashboard'>
Pick<StartDependencies, 'data' | 'uiActionsEnhanced' | 'share'>
>,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"@kbn/presentation-util-plugin",
"@kbn/presentation-containers",
"@kbn/presentation-publishing",
"@kbn/react-kibana-mount"
"@kbn/react-kibana-mount",
"@kbn/deeplinks-analytics"
],
"exclude": ["target/**/*"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import {
import { isDefined } from '@kbn/ml-is-defined';
import { parseInterval } from '@kbn/ml-parse-interval';

import type { SharePluginStart } from '@kbn/share-plugin/public';
import { DASHBOARD_APP_LOCATOR } from '@kbn/deeplinks-analytics';
import type { DashboardItems } from '../../../services/dashboard_service';
import { categoryFieldTypes } from '../../../../../common/util/fields_utils';
import { TIME_RANGE_TYPE, URL_TYPE } from './constants';
Expand Down Expand Up @@ -221,12 +223,13 @@ export function isValidCustomUrlSettings(

export function buildCustomUrlFromSettings(
dashboardService: DashboardStart,
share: SharePluginStart,
settings: CustomUrlSettings
): Promise<MlUrlConfig> {
// Dashboard URL returns a Promise as a query is made to obtain the full dashboard config.
// So wrap the other two return types in a Promise for consistent return type.
if (settings.type === URL_TYPE.KIBANA_DASHBOARD) {
return buildDashboardUrlFromSettings(dashboardService, settings);
return buildDashboardUrlFromSettings(dashboardService, share, settings);
} else if (settings.type === URL_TYPE.KIBANA_DISCOVER) {
return Promise.resolve(buildDiscoverUrlFromSettings(settings));
} else {
Expand Down Expand Up @@ -256,6 +259,7 @@ function getUrlRangeFromSettings(settings: CustomUrlSettings) {

async function buildDashboardUrlFromSettings(
dashboardService: DashboardStart,
share: SharePluginStart,
settings: CustomUrlSettings,
isPartialDFAJob?: boolean
): Promise<MlUrlConfig> {
Expand Down Expand Up @@ -300,7 +304,7 @@ async function buildDashboardUrlFromSettings(

const { from, to } = getUrlRangeFromSettings(settings);

const location = await dashboardService.locator?.getLocation({
const location = await share.url.locators.get(DASHBOARD_APP_LOCATOR)?.getLocation({
dashboardId,
timeRange: {
from,
Expand Down
Loading