Skip to content

Commit

Permalink
remove locator from dashboard setup and start contract
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Mar 3, 2025
1 parent 7d79495 commit fea861e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 40 deletions.
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 @@ -20,7 +20,7 @@ export type { DashboardApi, DashboardCreationOptions } from './dashboard_api/typ
export { DASHBOARD_API_TYPE } from './dashboard_api/types';
export { LazyDashboardRenderer as DashboardRenderer } from './dashboard_container/external_api/lazy_dashboard_renderer';
export type { DashboardLocatorParams } from './dashboard_container/types';
export type { DashboardSetup, DashboardStart } from './plugin';
export type { DashboardStart } from './plugin';

export { DashboardListingTable } from './dashboard_listing';
export { DashboardTopNav } from './dashboard_top_nav';
Expand Down
31 changes: 6 additions & 25 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 Down Expand Up @@ -122,22 +119,10 @@ 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;
findDashboardsService: () => Promise<FindDashboardsService>;
registerDashboardPanelPlacementSetting: <SerializedState extends object = object>(
embeddableType: string,
Expand All @@ -156,19 +141,18 @@ export class DashboardPlugin
private appStateUpdater = new BehaviorSubject<AppUpdater>(() => ({}));
private stopUrlTracking: (() => void) | undefined = undefined;
private currentHistory: ScopedHistory | undefined = undefined;
private locator?: DashboardAppLocator;

public setup(
core: CoreSetup<DashboardStartDependencies, DashboardStart>,
{ share, embeddable, home, urlForwarding, data, contentManagement }: DashboardSetupDependencies
): DashboardSetup {
) {
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 @@ -319,9 +303,7 @@ export class DashboardPlugin
name: dashboardAppTitle,
});

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

public start(core: CoreStart, plugins: DashboardStartDependencies): DashboardStart {
Expand All @@ -336,7 +318,6 @@ export class DashboardPlugin
});

return {
locator: this.locator,
registerDashboardPanelPlacementSetting,
findDashboardsService: async () => {
const { getDashboardContentManagementService } = await import(
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

0 comments on commit fea861e

Please sign in to comment.