-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Drilldowns] import dashboard url generator from plugin contract #64628
Changes from all commits
18935b8
23516f2
e27c67c
834c38c
46193dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,14 +44,23 @@ export class DashboardDrilldownsService { | |
{ advancedUiActions: uiActions }: SetupDependencies | ||
) { | ||
const start = createStartServicesGetter(core.getStartServices); | ||
const getDashboardUrlGenerator = () => { | ||
const urlGenerator = start().plugins.dashboard.dashboardUrlGenerator; | ||
if (!urlGenerator) | ||
throw new Error('dashboardUrlGenerator is required for dashboard to dashboard drilldown'); | ||
return urlGenerator; | ||
}; | ||
|
||
const actionFlyoutCreateDrilldown = new FlyoutCreateDrilldownAction({ start }); | ||
uiActions.addTriggerAction(CONTEXT_MENU_TRIGGER, actionFlyoutCreateDrilldown); | ||
|
||
const actionFlyoutEditDrilldown = new FlyoutEditDrilldownAction({ start }); | ||
uiActions.addTriggerAction(CONTEXT_MENU_TRIGGER, actionFlyoutEditDrilldown); | ||
|
||
const dashboardToDashboardDrilldown = new DashboardToDashboardDrilldown({ start }); | ||
const dashboardToDashboardDrilldown = new DashboardToDashboardDrilldown({ | ||
start, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a move in the wrong direction. While it's very easy to just pass down There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had a similar comment in a PR from Vadim, we can move this discussion outside this PR. Don't let it block you. |
||
getDashboardUrlGenerator, | ||
}); | ||
uiActions.registerDrilldown(dashboardToDashboardDrilldown); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
|
||
import React from 'react'; | ||
import { reactToUiComponent } from '../../../../../../../src/plugins/kibana_react/public'; | ||
import { DASHBOARD_APP_URL_GENERATOR } from '../../../../../../../src/plugins/dashboard/public'; | ||
import { DashboardUrlGenerator } from '../../../../../../../src/plugins/dashboard/public'; | ||
import { ActionContext, Config } from './types'; | ||
import { CollectConfigContainer } from './components'; | ||
import { DASHBOARD_TO_DASHBOARD_DRILLDOWN } from './constants'; | ||
|
@@ -22,7 +22,8 @@ import { StartServicesGetter } from '../../../../../../../src/plugins/kibana_uti | |
import { StartDependencies } from '../../../plugin'; | ||
|
||
export interface Params { | ||
start: StartServicesGetter<Pick<StartDependencies, 'data' | 'advancedUiActions' | 'share'>>; | ||
start: StartServicesGetter<Pick<StartDependencies, 'data' | 'advancedUiActions'>>; | ||
getDashboardUrlGenerator: () => DashboardUrlGenerator; | ||
} | ||
|
||
export class DashboardToDashboardDrilldown | ||
|
@@ -142,9 +143,7 @@ export class DashboardToDashboardDrilldown | |
} | ||
} | ||
|
||
const { plugins } = this.params.start(); | ||
|
||
return plugins.share.urlGenerators.getUrlGenerator(DASHBOARD_APP_URL_GENERATOR).createUrl({ | ||
return this.params.getDashboardUrlGenerator().createUrl({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks much cleaner! |
||
dashboardId: config.dashboardId, | ||
query: config.useCurrentFilters ? query : undefined, | ||
timeRange, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message contains error message specific for drilldowns.
When somebody else in this plugin will start using the dashboard URL generator, this error message will not make sense for them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it is inside
/dashboard_drilldowns_services.ts
🤔